akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 2;

char s[N];

int main()
{
	//File("");
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	if (s[1] != s[n])
	{
		if (n & 1) puts("First");
		else puts("Second");
	}
	else
	{
		if (n & 1) puts("Second");
		else puts("First");
	}
	return 0;
}


Measured memory_bytes: 3856
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int n=in(),x=in()-1,y=in()-1;
    vec num(n-1);
    for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)num[min(j-i-1,abs(i-x)+abs(j-y))]++;
    REP(k,num)cout<<k<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    ll n, a , b;
    cin >> n >> a >> b;
    if(a > b) swap(a, b);
    ll d = b - a;
    if(d % 2 == 0) {
        cout << d / 2 << endl;
    }
    else {
        // cout << min(b-1, n-a) << endl;
        ll x = a-1 + 1 + (b-a-1)/2;
        ll y = n-b + 1 + (b-a-1)/2;
        cout << min(x, y) << endl;
    }
    return 0;
}

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

int main(void)
{
    int n, shuffle;
    char str[500];
    char tmp;
    while (1){
        for (int i = 0; i < 500; i++){
            str[i] = '\0';
        }
        scanf(" %s", str);
        if (!strcmp(str, "-")){
            break;
        }
        scanf(" %d", &n);
        for (int i = 0; i < n; i++){
            scanf(" %d", &shuffle);
            for (int j = 0; j < shuffle; j++){
                tmp = str[0];
                for (int k = 0; k < strlen(str) - 1; k++){
                    str[k] = str[k+1];
                }
                str[strlen(str)-1] = tmp;
            }
        }
        printf("%s\n", str);
    }
    return 0;
}


Measured memory_bytes: 2036
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(10);
}

#define int ll
void solve() {
	while (true) {
		int b, c, d;;
		string s;
		cin >> s;
		if (s == "#") return;
		cin >> b >> c >> d;
		int kaigen = 0;
		if (b > 31) {
			kaigen = 1;
		}
		if (b == 31 && c >= 5) {
			kaigen = 1;
		}
		if (kaigen == 1) {
			b -= 30;
			cout << "?";
		}
		else {
			cout << "HEISEI";
		}
		cout << " " << b << " " << c << " " << d << endl;
	}
}
#undef int

int main() {
	init();
	solve();
}


Measured memory_bytes: 3188
#include <stdio.h>

int factorize(long long n, long long p[], int m[])
{
	int k;
	long long i;
	for (i = 2, k = 0; i * i <= n; i++) {
		if (n % i != 0) continue;
		p[k] = i;
		for (m[k] = 0; n % p[k] == 0; m[k]++, n /= p[k]);
		k++;
	}
	if (n > 1) {
		p[k] = n;
		m[k++] = 1;
	}
	return k;
}

int main()
{
	long long N;
	scanf("%lld", &N);
	
	long long p[100];
	int i, j, m[100], k = factorize(N, p, m), ans = 0;
	for (i = 0; i < k; i++) {
		for (j = 0; j * (j + 1) <= m[i] * 2; j++);
		ans += j - 1;
	}
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n, a, b; cin >> n >> a >> b;
    if( (b-a) % 2 == 0){
        cout << "Alice" << endl;
    }else{
        cout << "Borys" << endl;
    }
}

Measured memory_bytes: 384
from collections import defaultdict


