akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int n,a,b,c,d;
ll res=0;

ll fact[200000], invFact[200000]; 

long long power(long long x, long long c) {
    if(c==0) return 1;
    if(c==1) return x;
    if (c%2==1) return (power( (x*x)%MOD, c/2)*x)%MOD;
    else return power( (x*x)%MOD, c/2)%MOD;
}

void make_combT(ll n){
    fact[0]=1;
    rep1(i,n) fact[i]= fact[i-1]*i%MOD;
    
    invFact[n] = power(fact[n],MOD-2);
    rrep(i,n-1) invFact[i] = invFact[i+1] * (i+1) %MOD;
}

ll comb(ll n, ll m){
    if(n<m||n<0||m<0) return 0;
    return (fact[n] * invFact[m] %MOD) * invFact[n-m] %MOD;
}

ll hcomb(ll n, ll m){
    if(n==0&&m==0) return 1;
    return comb(n+m-1,m);
}

ll dp[1009][1009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>a>>b>>c>>d;
    make_combT(2000);
    
    dp[0][0]=1;
    rep1(i,b-a+1){
        rep(j,n+1){
            dp[i][j]+=dp[i-1][j];
            int e=a+i-1;
            for(int f=c;f<=d&&e*f<=j;f++){
                dp[i][j] += dp[i-1][j-e*f]*fact[n-j+e*f]%MOD*power(fact[f]*fact[n-j]%MOD*power(fact[e],f)%MOD,MOD-2)%MOD;
                dp[i][j]%=MOD;
            }
        }
    }
    cout1(dp[b-a+1][n]);
}

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

int main(){
	int n;
	cin>>n;
	
	int t = 0;
	int flag = 0;
	for(int i = 0; i < n; i++){
		int x;
		cin>>x;
		if(x != i+1 && t == 0){
			t = x;
		}else if(x != i+1){
			if(t != i+1){
				flag = 1;
			}
		}
	}
	if(flag){
		cout<<"NO"<<endl;
	}else{
		cout<<"YES"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int P=139;
const int mod=149;
const int maxn=1e6+5;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int minn=0xc0c0c0c0;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    if(n==0)
    	cout<<1<<endl;
    else if(n==1)
    	cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3600
w,h,c=input().split()
w=int(w)
h=int(h)
a=""
d=""
d_e=""
cnt=2

for i in range(w-2):
    cnt+=1
    a+="-"
    d+="."
    if cnt!=w//2+2:
        d_e+="."
    else:
        d_e+=c
    
print("+"+a+"+")

cnt=2

for j in range(h-2):
    cnt+=1
    if cnt!=h//2+2:
        print("|"+d+"|")
    else :
        print("|"+d_e+"|")
print("+"+a+"+")
        
        



Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {
	int N,K;
	cin >> N >> K;
	int D[K];
	for(int i=0; i<K; i++){
		cin>>D[i];
	}
	
	for(int i=N; ; i++){
		int j=i;
		int flag=1;
		while(j>0){
			for(int k=0; k<K; k++){
				if(j%10 == D[k]){
					flag=0;
				}
			}
			j/=10;
		}
		if(flag==1){cout << i <<endl; return 0;}
	}
	return 0;
}

Measured memory_bytes: 256
import math
import sys
x=input()
x0=x.split()
a=int(x0[0])
b=int(x0[1])
n=int(x0[2])
b0=n%b
b1=0
q1=0
if b==1:
    print(0)
    sys.exit()
for i in range(1,math.floor(n/b)+1):
    b1=b*i-1
    q1=max(q1,math.floor(a*b1/b)-a*math.floor(b1/b))
q2=math.floor(a*b0/b)-a*math.floor(b0/b)
print(max(q1,q2))

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

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

using namespace std;
using lint=long long;

int main(){
	lint x; cin>>x;
	for(lint a=-1000;a<=1000;a++)  for(lint b=-1000;b<=1000;b++) if(a*a*a*a*a-b*b*b*b*b==x) {
		printf("%lld %lld\n",a,b);
		return 0;
	}
	return 0;
}


Measured memory_bytes: 3760
package main

import "fmt"

func pow(a, p, m int) int {
	ret := 1
	for p > 0 {
		if p%2 == 1 {
			ret = (ret * a) % m
		}
		a = (a * a) % m
		p /= 2
	}
	return ret
}

const M = 1000000007

func main() {
	var m, n int
	fmt.Scanln(&m, &n)
	fmt.Println(pow(m, n, M))
}


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

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

    switch(n % 10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon";
            break;
        default:
            cout << "bon";
    }
    cout << endl;

}

Measured memory_bytes: 3592
N = gets.to_i
W = N.times.map { gets.split.map(&:to_s) }
ngMatsubi = 0
ngUniq = 0
matsubi = W[0][0].size
preMatsubi = W[0][0][matsubi - 1]
(1..W.size - 1).each do |y|
  matsubi = W[y][0].size
  ngMatsubi = 1 if preMatsubi != W[y][0][0]
  preMatsubi = W[y][0][matsubi - 1]
end
(0..W.size - 1).each do |y|
  (y + 1..W.size - 1).each do |i|
    ngUniq = 1 if W[y][0] == W[i][0]
  end
end
if ngMatsubi == 1 || ngUniq == 1
  puts 'No'
else
  puts 'Yes'
end

Measured memory_bytes: 1788
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    s = str(input().rstrip('\n'))
    a = []
    for i in range(n):
        if i == k - 1:
            a.append(s[i].lower())
        else:
            a.append(s[i])
    print("".join(a))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	m := map[int]bool{}
	for i := 0; i < k; i++ {
		var d int
		fmt.Scan(&d)
		for j := 0; j < d; j++ {
			var a int
			fmt.Scan(&a)
			m[a] = true
		}
	}
	fmt.Println(n - len(m))
}


