akhauriyash/Code-Regression huggingface dataset:
package main

import (
  "bufio"
  "container/heap"
  "fmt"
  "os"
  "strconv"
  "strings"
)

func main() {
  io := IO{bufio.NewReaderSize(os.Stdin,100000),bufio.NewWriterSize(os.Stdout,100)}
  x,y,a,b,c := io.NextInts()
  p := io.NextIntArray()
  q := io.NextIntArray()
  r := io.NextIntArray()
  var pq PriorityQueue
  heap.Init(&pq)
  for i:=0;i<a;i++ { heap.Push(&pq,&Item{p[i],0}) }
  for i:=0;i<b;i++ { heap.Push(&pq,&Item{q[i],1}) }
  for i:=0;i<c;i++ { heap.Push(&pq,&Item{r[i],2}) }
  n,np,nq := 0,0,0
  ans := int64(0)
  for n < x+y {
    it := heap.Pop(&pq).(*Item)
    if np == x && it.color == 0 { continue }
    if nq == y && it.color == 1 { continue }
    if it.color == 0 { np++ }
    if it.color == 1 { nq++ }
    n++
    ans += it.value
  }
  io.Println(ans)
  io.Flush()
}

type Item struct {
  value int64
  color int
}
type PriorityQueue []*Item
func(pq PriorityQueue) Len() int { return len(pq) }
func(pq PriorityQueue) Less(i,j int) bool { return pq[i].value > pq[j].value }
func(pq PriorityQueue) Swap(i,j int) { pq[i],pq[j] = pq[j],pq[i] }
func(pq *PriorityQueue) Push(x interface{}) {
  item := x.(*Item)
  *pq = append(*pq,item)
}
func(pq *PriorityQueue) Pop() interface{} {
  old := *pq
  n := len(old)
  item := old[n-1]
  *pq = old[0:n-1]
  return item
}