def main():
    n = input()
    vv = map(int, raw_input().split())
    d1 = defaultdict(int)
    for x in vv[::2]:
        d1[x] += 1
    d2 = defaultdict(int)
    for x in vv[1::2]:
        d2[x] += 1
    d1 = sorted([[c, x] for x, c in d1.items()], reverse=True)
    d2 = sorted([[c, x] for x, c in d2.items()], reverse=True)
    if d1[0][1] != d2[0][1]:
        print(n - d1[0][0] - d2[0][0])
        return
    if len(d1) == len(d2) == 1:
        print(n // 2)
        return
    if len(d1) == 1:
        print(n - d1[0][0] - d2[1][0])
        return
    if len(d2) == 1:
        print(n - d1[1][0] - d2[0][0])
        return
    print(n - max(d1[0][0] + d2[1][0], d1[1][0] + d2[0][0]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 57260
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i  = a; i < b; i++)
using ll = long long;
using ld = long double;
using P = std::complex<long double>;

const double eps = 1e-10;

ld cross(const P &l, const P &r) {
  return l.real() * r.imag() - l.imag() * r.real();
}

template <class iter>
std::pair<P, ld> min_ball(iter left, iter right, int seed = 1333) {
    const int n = right - left;

    assert(n >= 1);
    if (n == 1) {
        return {*left, ld(0)};
    }

    std::mt19937 mt(seed);
    std::shuffle(left, right, mt);
    // std::random_shuffle(left, right); // simple but deprecated

    iter ps = left;
    using circle = std::pair<P, ld>;

    auto make_circle_3 = [](const P &a, const P &b, const P &c) -> circle {
        ld A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b),
           S = cross(b - a, c - a);
        P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / (4 * S * S);
        ld r2 = std::norm(p - a);
        return {p, r2};
    };

    auto make_circle_2 = [](const P &a, const P &b) -> circle {
        P c = (a + b) / (ld)2;
        ld r2 = std::norm(a - c);
        return {c, r2};
    };

    auto in_circle = [](const P &a, const circle &c) -> bool {
        return std::norm(a - c.first) <= c.second + eps;
    };

    circle c = make_circle_2(ps[0], ps[1]);

    // MiniDisc
    for (int i = 2; i < n; ++i) {
        if (!in_circle(ps[i], c)) {
            // MiniDiscWithPoint
            c = make_circle_2(ps[0], ps[i]);
            for (int j = 1; j < i; ++j) {
                if (!in_circle(ps[j], c)) {
                    // MiniDiscWith2Points
                    c = make_circle_2(ps[i], ps[j]);
                    for (int k = 0; k < j; ++k) {
                        if (!in_circle(ps[k], c)) {
                            c = make_circle_3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}


int main(){
    int N; cin >> N;
    vector<P> p(N);
    rep(i, 0, N){
        int x, y;
        cin >> x >> y;
        p[i].real(x);
        p[i].imag(y);
    }

    cout << setprecision(10) <<  sqrt(min_ball(p.begin(), p.end()).second) << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e;
  cin >> a;
  b = a / 1000; //1000のくらい
  c = a % 1000 / 100; //100
  d = a % 100 / 10; //10
  e = a % 10; //1
  if(b==c && c==d){
  cout <<"Yes"<< endl;
  }
  else if(c==d && d==e){
  cout <<"Yes"<< endl;
  }
  else{
  cout <<"No"<< endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        if(A*B>C){          
            System.out.println(C);  
        }else{
            System.out.println(A*B);
        }        
    }
}

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

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

  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a * n, b) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000007
typedef long long ll;
using namespace std;

int cnt[9];
int main(){
  int a[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++) cin >> a[i][j];
  }
  int n; cin >> n;
  
  for(int i=0;i<n;i++){
    int b; cin >> b;
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(b == a[i][j]){
          cnt[i*3+j] = 1;
        }
      }
    }
  }
  bool flag = false;
  if(cnt[0] + cnt[1] + cnt[2] == 3) flag = true;
  if(cnt[3] + cnt[4] + cnt[5] == 3) flag = true;
  if(cnt[6] + cnt[7] + cnt[8] == 3) flag = true;
  if(cnt[0] + cnt[3] + cnt[6] == 3) flag = true;
  if(cnt[1] + cnt[4] + cnt[7] == 3) flag = true;
  if(cnt[2] + cnt[5] + cnt[8] == 3) flag = true;
  if(cnt[0] + cnt[4] + cnt[8] == 3) flag = true;
  if(cnt[2] + cnt[4] + cnt[6] == 3) flag = true;

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;

int IsPrime(int);

int main()
{
	int n;
	int count=0;
	int sosuuretu[247000] = { 0 };

	for (int i = 0; i < 247000; i++) {
		sosuuretu[i] = IsPrime(i);
	}

start:

	scanf("%d", &n);
	if (n == 0) goto finish;
	
	for (int i = n+1; i <= 2 * n; i++) {
		if (sosuuretu[i] == 1) {
			count++;
		}
	}

	cout << count << endl;

	count = 0;

	goto start;

finish:

	return 0;
}

int IsPrime(int n)
{
	int i;

	if (n < 2)
		return 0;
	else if (n == 2)
		return 1;

	if (n % 2 == 0)
		return 0;

	for (i = 3; i <= n / i; i += 2)
		if (n % i == 0)
			return 0;
	return 1;
}


Measured memory_bytes: 4180
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,ans,c=1,d=0;
  cin>>n;
  vector<long long>a(n);
  vector<long long>b(n+1);
  vector<long long>e(n+1);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    b.at(i)=a.at(i);
    e.at(a.at(i)-1)++;
  }
  sort(b.begin(),b.end()-1);
  for(int i=0;i<n;i++){
    if(b.at(i)==b.at(i+1)){
      c++;
    }
    else if(b.at(i)!=b.at(i+1)){
      ans=ans+c*(c-1)/2;
      c=1;
    }
  }
  d=ans;
  c=1;
  for(int i=0;i<n;i++){
    ans=d;
    m=a.at(i)-1;
    ans=ans-e.at(m)*(e.at(m)-1)/2+(e.at(m)-1)*(e.at(m)-2)/2;
    cout <<ans<<endl;
  }
}


Measured memory_bytes: 7296
#!python3

LI = lambda: list(map(int, input().split()))

# input
N = int(input())
A = LI()


def main():
    ans = 0
    for i in range(0, N, 2):
        if A[i] % 2 == 1:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9108
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int N, count = 0, mcount, max;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        int tmp = i;
        while (tmp % 2 == 0) {
            count++;
            tmp = tmp/2;
        }
        if (count >= mcount) {
            max = i;
            mcount = count;
        }
        count = 0;
    }
    cout << max << endl;
}

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

