akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc *bufio.Scanner

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

const INF = 10000000000

type info struct {
	supply int
	fuel   int
}

type infoes []info

func less(info1, info2 info) bool {
	if info1.supply != info2.supply {
		return info1.supply < info2.supply
	}
	return info1.fuel >= info2.fuel
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	n, m, l := nextInt(), nextInt(), nextInt()
	adj := make([][]int, n)
	for i := range adj {
		adj[i] = make([]int, n)
		for j := range adj[i] {
			if i != j {
				adj[i][j] = INF
			}
		}
	}
	for k := 0; k < m; k++ {
		a, b, c := nextInt(), nextInt(), nextInt()
		if c <= l {
			adj[a-1][b-1], adj[b-1][a-1] = c, c
		}
	}

	dist := make([]infoes, n)
	for i := range dist {
		dist[i] = make(infoes, n)
		dist[i][i] = info{0, l}
		for j := range dist[i] {
			if i != j {
				dist[i][j] = info{INF, 0}
			}
		}
		remain := make(map[int]struct{})
		for j := 0; j < n; j++ {
			remain[j] = struct{}{}
		}
		for len(remain) > 0 {
			u := -1
			for k := range remain {
				if u == -1 || less(dist[i][k], dist[i][u]) {
					u = k
				}
			}
			delete(remain, u)
			for v, a := range adj[u] {
				if a > l {
					continue
				}
				next := dist[i][u]
				if next.fuel < a {
					next.supply++
					next.fuel = l
				}
				next.fuel -= a
				if less(next, dist[i][v]) {
					dist[i][v] = next
				}
			}
		}
	}

	q := nextInt()
	for p := 0; p < q; p++ {
		s, t := nextInt(), nextInt()
		ans := dist[s-1][t-1].supply
		switch {
		case ans == INF:
			fmt.Println(-1)
		default:
			fmt.Println(ans)
		}
	}
}


Measured memory_bytes: 5632
from bisect import bisect_left
n = int(input())
list_L = list(map(int, input().split()))
list_L.sort()
ans = 0

for i in range(n):
    for j in range(i+1, n):
        ans += bisect_left(list_L, list_L[i]+list_L[j]) - j - 1

print(ans)

Measured memory_bytes: 9364
import numpy as np
H, W = map(int, raw_input().split())
grids = []
for i in xrange(H):
  grids.append(raw_input())
  
grid_num = []
for grid in grids:
  grid_num.append(map(lambda x: 1 if x == '#' else 0, grid))
  
grid_num = np.array(grid_num)

comp_grid_num = []
for w in xrange(W):
  if grid_num[:, w].any():
    comp_grid_num.append(grid_num[:, w])

comp_grid_num = np.array(comp_grid_num)
comp_grid = ""
for h in xrange(H):
  if comp_grid_num[:, h].any():
    comp_grid += "".join(map(lambda x: '#' if x else '.', comp_grid_num[:, h])) + "\n"
    
print comp_grid
    

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



int main(void){
    int n;
    cin >> n;
    vector <tuple<string, int,int>> a;//tuple は複数を扱うことができる
    for(int i=1;i<=n;i++){
        string s;
        int x;
        cin >> s >> x;
        x = -x;
        a.push_back(tie(s,x,i)); //tieで一気に突っ込めるっぽい？
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        cout << get<2>(a[i]) << endl; //get<2> はstring int int の0,1,２の2番目を呼び出すため物
    }
    
    
    
    return 0;
}






























Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    right = 0
    cur_bin = 0
    for left in range(N):
        while right < N and (cur_bin ^ A[right] == cur_bin + A[right]):
            cur_bin += A[right]
            right += 1
        ans += right-left
        if left == right:
            right += 1
        else:
            cur_bin ^= A[left]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 77900
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    cin >> a >> b;
    int c = a + b;
    if (a % 3 == 0 || b % 3 == 0 || c % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"No", "Yes"};