Measured memory_bytes: 2468
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N;
int H[100005];
int DP[100005];

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

  int N;
  cin >> N;
  rep(i, N) cin >> H[i];

  rep(i, N) {
    if (i==0) {
      DP[0] = H[0]; // N=1のときはないので。
      continue;
    };
    if (i==1) {
      DP[1] = abs(H[1] - H[0]);
      continue;
    }
    if (i==2) {
      DP[i] = min(abs(H[i] - H[i-1])+DP[i-1], abs(H[i] - H[i-2]));
      continue;
    }
    DP[i] = min(abs(H[i] - H[i-1])+DP[i-1], abs(H[i] - H[i-2])+DP[i-2]);
  }

  cout << DP[N-1] << endl;
  return 0;
}

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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

// ----------------------------------------------

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

  string s;
  cin >> s;

  bool flag = 1;

  int k = 0;

  if (s[0] != 'A') {
    flag = 0;
  } else {
    int n = s.length();
    int count = 0;
    repi(i, 2, n-1) {
      if (s[i] == 'C') {
        count++;
        debug(i);
        debug(count);
        k = i;
      }
    }
    if (count != 1) {
      flag = 0;
    }

    repi(j, 1, n) {
      if (j == k) continue;
      if (!islower(s[j])) {
        flag = 0;
      }
    }
  }

  cout << (flag ? "AC" : "WA") << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        String S = sc.next();
        
        StringBuilder sb = new StringBuilder();
        
        for(int i = 0; i < N; i++){
            if ( i == K - 1 ){
                sb.append(Character.toLowerCase(S.charAt(i)));
            } else {
                sb.append(S.charAt(i));
            }
            
        }
        
        System.out.println(sb);
    }
}


Measured memory_bytes: 21844
import sys
#from collections import defaultdict, deque, Counter
#from bisect import bisect_left
#import heapq
#import math
#from itertools import groupby as gb
#from itertools import permutations as perm
#from itertools import combinations as comb
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
#A, B, C = map(int, stdin.readline().rstrip().split())
numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]

nx = 0
ny = 0
nt = 0
for number in numbers:
    t=number[0]
    x = number[1]
    y = number[2]
    sa = abs(x-nx) + abs(y-ny)
    if sa%2 == (t-nt)%2 and sa <= (t-nt):
        nx = x
        ny = y
        nt = t
    else:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 21068
import sys
def main():
  _int = int
  _abs = abs
  n = int(input())
  data = [[_int(e) for e in input().split()] for _ in range(n)]
  t, x, y = 0, 0, 0
  for d in data:
    rt = d[0] - t - _abs(x - d[1]) - _abs(y - d[2])
    if rt < 0 or rt & 1 == 1:
      print('No')
      sys.exit()
    t, x, y = d
  print('Yes')
main()


Measured memory_bytes: 21156
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
const ll INF = 1ll<<60;
 
typedef pair<ll,ll> P;
 