using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using usize = std::size_t;
using namespace std;

#define rep(i, max) for(i32 i = 0; i < (i32)max; ++i)
#define loop while(true)
#define allOf(collection) collection.begin(), collection.end()

unique_ptr<string> readLine() { unique_ptr<string> line(new string()); getline(cin, *line); return line; }
template<typename T1, typename T2> pair<T1, T2> readPair() { T1 res1; cin >> res1; T2 res2; cin >> res2; readLine(); return make_pair(res1, res2);}
template<typename T> unique_ptr<vector<T>> readVector(usize num, bool isForIndex = false) { unique_ptr<vector<T>> list(new vector<T>(num)); rep(i, num) { cin >> (*list)[i]; if(isForIndex) --(*list)[i]; } readLine(); return list; }
void readValues() { readLine(); }
template<typename H, typename... T> void readValues(H& head, T&&... tails){ H a; cin >> a; head = a; readValues(forward<T>(tails)...); }
void writeLine() { cout << endl; }
template<typename T> void write(const T& arg) { cout << arg; }
template<typename T> void writeLine(const vector<T>& arg){ if(arg.empty()) { writeLine(); return; } write(arg[0]); for(int i = 1; i < arg.size(); ++i){ write(" "); write(arg[i]); } writeLine(); }
template<typename T> void writeLine(const T& arg) { cout << arg << endl; }
void recursiveCombination(vector<i32>& indexes, i32 s, i32 rest, function<void(vector<i32>&)> f) { if (rest == 0) { f(indexes); } else { if (s < 0) return; recursiveCombination(indexes, s - 1, rest, f); indexes[rest - 1] = s; recursiveCombination(indexes, s - 1, rest - 1, f); } }
void foreachWithCombination(i32 n, i32 k, function<void(vector<i32>&)> f) { auto indexes = vector<i32>(k); recursiveCombination(indexes, n - 1, k, f); }
void foreachWithPermutaton(i32 n, function<void(vector<i32>&)> f) { auto indexes = vector<i32>(); indexes.reserve(n); rep(i, (usize)n) indexes.push_back(i); do f(indexes); while (next_permutation(allOf(indexes))); }
void foreachWithPermutaton(i32 n, i32 k, function<void(vector<i32>&)> f){ foreachWithCombination(n, k, [=](vector<i32>& combIndexes){ foreachWithPermutaton(k, [=](vector<i32>& permIndexes){ auto indexes = vector<i32>(); indexes.reserve(k); rep(i, (usize)k){ indexes.push_back(combIndexes[permIndexes[i]]); } f(indexes); }); }); }
void program();
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    program();
}

void program() {
    i32 n;
    readValues(n);
    auto a = *readVector<i32>(n);
    i32 q;
    readValues(q);
    auto numVec = vector<i32>(100000, 0);
    for(const auto& item: a) {
        ++numVec[item - 1];
    }
    i64 sum = accumulate(allOf(a), 0LL);

    auto b = vector<i32>();
    auto c = vector<i32>();

    rep(i, q) {
        i32 bVal, cVal;
        readValues(bVal, cVal);
        b.push_back(bVal);
        c.push_back(cVal); 
    }

    rep(i, q) {
        sum += numVec[b[i] - 1] * (c[i] - b[i]);
        numVec[c[i] - 1] += numVec[b[i] - 1];
        numVec[b[i] - 1] = 0;
        writeLine(sum);
    }
}

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

ans = 0
for i in range(0,10):
    for j in range(0,10):
        for k in range(0,10):
            p1 = s.find(str(i))
            if p1 == -1:
                continue
            p2 = s.find(str(j),p1+1)
            if p2 == -1:
                continue
            if s.find(str(k),p2+1) != -1:
                ans += 1

print(ans)

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, q;
  std::cin >> n >> q;
  std::vector<std::tuple<int64_t, int64_t, int64_t>> st(n);
  int64_t max_x = 1;
  for (int64_t i = 0; i < n; i++) {
    int64_t s, t, x;
    std::cin >> s >> t >> x;
    st[i] = std::make_tuple(-x, s, t);
    max_x = std::max(max_x, x);
  }
  std::vector<int64_t> d(q);
  std::cin >> d;

  std::sort(st.begin(), st.end());

  std::set<std::pair<int64_t, int64_t>> p;

  for (const auto i : st) {
    const auto s = std::get<1>(i);
    const auto x = -std::get<0>(i);
    const auto t = std::get<2>(i);
    const auto begin = s - x;
    const auto end = t - x;
    // std::cout << x << std::endl;
    if (p.empty()) {
      p.insert({begin, x});
      p.insert({end, -1});
    } else {
      auto itr = p.lower_bound({begin, -1});
      int64_t val = -1;
      auto itr2 = p.upper_bound({begin, -1});
      if (itr2 != p.begin()) {
        itr2--;
        val = itr2->second;
        // std::cout << "*+" << val << std::endl;
      }

      while (itr != p.end() && itr->first <= end) {
        // std::cout << itr->first << ":" << itr->second << std::endl;
        const auto before = itr;
        val = before->second;
        itr++;
        p.erase(before);
      }
      p.insert({begin, x});
      p.insert({end, val});
    }
  }
  /*
    for (const auto i : p) {
      std::cout << i.first << "," << i.second << std::endl;
    }
    */

  for (const auto i : d) {
    auto itr = p.upper_bound({i, max_x});
    if (itr == p.begin()) {
      std::cout << -1 << std::endl;
    } else {
      std::cout << (--itr)->second << std::endl;
    }
  }

  return 0;
}