string ANS[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, x;
    cin >> n >> x;
    cout << n + 1 - x;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


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


void solve(long long X){
    ll ans = 0;
    ans += 1000 * (X / 500);
    X = X % 500;
    ans += 5 * (X / 5);
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;


signed main()
{
    int n;cin>>n;
    std::vector<int> a(n),b(n),c(n);
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];--a[i];
    }
    for (int i = 0; i < n; ++i)
    {
        cin>>b[i];
    }
    for (int i = 0; i < n-1; ++i)
    {
        cin>>c[i];
    }
    int ans=0;
    for (int i = 0; i < n; ++i)
    {
        ans+=b[a[i]];
    }
    for (int i = 0; i < n-1; ++i)
    {
        if(a[i]+1==a[i+1])
        {
            ans+=c[a[i]];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>

using namespace std;
int main() {
    int a,b;
    cin>>a>>b;
    if(a>=13)
        cout<<b<<endl;
    else if(a>=6)
        cout<<b/2<<endl;
    else
        cout<<0<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
int w,n,t[31][31],a,b;
char ch;
  for(int i=0;i<31;i++){
    for(int j=0;j<31;j++){
      t[i][j]=j;
    }
  } 
  cin>>w>>n;
  for(int i=1;i<=n;i++){
    cin>>a>>ch>>b;
    t[i][a]=b;
    t[i][b]=a;
  }
  for(int j=1;j<=w;j++){
    a=j;
    for(int i=n;i>=0;i--){
      a=t[i][a];
    }
    cout<<a<<endl;
  }
  return 0;
} 


Measured memory_bytes: 3084
#include <iostream>
#include <queue>
 
using namespace std;
 
struct Point {
  int x, y, dist;
};
 
int main() {
  int w, h;
  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    int lr[h][w], td[h][w];
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        lr[i][j] = td[i][j] = 0;
      }
    }
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w-1; j++) {
        cin >> lr[i][j];
      }
      if(i == h-1) break;
      for(int j = 0; j < w; j++) {
        cin >> td[i][j];
      }
    }
 
 
    bool visited[h][w];
    for(int i = 0; i < h; i++)
      for(int j = 0; j < w; j++)
        visited[i][j] = false;
 
    Point p;
    p.x = 0;
    p.y = 0;
    p.dist = 0;
 
    queue<Point> Q;
    Q.push(p);
 
    int ans = -1;
 
    while(!Q.empty()) {
      int d[4][2] = {{1,0}, {0,1}, {-1,0}, {0,-1}};
 
      p = Q.front();
      Q.pop();
      visited[p.y][p.x] = true;
      if(p.x == w-1 && p.y == h-1) {
        ans = p.dist;
        break;
      }
 
      for(int i = 0; i < 4; i++) {
        if(lr[p.y][p.x] && i == 0) continue;
        if(p.x-1 >= 0 && lr[p.y][p.x-1] && i == 2) continue;
        if(td[p.y][p.x] && i == 1) continue;
        if(p.y-1 >= 0 && td[p.y-1][p.x] && i == 3) continue;
 
        int nx = p.x + d[i][0];
        int ny = p.y + d[i][1];
        if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
 
        if(visited[ny][nx]) continue;
 
        Point temp;
        temp.x = nx;
        temp.y = ny;
        temp.dist = p.dist + 1;
        Q.push(temp);
        visited[ny][nx] = true;
      }
    }
    if(ans != -1) cout << ans + 1 << endl;
    else cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

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