int main() {
  ll n, x, d;
  cin >> n >> x >> d;
 
  if (d == 0) {
    if (x == 0) {
      cout << 1 << endl;
    } else {
      cout << n+1 << endl;
    }
    return 0;
  }
 
  map<int,vector<P>> mp;
  rep(i,n+1) {
    ll s = x*i;
    ll l = (ll)i*(i-1)/2;
    ll r = l + (ll)i*(n-i);
    s += l*d;
    r -= l;
    mp[(s+(d<<30))%d].emplace_back(s,r);
  }
 
  ll ans = 0;
  for (auto p : mp) {
    auto a = p.second;
    int m = a.size();
    rep(i,m) a[i].first = (a[i].first-p.first)/d;
    vector<P> ev;
    rep(i,m) {
      ev.emplace_back(a[i].first, 1);
      ev.emplace_back(a[i].first+a[i].second+1, -1);
    }
    sort(ev.begin(), ev.end());
    ll cnt = 0, pre = -INF;
    for (auto e : ev) {
      ll len = e.first-pre;
      if (cnt) ans += len;
      cnt += e.second;
      pre = e.first;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 25500
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

p2 = p[:x]
q2 = q[:y]

l = p2 + q2 + r
l.sort(reverse=True)

ans = sum(l[:x+y])
print(ans)

Measured memory_bytes: 29532
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_C
{
    class C099
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[] c = new int[N+1];

            List<int> x = new List<int>();
            int z = 1;
            x.Add(z);
            while (true)
            {
                z *= 6;
                if (z > N) break;
                x.Add(z);
            }
            z = 1;
            while (true)
            {
                z *= 9;
                if (z > N) break;
                x.Add(z);
            }


            int counter = 1;
            List<int> current = new List<int>();
            current.Add(0);

            while (c[N] == 0){
                List<int> next = new List<int>();
                foreach (int n in current)
                {
                    foreach (int m in x)
                    {
                        if (n + m > N) continue;
                        if (c[n + m] == 0)
                        {
                            c[n + m] = counter;
                            next.Add(n + m);
                        }
                    }
                }
                counter++;
                current = next;
            }
            Console.WriteLine(c[N]);
        }

    }
}


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

using namespace std;

typedef long long ll;

string s;
int ps[500000];
int n, m;

signed main()
{
    cin >> s;

    if (s == "A")
    {
        cout << "T";
    }
    if (s == "T")
    {
        cout << "A";
    }
    if (s == "G")
    {
        cout << "C";
    }
    if (s == "C")
    {
        cout << "G";
    }
}


Measured memory_bytes: 256
def func():
    len_num_seq = int(input())
    count = 0
    a_n = input().rstrip().split(' ')
    for j in range(len_num_seq-2):
        if ((int(a_n[j]) < int(a_n[j+1]) and int(a_n[j+1]) < int(a_n[j+2])) or
           (int(a_n[j]) > int(a_n[j+1]) and int(a_n[j+1]) > int(a_n[j+2]))):
            count += 1
    print(count)

if __name__ == "__main__":
    func()



         

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, K, XI;
    int C = 0;
    cin >> N;
    cin >> K;
    for (int i = 0; i < N; i++){
        cin >> XI;
        if (XI < K - XI){
            C = C + (XI * 2);
        }
        else{
            C = (K - XI) * 2 + C;
        }
    }
    cout << C << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int r;
    cin>>r;
    if (r<1200)
        cout<<"ABC\n";
    else if (r<2800)
        cout<<"ARC\n";
    else
        cout<<"AGC\n";
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }




// ***************************************

double dist(vector<int>y, vector<int>z){
    double ans = 0;
    REP(i, y.size()){
        ans += pow(y[i] - z[i], 2);
    }
    return sqrt(ans);
}

int main(){

    int N, D;
    cin >> N >> D;

    vector<vector<int>> X(N, vector<int>(D));

    for(auto& x: X){
        REP(i, D){
            cin >> x[i];
        }
    }

    int ans = 0;
    REP(i, N-1){
        FOR(j, i+1, N){
            double d = dist(X[i], X[j]);
            if (d == floor(d)) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N, A, B;
  cin >> N;
  cin >> A >> B;
  int counts[3] = {};
  rep (i, N) {
    int P;
    cin >> P;
    if (P <= A) counts[0]++;
    else if (P >= A + 1 && P <= B) counts[1]++;
    else counts[2]++;
  }
  int ans = 100;
  for (const int &count : counts) ans = min(ans, count);
  cout << ans << endl;
  return 0;
}

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

struct Stat {
    int unmatchedOpening, unmatchedClosing, index;
    Stat(int _uo, int _uc, int _index): unmatchedOpening(_uo), unmatchedClosing(_uc), index(_index) {}
};

//Comparing two stats which unmatchedOpening - unmatchedClosing >= 0
bool cmpFirst(Stat a, Stat b) {
    return a.unmatchedClosing < b.unmatchedClosing;
}

//Comparing two stats which unmatchedOpening - unmatchedClosing < 0
bool cmpSecond(Stat a, Stat b) {
    return a.unmatchedOpening > b.unmatchedOpening;
}

//{unmatchedOpening, unmatchedClosing}
pair<int, int> getStat(string s) {
    int unmatchedOpening = 0;
    int unmatchedClosing = 0;

    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '(') {
            unmatchedOpening += 1;
        } else {
            if (unmatchedOpening > 0)
                unmatchedOpening -= 1;
            else
                unmatchedClosing += 1;
        }
    }

    return make_pair(unmatchedOpening, unmatchedClosing);
}