Measured memory_bytes: 30848
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <set>
using namespace std;

set<long long int> S;

int N;

long long int A[200005];

int main(void) {
	cin >> N;

	for (int i = 1; i <= N; i++) { cin >> A[i]; S.insert(A[i]); }

	if (S.size() == N) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }

	return 0;
}

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

using namespace std;

int main(){
	
	int n;
	cin>>n;
	int n1=n;
	int sum=INT_MAX;
	int a[500];
	
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	for(int i=1;i<=100;i++){
		int cost=0;
		for(int j=0;j<n;j++){
			cost+=(a[j]-i)*(a[j]-i);
			
		}
		sum=min(sum,cost);
	}
	
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int n,m,d[21][21],s,g,pr,pi;
const int INF=9999999;
char com;
struct road{int a,b,c,d;};
road r[400];

int main() {
    cin>>n>>m;
    for(int i=0;i<m;i++)cin>>r[i].a>>com>>r[i].b>>com>>r[i].c>>com>>r[i].d;
    cin>>s>>com>>g>>com>>pr>>com>>pi;
    for(int i=0;i<441;i++)d[i/21][i%21]=INF;
    for(int i=0;i<m;i++){
	d[r[i].a][r[i].b]=r[i].c;
	d[r[i].b][r[i].a]=r[i].d;
    }
    for(int k=1;k<=n;k++)for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    cout<<pr-pi-d[s][g]-d[g][s]<<endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int rog[20][20];
  for (int i = 0; i < N; i ++) {
    for (int j = 0; j < N; j ++) {
      rog[i][j] = -1;
    }
  }
  for (int i = 0; i < N; i ++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j ++) {
      int x, y;
      cin >> x >> y;
      rog[i][x - 1] = y;
    }
  }
  int kou[20];
  int ans = 0;
  for (int i = 0; i < 1 << N; i ++) {
    int sum = 0;
    int i_ = i;
    for (int j = 0; j < N; j ++) {
      kou[j] = 0;
      if (i_ % 2) {
        sum ++;
        kou[j]  = 1;
      }
      i_ /= 2;
    }
    bool ok = true;
    for (int j = 0; j < N; j ++) {
      for (int k = 0; k < N; k ++) {
        if (rog[j][k] == 0 && kou[j] == 1 && kou[k] == 1) ok = false;
        if (rog[j][k] == 1 && kou[j] == 1 && kou[k] == 0) ok = false;
      }
    }
    if (ok) ans = max(ans, sum);
  }
  cout << ans << endl;
}



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

using namespace std;

int a[20][2],n,f[262144][19][2];

int F(int i,int j,int ok)
{
    if(f[i][j][ok]!=-1) return f[i][j][ok];
    else if(i==(1<<n)-1) return 0;
    else
    {
        int res=1e9,sl=0;
        for(int id=1;id<=n;id++)
        {
            if(((i>>(id-1))&1)==1) sl++;
        }
        //cout<<i<<" "<<j<<" "<<ok<<" "<<sl<<'\n';
        sl++;
        int cnt=0;
        for(int id=1;id<=n;id++)
        {
            if(((i>>(id-1))&1)==0)
            {
                //cout<<id<<'\n';
                int okms=abs(id-sl)%2;
                //cout<<id<<" "<<okms<<" "<<abs(id-sl)<<'\n';
                if(a[id][okms]>=a[j][ok]) res=min(res,F(i+(1<<(id-1)),id,okms)+id-1-cnt);
            }
            else cnt++;
        }
        f[i][j][ok]=res;
        return res;
    }
}

main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i][0];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>a[i][1];
    }
    memset(f,-1,sizeof(f));
    int ans=F(0,0,0);
    if(ans>=1e9) ans=-1;
    cout<<ans;
}


Measured memory_bytes: 39296
def main():
    name = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
    N = int(input())
    y = N
    ans = []
    for i in range(100):
        y -= 1
        x = y%26
        y = y//26
        ans.insert(0,name[x])
        if y == 0:
            break
    
    
    print(''.join(ans))
    
if __name__ == '__main__':
    main()

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