ll func(ll x){
    if(x == 1)
        return 1;
    return 2*func(x/2)+1;

}
int main() {
    ll h;
    cin >> h;
    cout << func(h) << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
h,w=map(int,input().split())
p=[list("#"*(w+2))]+[list("#"+input()+"#") for i in range(h)]+[list("#"*(w+2))]
q=deque([])
for i in range(1,h+1):
	for j in range(1,w+1):
		if p[i][j]=='#':
			p[i][j]=0
			q.append([i,j])
d=[(1,0),(-1,0),(0,1),(0,-1)]
while q:
	x,y=q.popleft()
	for dx,dy in d:
		if p[x+dx][y+dy]==".":
			p[x+dx][y+dy]=p[x][y]+1
			q.append([x+dx,y+dy])
ans=0
for i in range(1,h+1):
	for j in range(1,w+1):
		ans=max(ans,p[i][j])
print(ans)

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

int main(){
	long n,q,l,r,i;
	string s;
	cin >> n >> q >> s;
	vector<long> ans(n);
	for(i=1; i<n; i++){
		ans[i]=ans[i-1];
		if(s[i-1]=='A' && s[i]=='C'){
			ans[i]++; 
		}
	}
	cout << endl;
	for(i=0; i<q; i++){
		cin >> l >> r; l--; r--;
		cout << ans[r]-ans[l] << endl;
	}

}

Measured memory_bytes: 1792
n,k=map(int,input().split())
a=list(map(int,input().split()))
d={}
l=[]
for i in range(n):
    try:
        l[d[a[i]]]+=1
    except:
        d[a[i]]=len(l)
        l.append(1)
ans=0
l.sort()
for i in range(len(l)-k):
    ans+=l[i]
print(ans)


Measured memory_bytes: 37408
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

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

    int maxLength = 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int len;
        cin >> len;
        
        maxLength = (len > maxLength) ? len : maxLength;
        sum += len;
    }

    if (maxLength < sum - maxLength) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(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()
using namespace std;
typedef long long ll;
typedef long double ld;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,m,k;
	cin >> n >> m >> k;
	UnionFind tree(n);
	vector<set<int>> bl(n);
	REP(i,m){
		int a,b;
		cin >> a >> b;
		a--, b--;
		tree.merge(a,b);
		bl[a].insert(b);
		bl[b].insert(a);
	}
	REP(i,k){
		int a,b;
		cin >> a >> b;
		a--, b--;
		if(!tree.issame(a,b)) continue;
		bl[a].insert(b);
		bl[b].insert(a);
	}
	
	REP(i,n) cout << tree.size(i) - bl[i].size() -1 << " ";
	return 0;
}



Measured memory_bytes: 24704
input1 = input()
inputbox1 = input1

if(inputbox1 == "SAT"):
    print("1")
elif(inputbox1 == "SUN"):
    print("7")
elif(inputbox1 == "MON"):
    print("6")
elif(inputbox1 == "TUE"):
    print("5")
elif(inputbox1 == "WED"):
    print("4")
elif(inputbox1 == "THU"):
    print("3")
elif(inputbox1 == "FRI"):
    print("2")

Measured memory_bytes: 3060
import sys
def input(): return sys.stdin.readline().rstrip()
class Sieve: #区間[2,n]の値の素因数分解
    def __init__(self,n=1):
        self.primes=[]
        self.f=[0]*(n+1) #ふるい（素数ならその値）
        self.f[0]=self.f[1]=-1
        for i in range(2,n+1): #素数リスト作成
            if self.f[i]: continue
            self.primes.append(i)
            self.f[i]=i
            for j in range(i*i,n+1,i):
                if not self.f[j]:
                    self.f[j]=i  # 最小の素因数を代入
    def is_prime(self, x):
        return self.f[x]==x
    def prime_fact(self,x): # 素因数分解の昇順リスト, {2:p,3:q,5:r,...}
        fact_dict=dict()
        while x!=1:
            p=self.f[x]
            fact_dict[p]=fact_dict.get(p,0)+1
            x//=self.f[x]
        return fact_dict

def main():
    n=int(input())
    A=list(map(int,input().split()))
    mod=10**9+7
    p_lis={}
    Prime=Sieve(10**6+5)
    for a in A:
        f=Prime.prime_fact(a)
        #print(f)
        for key in f:
            p_lis[key]=max(p_lis.get(key,0),f[key])
    lcm=1
    #print(p_lis)
    for key in p_lis:
        lcm=(lcm*pow(key,p_lis[key],mod))%mod
    ans=0
    #print(lcm)
    for a in A:
        b=lcm*pow(a,mod-2,mod)%mod
        ans=(ans+b)%mod
    print(ans)


if __name__ == '__main__':
    main()



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

