akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=a;i<b;++i)

int p[7][7] = {
	{0, 1, 3, 4, 5, 8, 9},
	{1, 2, 4, 5, 6, 9, 10},
	{3, 4, 7, 8, 9, 12, 13},
	{4, 5, 8, 9, 10, 13, 14},
	{5, 6, 9, 10, 11, 14, 15},
	{8, 9, 12, 13, 14, 16, 17},
	{9, 10, 13, 14, 15, 17, 18}
};

string c;

int main() {
	while (cin >> c, c != "#") {
		bool ans = true;
		
		for_(bit,0,1<<19) {
			int f = 0, b = 0;
			
			for_(i,0,7) {
				int t = 0;
				for_(j,0,7) if (bit & (1 << p[i][j])) t |= 1 << j;
				if (c[t] - '0') f |= (1 << i);
				if (i == 3) b = c[t] - '0';
			}
			
			ans &= !(b == 1 && c[f] == '0') && !(b == 0 && c[f] == '1');
		}
		
		if (ans) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1180
#!/usr/bin/env ruby

def minc(x, y, pp)
  x.zip(y).map { |k| (k[0] - k[1]).abs**pp }.inject(:+)**(1.0 / pp)
end

def chv(x, y)
  x.zip(y).map { |k| (k[0] - k[1]).abs }.max
end

n = gets.chomp.to_i
x = gets.chomp.split.map(&:to_f)
y = gets.chomp.split.map(&:to_f)

puts minc(x, y, 1)
puts minc(x, y, 2)
puts minc(x, y, 3)
puts chv(x, y)

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

int main(){
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);

    if(abs(x-a)>abs(x-b)){
        printf("B");
    }else{
        printf("A");
    }
    return 0;
}

Measured memory_bytes: 128
#ifdef ConanYu
#include "E:\yuzining\code\local.hpp"
#else
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(...) do { } while(false)
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie();
  Main();
  return 0;
}
#endif

void Main() {
  int a, b, c; cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << ' ' << b << ' ' << c << '\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int n, x, y, a[100005];

int f(int p, int q) {
	if(x+y<n || q-p>1) return 0;
	if(x==n) return p==n-1 || p<=n/2;
	return x+1<=q && q<=x+y/2;
}

int main() {
	int i, j;
	scanf("%d", &n);
	for(i=0; i<n; i++) scanf("%d", a+i);
	sort(a, a+n);
	for(i=0; a[i]==a[0]; i++, x++);
	for(j=i; a[j]==a[i]; j++, y++);
	puts(f(a[0], a[n-1]) ? "Yes":"No");
	return 0;
}

Measured memory_bytes: 512
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

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

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

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() string {
	return scanString(sc)
}

func resolve(s string) string {
	bytes := make([]byte, len(s))
	j := 0
	for i := range s {
		switch s[i] {
		case 'B':
			if j > 0 {
				j--
			}
		default:
			bytes[j] = s[i]
			j++
		}
	}
	return string(bytes[0:j])
}

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


Measured memory_bytes: 1780
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

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

ll n, d;

void func() {
    cin >> n >> d;
    d <<= 1; d++;
    ll ans = n / d;
    if (n % d > 0) {
        ans++;
    }
    cout << ans << endl;
}

int main() {
    fast_io; cout.precision(32);
    ll t = 1; // cin >> t;
    for (ll i = 1; i <= t; i++) {
        func();
    }
}


Measured memory_bytes: 256
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define REP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define REPI(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define REPITER(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;
vector<VII> adj(100008);
bool visited[100008];
int level[100008];
int ans=0;
void dfs(int src)
{
    visited[src]=true;

    for(auto it:adj[src])
    {
        if(!visited[it])
        dfs(it);

        level[src]=max(level[src],level[it]+1);
        ans=max(ans,level[src]);
    }
}
int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    memset(visited,0,sizeof(visited));
    while(m--)
    {
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
    }
    for(int i=1;i<=n;++i)
    if(!visited[i])
    dfs(i);

    cout<<ans;
    return 0;
}

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

import javax.security.auth.kerberos.KerberosKey;

//満点解法
//ナップサック問題として考える
public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);

		// input
		int n = sc.nextInt();
		int a = sc.nextInt();

		int[] x = new int[n + 1];
		x[0] = -1;
		for (int i = 1; i <= n; i++) {
			x[i] = sc.nextInt();
		}

		int max = a;
		for (int i = 0; i < n; i++) {
			max = Math.max(max, x[i]);
		}
		int X = max * n;

		// dp[j][k][s]:x[1]~x[j]までk枚選んだ時の和がsになるような選び方の総数
		// 0<=j<=n, 0<=k<=n, 0<=s<=X
		long[][][] dp = new long[n + 1][n + 1][X + 1];

		// 基底
		dp[0][0][0] = 1;

		for (int j = 1; j <= n; j++) {
			for (int k = 0; k <= n; k++) {
				for (int s = 0; s <= X; s++) {
					if (j == 0 && k == 0 && s == 0) {
						continue;
					}
					long count = 0;
					if (s >= x[j] && k >= 1) {
						// x[j]を選ばない
						count += dp[j - 1][k][s];
						// x[j]を選ぶ
						count += dp[j - 1][k - 1][s - x[j]];
					} else if (s < x[j]) {
						// x[j]を選べない
						count += dp[j - 1][k][s];
					}
					dp[j][k][s] = count;
				}
			}
		}

		// debug
		// for (int j = 0; j <= n; j++) {
		// for (int k = 0; k <= n; k++) {
		// System.out.println("j:" + j + " k:" + k);
		// System.out.println(Arrays.toString(dp[j][k]));
		// }
		// }

		// 和k*aとなる、1~n枚選んだ時の選び方の和を求める
		long sum = 0;
		for (int k = 1; k <= n; k++) {
			sum += dp[n][k][k * a];
		}

		System.out.println(sum);
	}

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

}