int main(){
  int N;
  cin >> N;
  int counter = 0;
  rep(i,N){
    int A;
    cin >> A;
    if(0 == A%2){
      counter++;
      if(0 == A % 6 || 0 == A % 10){
        counter--;
      }
    }
  }
  
  if(0 == counter){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	static class FenwickTree {
	    int n;
	    int x[];
	    public FenwickTree(int N) {
	    	this.n = N;
	    	x = new int[N + 1] ;
		}
	    int size()  { return n; }
	    int max(int r) {
	        int S = 0;
	        for (r = r - 1; r >= 0; r = (r & (r + 1)) - 1) {
	        	S = Math.max(S,  x[r]);
	        }
	        return S;
	    }
	    void update(int k, int a) {
	        for (; k < n; k |= k + 1) {
	        	x[k] = Math.max(x[k], a);
	        }
	    }
	};

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int C = sc.nextInt();
		String S = sc.next();
		FenwickTree fw = new FenwickTree(N);
		List<Integer> workDays = new ArrayList<Integer>();
		for(int i = 0 ; i < S.length() ; ++i){
			int maxWork = i >= 1 ? fw.max(i - 1) : 0;
			if(S.charAt(i) == 'o'){
				int maxWork2 = i >= C ? fw.max(i - C) : 0;
				fw.update(i, Math.max(maxWork, maxWork2 + 1));
				workDays.add(i + 1);
			}else{
				fw.update(i, maxWork);
			}
		}
		Collections.reverse(workDays);
		int currentDay = workDays.get(0);
		int leftWork = K;
		List<Integer> mustDays = new ArrayList<Integer>();
		for(int i = 0 ; i < workDays.size() ; ++i){
			int wd = workDays.get(i);
			if(wd > currentDay){
				continue;
			}
//			System.out.println(leftWork+" "+currentDay+" "+wd+" "+ fw.max(wd - 1));
			int ni = fw.max(wd - 1);
			if(ni < leftWork){
				mustDays.add(wd);
				leftWork--;
				currentDay = wd - C - 1;
			}else{
				leftWork--;
				currentDay = wd - C - 1;
			}
			if(leftWork <= 0){
				break;
			}
		}
		Collections.reverse(mustDays);
		for(int w : mustDays){
			System.out.println(w);
		}
	}
}


Measured memory_bytes: 52828
def conv(st):
    res = [0]*26
    for s in st:
        res[ord(s)-ord('a')] += 1
    return ''.join(map(str,res))

N = int(input())
S = {}
res = 0
for i in range(N):
    s = conv(input())
    if s not in S.keys():
        S[s] = 1
    else:
        S[s] += 1
    if S[s] > 1:
        res += S[s]-1
print(res)

Measured memory_bytes: 19292
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> v;
    int t;
    int val;
    cin>>t;
    while(t--)
    {
        cin>>val;
    
                v.push_back(val);
        
        
    }
    int count=0;
    for(int i=0;i<v.size();++i)
    {
        for(int j=i+1;j<v.size();++j)
        {
            if(v[i]==v[j])
                continue;
            for(int k=j+1;k<v.size();++k)
            {
                if(v[k]==v[i] || v[k]==v[j])
                continue;
                if( (v[i]<v[j]+v[k]) && (v[j]<v[i]+v[k]) && (v[k]<v[i]+v[j]) )
                count++;
            }
        }
    }
    cout<<count;
    
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int mod=1e9+7;
int n,m,s[(int)2e3+10],t[(int)2e3+10];
int dp[(int)2e3+10][(int)2e3+10]={0};

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

    int i,j;
    cin>>n>>m;
    for(i=1;i<=n;i++)
        cin>>s[i];
    for(i=1;i<=m;i++)
        cin>>t[i];
    /*for(i=0;i<=n;i++)
        dp[i][0]=1;
    for(i=0;i<=m;i++)
        dp[0][i]=1;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
            if(s[i]==t[j])
                dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
        }
    }*/
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
        {
            dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%mod;
            if(s[i]==t[j])
                dp[i][j]=(dp[i][j]+1+dp[i-1][j-1])%mod;
        }
    cout<<(dp[n][m]+1+mod)%mod<<endl;
    /*for(i=0;i<=n;i++)
    {
        for(j=0;j<=m;j++)
            cout<<dp[i][j]<<' ';
        cout<<endl;
    }*/
    return 0;
}


Measured memory_bytes: 16000
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
int N =sc.nextInt();
String S = sc.next();
String T = sc.next();
char[] s = S.toCharArray();
char[] t = T.toCharArray();
String a = "";
for(int i=0;i<N;i++){
a += "" +s[i] + "" + t[i] + "";
}
System.out.println(a);
  }
}

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

int main()
{
    ll W, H, x, y;
    cin >> W >> H >> x >> y;

    ll same = 0;
    if (2*x == W && 2*y == H){
        same = 1;
    }
    cout << fixed << setprecision(20) << double(W*H)/2.0 << " " << same << endl;

    return 0;
}