int main() {
    int n;
    vector<Stat> first; //unmatchedOpening - unmatchedClosing >= 0
    vector<Stat> second; //unmatchedOpening - unmatchedClosing < 0

    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;

        auto stat = getStat(s);
        if (stat.first - stat.second >= 0)
            first.push_back(Stat(stat.first, stat.second, i));
        else
            second.push_back(Stat(stat.first, stat.second, i));
    }

    sort(first.begin(), first.end(), cmpFirst);
    sort(second.begin(), second.end(), cmpSecond);

    bool valid = true;
    int balance = 0;

    for (auto f: first) {
        if (balance - f.unmatchedClosing < 0) {
            valid = false;
            break;
        }

        balance -= f.unmatchedClosing;
        balance += f.unmatchedOpening;
    }

    for (auto s: second) {
        if (balance - s.unmatchedClosing < 0) {
            valid = false;
            break;
        }

        balance -= s.unmatchedClosing;
        balance += s.unmatchedOpening;
    }

    if (balance != 0)
        valid = false;

    if (valid) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

/*
Test cases:

4
(
))(((
)((
)))
*/


Measured memory_bytes: 15144
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int K; cin >> K;
    //7/9 * (10^x -1) = 0 mod K

    if (K == 1 || K == 7){
        cout << 1 << endl;
        return 0;
    } 

    int ans = 1;
    int X = 7;
    while (ans < 1e8){
        if (X%K == 0){
            cout << ans << endl;
            return 0;
        }

        ans++;
        X *= 10;
        X += 7;
        X %= K;   
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    string S;
    cin >> S;
    int a = 0, b = 0;
    rep(i, 3) {
        if (S[i] == 'A') a++;
        if (S[i] == 'B') b++;
    }

    if (a > 0 && b > 0) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
struct Dscc {
public:

	//fst:belongs , scd:newedges
	pair<vector<vector<int>>, vector<vector<int>>>get(const vector<vector<int>>&edges) {
		nums.resize(edges.size());
		fill(nums.begin(), nums.end(), -1);
		vector<vector<int>>revedges(edges.size());
		for (int i = 0; i < edges.size(); ++i) {
			for (auto j : edges[i]) {
				revedges[j].push_back(i);
			}
		}
		int num = 0;
		for (int i = 0; i < edges.size(); ++i) {
			dfs(i, num, edges);
		}
		vector<int>big(nums.size());
		for (int i = 0; i < nums.size(); ++i) {
			big[nums[i]] = i;
		}
		reverse(big.begin(), big.end());
		unis.resize(edges.size());
		fill(unis.begin(), unis.end(), -1);
		num = 0;
		for (int i = 0; i < big.size(); ++i) {

			dfs2(big[i], num, revedges);
			num++;
		}
		vector<int>nums;
		for (int i = 0; i < unis.size(); ++i) {
			nums.push_back(unis[i]);
		}
		sort(nums.begin(), nums.end());
		nums.erase(unique(nums.begin(), nums.end()), nums.end());


		map<int, int>mp;
		for (int i = 0; i < nums.size(); ++i) {
			mp[nums[i]] = i;
		}
		for (int i = 0; i < unis.size(); ++i) {
			unis[i] = mp[unis[i]];
		}

		vector<vector<int>>belongs(nums.size());
		for (int i = 0; i < unis.size(); ++i) {
			belongs[unis[i]].push_back(i);
		}
		vector<vector<int>>newedges(nums.size());
		for (int i = 0; i < edges.size(); ++i) {
			for (auto j : edges[i]) {
				if (unis[i] != unis[j]) {
					newedges[unis[i]].push_back(unis[j]);
				}
			}
		}
		return make_pair(belongs, newedges);
	}
private:
	vector<int>nums;
	vector<int>unis;


	void dfs(const int id, int &num, const vector<vector<int>>&edges) {
		if (nums[id] != -1)return;
		else {
			nums[id] = -2;
			for (auto i : edges[id]) {
				dfs(i, num, edges);
			}
		}
		nums[id] = num++;
		return;
	}
	void dfs2(const int id, const int &num, const vector<vector<int>>&edges) {
		if (unis[id] != -1)return;
		else {
			unis[id] = -2;
			for (auto i : edges[id])
				dfs2(i, num, edges);
		}
		unis[id] = num;
		return;
	}

}dscc;

int main() {
	int N; cin >> N;
	vector<vector<int>>edges(N);
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		edges[i].push_back((i + a) % N);
	}
	auto p = dscc.get(edges);
	int ans = 0;
	for (int i = 0; i < p.second.size(); ++i) {
		if (p.second[i].empty())ans += p.first[i].size();
	}
	cout << ans << endl;


	return 0;
}

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