Measured memory_bytes: 77648
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int N = Cin();
        int n = Cin();
        Console.WriteLine(((N % 500) > n ? "No" : "Yes"));
    }

}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int Cin()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
}


Measured memory_bytes: 13140
while True :
    try :
        a = float(input())
    except EOFError :
        break
    
    S = []
    S.append(0)
    S.append(a)
    for i in range(2, 11) :
        if i % 2 == 0 :
            S.append(S[i-1] * 2)
        else :
            S.append(S[i-1] / 3)
    print(sum(S))


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n,m; cin >> n >> m;
  int ans = 1;
  for(int i = 2;i<n;i++) ans+=1;
  
  int tmp = ans;
  for(int j = 2;j<m;j++) ans+=tmp;

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


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int m; cin>>m;
	for(int n = 11; m > 0 && n <= 55555; n += 5){
		bool flg = true;
		for(int p = 2; p*p <= n; p++){
			if(n%p == 0){
				flg = false;
				break;
			}
		}
		if(flg){
			cout<<n<<" "; m--;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[11],n,i=0,sum=0,big=0;
	scanf("%d",&n);
	
	for(i;i<n;i++){
		scanf("%d",&a[i]);
		sum=sum+a[i];
		if(a[i]>big)big=a[i];
	}
	
	if(sum>2*big)printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 128
package main

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

// AtCoder Functions
var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func spliceRemove(index int, slice []int) []int {
	slice = append(slice[:index], slice[index+1:]...)
	return slice
}
func gcd(A int, B int) int {
	a := A
	b := B
	r := a % b
	for {
		if r == 0 {
			break
		}
		a = b
		b = r
		r = a % b
	}
	return b
}

func primeFactors(n int) []int {
	pfs := make([]int, 0)
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return pfs
}

func main() {
	sc.Split(bufio.ScanWords)
	A := nextInt()
	B := nextInt()

	maxk := gcd(A, B)

	// 最大公約数を素因数分解して素因数の個数を数える
	m := map[int]int{}
	primeFactors := primeFactors(maxk)
	for i := 0; i < len(primeFactors); i++ {
		m[primeFactors[i]]++
	}
	fmt.Println(len(m) + 1)

	// 公約数求める
	// k := make([]int, 0)
	// for i := 1; i <= maxk; i++ {
	// 	if maxk%i == 0 {
	// 		k = append(k, i)
	// 	}
	// }
	// k = spliceRemove(0, k)
	// fmt.Println(k)

	// 互いに素のみを残す
	// max := len(k)
	// for i := 0; i < max; i++ {
	// 	for j := i + 1; j < max; j++ {
	// 		if k[j]%k[i] == 0 {
	// 			k = spliceRemove(j, k)
	// 			j--
	// 			max--
	// 		}
	// 	}
	// }

	// fmt.Println(k)
	// fmt.Println(len(k) + 1)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 3010
using namespace std;
/*
Before Submitting, check:(Delete them before submitting)
*int or long long
*the range of every array(will it get an RE and is it bg enough?)
*special cases(0,1...)
*/
ll n,s,dp[N][N],a[N],ans=0;
int main(){
	ll i,j;
	cin>>n>>s;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(i=1;i<=n;i++)
	{
		if(a[i]<=s)
		{
			ans=(ans+dp[i-1][s-a[i]]*(n-i+1))%mod;
		}
		if(a[i]==s)
		{
			ans=(ans+(n-i+1)*i)%mod;
		}
		for(j=0;j<N;j++)
		{
			dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
			if(j+a[i]<N)
			{
				dp[i][j+a[i]]=(dp[i][j+a[i]]+dp[i-1][j])%mod;
			}
		}
		dp[i][a[i]]=(dp[i][a[i]]+i)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 70912
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    s = input()
    if is_m(s[0:2]) and is_m(s[2:4]):
        print("AMBIGUOUS")
    elif is_m(s[0:2]) and not is_m(s[2:4]):
        print("MMYY")
    elif not is_m(s[0:2]) and is_m(s[2:4]):
        print("YYMM")
    else:
        print("NA")

# y の可能性もある
def is_m(i):
    n = int(i)
    return 0 < n and n <= 12

main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    --a;
    --b;
    --c;
    --d;

    if (c < d) {
        srep(i, b+1, d-1) {
            if (s[i] == '#' && s[i+1] == '#') {
                puts("No");
                return 0;
            }
        }
        s[d] = '#';
        srep(i, a+1, c-1) {
            if (s[i] == '#' && s[i+1] == '#') {
                puts("No");
                return 0;
            }
        }
    }
    else {
        bool c = false;
        srep(i, b-1, d) {
            if (s[i] == '.' && s[i+1] == '.' && s[i+2] == '.') c = true;
        }
        if (!c) {
            puts("No");
            return 0;
        }
        srep(i, a+1, c-1) {
            if (s[i] == '#' && s[i+1] == '#') {
                puts("No");
                return 0;
            }
        }
        s[c] = '#';
        srep(i, b+1, d-1) {
            if (s[i] == '#' && s[i+1] == '#') {
                puts("No");
                return 0;
            }
        }

    }

    puts("Yes");
    return 0;
}

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

int main(){
    char str1[25];
    char str2[25];
    char str3[25];

    scanf("%s %s %s", str1, str2, str3);

    if (str1[strlen(str1)-1] == str2[0]){
        if (str2[strlen(str2)-1] == str3[0]){
            printf("YES\n");
        }
        else
        {
        printf("NO\n");
        }
    }
    else
    {
        printf("NO\n");
    }
    
    return 0;
}

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

template< typename T >
struct edge {
  int src, to;
  T cost;
  ll ginka;


  edge(int to, T cost, ll ginka) : src(-1), to(to), cost(cost), ginka(ginka){}//分、銀貨

  edge(int src, int to, T cost, ll ginka) : src(src), to(to), cost(cost), ginka(ginka){}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

const int n_max = 51;
vector<pair<ll,ll>> excha(n_max); // 分　銀貨
const int a_max = 51;

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector<vector< T >> dijkstra(WeightedGraph< T > &g, ll init_mai,int s) {
  const auto INF = numeric_limits< T >::max();
  vector<vector< T > > dist(g.size(), vector<T>(g.size() * a_max , INF));

  using Pi = tuple< T, ll, int >; // 時間、枚数、都市
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s][init_mai] = 0;
  que.push(make_tuple(dist[s][init_mai], init_mai, s));
  while(!que.empty()) {
    auto ctup = que.top(); que.pop();
    T cost = get<0>(ctup);
    ll mai = min(get<1>(ctup),((ll)g.size()*a_max));
    int idx = get<2>(ctup);
    if(dist[idx][mai] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;//cost 分　ginka 銀貨
      auto next_ginka = mai - e.ginka;
      if(next_ginka<0) continue;
      if(dist[e.to][next_ginka] <= next_cost) continue;
      dist[e.to][next_ginka] = next_cost;
      que.push(make_tuple(dist[e.to][next_ginka],next_ginka, e.to));
    }
    auto next_cost = cost + excha[idx].first;
    auto next_ginka = min(((ll) g.size()*a_max-1),mai + excha[idx].second);
    if(dist[idx][next_ginka] <= next_cost) continue;
    dist[idx][next_ginka] = next_cost;
    que.push(make_tuple(dist[idx][next_ginka],next_ginka, idx));
  }
  return dist;
}



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

  int n,m;
  ll s;
  cin >> n >> m >> s;
  WeightedGraph< ll > g(n);
  rep(i,m){
    int u,v,a,b;
    cin >> u >> v >> a >> b;
    --u;--v;
    g[u].emplace_back(v,b,a);
    g[v].emplace_back(u,b,a);
  }

  rep(i,n){
    int c,d;
    cin >> c >> d;
    excha[i] = {d,c};
  }
  s = min(((ll) g.size()*a_max -1),s);
  auto res = dijkstra(g,s,0);

  rep1(i,n-1){
    ll ans = LLONG_MAX;
    rep(j,g.size() * a_max){
      ans = min(ans,res[i][j]);
      // cout << "i j dist " << i << " " << j << " " << res[i][j] << endl;
    }
    cout << ans << endl;
  }

  

  return 0;
    

}


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

#define F(i, a, b) for(int i=a; i<b; i++)
#define mem(arr, val) memset(arr, val, sizeof(arr))
#define rev(str) reverse(str.begin(), str.end())
#define UPPER(str) transform(str.begin(), str.end(), str.begin(), ::toupper)
#define LOWER(str) transform(str.begin(), str.end(), str.begin(), ::tolower)

#define MOD 1000000007
#define INF 1000000000000001
#define epsilon 1e-15

typedef long long int ll;
typedef unsigned long long int ull;

class graph{
    int V, E;
    vector<int> *adj;
public:
    graph(int n, int m){
        this->V = n;
        this->E = m;
        adj = new vector<int>[V];
    }

    void insert_edge(int u, int v){
        adj[u].push_back(v);
    }

    int longest_path(){
        int indegree[V] = {};
        for(int i=0; i<V; i++){
            for(auto j : adj[i])
                indegree[j]++;
        }

        int d[V] = {}, ans = 0;

        queue<int> Q;
        for(int i=0; i<V; i++){
            if(indegree[i]==0)
                Q.push(i);
        }

        while(!Q.empty()){
            int s = Q.front();
            Q.pop();
            indegree[s] = -1;
            for(auto u : adj[s]){
                indegree[u]--;
                d[u] = max(d[u], d[s]+1);
                ans = max(d[u], ans);
                if(indegree[u]==0)
                    Q.push(u);
            }
        }

        return ans;
    }


    void clear(){
        delete[] adj;
    }
};

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int N, M, u, v;
    cin >> N >> M;

    graph G(N, M);

    for(int i=0; i<M; i++){
        cin >> u >> v;
        u--;v--;
        G.insert_edge(u, v); 
    }

    int ans = G.longest_path();

    cout << ans << '\n';

    G.clear();

    return 0;
   
}

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

const double PI=acos(-1.0);

int main() {
    int h, w;
    cin >> h >> w;
    string board[50];

    rep(i, h) cin >> board[i];

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

    rep(i, h) {
        rep(j, w) {
            if(board[i][j] == '#') continue;

            int num = 0;
            rep(d, 8) {
                int ni = i + dy[d];
                int nj = j + dx[d];

                if(ni < 0 || h <= ni) continue;
                if(nj < 0 || w <= nj) continue;
                if(board[ni][nj] == '#') num++;
            }

            board[i][j] = char(num + '0');
        }
    }

    rep(i, h) cout << board[i] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int a = 0;
    int b= 0;
    int total = 0;
    std::cin >> a >> b >> total;
    int result = 0;
    for (int i = 0; i <= total;++i) {
        if (i == 0) continue;
        if (i%a == 0)result += b;
    }
    std::cout << result;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

// Union-Find木
struct UnionFind {
    vector<int> par;
    vector<int> r;

    // コンストラクタ 親の初期値は自分
    UnionFind(int n) : par(n) ,r(n,1) {
        REP(i,n) par[i] = i;
    }

    // 親を返す
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    // 木の統合
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        r[rx] += r[ry];
        par[ry] = rx;
    }

    // 同じ木に属しているか
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    // つながってる要素の数
    int size(int x) {
        return r[root(x)];
    }
};

int main(void)
{
    IOS
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<int> fb(n);
    
    REP(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a,b);
        fb[a]++;
        fb[b]++;
    }
    REP(i,k) {
        int c, d;
        cin >> c >> d;
        c--; d--;
        if (uf.same(c,d)) {
            fb[c]++;
            fb[d]++;
        }
    }

    REP(i,n) cout << uf.size(i) - fb[i] -1 << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n,k;
	cin>>n>>k;
	vector<ll> vec(n,0);
	for(ll i=0;i<n;i++) cin>>vec[i];
	sort(vec.rbegin(),vec.rend());
	
	if(n<=k){
		cout<<0<<endl;
		return 0;
	}
	ll sum=0;
	for(ll i=k;i<n;i++){
		sum+=vec[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	map<string, int>m;
	rep(i, N) {
		string S;
		cin >> S;
		m[S]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;
}

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

int main(){
  unsigned short *A, *B;
  int C[10001];
  int i,j,n;
  scanf("%d",&n);
  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

  for(i=0;i<=10001;i++){
    C[i]=0;
  }
  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  for(i=1;i<=10001;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 9576
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n;
	cin>>n;
	cout<<(n-1)/2;


}


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


namespace Atcoder01
{
    class Program
    {
        //ABC96B
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = int.Parse(Console.ReadLine());
            Array.Sort(input);
            int Ans = input[0] + input[1];
            var ans = input.Max();
            for (int i = 0; i < N; i++)
            {
                ans = ans * 2;
            }
            Console.WriteLine(ans + Ans);
        }
    }
}


Measured memory_bytes: 13396
def get_xor_product(n):
    ans = 0
    if n % 2:
        ans = ((n + 1) // 2) % 2
    else:
        ans = (n // 2) % 2
        ans ^= n
    return ans


A, B = map(int, input().split())
ans = get_xor_product(A - 1) ^ get_xor_product(B)
print(ans)


Measured memory_bytes: 9172
#include<iostream>
#include<vector>
#include<utility>

using namespace std;

int main(){

	int A,B,C;
	bool flag =0;
	cin >> A >> B >> C;

	vector <pair <int ,int>> P(100);


	for(int i=A; i < A*B; i=i+A){ //見るのはAとBの最小公倍数まででよさそう？？

		//cout <<i <<" " << i%B <<endl;

		if(i%B == C)flag =1;


	}

	if (flag ==1) cout << "YES"<<endl;
	else cout << "NO" <<endl;


}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  int64_t n, m;
  cin >> n >> m;

  if (m <= n * 2) {
    cout << m / 2 << endl;
    return 0;
  }

  int64_t sum = n;
  m -= n * 2;
  sum += m / 4;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const ll mod=1000000007;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n; cin>>n;
  vll a(n); rep(i,n) cin>>a[i];
  ll sum=0;
  rep(i,n){
    sum+=a[i];
    sum%=mod;
  }
  ll sum2=0;
  rep(i,n){
    sum2+=(a[i]*a[i]);
    sum2%=mod;
  }
  ll x=1;
  rep(i,100000000){
    x*=1024;
    x%=mod;
  }
  x*=32;
  x%=mod;
  ll ans=0;
  ans=(sum*sum)-sum2;
  if(ans<0) ans+=mod;
  ans%=mod;
  ans*=x;
  ans%=mod;
  cout<<ans<<endl;
}


Measured memory_bytes: 4784
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    MOD = 1000000007
    n, m = map(int, input().split())
    a = {int(input()) for _ in range(m)}

    dp = [0] * (n+1)
    dp[:2] = 1, 1 if 1 not in a else 0

    for i in range(2, n+1):
        if i not in a:
            dp[i] += (dp[i-1] + dp[i-2]) % MOD
    print(dp[-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 11884
import numpy as np
H, N = map(int, input().split())
dp = np.zeros((N, H+1))
ab = [list(map(int, input().split())) for _ in range(N)]
max_a = max(a for a, _ in ab)
dp = [0]*(H+max_a)
for i in range(1,H+1):
  dp[i] = min(dp[i-a]+b for a,b in ab)
#print(ab)
print(dp[H])



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

int main() {
 UL N;scanf("%u",&N);
 pair<int,int> P[100000];
 rep(i,N) scanf("%d%d",&P[i].first,&P[i].second);
 sort(P,P+N);
 rep(i,N) printf("%d %d\n",P[i].first,P[i].second);
 return 0;
}



Measured memory_bytes: 3988
#include <stdio.h>

int main(){
	char ch;
	while((ch = getchar()) != EOF){
			if(ch >= 97 && ch <= 122)
				printf("%c",ch-32);
			else if(ch >= 65 && ch <= 90)
				printf("%c",ch+32);
			else
				printf("%c",ch);
	}
}


Measured memory_bytes: 2564
s = input()

for i in range(8):
    cal = ""
    for j in range(3):
        cal += s[j]
        if (i >> j) & 1:
            cal += "+"
        else:
            cal += "-"
    cal += s[3]
    if eval(cal) == 7:
        break

print(f"{cal}=7")


Measured memory_bytes: 9112
# include <iostream>
# include <cstdio>
using namespace std;
const int N = 2e5 + 12;
const int inf = 0x3f3f3f3f;
long long h[N];
int main()
{
	for(int i = 1;i <= 1000;i++)h[i] = h[i - 1] + (long long)i;
	long long a,b;
	scanf("%lld %lld",&a,&b);
	printf("%lld\n",h[b - a] - b);
}

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

using namespace std;

typedef long long LL;

const int N = 100 + 5;



int a[10];

int check(int x){

	while(x){

		if(a[x % 10]) return 0;//每次获取末位数字判断是否不喜欢

		x /= 10;//更高位

		}

	return 1;//当所有都0喜欢就返回1;

	}

int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	

	int n , k , q;

	cin>>n>>k;

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

		cin>>q;

		a[q] = 1;

		}

	while(1){

		if(check(n)){

			cout<<n<<endl;

			break;

			}

		n++;//直到找到

		}

	return 0;

	}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int n;
ll a[300000];

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

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

	cin >> n;
	REP(i, n) cin >> a[i];
	ll ans = 0;
	REP(i, 60) {
		ll cnt = 0;
		REP(j, n) {
			if ((a[j] >> i) % 2 == 1)cnt++;
		}
		ans += ((cnt*(n - cnt)) % MOD)*(((ll)1 << i) % MOD);
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
import argparse
import sys
inf = float('inf')
from itertools import product


def washall_floyd(d):
    for k, i, j in product(range(n_node), repeat=3):
        d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


def have_negative_loop(dist_mat):
    for i in range(n_node):
        if dist_mat[i][i] < 0:
            return True

    return False


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument('--input', type=str)
    args = parser.parse_args()
    edge_input = []
    if args.input:
        f = open(args.input, 'r')
        n_node, n_edge = tuple(map(int, f.readline().split()))
        
        if n_node > 0:
            dist_mat = [[inf for _ in range(n_node)] for _ in range(n_node)]
            for _ in range(n_edge):
                from_node, to_node, cost = tuple(map(int, f.readline().split()))
                dist_mat[from_node][to_node] = cost
        f.close()
            
    else:
        n_node, n_edge = tuple(map(int, input().split()))
        dist_mat = \
            [[0 if i==j else inf for i in range(n_node)] for j in range(n_node)]
        if n_edge > 0:            
            for _ in range(n_edge):
                from_node, to_node, cost = tuple(map(int, input().split()))
                dist_mat[from_node][to_node] = cost

    dist_mat = washall_floyd(dist_mat)
    if have_negative_loop(dist_mat):
        print('NEGATIVE CYCLE')
    else:
        for i in range(n_node):
            dist = ' '.join(['INF' if j==inf else str(j) for j in dist_mat[i]])
            print(dist)
            # if i == n_node - 1:
            #     print(dist, end='')
            # else:
            #     print(dist)



Measured memory_bytes: 7868
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

ll N;
ll a[16][16];
ll dp[1 << 17];
bool used[1 << 17];
ll num[1 << 17];

ll solve(ll mask) {
    if (used[mask]) {
        return dp[mask];
    }
    used[mask] = true;
    ll ans = num[mask];
    for (ll i = (mask - 1) & mask; i > 0; i = (i - 1) & mask) {
        ans = max(ans, solve(i) + solve(i ^ mask));
    }
    return dp[mask] = ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, 0, N) {
        REP(j, 0, N) {
            cin >> a[i][j];
        }
    }
    REP(i, 0, (1 << N)) {
        ll tmp = 0;
        REP(j, 0, N) {
            REP(k, j + 1, N) {
                if (((i >> j) & 1) && ((i >> k) & 1)) {
                    tmp += a[j][k];
                }
            }
        }
        num[i] = tmp;
    }
    // REP(i, 0, 8) {
    //     cout << num[i] << " ";
    // }
    // cout << endl;
    fill(used, used + (1 << N), false);
    ll ans = solve((1 << N) - 1);
    cout << ans << endl;
}


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

typedef long long ll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << '\n'; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << " "; err(++it, args...); }

#define        optimize           ios::sync_with_stdio(0); cin.tie(0);
#define PI    acos(-1.0)
#define pb push_back
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define RESET(a, b) memset(a, b, sizeof(a))
#define pii pair <int, int>
#define gcd(a, b) __gcd(a, b)
#define min3(a, b, c) min(c, min(a, b))
#define max3(a, b, c) max(c, max(a, b))

const ll MX = 3e3 + 5;

ll dp[MX][MX];
ll ara[MX];

int main()
{
    optimize
    int n;
    cin>>n;
    for(int i = 0; i < n; i++) cin>>ara[i];

    for(int R = 0; R < n; R++){
        for(int L = R; L >= 0; L--){
            if(L == R) dp[L][R] = ara[L];
            else{
                dp[L][R] = max(ara[L]-dp[L+1][R], ara[R]-dp[L][R-1]);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
}


Measured memory_bytes: 49756
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
int  main(){
ll n,m;
cin >> n >> m;
if(n>=2)n-=2;
if(m>=2)m-=2;

ll ans = n*m;
cout<<ans<<endl;
}







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

using namespace std;

int arr[200005], pos[200005];
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        pos[arr[i]] = i;
    }
    set <int> s;
    long long res = 0;
    for (int i = 1; i <= n; i++) {
        int l = 0, r = n + 1;
        if (s.size() > 0) {
            auto x = s.lower_bound(pos[i]);
            if (x == s.end()) {
                x = --s.end();
            }
            if (*x < pos[i]) {
                l = *x;
            } else {
                r = *x;
                if (x != s.begin()) {
                    l = *(--x);
                }
            }
        }
        res += 1LL * i * (r - pos[i]) * (pos[i] - l);
        s.insert(pos[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 11136
/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL; 
typedef long double LD;

const int MAX=1e5+5;

int arr[MAX];
int incr[MAX];
int decr[MAX];
int dp[MAX];
int ans;
int n;
int solve(int i)
{
	if(i==(n+1))
	{
		return 0;
	}
	if(dp[i]!=-1)
	{
		return dp[i];
	}
	dp[i]=(min(solve(incr[i]),solve(decr[i]))+1);
	return dp[i];
}

int main() 
{
	scanf("%d",&n);
	ans=n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&arr[i]);
	}
	int flg=0;
	incr[n]=n+1;
	decr[n]=n+1;
	for(int i=n-1;i>=1;i--)
	{
		if(arr[i]<=arr[i+1])
		{
			incr[i]=incr[i+1];
		}
		else
		{
			incr[i]=i+1;
		}
		if(arr[i]>=arr[i+1])
		{
			decr[i]=decr[i+1];
		}
		else
		{
			decr[i]=i+1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		dp[i]=-1;
	}
	printf("%d\n",solve(1));
	return 0;
}

Measured memory_bytes: 4864
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws Exception
	{
		int x=nextInt();
		int y=nextInt();
		if(y%2==0 && y>=2*x && y<=4*x)
			out.println("Yes");
		else
			out.println("No");
	}

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

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

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

int main() {
    ll N, K; cin >> N >> K;
    ll ans = 0;
    for (int k = K; k < N; ++k) {
        ll a = (k - K + 1);
        ll b = min(N, (N - K + 1)) / (k + 1);
        ll c = min(a, min(N, (N - K + 1)) % (k + 1));
        ans += a * b + c;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
using std::cin;
using std::cout;
std::string a, b;
int f[1010][1010];
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //cout << std::setiosflags(std::ios::fixed) << std::setprecision(3);
    cin >> a >> b;
    for (int i = 0; i < a.size(); ++i) {
        for (int j = 0; j <= i && j < b.size(); ++j) {
            if (a[i] == b[j]) f[i + 1][j + 1] = f[i][j];
            else f[i + 1][j + 1] = f[i][j] + 1;
        }
    }
    int ans = 10000;
    for (int i = b.size(); i <= a.size(); ++i) ans = std::min(ans, f[i][b.size()]);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 7584
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

int n,a,b;

int dp[31][1000001]={};
int d[31][1000001]={};

const ll INF=100000000001;
int main() {
	int c;

	cin>>n>>c;
	int s1,t1,c1;
	for(int i=0;i<n;i++){
		cin>>s1>>t1>>c1;
		d[c1][s1-1]+=1;
		d[c1][t1]-=1;
	}
	int k=0;
	for(int j=1;j<31;j++){
		dp[j][0]=d[j][0];
		k+=d[j][0];
	}
	int total=k;
	for(int i=1;i<100001;i++){
		k=0;
		for(int j=1;j<31;j++){
			dp[j][i]=dp[j][i-1]+d[j][i];
			if(dp[j][i]>0)k++;
		}
		total=max(total,k);
	}


	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 149760
#include <stdio.h>
int main(void){
	int array[4][3][10] = {0};
	int n, i, j;
	int b, f, r, v;
	scanf("%d\n", &n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b, &f, &r, &v);
		array[b - 1][f - 1][r - 1] += v;
	}
	for(n=0;n<4;n++){
		for(i=0;i<3;i++){
			for(j=0;j<10;j++){
				printf(" %d",array[n][i][j]);
			}
			printf("\n");
		}
		if(n<3) printf("####################\n");
	}
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);

const int N = 2e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
int tc;

int main()
{
    FIO
    int n; cin>>n;
    vector<pair<int, int> > vec(n);
    for(auto &it : vec)
        cin>>it.first>>it.second;
    bool v = 0;
    for(int i = 0 ; i < n - 2 && !v; i++ )
    {
        if(vec[i].first == vec[i].second && vec[i+1].first == vec[i+1].second && vec[i+2].first == vec[i+2].second)
            v = 1;
    }
    v ? cout<<"Yes" : cout<<"No";
    return 0;
}

Measured memory_bytes: 3656
n,m=map(int,input().split())
a=set(int(input()) for i in range(m))
mod=10**9+7

dp=[0]*(n+1)
dp[0]=1

for i in range(1,n+1):
    if i in a:
        continue
    if i==1:
        dp[i]=1
    else:
        dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[-1])

Measured memory_bytes: 11884
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cassert>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<utility>
using namespace std;
int n;

int solve(){
  int ans=0;
  int i=0,j=0;
  int sum=0;
  while(i<n){
    while(sum<n&&i<n){
      i++;
      sum+=i;
    }
    while(sum>n){
      j++;
      sum-=j;
    }
    if(i!=j&&sum==n&&i!=n){
      ans++;
    }
    j++;
    sum-=j;
  }
  return ans;
}

int main(){
  while(cin>>n,n!=0){
    cout<<solve()<<endl;
  };
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

  int flg = 0;
  if (W % 2 == 0 && W / 2 == x && H % 2 == 0 && H / 2 == y) flg = 1;

  printf("%.10f %d\n", (double)W * H / 2, flg);
}


Measured memory_bytes: 256
"use strict";
function main(input) {
  let kari = input[0].trim().split(" ").map(i => parseInt(i));
  const l = kari[0];
  console.log(l/3 * l/3 * l/3);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 21064
n = int(input())
ans = 0
li = []
tmp = 0
for i in range(n):
    t = int(input())
    if t == 0:
        li.append(tmp)
        tmp = 0
    else:
        tmp += t
li.append(tmp)
for l in li:
    ans += l//2
#print(li)
print(ans)

Measured memory_bytes: 4360
#include <iostream>

using namespace std;

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

	int odd_count = 0;
	for (int i = 0; i < N; ++i) {
		int A;
		cin >> A;
		if (A & 1) {
			++odd_count;
		}
	}
	if (odd_count & 1) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}


Measured memory_bytes: 764
#include<stdio.h>

int bool(int n){
  int a,b;
  a=n/100;
  b=n%100;
  if(a*5<b)return 0;
  else return 1;
}

int main(){
  int x;
  scanf("%d",&x);
  printf("%d",bool(x));
  return 0;
}

Measured memory_bytes: 128
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iostream>

using namespace std;
int main(){
    string s;
    cin >> s;
    for(int i = 0; i <s.size(); i++){
        if(s[i] == '?'){
            s[i] = 'D';
        }
    }
    cout << s;
    
}




Measured memory_bytes: 3704