Measured memory_bytes: 3748
(defn input []
  (letfn [(inner-func []
            (->> (clojure.string/split (read-line) #"\s")
              (map #(Integer/parseInt %))))]
    (let [[N H W] (inner-func)]
      (list N H W
        (repeatedly N inner-func)))))

(defn AtCoderAlloy [[N H W Items]]
  (->> Items
    (filter (fn [[A B]] (and (<= H A) (<= W B))))
    count))

(->> (input)
  AtCoderAlloy
  println)

Measured memory_bytes: 66392
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N, x = map(int, input().split())
list_N = list(map(int, input().split()))
list_N.sort()

list_sum = [0]
for i in range(N):
    list_sum.append(list_sum[i] + list_N[i])

ans = 0
for i in range(N + 1):
    if list_sum[i] <= x and i < N:
        ans = i
    elif i == N and list_sum[i] == x:
        ans = i


print(ans)


Measured memory_bytes: 9196
#include<iostream>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        if(i % 3 == 0){
            cout << " " << i;
        }
        else{
            for(int x = i; x != 0; x /= 10){
                if(x % 10 == 3){
                    cout << " " << i;
                    break;
                }
            }
        }
    }
    cout << endl;
 
    return 0;
}

Measured memory_bytes: 1160
a = []
for i in range(3):
  a += [list(map(int, input().split()))]

for i in range(3):
  x = a[i][0] - a[(i+1)%3][0]
  y = a[0][i] - a[0][(i+1)%3]
  if x != a[i][1] - a[(i+1)%3][1] or x != a[i][2] - a[(i+1)%3][2]:
    print('No')
    exit()
  
  if y != a[1][i] - a[1][(i+1)%3] or y != a[2][i] - a[2][(i+1)%3]:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    LL A,B,N; cin >>A>>B>>N;
    LL t2 = min(B-1,N);
    cout << A * t2 / B << endl;

}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
const int MAX_V= 1005,MAX=1e9;
 
struct edge{
  int to,cap,cost,rev;
  edge(int to,int cap,int cost,int rev) :
    to(to),cap(cap),cost(cost),rev(rev) {}
};
  
vector<edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];
  
void add_edge(int from,int to,int cap,int cost){
  G[from].push_back(edge(to,cap,cost,G[to].size()));
  G[to].push_back(edge(from,0,-cost,G[from].size()-1));
}

int min_cost_flow(int s,int t,int f){
  int res = 0;
  while(f>0){
    fill(dist,dist+MAX_V,MAX); dist[s] = 0;
    bool update=true;
    while(update){
      update=false;
      for(int v=0; v<MAX_V; v++){
        if(dist[v]==MAX) continue;
        for(int i=0; i<(int)G[v].size(); i++){
          edge &e=G[v][i];
          if(e.cap>0 && dist[e.to]>dist[v]+e.cost){
            dist[e.to]=dist[v]+e.cost;
            prevv[e.to]=v; preve[e.to]=i; update=true;
          }
        }
      }
    }
    if(dist[t]==MAX) return -1;
    int d = f;
    for(int v=t; v!=s; v=prevv[v]){
      d=min(d,G[prevv[v]][preve[v]].cap);
    }
    f-=d;res+=d*dist[t];
    for(int v=t; v!=s; v=prevv[v]){
      edge &e=G[prevv[v]][preve[v]];
      e.cap-=d;G[v][e.rev].cap+=d;
    }
  }
  return res;
}
 
int main() {
  int n,m,k;
  cin >> n >> m >> k;
  int a[n],ans=0;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    ans+=a[i];
    add_edge(1000,i,1,0);
    add_edge(i,1002,1,0);
  }
  add_edge(1002,1001,1<<29,0);
  for(int j=0; j<m; j++) {
    for(int i=0,x; i<n; i++) {
      cin >> x;
      add_edge(i,j+n,1,min(0,a[i]-x));
    }
  }
  for(int i=0,x; i<m; i++) {
    cin >> x;
    add_edge(i+n,1001,x,0);
  }
  cout << ans-min_cost_flow(1000,1001,n-k) << endl;
  return 0;
}


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

int main() {
    int h, w;
    std::cin >> h >> w;
    std::string line;
    int ab[26] { 0 };
    bool ret = true;

    for (int i = 0; i < h; i++) {
        std::cin >> line;
        for (auto c : line) {
            ab[c - 'a']++;
        }
    }

    if (h % 2 == 0 && w % 2 == 0) {
        for (int i = 0; i < 26; i++) {
            ret = ret && (ab[i] % 4 == 0);
        }
    } else if ((h % 2) + (w % 2) == 1) {
        int limit = ((h % 2 == 0) ? h / 2 : w / 2);
        int count = 0;
        for (int i = 0; i < 26; i++) {
            if (ab[i] % 4 == 2) count++;
            else if (ab[i] % 2 == 1) ret = false;
        }
        if (count > limit) ret = false;
    } else {
        int limit = (h - 1) / 2 + (w - 1) / 2;
        int count2s = 0, countOdd = 0;
        for (int i = 0; i < 26; i++) {
            if (ab[i] % 2 == 1) countOdd++;
            else if (ab[i] % 4 == 2) count2s++;
        }
        ret = (count2s <= limit) && (countOdd == 1);
    }

    std::cout << (ret ? "Yes" : "No") << std::endl;
    return 0;
}

Measured memory_bytes: 256
/*WELCOME TO AYUSH RANJAN CODE'S*/
/*EVERY PROBLEM HAS A SOLUTION SOMETIMES ELEGENT OTHERWISE COMPLEX ELEGENCE*/