int main( void)
{
int x, a,b;
do
{
scanf("%d %d %d",&x,&a,&b);
}while(x>=1 && x<=1000 && a>=1 && a<=1000 && b<=1 && b<=1000);
if(abs(a-x)>abs(b-x))
printf("B\n");
else
printf("A\n");
}

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

int main(){
    string s;
    cin>>s;
    map<char,int> mp;
    rep(i,s.size()) mp[s[i]]++;
    if(s.size()<26){
        char p='a';
        while(p<='z'){
            if(mp[p]==0) break;
            else p=char(p+1);
        }
        cout<<s<<p;
        return 0;
    }
    else{
        if(s=="zyxwvutsrqponmlkjihgfedcba"){
            cout<<"-1";
            return 0;
        }
        else{
            string t=s;
            next_permutation(t.begin(),t.end());
            rep(i,26){
                if(s[i]==t[i]) cout<<s[i];
                else{
                    cout<<t[i];
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int l=s.length();
	for(int i=0;i<l;i++)
	{
		if(s[i]=='C')
		{
			for(int j=i+1;j<l;j++)
			{
				if(s[j]=='F')
				{
					cout<<"Yes"<<endl;
					return 0;
				}
			}	
		}	
	}	
	cout<<"No"<<endl;
} 

Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : December 03 2019 23:02:17 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    string s;
    cin >> s;
    int n=sz(s);
    fori(i,n-1){
        if(s[i]==s[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    fori(i,n-2){
        if(s[i]==s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
    time_taken();
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef long long ll;
typedef long double ld;

using namespace std;
using namespace __gnu_pbds;

void solve();

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(time(NULL));
    solve();
    return 0;
}

const int INF = 1e9;
const ll INFL = 1e18;
const double EPS = 1e-9;

void solve(){
    string s, t;
    cin >> s >> t;
    map<char, char> letters;
    bool first = true, second = true;
    for(int i = 0; i < t.length(); i++){
        if(letters.find(t[i]) != letters.end()){
            if(letters[t[i]] != s[i]){
                first = false;
                break;
            }
        }
        else{
            letters.insert({t[i], s[i]});
        }
    }
    letters.clear();
    for(int i = 0; i < s.length(); i++){
        if(letters.find(s[i]) != letters.end()){
            if(letters[s[i]] != t[i]){
                second = false;
                break;
            }
        }
        else{
            letters.insert({s[i], t[i]});
        }
    }
    if(first && second){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return;
}


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

int main() {
	ll n;
	ll p = 1e9+7;
	cin >> n;
	vector<ll> cnt(61,0);
	rep(i,n) {
		ll a;
		cin >> a;
		ll j = 0;
		while(a>=1) {
			if(a%2==1) cnt[j]++;
			a/=2; j++;
		}
	}
	ll ans = 0;
	rep(i,61) {
		ll base = cnt[i] * (n-cnt[i]);
		//printf("%lld, %lld\n", i, cnt[i]);
		ll tmp = base;
		rep(j,i) tmp = ((tmp<<1) % p);
		ans = (ans + tmp) % p;
	}
	cout << ans << endl;
	return 0;
}


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

int H;

int parent(int i);
int left(int i);
int right(int i);
void swap(int *a, int *b);
void maxHeapify(int *A, int i);
void buildMaxHeap(int *A);

int main(){
  int i;
  int *A;

  scanf("%d", &H);
  A = malloc(sizeof(int) * (H+1));

  for(i = 1; i <= H; i++){
    scanf("%d", &A[i]);
  }

  buildMaxHeap(A);

  for(i = 1; i <= H; i++){
    printf(" %d", A[i]);
  }

  printf("\n");
  return 0;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return i*2;
}

int right(int i){
  return i*2+1;
}

void swap(int *x, int *y){
  int temp;
  temp = *x;
  *x = *y;
  *y = temp;
}

void maxHeapify(int *A, int i){
  int l, r, largest;

  l = left(i);
  r = right(i);

  if(l <= H && A[l] > A[i]){
    largest = l;
  } else {
    largest = i;
  }

  if(r <= H && A[r] > A[largest]){
    largest = r;
  }

  if(largest != i){
    swap(&A[i], &A[largest]);
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int *A){
  int i;
  for(i = H/2; i > 0; i--){
    maxHeapify(A, i);
  }
}

Measured memory_bytes: 2556
import math
L, N = map(int, input().split())
X = [None for i in range(N)]
DistAntiClock, DistClock = [0 for i in range(N+1)], [0 for i in range(N+1)]
for i in range(N):
    X[i] = int(input())
    DistAntiClock[i+1] = DistAntiClock[i] + 2 * X[i]
for i in range(N):
    DistClock[i+1] = DistClock[i] + (L - X[-1-i]) * 2

maxLength = max(X[N-1], L - X[0])
for i in range(1, N):
    finIndex = math.ceil((i + N)/2)
    if (i + N) % 2 == 0:
        AntiClockLength = DistAntiClock[finIndex] - DistAntiClock[i-1] - X[finIndex-1] + DistClock[N - finIndex] 
        ClockLength = DistClock[finIndex] - DistClock[i-1] - (L-X[-finIndex]) + DistAntiClock[N - finIndex]
    else:
        AntiClockLength = DistAntiClock[finIndex - 1] - DistAntiClock[i-1] + DistClock[N - finIndex + 1] - (L - X[finIndex - 1])
        ClockLength = DistClock[finIndex - 1] - DistClock[i-1] + DistAntiClock[N - finIndex + 1] - X[N - finIndex]
    maxLength = max(max(AntiClockLength, ClockLength), maxLength)

print(maxLength)

Measured memory_bytes: 31976
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 座標数
		int N = sc.nextInt();

		//x
		int[] x = new int[N];
		//y
		int[] y = new int[N];
		//z(高さ)
		int[] h = new int[N];
		//各座標を配列に順に詰める
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			h[i] = sc.nextInt();
		}
		//Nは1以上100以下の整数より
		for (int i = 0; i <= 100; i++) {
			for (int j = 0; j <= 100; j++) {
				int H = 0;
				Boolean B = true;
				for (int k = 0; k < N; k++) {

					if (h[k] != 0) {
						H = h[k] + Math.abs(x[k] - i) + Math.abs(y[k] - j);
					}
				}
				for (int k = 0; k < N; k++) {
					if (h[k] != Math.max(H - Math.abs(x[k] - i) - Math.abs(y[k] - j), 0)) {
						B = false;
					}
				}
				if (B) {
					System.out.println(i + " " + j + " " + H);
				}
			}
		}

	}
}

Measured memory_bytes: 23864
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d,f;
    scanf("%d %d %d %d %d",&a,&b,&c,&d,&f);
    if(a==0){
        printf("1");
    }else if(b==0){
        printf("2");
    }else if(c==0){
        printf("3");
    }else if(d==0){
        printf("4");
    }else{
        printf("5");
    }
}


Measured memory_bytes: 3760
// Dāritys Morgho ban Rōvēgrie
// Math = ♥
// Sometimes it is people that no one imagines anything of who do things that no one can imagine
// After all this time? Always

#include <bits/stdc++.h>                        // uncomment before submission
//#include <ext/pb_ds/assoc_container.hpp>		// uncomment before submission
//#include <ext/pb_ds/tree_policy.hpp>			// uncomment before submission
//using namespace __gnu_pbds;					// uncomment before submission
using namespace std;
//<---------------------------------------------------Template----------------------------------------------------------->
#define int long long
#define ll long long
#define ld long double
const int INF = 1e15 + 7;
const int MAX = 310;
const int MOD = 1e9 + 7;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;                  // Vector of long long
typedef vector<vi> vvi;                 // Vector of vi
typedef vector<ii> vii;                 // Vector of pairs
typedef vector<vii> vvii;               // Vector of Vector of pairs
typedef vector<bool> vb;                // Vector of bool
#define pq priority_queue               // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                        // For pairs
#define ss second                       // For pairs
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//<----------------------------------------------------------------------------------------------------------------------->

int f[MAX][MAX][MAX] = {0};

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;

    vvii g(n + 5);
    for (int i = 1; i <= m; i++)
    {
        int l, r, x;
        cin >> l >> r >> x;
        g[r].pb(mp(l, x));
    }

    f[1][0][0] = 3;
    int ans = 0;
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            for (int k = 0; k <= n; k++)
            {
                for (ii l: g[i])
                {
                    int x = 0;

                    if (i >= l.ff)x++;
                    if (j >= l.ff) x++;
                    if (k >= l.ff)x++;

                    if (x != l.ss)
                        f[i][j][k] = 0;
                }

                if (i == n)
                    ans += f[i][j][k], ans %= MOD;
                else
                    f[i + 1][j][k] = (f[i + 1][j][k] + f[i][j][k]) % MOD,
                    f[i + 1][i][k] = (f[i + 1][i][k] + f[i][j][k]) % MOD,
                    f[i + 1][i][j] = (f[i + 1][i][j] + f[i][j][k]) % MOD;
            }
        }
    }

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


Measured memory_bytes: 226816
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	ll n=s.size();
	vl cnts(2019);
	cnts[0]++;
	ll cur=0,mult=1;
	rrep(i,n){
		cur+=mult*(s[i]-'0');
		cur%=2019;
		mult=(mult*10)%2019;
		cnts[cur]++;
	}
	ll ans=0;
	for(auto x:cnts){
		ans+=(x-1)*x/2;
		ans%=MOD;
	}
	puta(ans);
}


Measured memory_bytes: 3692
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  int A, B;
  string S, T, U;

  cin >> S >> T;
  cin >> A >> B;
  cin >> U;

  if (S.compare(U) == 0) {
    cout << A - 1 << " " << B << endl;
  } else {
    cout << A << " " << B - 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <cassert>

using namespace std;

#define TT1T2 template<class T1, class T2>
TT1T2 void debug_print_array(const T1 &a, T2 sz, T2 beg = 0){ for (T2 i = beg; i<sz; i++) cerr << a[i] << (i + 1 != sz ? "," : ""); cout << endl; }
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DA(a,n) cerr<<#a<<"=["; debug_print_array(a,n); cerr<<"]\n"
double __begin;
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <typename T, const int N> using Graph = vector <T> [N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(20);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    string s;
    cin >> s;

    string pattern = "YAKI";
    if (s.size() < 4) {
        cout << "No" << endl;
        return 0;
    }

    if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    sort(A.rbegin(),A.rend());
    res += A[0];
    int cnt = 2;
    for(int i = 1; i < N;i++){
        if(cnt == N) break;
        res += A[i];
        cnt++;
        if(cnt == N) break;
        res += A[i];
        cnt++;
        if(cnt == N) break;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 4704
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
#include<set>
#include <cstdint>
using namespace std;
using ll = __int64_t;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;
const ll mod=1e9+7;


//II→factorialを計算するrange
constexpr ll MOD = 998244353;
template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};


int main(void){
      int n;
      cin>>n;
      int a[n];
      rep0(i,n) cin>>a[i];
      constexpr int V=1e6+3;
      vector<modint<MOD>> w(V+2,0);
      vector<modint<MOD>> c(V+3,0);
      vector<modint<MOD>> s(V+3,0);
      vector<modint<MOD>> sum1(V+3,0);
      vector<modint<MOD>> sum2(V+3,0);
      constexpr modint<MOD> I=1;
      constexpr modint<MOD> II=2;
      w[0]=0;
      for(int i=1;i<V;i++){
            modint<MOD> j=i;
            w[i]=I/j;
      }
      for(int i=1; i<V;i++){
            for(int j=2*i;j<V;j+=i){
                  w[j]-=w[i];
            }
      }
      for(int i=0;i<n;i++){
            c[a[i]]+=I;
      }
      for(int d=1;d<V;d++){
            for(int j=d;j<V;j+=d){
              if(c[j].a==0) continue;
                  modint<MOD> l=j;
                  sum1[d]+=(l*c[j]);
            }
      }
      for(int d=1;d<V;d++){
            for(int j=d;j<V;j+=d){
              if(c[j].a==0) continue;
                  modint<MOD> l=j;
                  sum2[d]+=(l*l*c[j]);
            }
      }
      for(int d=1;d<V;d++){
            s[d]=((sum1[d]*sum1[d])-sum2[d])/II;
      }
      modint<MOD> ans=0;
      for(int d=1;d<V;d++){
            ans+=w[d]*s[d];
      }
      cout<<ans.a<<endl;
      return 0;
}

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

int n;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    int cnt = 0;
    cin >> s;
    for(int i = 0 , j = s.length()-1 ; (i < s.length()/2) && (j >= s.length()/2) ; i++,j--){
        if(i == j)break;
        if(s[i] != s[j]){
            cnt += 1;
        }

    }
    cout << cnt << '\n';
    return 0;
}







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

using namespace std;


int N;
int l[100001];
int dp[100001][3] = {};

int main() {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> l[i];
	}

	dp[1][0] = 1;
	dp[1][1] = 1;
	dp[1][2] = 1;

	for (int i = 2; i <= N; i++) {
		if (l[i] != l[i-1]) {
			dp[i][0] = dp[i - 1][0] + 1;
			dp[i][1] = dp[i - 1][1] + 1;
			dp[i][2] = dp[i - 1][2] + 1;
		}
		else {
			dp[i][0] = 1;
			dp[i][1] = dp[i - 1][0] + 1;
			dp[i][2] = dp[i - 1][1] + 1;
		}
	}

	int ans = 0;
	for (int i = 2; i <= N; i++) {
		for (int j = 0; j < 3; j++) {
			ans = max(ans, dp[i][j]);
		}
	}

	cout << ans << endl;


	return 0;
}




Measured memory_bytes: 4652
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int N,T;
 
vector<int> G[1111];
bool F[1111][1111];
int X,Y;
 
int dub(int a){ return a*a; }
int abs( P a, P b ){
  return dub(a.first-b.first)+dub(a.second-b.second);
}
 
int main(){
  cin >> T;
  while( T-- ){
    for(int i=0;i<N;i++) G[i].clear();
    cin >> N >> X >> Y;
    P s;
    cin >> s.first >> s.second;
    P v[1111];
    for(int i=0;i<N;i++)
      cin>> v[i].first >> v[i].second;    
    queue<int> q;
    int H[1111] = {};
    for(int i=0;i<N;i++){
      if( abs( s, v[i] ) <= 10*10 ) {
        q.push( i );
        H[i] = X;
      }
      for(int j=i+1;j<N;j++){       
        if( abs(v[i],v[j]) <= 50*50 ){
          G[i].push_back( j );
          G[j].push_back( i );
        }
      }
    }
     
    memset(F,0,sizeof(F));
    int res = 0;
    while( !q.empty() ){
      int p = q.front(); q.pop();
      int time = H[p];
      res = max( res, time );
      //  cout<< p << " "<< time << endl;
      for(int i=0;i<(int)G[p].size();i++){
        int to =G[p][i];
        if( H[to] > 0 && H[to] >= time - Y ) continue;
        if( F[i][to] ){
          res = -1; goto end;
        }
        F[i][to] = true;
        q.push( to );
        H[to] = time + X;
      }
    }
  end:;
    if( res == -1 ) cout << "You're always welcome!" << endl;
    else cout << res << endl;
  }
   
}

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

#ifdef DEBUG
#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))

#define LOGM(msg) (cerr << (msg))

#define LOGV(vec, sep) {                                        \
    cerr << #vec << " =";                                       \
    for (const auto& v : (vec)) cerr << " " << v;               \
    cerr << (sep); }

#define LOGA(arr, N, sep) {                                     \
        cerr << #arr << " =";                                   \
        for (int i = 0; i < N; ++i) cerr << " " << (arr)[i];    \
        cerr << (sep); }

#define LOGA2(arr, N, M, sep) {                                 \
        cerr << #arr << " =\n";                                 \
        for (int i = 0; i < N; ++i) {                           \
            for (int j = 0; j < M; ++j)                         \
                cerr << (arr)[i][j] << " ";                     \
            cerr << endl;                                       \
        } cerr << (sep); }