int main () {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  vector<int> A(n), dp(n, 1);
  for (int i = 0; i < n; ++i) cin >> A[i];
  for (int i = n - 1; i >= 0; --i) {
    dp[i] = A[i] >= A[i + 1] ? dp[i + 1] : 0;
    dp[i] += 1;
  }
  cout << *max_element(dp.begin(), dp.end()) - 1 << '\n';
}



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

def return_prob(x):
  if K <= x:
    return 1
  else:
    return 1 / (2 ** math.ceil(math.log2(K/x)))

prob = 0
for i in range(1, N+1):
  prob += return_prob(i)
prob /= N
print(prob)

Measured memory_bytes: 9296
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

vector<int> pre,in,post;
int n,pos;

void reconstruction(int l,int r)
{
	if(l>=r)return;
	int c=pre[pos++];
	int m=distance(in.begin(),find(in.begin(),in.end(),c));
	reconstruction(l,m);
	reconstruction(m+1,r);
	post.push_back(c);
}

int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		int j;
		cin>>j;
		pre.push_back(j);
	}
	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		in.push_back(k);
	}
	reconstruction(0,n);
	for(int i=0;i<n;i++){
		if(i)cout<<" ";
		cout<<post[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3144
def main():
    n, k = map(int, input().split())
    x = sum(2 * i % k == 0 for i in range(1, k))
    a, b = n // k, n % k
    y = sum(2 * i % k == 0 for i in range(k * a + 1, k * a + b + 1))
    c = x * a + y
    ans = (x * a + y) ** 3 + a ** 3
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
# encoding: utf-8
x = int(input())

dice = [6, 5]

score_tmp = x - (x % 11)
ans = (score_tmp // 11) * 2

for i in range(2):
    if score_tmp >= x: break
    score_tmp += dice[i % 2]
    ans += 1

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;
  
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;
 
struct LowLink {
    
    vector < vector < int > > G;
    vector < int > ord, low;
    vector < bool > used;
    vector < pair < int, int > > bridge;
    vector < int > articulation_point;
    const int INF = 1145141919;
    
    LowLink (int n) : G(n), ord(n), low(n), used(n) {}
    
    void add_edge(int a, int b) {
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    void build(int root) {
        fill(low.begin(), low.end(), INF);
        fill(used.begin(), used.end(), false);
        dfs(root, -1, 1);
    }
    
    int dfs(int v, int prev, int cnt) {
        used[v] = true;
        low[v] = ord[v] = cnt;
        int min_low = cnt;
        int route = 0;
        bool isArticulation = false;
        for (int i = 0; i < G[v].size(); i++) {
            if (!used[G[v][i]]) {
                route++;
                int low_nxt = dfs(G[v][i], v, cnt + 1);
                if (ord[v] < low_nxt) {
                    bridge.push_back(make_pair(v, G[v][i]));
                }
                if (prev != -1 && G[v].size() >= 2 && low_nxt >= cnt) {
                    isArticulation = true;
                }
                min_low = min(min_low, low_nxt);
            } else if (G[v][i] != prev) {
                min_low = min(min_low, low[G[v][i]]);
            }
        }
        if (prev == -1 && route > 1) isArticulation = true;
        if (isArticulation) articulation_point.push_back(v);
        return low[v] = min_low;
    }
    
};

 
int main() {
 
    int V,E; cin >> V >> E;
    LowLink inst(100010);
 
    REP(i,E) {
        int a,b; cin >> a >> b;
        inst.add_edge(a, b);
    }
 
    inst.build(0);
 
    sort(inst.articulation_point.begin(), inst.articulation_point.end());
 
    REP(i,inst.articulation_point.size()) {
        cout << inst.articulation_point[i] << endl;
    }
 
    return 0;
}

Measured memory_bytes: 7204
#include <stdio.h> 
 
 
 int main(){ 
     int x; 
     int i=0; 
     while(1){ 
         scanf("%d", &x); 
         if(x==0)break; 
         printf("Case %d: %d\n", ++i, x); 
     } 
     return 0; 
 } 



Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int unsigned long long
#define mod 1000000007
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
#define Set setprecision
#define NO cout<<"NO\n"
#define YES cout<<"YES\n"
#define No cout<<"No\n"
#define Yes cout<<"Yes\n"
const int INFi=2147483647;
const long long INFl=9223372036854775807LL;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,c;
    int q;
    int t,f;
    itn sum=0;
    cin>>s>>q;
    for(int i=0;i<q;i++){
	cin>>t;
	if(t==1){
	    sum++;
	}
	else{
	    cin>>f>>c;
	    if(f==1){
		if(sum%2==0){
		    s.insert(0,c);
		}
		else s+=c;
	    }
	    else {
		if(sum%2==0){
		    s+=c;
		}
		else{
		    s.insert(0,c);		   
		}
	    }
	}
    }
    if(sum%2==1) re(s.be,s.en);
    cout<<s<<"\n";
}


Measured memory_bytes: 912
import java.util.*;
import java.io.*;

public class Main {

  private static void solve() {
    int n = nextInt();
    int w = nextInt();

    int[] value = new int[n];
    int[] weight = new int[n];

    for (int i = 0; i < n; i++) {
      weight[i] = nextInt();
      value[i] = nextInt();
    }

    long[][] dp = new long[n][w + 1];

    for (int i = 0; i < n; i++) {
      Arrays.fill(dp[i], -1);
    }

    dp[0][0] = 0;
    dp[0][weight[0]] = value[0];

    for (int i = 1; i < n; i++) {
      for (int j = 0; j <= w; j++) {
        dp[i][j] = dp[i - 1][j];
        if (j - weight[i] >= 0 && dp[i - 1][j - weight[i]] != -1) {
          dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - weight[i]] + value[i]);
        }
      }
    }

    long max = 0;
    for (int i = 0; i <= w; i++) {
      max = Math.max(max, dp[n - 1][i]);
    }

    System.out.println(max);
  }

  private static void run() {
    br = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);

    solve();

    out.close();
  }

  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;

  private static String next() {
    while (st == null || !st.hasMoreElements()) {
      String s;
      try {
        s = br.readLine();
      } catch (IOException e) {
        return null;
      }
      st = new StringTokenizer(s);
    }
    return st.nextToken();
  }

  private static int nextInt() {
    return Integer.parseInt(next());
  }

  private static long nextLong() {
    return Long.parseLong(next());
  }

  public static void main(String[] args) {
    run();
  }
}