#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int chkpower2(int x){
    return (x&&!(x&x-1));
}
int n;


void solve(){
    int n;
    cin>>n;
    if(n>=30){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return;
}

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

    int t;
    t=1;//cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3588
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		
		long K = sc.nextInt();
		long A = sc.nextInt();
		long B = sc.nextInt();
		
		if (B-A <= 2) {
			System.out.println(K+1);
			return;
		}
		
		long n = (K-A+1)/2;
		if (A-1+2*n == K) {
			System.out.println(A+(B-A)*n);
			return;
		}
		System.out.println(A+(B-A)*n + 1);
	}
}


Measured memory_bytes: 23760
N = int(input())
A = list(map(int, input().split()))

count = 0
flag = True
while flag:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = A[i] // 2
        else:
            flag = False
            break
    else:
        count += 1

print(count)

Measured memory_bytes: 9004
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<ll>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 1000000007
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000


int main(void) {
	double a, v, b, w, t; cin >> a >> v >> b >> w >> t;
	double d = max(a, b) - min(a, b);
	double v1 = v - w;
	if (v1 <= 0) {
		cout << "NO" << endl;
		return 0;
	}
	if (d / v1 <= t) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3692
while 1:
    n, m = map(int, input().split())
    if n == m == 0:
        break
    A=sorted(map(int, input().split()))
    def f():
        j = n-1
        yield 0
        for i in range(n):
            while j >= 0 and m < A[i]+A[j]:
                j -= 1
            if j <= i:
                break
            if j >= 0:
                yield A[i]+A[j]
    print(max(f()) or"NONE")

Measured memory_bytes: 7764
import java.util.Scanner;
import java.util.InputMismatchException;

public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String inputN = scanner.nextLine();
		
		String inputP = scanner.nextLine();
		String[] pStr = inputP.split(" ", 0);
		
		int n = Integer.parseInt(inputN);
		int pInt[] = new int[n];
		for(int i=0;i<n;i++){
			pInt[i] = Integer.parseInt(pStr[i]);
		}
		
		int iCount = 0;
		
		for(int i=0;i+2<n;i++){
			if(pInt[i] > pInt[i+1] && pInt[i+1] > pInt[i+2]){
				iCount++;
			} else if(pInt[i] < pInt[i+1] && pInt[i+1] < pInt[i+2]){
				iCount++;
			}
		}
		
		System.out.println(iCount);
	}
}

Measured memory_bytes: 23252
#include <array>
#include <cstddef>
#include <functional>
#include <type_traits>
#include <utility>

template <class Key, class T, Key Empty, std::size_t N,
	class Hash = std::hash<Key>>
	struct mu_hashmap {

	std::array<std::pair<Key, T>, N> table;
	Hash hash;

	explicit mu_hashmap(Hash hash = Hash()) : table(), hash(hash) {
		for (auto itr = table.begin(), end = table.end(); itr != end; ++itr) {
			itr->first = Empty;
		}
	}

	T& operator[](const Key key) {
		typename std::array<std::pair<Key, T>, N>::iterator itr =
			table.begin() + hash(key) % N;
		while (itr->first != key) {
			if (itr->first == Empty) {
				itr->first = key;
				break;
			}
			++itr;
			if (itr == table.end()) {
				itr = table.begin();
			}
		}
		return itr->second;
	}
};

#include<cstddef>
#include<cstdint>
#include<iostream>

int main() {
	using usize = std::size_t;
	using u32 = std::uint_fast32_t;
	using i64 = std::int_fast64_t;

	usize n;
	std::cin >> n;

	u32 ans = 0;
	i64 acc = 0;
	mu_hashmap<i64, u32, 200000ULL * 1000000000 + 1, 200000 * 2> count;
	++count[acc];

	for (usize i = 0; i != n; ++i) {
		i64 a;
		std::cin >> a;

		acc += a;
		ans += count[acc];
		++count[acc];
	}

	std::cout << ans << std::endl;

	return 0;
}



Measured memory_bytes: 6528
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