#else
#define LOG(var, sep)
#define LOGM(msg)
#define LOGV(vec, sep)
#define LOGA(arr, N, sep)
#define LOGA2(arr, N, M, sep)
#endif

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll mod(ll x)
{
    return (((x % MOD) + MOD) % MOD);
}

ll mod_pow(ll a, ll n)
{
    ll res = 1, base = a;

    while (n)
    {
        if (n & 1)
            res = (res * base) % MOD;

        base = (base * base) % MOD;
        n >>= 1;
    }

    return res;
}

ll solve(int, const vector<ll>& xs)
{
    ll sum = accumulate(xs.begin(), xs.end(), 0LL);
    sum = mod(sum);
    ll ans = mod(sum * sum);

    for (auto x : xs)
        ans = mod(ans - x*x);

    ans = mod(ans * mod_pow(2, MOD - 2));

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<ll> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i];

    auto ans = solve(N, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4828
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< string, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


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

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

int N, K;
int V[100];
int num;
int ans = 0;
priority_queue< int >pq;

int main(){
    
    cin>>N>>K;
    
    REP( i, N ) cin>>V[i];
    
    REP( i, min( K+1, N+1 ) ){
        REP( j, i+1 ){
            num = 0;
            while( !pq.empty() ) pq.pop();
            REP( x, j ){
                num += V[x];
                if( V[x] < 0 ) pq.push( -V[x] );
            }
            REP( x, i-j ){
                num += V[N-x-1];
                if( V[N-x-1] < 0 ) pq.push( -V[N-x-1] );
            }
            REP( x, K-i ){
                if( pq.empty() ) break;
                num += pq.top();
                pq.pop();
            }
            //cout<<"***"<<i<<"-"<<num<<endl;
            ans = max( ans, num );
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 256
import sys
_,*s = sys.stdin.read().strip().split("\n")
s = [i[0] for i in s]
c = [s.count("M"),s.count("A"),s.count("R"),s.count("C"),s.count("H")]
a = 0
for i in range(3):
    for j in range(3-i):
        for k in range(3-i-j):
            a += c[i]*c[i+j+1]*c[i+j+k+2]
print(a)

Measured memory_bytes: 11196
// ================
// Himanshu Lal
// MNIT Jaipur
// ================
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define TEZ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define INF 1e18
#define vi vector<pair<ll,ll>>
#define ff first
#define ss second
#define mp map<ll,ll>
#define test ll tp; cin>>tp; while(tp--)
#define srt(v) sort(v.begin(),v.end())
double pi=acos(-1);
void OJ(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
}
int main(){
    TEZ;
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n);
    f(i,0,n)
        cin>>v[i];
    srt(v);
    ll ans=0,i=0;
    while(k--){
        ans+=v[i++];
    }
    cout<<ans;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<math.h>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, k = 0;
	int a, b, c;
	int HappyValue[2][3];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d %d %d", &a, &b, &c);
		if (i == 0)
		{
			HappyValue[0][0] = a;
			HappyValue[0][1] = b;
			HappyValue[0][2] = c;
		}
		else
		{
			HappyValue[k][0] = a + max(HappyValue[1 - k][1], HappyValue[1 - k][2]);
			HappyValue[k][1] = b + max(HappyValue[1 - k][2], HappyValue[1 - k][0]);
			HappyValue[k][2] = c + max(HappyValue[1 - k][0], HappyValue[1 - k][1]);

			//printf("%d %d %d %d\n", i, HappyValue[k][0], HappyValue[k][1], HappyValue[k][2]);
		}
		k = 1 - k;
	}
	k = 1 - k;
	printf("%d\n", max(max(HappyValue[k][0], HappyValue[k][1]), HappyValue[k][2]));
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N= sc.nextInt();
		long a[] = new long[N*3];
		for(int i=0;i<N*3;i++) {
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);
		long sum =0;
		for (int i=N;i<3*N;i+=2) {
			sum +=a[i];
		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 97080