Measured memory_bytes: 124628
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
signed main() {
	int n; cin >> n;
	string ans = "second";
	for0(i, n) { int p; cin >> p; if (p % 2)ans = "first"; }
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	if resolve(parseProblem()) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func parseProblem() (a, b, c, k int) {
	return scanInt(sc), scanInt(sc), scanInt(sc), scanInt(sc)
}

func resolve(a, b, c, k int) bool {
	state := []int{a, b, c}
	return dfs(state, k)
}

func dfs(state []int, k int) (success bool) {
	if state[0] < state[1] && state[1] < state[2] {
		return true
	}
	if k == 0 {
		return false
	}
	for i := 0; i < len(state); i++ {
		next := make([]int, len(state))
		copy(next, state)
		next[i] = state[i] * 2
		success := dfs(next, k-1)
		if success {
			return success
		}
	}
	return false
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1800
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define eps 1e-8
using namespace std;
const ll maxn = 1e6 + 5;
ll a,b,c,d,k,n,m,t,num[maxn],cnt = 2;
ll ans[maxn];
queue<ll> qu;
vector<ll> v;
double sum;
void slove()
{
    cin >> k;
    for(int i = 0; i < 9; i++)
        qu.push(i + 1);
    while(qu.size())
    {
        ll t = qu.front();
        qu.pop();
        if(t >= 4294967297)
            continue;
        v.push_back(t);
        ll temp2 = t % 10;
        if(temp2 == 9)
        {
            qu.push(t * 10 + 9);
            qu.push(t * 10 + 8);
        }
        else if(temp2 == 0)
        {
            qu.push(t * 10);
            qu.push(t * 10 + 1);
        }
        else
        {
            qu.push(t * 10 + temp2);
            qu.push(t * 10 + temp2 - 1);
            qu.push(t * 10 + temp2 + 1);
        }
    }
}
int main()
{
    slove();
    sort(v.begin(),v.end());
    cout << v[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 2932
#include <bits/stdc++.h>
using namespace std;
#define endl       "\n"
#define ll         long long
#define pb         push_back
#define FIO        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define NUM        1000000007
#define MOD        998244353
#define F          first
#define S          second
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a-1;i>=b;i--)
#define vi         vector<ll>
#define pii        pair<ll,ll>
#define vpi        vector<pii>
#define mi         map<ll,ll>
#define mpi        map<pii,ll>
#define all(v)     (v).begin(),(v).end()
#define rall(v)    (v).rbegin(),(v).rend()
#define fac(a)     tgamma(a+1)

bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b)
{ 
    return (a.second < b.second);      // compare function for sorting modification
}

vector<ll> primes;
vector<bool> PRIME(1000005,true);       // prime no.s less than 10^6
void sieve(ll n)                        // PRIME[i]=true => i=prime no.
{  PRIME[0]=false;PRIME[1]=false;
    for (ll p=2; p*p<=n; p++) { 
        if (PRIME[p] == true) { 
            for (ll i=p*p; i<=n; i += p){PRIME[i]=false;} 
        } 
    } rep(i,2,n+1){if(PRIME[i]){primes.pb(i);}}
}  

ll nCr[1001][1001];
void combination(ll n)                  // nCr values
{
    rep(i,0,n+1){
        rep(j,0,i+1){
            if(j==0 or j==i)nCr[i][j]=1;
            else nCr[i][j]=(nCr[i-1][j-1]+nCr[i-1][j])%NUM;
        }
    }
}

#define N  1000005

ll a,b,c,d,e,i,j,k,l,m,n,q,p,r,u,v,w,x,y,z,mn,mx;
ll arr[N];
//ll dp[2005][2005];

int main() 
{
    FIO;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        mn=LONG_LONG_MAX;
        mx=LONG_LONG_MIN;
        cin>>n;
        if(n%1000==0)cout<<"0";
        else cout<<1000-n%1000;
        
        
        
        
        
        
        
        
        
        
        h:;
        cout<<endl;
    }
    
    return 0;
}


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

int main (){
  int N ;
  cin >> N ;
  int line[N] ;
  int ans = 0;
  for(int i = 0 ; i < N ; i++ ) cin >> line[i] ;
  sort(line,line+N) ;
  int pre =  0;
  for(int i = 0 ; i < N ; i++ ){
    if(line[i]>pre) {
      ans ++ ;
      pre = line[i] ;
    }
  }
  cout << ans << endl ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

typedef long long LL;
typedef vector<int> VI;

int main() {
  int64_t L, R;
  cin >> L >> R;
  if (R - L >= 2018) {
    cout << 0 << endl;
    return 0;
  }
  int64_t minv = INT64_MAX;
  for (int64_t i = L; i < R; i++) {
    for (int64_t j = i+1; j <= R; j++) {
      minv = min({minv, i * j % 2019});
    }
  }
  cout << minv << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;
int main(){
    ll w,h,x,y;
    std::cin >> w>>h>>x>>y;
    std::cout <<keta(10)<< double(w*h)/2 << " ";
    if(w%2==0&&h%2==0){
        if((h/2==y&&w/2==x))std::cout << 1 << std::endl;
        else std::cout << 0 << std::endl;
    }
    else {
        std::cout << 0 << std::endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace  std;
 
typedef  long  long int ll;
typedef  vector<int> vi;
#define  fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  all(x) x.begin(), x.end()
const ll mod = (ll)(1e9 + 7); 
const double pi = 3.14159265358979323846;


void solve()
{
    ll a,b;cin>>a>>b;
    cout<<a*b<<endl;
}

int main()
{
    fast
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
// int t; cin>>t; while(t--) 
solve();
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;

    int a = 0;
    while (s[a] != x) ++a;

    int ans = 0;
    for (int i = a+1; i < n; ++i) {
        ans += t[i];
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <queue>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    int a, b;
    cin >> a >> b;
    cout<<max({a+b,a-b,a*b})<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <climits>

using namespace std;

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

struct Edge
{
	int to;
	int cost;
};

struct Node
{
	int city_index;
	int total_cost;
	int current_life;
	int can_regain_remain;

	bool operator >(const Node &a) const
	{
		return total_cost > a.total_cost;
	}
};

int main()
{
	int city_count, initial_life, cooler_count, road_count, start_index, goal_index;
	while (cin >> city_count >> initial_life >> cooler_count >> road_count >> start_index >> goal_index,
		city_count)
	{
		// input
		vector<int> is_cooler(city_count, false);
		REP(i, cooler_count)
		{
			int cooler_index;
			cin >> cooler_index;
			is_cooler[cooler_index] = true;
		}
		vector<vector<Edge>> roads(city_count);
		REP(i, road_count)
		{
			int from, to, cost;
			cin >> from >> to >> cost;
			roads[from].push_back({ to, cost });
			roads[to].push_back({ from, cost });
		}

		// dijkstra
		vector<vector<int>> d(city_count, vector<int>(initial_life + 1, INT_MAX)); // [city_index][current_life] => total_cost
		d[start_index][initial_life] = 0;
		priority_queue<Node, vector<Node>, greater<Node> > pq;
		pq.push({ start_index, 0, initial_life, 0});
		while (true)
		{
			if (pq.empty())
			{
				cout << "Help!" << endl;
				break;
			}
			auto current_node = pq.top(); pq.pop();
			if (current_node.city_index == goal_index)
			{
				cout << current_node.total_cost << endl;
				break;
			}
			for (auto &road : roads[current_node.city_index])
			{
				int total_cost = current_node.total_cost + road.cost;
				int life = current_node.current_life - road.cost;
				int can_regain_remain = is_cooler[current_node.city_index] ? initial_life - current_node.current_life : current_node.can_regain_remain;
				if (life < 0)
				{
					int shortage = -life;
					can_regain_remain -= shortage;
					if (can_regain_remain < 0)
					{
						continue;
					}
					total_cost += shortage;
					life = 0;
				}
				auto &di = d[road.to][can_regain_remain];
				if (total_cost < di)
				{
					di = total_cost;
					pq.push({ road.to, total_cost, life, can_regain_remain });
				}
			}

		}
	}

	return 0;
}

Measured memory_bytes: 1456
#include<iostream>
using namespace std;
int main(){
	int a,b,min=1000000,max=-1000000;
	long long s=0;
	cin >>a;
	for(int i=0;i<a;i++){
		cin >>b;
		if(b>max)
			max=b;
		if(b<min)
			min=b;
		s+=b;
	}
	cout  <<min<<" "<<max<<" "<<s<<endl;
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int P,Q,R;
  cin >>  P >> Q >> R;
  cout << min({P+Q,Q+R,R+P}) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

signed main(){
	int n, k;
	cin >> n >> k;

	vector<pair<int,int>> p(n);
	rep(i,n){
		cin >> p[i].second >> p[i].first;
	}
	sort(all(p), greater<pair<int, int>>());

	stack<int> s;
	vector<bool> eat(n + 1, false);
	int sum_k = 0, sum = 0;
	rep(i,k){
		sum += p[i].first;
		if(not eat[p[i].second]){
			sum_k++;
			eat[p[i].second] = true;
		}else{
			s.emplace(p[i].first);
		}
	}

	int ans = sum + sum_k * sum_k;;
	range(i,k,n){
		sum += p[i].first;
		if(not eat[p[i].second]){
			sum_k++;
			eat[p[i].second] = true;
		}else{
			s.emplace(p[i].first);
		}

		if(s.empty()){
			break;
		}

		sum -= s.top();
		s.pop();

		ans = max(ans, sum + sum_k * sum_k);
	}
	cout << ans << endl;
}


Measured memory_bytes: 2176
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
#define db double
const db eps = 1e-8;

struct Point{
    db x, y;
    Point(db x=0, db y=0): x(x), y(y) {}    //必须有初始化
    bool operator < (const Point &p){
        return x < p.x || (x == p.x && y < p.y);
    }
};

typedef Point Vector;
Vector operator + (Vector a, Vector b){ return Point(a.x+b.x, a.y+b.y);}
Vector operator - (Point a, Point b){ return Vector(a.x-b.x, a.y-b.y);}
Vector operator * (Vector a, db k){ return Vector(a.x*k, a.y*k);}
Vector operator / (Vector a, db k){ return Vector(a.x/k, a.y/k);}

//inline将函数名为内联函数，不使用栈空间，直接运算，但不能有while,switch等复杂语句
inline db dot(Vector a, Vector b){
    return a.x*b.x + a.y*b.y;
}
inline db cross(Vector a, Vector b){
    return a.x*b.y - b.x*a.y;
}
db length(Vector a){
    return sqrt(dot(a, a));
}
db angle(Vector a, Vector b){
    return acos(dot(a, b) / length(a) / length(b));
}

int dcmp(db x){
    if(fabs(x) < eps) return 0;
    return x < 0? -1: 1;
}
bool operator == (Point a, Point b){
    return dcmp(a.x-b.x) == 0 && dcmp(a.y-b.y) == 0;
}

struct Segment{
    Point p1, p2;
};
typedef Segment Line;
vector<Point> Polygon;
Point project(Line l, Point p){
    Point p1 = l.p1, p2 = l.p2;
    Vector a = p2 - p1, b = p - p1;
    db len_a = dot(a, a);   //这里不加sqrt，是因为下面算投影长度时，要除以两次len_a
    Vector tmp = a * (dot(a, b) / len_a);
    return Point(tmp.x+p1.x, tmp.y+p1.y);
}
Point reflect(Line l, Point p){
    Point tmp = project(l, p);
    return p + (tmp - p)*2;
}

int line_relation(Line l1, Line l2){
    Vector a = l1.p2 - l1.p1, b = l2.p2 - l2.p1;
    if(cross(a, b) == 0)
        return 2;
    else if(dot(a, b) == 0)
        return 1;
    return 0;
}
int segment_relation(Segment s1, Segment s2){
    Vector a = s1.p2 - s1.p1, b = s2.p2 - s2.p1;
    db flag = cross(a, b);
    if(flag < 0)  return 2;
    else if(flag > 0)  return 1;
    else{       //重合
        if(a.x*b.x < 0 || a.y*b.y < 0) return 3;
        else if(length(a) < length(b)) return 4;
        else return 5;
    }
}
int main()
{
    Line l1, l2;
    int n;
    cin >>n;
    while(n --){
        cin >>l1.p1.x >>l1.p1.y >>l1.p2.x >>l1.p2.y >>l2.p1.x >>l2.p1.y >>l2.p2.x >>l2.p2.y;
        int flag = line_relation(l1, l2);
        cout <<flag;
        cout << "\n";
    }
    return 0;
}



Measured memory_bytes: 3232