void dijkstra(vl& d, vvi& es, int s, map<pii,ll>& cost) {
    int N = es.size();
    d = vl(N, LINF);

    d[s] = 0;

    priority_queue<pll, vector<pll>, greater<pll>> pq;

    pq.push(pll(d[s], s));
    vb vis(N, false);

    while (!pq.empty()) {
        // get the smallest(nearest) element
        pll p = pq.top(); pq.pop();

        int i = p.second;
        vis[i] = true;

        for (int t : es[i]) {
            if (vis[t]) continue;

            if (p.first + cost[pii(i, t)] < d[t]) {
                d[t] = p.first + cost[pii(i, t)];
                pq.push(pll(d[t], t));
            }
        }
    }
}

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

  int N,M; cin>>N>>M;
  vi L(M),R(M),C(M);
  REP(i,M) {
    cin>>L[i]>>R[i]>>C[i];
    L[i]--;R[i]--;
  }

  vvi es(N);
  map<pii, ll> cost;

  REP(i,M) {
    int l = L[i], r = R[i];
    if (cost.count(pii(l,r)) == 0) {
      es[l].push_back(r);
      cost[pii(l,r)] = (ll)C[i];
    } else {
      cost[pii(l,r)] = min(cost[pii(l,r)], (ll)C[i]);
    }

    /*for(int i = l; i<r; i++) {
      if (cost.count(pii(i+1,i)) == 0) {
        es[i+1].push_back(i);
        cost[pii(i+1,i)] = 0LL;
      }
    }*/
  }

  for(int i = 0; i < N-1; i++) {
    if (cost.count(pii(i+1,i)) == 0) {
      es[i+1].push_back(i);
      cost[pii(i+1,i)] = 0LL;
    }
  }

  vl dist;
  dijkstra(dist, es, 0, cost);

  ll ans = dist[N-1] >= LINF ? -1 : dist[N-1];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 20600
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  // input the data
  vector<vector<int>> A(3,vector<int>(3));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> A.at(i).at(j);
    }
  }
  
  int N;
  cin >> N;
  vector<int> b(N);
  for(int i=0; i<N; i++){
    cin>>b.at(i);
  }
  
  vector<vector<bool>> X(3,vector<bool>(3,false));
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
        if(b.at(i)==A.at(j).at(k)) X.at(j).at(k)=true;
      }
    }
  }
  
  int h,w;
  for(int i=0; i<3; i++){
    h=0;
    w=0;
    for(int j=0; j<3; j++){
      if(X.at(i).at(j)==true) h++;
      if(X.at(j).at(i)==true) w++;
    }
    if (h==3 || w==3){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  int c=0;
  int d=0;
  for(int i=0; i<3; i++){
    if(X.at(i).at(i)==true) c++;
    if(X.at(2-i).at(i)==true) d++; 
  }
  if(c==3 || d==3){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fori(x,a,b) for (int x=a;x<=b;x++)
#define ll long long
using namespace std;
ll a[410],f[410][410],sum[410];
ll oo = LONG_MAX;

ll dp(int i,int j)
{
    if (f[i][j] > 0) return f[i][j];
    if (i==j) return 0;
    ll tg = oo;
    fori(k,i,j-1)
    {
        tg = min(dp(i,k) + dp(k+1,j) ,tg);
    }
    f[i][j] = tg + sum[j] - sum[i-1];
    return f[i][j];
}
int main()
{
   int n;
   cin>>n;
   fori(i,1,n)  cin>>a[i];
   fori(i,1,n) sum[i] = sum[i-1] + a[i];
   cout<<dp(1,n);
}


Measured memory_bytes: 4908
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {
	int x;
	int sum = 0;
	for (int i = 0; i < 5; i++) {
		cin >> x;
		sum += x;
	}
	cout << 15 - sum << endl;
	return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    bool c=1,b=1,a=1;
    for(int i=0,j=s.size()-1;i<(s.size()-1)/2;i++,j--){
        if(s[i]!=s[j]){
            c=0;
            break;
        }
    }
    for(int i=0,j=(s.size()-1)/2-1;i<(s.size()-1)/4;i++,j--){
        if(s[i]!=s[j]){
            b=0;
            break;
        }
    }
    for(int i=(s.size()+3)/2-1,j=s.size()-1;i<s.size();i++,j--){
        if(s[i]!=s[j]){
            a=0;
            break;
        }
    }
    if(a==1&&b==1&&c==1){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


X = int(input())
while True:
    if is_prime(X) == True:
        print(X)
        break
    else:
        X = X + 1





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

int powmod(int a,int n,int p)
{
    long long int temp;

    if(n==1)
    {
        return a;
    }
    else
    {
        if (n%2==0)             
        {
            temp=powmod(a,n/2,p);
            return (temp*temp)%p;
        }
        else
        {
            temp=powmod(a,n/2,p);
            return (((temp*temp)%p)*a)%p;
        }
    }
}

int inv(int a,int p)
{
    return powmod(a,p-2,p);
}

int main()
{
    int n,k;
    long long int ans;
    long long int p=1000000007;
    cin>>n>>k;
    ans=n-k+1;
    cout<<ans<<endl;
    for(int i=2;i<=k;i++)
    {
        if(k>=i&&k<=n-i+1)
        {
            ans=(ans*(n-k+2-i))%p;
            ans=(ans*(k-i+1))%p;
            ans=(ans*inv(i,p))%p;
            ans=(ans*inv(i-1,p))%p;
            cout<<ans<<endl;
        }
        else
        {
            cout<<'0'<<endl;
        }
    }
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    auto A = [0L] ~ aryread();
    A ~= 0;
    auto D = new long[](N + 1);
    foreach (i; 0 .. N + 1)
    {
        D[i] = abs(A[i + 1] - A[i]);
    }
    long sum = D.sum();
    // writeln(A);
    // writeln(D);
    // writeln(sum);
    foreach (i; 0 .. N)
    {
        writeln(sum - (D[i] + D[i + 1]) + abs(A[i + 2] - A[i]));
    }
}


Measured memory_bytes: 7672