type IO struct {
  reader *bufio.Reader
  writer *bufio.Writer
}
func(io *IO) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := io.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(io *IO) Println(a ...interface{}) (int,error) {
  return fmt.Fprintln(io.writer,a...)
}
func(io *IO) Flush() error {
  return io.writer.Flush()
}
func(io *IO) NextInts() (int,int,int,int,int) {
  s := strings.Fields(io.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  a,_ := strconv.Atoi(s[2])
  b,_ := strconv.Atoi(s[3])
  c,_ := strconv.Atoi(s[4])
  return x,y,a,b,c
}
func(io *IO) NextIntArray() []int64 {
  s := strings.Fields(io.NextLine())
  a := make([]int64,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.ParseInt(s[i],10,64) }
  return a
}

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

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

int main(void){
    ll x;
    cin >> x;
    cout << f(x) << endl;
    return 0;
}



Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
    ll x,y;cin>>x>>y;
    ll c1,c2;
    c1=x*y;c2=2*x+2*y;
    cout<<c1<<" "<<c2<<"\n";
    return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
const constexpr int MAX = 100;
const constexpr ll INF = 1LL<<32;
int n;
vv(ll, d, MAX, MAX, INF);
inline void floyd() {
	rep(k, 0, n) {
		rep(i, 0, n) {
			if(d[i][k] == INF) continue;
			rep(j, 0, n) {
				if(d[k][j] == INF) continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}
int main() {
	int e; cin >> n >> e;
	rep(i, 0, n) d[i][i] = 0LL;
	int u, v, c;
	rep(i, 0, e) {
		cin >> u >> v >> c;
		d[u][v] = c;
	}
	floyd();
	bool negative = false;
	rep(i, 0, n) if(d[i][i] < 0) { negative = true; break; }
	if(negative) P("NEGATIVE CYCLE");
	else {
		rep(i, 0, n) {
			rep(j, 0, n) {
				if(d[i][j] == INF) p("INF");
				else p(d[i][j]);
				p(j + 1 == n ? "\n" : " ");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,ans,tmp,hoge,fuga,piyo;
ll x[10010],y[10010];
string s,str;
int main(){
  cin>>b>>c>>a;
  cout<<a<<" "<<b<<" "<<c;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    
    vector<bool> prime(n+1,true);
    for(int i=2;i<=n;i++){
        if(prime.at(i)){
            for(int j=i*2;j<=n;j+=i) prime.at(j)=false;
        }
    }
    
    ll ans=1;
    for(int i=2;i<=n;i++){//素因数
        if(prime.at(i)){
            ll x=1;
            for(int j=1;j<=n;j++){
                int p=j;
                while(p%i==0){
                    p/=i;
                    x++;
                }
            }
            ans*=x;
            ans%=1000000007;
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int i = 1;
	int n;
	int x[100];
	
	scanf("%d",&n);
	
	for(i = 0;i< n;i++){
		scanf("%d ",&x[i]);
	}
	
	for(i =n - 1;i >= 0;i--){
		if(i != 0){
			printf("%d ",x[i]);
		}else{
			printf("%d",x[i]);
		}
	}
	printf("\n");

	return 0;
}



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

using namespace std;

int main() {
	long long a, b, k;
	cin >> a >> b >> k;
	long long aa = a - min(a, k);
	k -= min(a, k);
	long long bb = b - min(b, k);
	cout << aa << " " << bb << "\n";
	return 0;
}


Measured memory_bytes: 256
while True:
    n=int(input())
    if n==0:
        break
    c=[]
    for i in range(n):
        c.append(int(input()))
    for j in range (10):
        p=c.count(j)
        if p==0:
            print('-')
        else:
            print((int(p))*"*")
    if n==0:
        break


Measured memory_bytes: 5700
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int> > VVi;
typedef vector<vector<ll> > VVl;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 28;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

int n;
Vi desc, asc;
map<int, ll> done_c;

int main()
{
	cin >> n;
	desc.resize(n);
	REP(i, n) cin >> desc[i];
	sort(ALL(desc), greater<>());
	asc = desc;
	reverse(ALL(asc));
	ll ans = 0;

	REP(i_c, n - 2)
	{
		int c = desc[i_c];
		for (int i_b = i_c + 1; i_b < n - 1; ++i_b)
		{
			int b = desc[i_b];
			if (2 * b <= c)
				break;

			int hi = b;
			int lo = c + 1 - b;

			if (lo > hi)
				continue;

			ll cnt = upper_bound(asc.begin(), asc.end() - 1- i_b, hi)\
				- lower_bound(asc.begin(), asc.end() - 1- i_b, lo);
			if (cnt)
				ans += cnt;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
 
using namespace std;

int main()
{
    int x, n;
    cin >> x >> n;
    map<int, int> p;
    int tmp =0;
    for(int i =0; i< n; i++){
        cin >> tmp;
        p[tmp]++;
    }

    int ans = 1001001001;
    for(int i = 0; i< n+1; i++){
        if(p[x+i] == 0){
            ans = min(ans, x +i);
        }
        
        if(p[x-i] == 0){
            ans = min(ans,x-i);
        }

        if(ans < 1001001001){
            cout << ans << endl;
            exit(0);
        }
    }

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int r(){
	char c=getchar();int f=1,sum=0;
	while(c>'9' or c<'0') if(c=='-'){f=-1;c=getchar();} while(c<='9' and c>='0'){sum=sum*10+c-'0';c=getchar();}
	return sum*f;}
int gcd(int a,int b){
	if(a==0) return b;
	return gcd(b%a,a);}
int prime(int a){
	if(a==1 or a==0)return 0;
	if(a%2==0 and a!=2) return 0;
	for(int i=3;i*i<=a;i++)if(a%i==0)return 0;
	return 1;//O(sprt(n)/2)
}



int main(){
	int a,b;cin>>a>>b;
	if(a<=0 and b>=0) cout<<"Zero"<<endl;
	else if(a>0 and b>0) cout<<"Positive"<<endl;
	else if(a<0 and b<0){
		int f=b-a+1;
		if(f%2==0) cout<<"Positive"<<endl;
		if(f%2==1) cout<<"Negative"<<endl;
		
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef pair <int,int> P;
typedef long long ll;
#define f first
#define s second
#define INF 1000000000
int tree[4][(1<<19)];
int n,d;
pair <int,pair <int,int> > star[(1<<18)];

void update(int i,int x,int flg){
  i = (1<<18)+i-1;
  tree[flg][i] = x;
  while(i){
    i = (i-1)/2;
    tree[flg][i] = max(tree[flg][i*2+1],tree[flg][i*2+2]);
  }
}

int find(int a,int b,int M,int L,int R,int flg){
  if(b <=L || a >= R) return -INF;
  if(a <=L && R <= b) return tree[flg][M];
  int nx = (L+R)/2;
  return max(find(a,b,M*2+1,L,nx,flg),find(a,b,M*2+2,nx,R,flg));
}

int main() {
  scanf("%d %d",&n,&d);
  for(int i=0;i<(1<<19);i++) 
    for(int j=0;j<4;j++) tree[j][i] = -INF;
  for(int i=0;i<n;i++)
    scanf("%d %d %d",&star[i].s.f,&star[i].s.s,&star[i].f);
  sort(star,star+n);
  for(int i=0;i<n;i++) {
    update(i,star[i].s.f,0); // max(x);
    update(i,star[i].s.s,1); // max(y);
    update(i,-star[i].s.f,2); // min(x);
    update(i,-star[i].s.s,3); // min(y);
  }
  ll now = 0,minx,maxx,miny,maxy,S=0;
  for(int i=0;i<n;i++) {
    while(now < n && star[now].f -star[i].f <=d) now++;
    maxx = find(i,now,0,0,(1<<18),0);
    maxy = find(i,now,0,0,(1<<18),1);
    minx = find(i,now,0,0,(1<<18),2);
    miny = find(i,now,0,0,(1<<18),3);
    S = max(S,((ll)maxx+minx)*((ll)maxy+miny));
  }
  cout << S <<endl;
  return 0;
}

Measured memory_bytes: 12480
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    String ans = "No";
    if(((c - a) * (c - b)) < 0) ans = "Yes";
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader(); 
        int MOD = 1000000007;
        int N = r.i();
        
        long[][] num = new long[N+1][10];
        num[0][0] = 1;
        
        int[][] p = {{2,0,2,2,0,2,0,1,1,1},
                     {1,1,0,1,0,1,1,1,0,0},
                     {1,0,1,0,0,0,0,1,1,1},
                     {0,1,0,0,0,0,0,0,0,0},
                     {0,1,0,0,0,0,1,0,0,0},
                     {0,1,0,0,0,0,1,0,0,0},
                     {0,0,1,0,1,0,0,0,1,1},
                     {0,0,0,0,1,0,0,0,0,0},
                     {0,0,0,0,1,0,0,0,0,0},
                     {0,0,0,0,0,1,0,0,0,0}};

        for(int i = 1; i <= N; i++)
            for(int j = 0; j < 10; j++)
                for(int k = 0; k < 10; k++)
                    num[i][j] = (num[i][j] + num[i-1][k]*p[j][k])%MOD;

        long ans = 0;
        for(long i : num[N])
            ans = (ans+i)%MOD;
        println(ans);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}


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

int main() {
	int n,k;
	scanf("%d %d", &n, &k);
	vector <double> media(n);
	double resp = 0;
	double total = 0;
	for(int i = 0; i < n; i++) {
		double val;
		scanf("%lf", &val);
		media[i] = (((val+1.0)*val)/2.0)/val;
		if(i < k) {
			resp += media[i];
		} else {
			total = max(resp, total);
			resp += media[i];
			resp -= media[i-k];
			total = max(resp, total);
		}
	}
	total = max(resp, total);

	printf("%lf\n", total);

	return 0;
}

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

int main(){
    int N, M, Q;
    int l, r;

    cin >> N >> M >> Q;
    vector<int> L(M);
    vector<int> R(M);
    vector<int> p(Q);
    vector<int> q(Q);

    for (int i=0; i<M; i++){
        cin >> l >> r;
        L[i] = l-1;
        R[i] = r-1;
    }
    for (int i=0; i<Q; i++){
        cin >> l >> r;
        p[i] = l-1;
        q[i] = r-1;
    }

    vector<vector<int> > coordinate(N, vector<int>(N, 0)), cumsum(N, vector<int>(N+1, 0));
    for (int coord_idx=0; coord_idx<M; coord_idx++){
        coordinate[L[coord_idx]][R[coord_idx]] += 1;
    }

    for (int i=0; i<N; i++){
        for (int j=0; j<N; j++){
            cumsum[i][j+1] = cumsum[i][j] + coordinate[i][j];
        }
    }

    int result=0, query_l, query_r;
    for (int query_idx=0; query_idx<Q; query_idx++){
        result = 0;
        query_l = p[query_idx];
        query_r = q[query_idx];
        for (int i=query_l; i<=query_r; i++){
            result += cumsum[i][query_r+1] - cumsum[i][query_l];
        }
        cout << result << endl;
    }
    
}


Measured memory_bytes: 5248
#include<iostream>
using namespace std;
int N;
int A[210];
int main(){
    cin >> N;
    for (int i=0; i<N;++i) cin>>A[i];
    int res = 0;

    //操作を行えるまで繰り返す
    while (true){
        bool exist_odd = false;
        for (int i=0;i<N;++i){
            if (A[i] % 2 !=0) exist_odd = true;
        }

        if (exist_odd) break;

        //操作を行えるなら操作を行う
        for (int i=0;i<N;++i){
            A[i] /= 2;
        }
        ++res;
    }

    cout << res << endl;

}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
using Int = int64_t;


void calc() {

	Int A, B; std::cin >> A >> B;
	Int ans = -1;

	Int MAX = 1250;
	for (Int i = 1; i <= MAX; ++i) {
		Int eight = static_cast<Int>((double)i * (double)0.08);
		Int ten = static_cast<Int>((double)i * (double)0.1);
		if (A == eight && B == ten) {
			ans = i;
			break;
		}
	}

	std::cout << ans << "\n";

}


int main() {

	calc();

	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B && B == C)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import product, combinations,permutations
from copy import deepcopy
import sys
sys.setrecursionlimit(4100000)



if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    acc_A = []
    acc = 0
    for a in A:
        acc += a
        acc_A.append(acc)

    minv = 10e10
    for i in range(0, N-1):
        minv = min(abs(acc_A[i]-(acc_A[-1]-acc_A[i])), minv)
    print(minv)

Measured memory_bytes: 33388
import  heapq

N, M = map(int, input().split())

Alist = list(map(lambda x : x * (-1), map(int, input().split())))
heapq.heapify(Alist)

for i in range(0,M):
    a = - (-heapq.heappop(Alist) // 2)
    heapq.heappush(Alist,a)

ans = 0
for j in Alist:
    ans += j * (-1)

print(ans)

Measured memory_bytes: 14180
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

using Edges = vector<pair<int, LL>>;
using Graph = vector<Edges>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
const LL INF = (1LL << 60);

void dijkstra(const Graph &g, int s, vector<LL> &dist) {
    min_priority_queue<pair<LL, int>> que;
    dist[s] = 0;
    que.push({0, s});
    while (not que.empty()) {
        auto dv = que.top(); que.pop();
        LL v = dv.second;
        int d = dv.first;

        if (dist[v] < d) continue;

        for (auto e : g[v]) {
            if (dist[e.first] > dist[v] + e.second) {
                dist[e.first] = dist[v] + e.second;
                que.push({ dist[e.first], e.first });
            }
        }
    }
}
LL d[100000 + 1];
int main() {
    int n, m, s, t; cin >> n >> m >> s >> t;
    --s; --t;
    Graph graph_yen(n), graph_snu(n);
    rep(i, m) {
        int u, v; LL a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        graph_yen[u].push_back(make_pair(v, a));
        graph_yen[v].push_back(make_pair(u, a));
        graph_snu[u].push_back(make_pair(v, b));
        graph_snu[v].push_back(make_pair(u, b));
    }
    vector<LL> dist_yen(n, INF), dist_snu(n, INF);
    dijkstra(graph_yen, s, dist_yen);
    dijkstra(graph_snu, t, dist_snu);

    rep(i, n) {
        d[i] = dist_yen[i] + dist_snu[i];
    }
    for (int i = n - 2; i >= 0; i--) {
        chmin(d[i], d[i + 1]);
    }

    LL maxi = 1e15;
    rep(i, n) d[i] = maxi - d[i];
    rep(i, n) printf("%lld\n", d[i]);
    return 0;
}


Measured memory_bytes: 20908
#include<iostream>
#include<algorithm>
#include<vector>
#include<climits>
using namespace std;

static const int MAX = 100;
static const long long INFTY = (1LL<<32);

int n;
long long d[MAX][MAX];

void floyd(){
    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            if(d[i][k] == INFTY) continue;
            for(int j=0; j<n; j++){
                if(d[k][j] == INFTY) continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main(){
    int e, u, v, c;
    cin >> n >> e;

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            d[i][j] = ( (i == j) ? 0 :INFTY);
        }
    }

    for(int i=0; i<e; i++){
        cin >> u >> v >> c;
        d[u][v] = c;
    }

    floyd();

    bool negative = false;
    for(int i=0; i<n; i++) if(d[i][i] < 0) negative = true;

    if(negative){
        cout << "NEGATIVE CYCLE" << endl;
    }else{
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(j) cout << " ";
                if(d[i][j] == INFTY) cout << "INF";
                else cout << d[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3200
#include<cstdio>
#include<cstring>
bool f[30];
char s[1100];
int n;

int main(){
	while(~scanf("%s", s)){
		n = strlen(s);
		memset(f, 0, sizeof(f));
		for(int i=0; i<n; i++){
			f[s[i]-'A'] = 1;
		}
        if(f['W'-'A'] != f['E'-'A'] || f['N'-'A'] != f['S'-'A']){
			puts("No");
        } else {
			puts("Yes");
        }
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int start, end,X, sum;
  string num;
  cin >>start >> end;
  for(int i = start; i<=end; i++){
    num = to_string(i);
    if(num[0] == num[4] && num[1] == num[3])
      sum++;
  }
  
  cout << sum << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int P, Q, R;
    cin >> P >> Q >> R;
    int ans = P + Q;
    ans = min(ans, Q + R);
    ans = min(ans, P + R);
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
d = 0;
A = []
okashi = [0] * N
ans = 0
for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for j in range(d):
    okashi[A[j] - 1] += 1
for num in okashi:
  if num == 0:
    ans += 1
print(ans)

Measured memory_bytes: 9072
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long

int main () {
  ll N, W;
  cin >> N >> W;
  ll w[N], v[N];
  ll num[4];
  for (ll i = 0; i < 4; i++) {
    num[i] = 0;  
  }
  for (ll i = 0; i < N; i++) {
    cin >> w[i] >> v[i];  
    num[w[i] - w[0]]++;
  }
  ll sum[4][101];
  ll box[4][101];
  ll it[4];
  for (ll i = 0; i < 4; i++) {
    it[i] = 0;
    for (ll j = 0; j <= 100; j++) {
      box[i][j] = 0;
      sum[i][j] = 0;  
    }    
  }
  for (ll i = 0; i < N; i++) {
    box[w[i] - w[0]][it[w[i] - w[0]]] = v[i];
    it[w[i] - w[0]]++;    
  }
  for (ll i = 0; i < 4; i++) {
    sort(box[i], box[i] + 100);
    reverse(box[i], box[i] + 100);  
  }
  for (ll i = 0; i < 4; i++) {
    for (ll j = 1; j <= num[i]; j++) {
      sum[i][j] = sum[i][j - 1] + box[i][j - 1];
    }  
  }
  
  ll ans = 0;
  for (ll i = 0; i <= num[0]; i++) {
    for (ll j = 0; j <= num[1]; j++) {
      for (ll k = 0; k <= num[2]; k++) {
        for (ll l = 0; l <= num[3]; l++) {
          ll SUM = sum[0][i] + sum[1][j] + sum[2][k] + sum[3][l];
          ll WWW = w[0] * i + (w[0] + 1) * j + (w[0] + 2) * k + (w[0] + 3) * l;
          if (W >= WWW) {
            if (ans < SUM) {
              ans = SUM;   
            }  
          }
        }  
      }  
    }       
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
/************************Code by Hardik Aggarwal!!!!***********************************/

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;

int main()
{
    
    
  
    IOS
    ll n;
    cin>>n;
    double a[n];
    double ans=0.0;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        ans+=(1.0/a[i]);
    }

    ans=1.0/ans;
    cout<<ans<<endl;
    

}
    
 
    
    



Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <array>
#include <vector>
#include <limits>

using namespace std;

int main(void) {
    int N, C;
    cin >> N >> C;
    vector<bitset<30>> table(2 * 100000);
    for(int i = 0; i < N; i++){
        int s, t, c;
        cin >> s >> t >> c;
        s = 2*s - 1;
        t = 2*t - 1;
        for(; s <= t; s++){
            table[s][c] = true;
        }
    }
    int ans = 0;
    for(auto const& b : table) ans = max(ans, (int)b.count());

    cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()


int main(){
  ll N,K,x=1,y=2;
  cin >> N >> K;
  if(K>((N-2)*(N-1))/2){
    cout << -1 << endl;
    return 0;
  }
  cout << (N*(N-1))/2-K << endl;
  rep(i,N-1){
    cout << i+1 << " " << N << endl;
  }
  rep(i,((N-2)*(N-1))/2-K){
    cout << x << " " << y << endl;
    y++;
    if(y==N){
      x++;
      y=x+1;
    }
  }
    
}

Measured memory_bytes: 3584
n = int(input())
list_n = list((map(int, input().split())))
def insertionSort(list_a, n):
    for i in range(1,n):
        v = list_a[i]
        j = i - 1
        while j >= 0 and list_a[j] > v:
            list_a[j+1] = list_a[j]
            j -= 1
        list_a[j+1] = v
        print(" ".join([str(number) for number in list_a]))
print(" ".join([str(number) for number in list_n]))
insertionSort(list_n, n)



Measured memory_bytes: 5604
#include<iostream>
#include<stack>
#include<string>
#include<sstream> //stringstreamを使う
#include<cstdlib>
#include<stdio.h>
 
using namespace std;
 
int main()
{
double n;          //答えを入れる
stack<double> stk; //double型のスタック
string str,t;     //tは"取り出す"の頭文字
 
while(getline(cin,str)){ 
while(stk.empty()==0){   // スタックが空になるまで出す
       stk.pop();  //後出し
        }
        n=0;       //答えの初期化
 
        stringstream mozi(str); //文字列以外の変数を文字列に
         
        while(mozi>>t){            
            if(t=="+"||t=="-"||t=="*"||t=="/"){
                double s1, s2;
                 
				 
                s2 = stk.top();
                stk.pop();
 
                s1 = stk.top();
                stk.pop();
 
 
                     if (t=="+"){
                    stk.push(s1 + s2);
                }
                else if (t=="-"){
                    stk.push(s1 - s2);
                }
                else if (t=="*"){
                    stk.push(s1 * s2);
                }
                else if (t=="/"){
                    stk.push(s1 / s2);
                }
                }
                else{
                stk.push(atof(t.c_str())); //文字列をdoubleに変換
                }
                }
                printf("%.6lf\n",stk.top());
                }
 
                return 0;
                }

Measured memory_bytes: 1276
H, W = map(int, input().split())
S = [[s if s == '#' else 0 for s in input().rstrip()] for _ in range(H)]

for i in S:
    i.insert(0, 0)
    i.append(0)

zero_ls = [i for i in range(W+2)]
S.insert(0, zero_ls)
S.append(zero_ls)

for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j] == '#':
            if S[i-1][j] != '#':  # top_center
                S[i-1][j] += 1
            if S[i-1][j-1] != '#':  # top_left
                S[i-1][j-1] += 1
            if S[i-1][j+1] != '#':  # top_right
                S[i-1][j+1] += 1
            if S[i][j-1] != '#':  # mid_left
                S[i][j-1] += 1
            if S[i][j+1] != '#':  # mid_right
                S[i][j+1] += 1
            if S[i+1][j] != '#':  # bottom_center
                S[i+1][j] += 1
            if S[i+1][j-1] != '#':  # bottom_left
                S[i+1][j-1] += 1
            if S[i+1][j+1] != '#':  # bottom_right
                S[i+1][j+1] += 1

for i in range(1, H+1):
    for j in range(1, W+1):
        print(S[i][j], end="")
    print()

Measured memory_bytes: 3572
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define ROOP() while (true)



int main(){
    
    int N,K;
    cin >> N >> K;
    int T[100000];
    vector<int> t;
    for(int i=0; i<N; i++){
        cin >> T[i];
        if(i != 0){
            t.push_back(T[i] - T[i-1] - 1);
        }
    }
    int sum = T[N-1] + 1 - T[0];

    sort(t.begin(), t.end(), greater<int>());
    for(int i=0; i<K-1; i++){
        sum -= t[i];
    }
    cout << sum << endl;    
    
    return 0;
}



Measured memory_bytes: 3916
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException{
	BufferedReader br =
	    new BufferedReader(new InputStreamReader(System.in));

	String str = br.readLine();
	int seconds = Integer.parseInt(str);
	int hours = 0;
	int minutes = 0;
	for (int i = 0; seconds >= (60*60); i++) {
	    hours++;
	    seconds -= (60*60);
	}
	for (int i = 0; seconds >= 60; i++) {
	    minutes++;
	    seconds -= 60;
	}
	System.out.println(hours+":"+minutes+":"+seconds);


    }
}

Measured memory_bytes: 24256
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		vector<int> hs(n+1),ws(m+1);
		for(int i=0;i<n;i++) cin>>hs[i+1],hs[i+1]+=hs[i];
		for(int i=0;i<m;i++) cin>>ws[i+1],ws[i+1]+=ws[i];;
		
		unordered_map<int,int> d;
		for(int i=0;i<=n;i++)
			for(int j=0;j<=m;j++)
				d[hs[i]-ws[j]]++;
		long long res=0;
		for(auto kv:d){
			int v=kv.second;
			res+=(long long)v*(v-1)/2;
		}
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 29704
# 052

# 1.値を正しく取得
a,b,c,d=(int(x) for x in input().split())

# 2.正しく処理

menseki1 = a * b
menseki2 = c * d

if menseki1 > menseki2:
    print(menseki1)

elif menseki1 < menseki2:
    print(menseki2)

else :
    print(menseki1)


Measured memory_bytes: 9004
#include <iostream>
#include <algorithm>
#include <map>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


#define N 200005
class uf {
private:
    int par[N] = {}, r[N] = {}, size[N] = {};

public:
    uf(int n) {
        int i;
        for (i = 0; i < n; i++) {
            par[i] = i;
            size[i] = 1;
        }
    }

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

    void unite(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (r[a] > r[b]) {
            par[b] = a;
            r[a]++;
            size[a] += size[b];
        }
        else {
            par[a] = b;
            r[b]++;
            size[b] += size[a];
        }
    }

    int show_size(int a) {
        return size[root(a)];
    }

    int group(int n) {
        int i, t, res = 0;
        bool u[N] = { false };
        for (i = 0; i < n; i++) {
            t = root(i);
            if (!u[t]) {
                res++;
                u[t] = true;
            }
        }
        return res;
    }

    bool isroot(int a) {
        return par[a] == a;
    }

};

int main(void) {
    int n, k, l, i, p, q, r, s;
    map<P, int> pm;

    scanf("%d%d%d", &n, &k, &l);

    uf ro(n), tr(n);

    for (i = 0; i < k; i++) {
        scanf("%d%d", &p, &q);
        ro.unite(p - 1, q - 1);
    }
    for (i = 0; i < l; i++) {
        scanf("%d%d", &r, &s);
        tr.unite(r - 1, s - 1);
    }

    for (i = 0; i < n; i++) {
        pm[P(ro.root(i), tr.root(i))]++;
    }

    for (i = 0; i < n; i++) {
        printf("%d ",pm[P(ro.root(i), tr.root(i))]);
    }
    printf("\n");

	return 0;
}

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

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

using namespace std;

vector<vector<int>> seg;

int query(int l,int r,int u,int a,int b){
	if(l<=a && b<=r) return lower_bound(seg[u].begin(),seg[u].end(),l)-seg[u].begin();

	int res=0;
	if(l<(a+b)/2) res+=query(l,r,2*u+1,a,(a+b)/2);
	if((a+b)/2<r) res+=query(l,r,2*u+2,(a+b)/2,b);
	return res;
}

int main(){
	int n,q; scanf("%d%d",&n,&q);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]), a[i]--;

	vector<int> pre(n,-1);
	rep(i,n){
		int x=a[i];
		a[i]=pre[x];
		pre[x]=i;
	}

	int N;
	for(N=1;N<n;N<<=1);
	seg.resize(2*N-1);
	rep(i,n) seg[N-1+i].emplace_back(a[i]);
	for(int i=N-2;i>=0;i--){
		merge(seg[2*i+1].begin(),seg[2*i+1].end(),
			  seg[2*i+2].begin(),seg[2*i+2].end(),
			  back_inserter(seg[i]));
	}

	rep(_,q){
		int l,r; scanf("%d%d",&l,&r); l--;
		printf("%d\n",query(l,r,0,0,N));
	}

	return 0;
}


Measured memory_bytes: 95152
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <string>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <vector>
#include <cstdlib>
#include <stack>
#include <time.h>
using namespace std;
typedef long long LL;
const int MOD = int(1e9)+7;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1.0); //M_PI;
const int maxn = 100001;
int a[maxn];
int vis[maxn];

void dfs(int cur , int next)
{
    if(cur >= 10 || next >= 10) return ;
    else{
        if(a[cur] < a[next]){
             vis[next] = 1;
             dfs(next , next + 1);
        }
        else{
            dfs(cur , next + 1);
        }
    }
}

int main()
{
    #ifdef DoubleQ
    freopen("in.txt" , "r" , stdin);
    #endif
    int n;
    cin >> n;
    while(n --){
        for(int i = 0 ; i < 10 ; i ++){
            cin >> a[i];
        }
        int flag = 0;
        int y = 0;
        for(int i = 0 ; i < 10 ; i ++){
            memset(vis , 0 , sizeof(vis));
            vis[i] = 1;
            dfs(i , i + 1);
            int tp = -1;
            flag = 0;
            for(int j = 0 ; j < 10 ; j ++){
                if(vis[j] == 0){
                    if(a[j] > tp){
                        tp = a[j];
                    }
                    else{
                        flag = 1;
                        break;
                    }
                }
            }
            if(flag == 0)
            {
                
                y = 1;
                cout << "YES" << endl;
                break;
            }
        }
        if(y == 0) cout << "NO" << endl;
    }
}

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

int main() {
  string S, T;
  cin >> S;
  cin >> T;
  bool result = true;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i)) {
      result = false;
      break;
    }
  }
  if(result) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	s := make([]string, N)
	m := make(map[string]int)
	max := 0
	for i := 0; i < N; i++ {
		s[i] = nextLine()
	}
	sort.Strings(s)
	for i := 0; i < N; i++ {
		m[s[i]]++
		if max < m[s[i]] {
			max = m[s[i]]
		}
	}
	keys := make([]string, 0, len(m))
	for k := range m {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	for _, k := range keys {
		if m[k] == max {
			fmt.Println(k)
		}
	}
}

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

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


Measured memory_bytes: 65664
#include<stdio.h>
int main(void){
  system("python3 -c \"h,w=map(int,input().split());r=[list('#'+'#.'[i%2]*(w-2)+'.')for i in range(h)];b=[list('.'+'.#'[i%2]*(w-2)+'#')for i in range(h)]\nfor i in range(h):\n  t=input()\n  for j in range(w):\n    if t[j]=='#':r[i][j]=b[i][j]='#'\nfor t in r:print(''.join(t))\nprint()\nfor t in b:print(''.join(t))\"");
  return 0;
}

Measured memory_bytes: 8272
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
long long power(long long k , long long n , long long m=1e9+7)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}
ll nck(ll n , ll k ,ll m=1e9+7)
{
    ll i , j,b=1,c=1 ;
    if(n-k<k)
    {
        k = n-k ;
    }
    while(k)
    {
        b*=n ;
        c*=k ;
        ll g = __gcd(b,c) ;
        b/=g ;
        c/=g ;
        n--;
        k-- ;
    }
    return(b) ;
}
long long fact(long long n , long long m = 1e9+7)
{
    long long a = 1 ;
    if(n==0 || n==1)
    {
        return(1) ;
    }
    while(n>0)
    {
        a = (a%m * n%m)%m ;
        n-- ;
    }
    return(a) ;
}
void READ(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cin>>a ;
        v.pb(a) ;
    }
}
void PRINT(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cout<<v[i]<<" " ;
    }
    cout<<"\n" ;
}
vll profit,weight;
ll siz = 1e5+3;
vll v1(siz,-1);
vvl dp(103,v1);
ll func(ll i , ll w , ll n)
{
    if(w<0)
    {
        return(-1e18);
    }
    if(i<0)
    {
        return(0);
    }
    if(dp[i][w]!=-1)
    {
        return(dp[i][w]);
    }
    ll ans = 0;
    ans = max(ans,func(i-1,w,n));
    ans = max(ans,func(i-1,w-weight[i],n)+profit[i]);
    dp[i][w] = ans;
    return(ans);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,e,x,i,j,n,t,m,k,y,w;
    double p,q,r,u,s ;
    string str = "",str1 = "" ;
    char ch,chr ;
    ll a1=0,a2=0,b1=0,b2=0 ;
    cin>>n>>w;
    for(i=0 ; i<n ; i=i+1)
    {
        cin>>a>>b;
        profit.pb(b);
        weight.pb(a);
    }
    a = func(n-1,w,n);
    cout<<a<<"\n" ;
}

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

int main(){
	ll s; cin >> s;
	ll a = s/100;
	ll b = s%100;
	if(0 < a && a <= 12 && 0 < b && b <= 12)cout << "AMBIGUOUS" << endl;
	else if(0 < a && a <= 12)cout << "MMYY" << endl;
	else if(0 < b && b <= 12)cout << "YYMM" << endl;
	else cout << "NA" << endl;
}

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

   typedef long long ll;

   const double EPS = (1e-7);
   const ll INF =(1e9);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   int gcd(int a,int b){return b?gcd(b,a%b):a;};

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

int main(){
    //input
    ll n; cin >> n;
    vector<ll> a(n); 
    REP(i, n){
        cin >> a[i];
    }
    
    map<ll, ll> p;
    map<ll, ll> q;
    ll diff = 0;
    REP(i, n){
        if (a[i] != a[n - 1 - i]){
            diff += 2 * (p[a[i]] - q[a[i]]) - 2 * (p[a[n - 1 - i]] - q[a[n - 1 - i]]) + 2;
        }
        if (diff == 0){
            cout << i + 1;
            if (i != n - 1){
                cout << ' ';
            }
        }
        p[a[i]] += 1;
        q[a[n - 1 - i]] += 1;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 9956
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    int N, K;
    int d;
    int c = 0;

    cin >> N >> K;

    vector<int> A(0);

    for (int i = 0; i < K; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            int c;
            cin >> c;
            A.push_back(c);
        }
    }

    sort(A.begin(), A.end());

    auto itr = unique(A.begin(), A.end());
    A.erase(itr, A.end());

    cout << (N - A.size());

    return 0;
}

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

int main(){
	int n,a,b,c,d;
	cin >> n >> a >> b >> c >> d;
	a--;b--;c--;d--;
	string s; cin >> s;
	if(d>c){
		bool ok = true;
		for (int i = b; i <= d-1; ++i) {
			if(s[i] == '#' && s[i+1] == '#') ok = false;
		}
		for (int i = a; i <= c-1; ++i) {
			if(s[i] == '#' && s[i+1] == '#') ok = false;
		}
		if(ok) {
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		bool ok = true;
		bool flag = false;
		for (int i = b-1; i <= d-1; ++i) {
			if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.') flag = true;
		}
		for (int i = a; i <= c-1; ++i) {
			if(s[i] == '#' && s[i+1] == '#') ok = false;
		}
		if(ok == true && flag == true){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 640
nums=list(map(int,input().split()))
W=nums[0]
a=nums[1]
b=nums[2]
if a<=(b+W) and b<=(a+W):
    print("0")
elif (b+W)<a:
    print(str(a-b-W))
else:
    print(str(b-a-W))

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
	int n;
	int a[4];
	int flag=0;
	scanf("%d",&n);
	if(n<1000||n>9999) return 0;
	for(int i=0;i<4;i++){
		a[i]=n%10;
		n/=10;
	}
	for(int i=0;i<4;i++){
		if(flag>=3) break;
		flag=0;
		for(int j=i;j<4;j++){
			if(a[i]!=a[j]&&i<=3) flag=0;
			if(a[i]==a[j]) flag++;
			if(flag>=3)break;
		}
	}

	if(flag>=3)printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

const i64 mod = 998244353;

using namespace std;

int main() {

	const int N = read_item();
	const int K = read_item();

	vector<pair<int,int>> sections(K);
	for(auto i : range(K)) {
		sections[i].first = read_item();
		sections[i].second = read_item();
	}

	vector<i64> ways(N);
	vector<i64> ways_csum(N + 1);
	ways[0] = 1;
	ways_csum[1] = 1;

	for(auto pos : range(1, N)) {

		i64& way = ways[pos];

		for(auto i : range(K)) {

			auto lo = sections[i].first;
			auto hi = sections[i].second;

			auto l = max(pos - hi, 0);
			auto r = max(pos - lo + 1, 0);
			assert(l <= r);

			i64 s = (ways_csum[r] - ways_csum[l]) + mod;
			way += s;
		}

		way = way % mod;
		ways_csum[pos + 1] = (ways_csum[pos] + way) % mod;
	}

	i64 ans = ways[N - 1];
	printf("%lld\n", ans);

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 6368
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int64_t N,M,A[10000],i,sum=0;

    cin>>N>>M;

    for(i=0;i<M;i++){
        cin>>A[i];
        sum=sum+A[i];
    }
    if(sum>N){
        cout<<"-1"<<endl;
    }
    else{
        cout<<N-sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636