akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long X = sc.nextInt();
		long[] x = new long[N];
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
		}

		long[] dist = new long[N];
		for (int i = 0; i < x.length; i++) {
			dist[i] = Math.abs(x[i] - X);
		}

		long ans = dist[0];
		for (int i = 0; i < dist.length; i++) {
			ans = gcd(ans, dist[i]);
		}

		System.out.println(ans);
	}

	private static long gcd(long x, long y) {
		if (x < y) return gcd(y, x);
		if (y == 0) return x;
		return gcd(y, x % y);
	}
}

Measured memory_bytes: 50000
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    h = list(map(int, input().rstrip('\n').split()))
    for i in range(1, n):
        if h[i] < h[i-1]:
            h[i] += 1
        if h[i] < h[i-1]:
            print("No")
            exit()
    print("Yes")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 63856
from bisect import *
A,B,Q=map(int,input().split())
INF=10**15
S=[-INF*10,-INF]
for i in range(A):
  S.append(int(input()))
S.append(INF)
S.append(INF*10)
T=[-INF*10,-INF]
for i in range(B):
  T.append(int(input()))
T.append(INF)
T.append(INF*10)
D,E,F,G,V,W,X,Y,Z,P=0,0,0,0,0,0,0,0,0,0
for i in range(Q):
  X=int(input())
  V=bisect_left(S,X)
  Y,Z=S[V-1],S[V]
  D,E=abs(X-Y),abs(X-Z)
  V,W=bisect_left(T,Y),bisect_left(T,Z)
  F,G=min(abs(Y-T[V-1]),abs(Y-T[V])),min(abs(Z-T[W-1]),abs(Z-T[W]))
  P=min(D+F,E+G)
  V=bisect_left(T,X)
  Y,Z=T[V-1],T[V]
  D,E=abs(X-Y),abs(X-Z)
  V,W=bisect_left(S,Y),bisect_left(S,Z)
  F,G=min(abs(Y-S[V-1]),abs(Y-S[V])),min(abs(Z-S[W-1]),abs(Z-S[W]))
  print(min(P,D+F,E+G))

Measured memory_bytes: 112008
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a = LI()
    k = I()
    t = max(a)

    return t * (2**k) + sum(a) - t



print(main())



Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
typedef pair<int, int> P;
const int INF = 1e9;

int main(){
	int N, M; cin >> N >> M;
	vector<P> vec(M);
	for(int i = 0; i < M; i++) cin >> vec[i].second >> vec[i].first;
	sort(vec.begin(), vec.end());
	int start = 0, ans = 0;
	for(int i = 0; i< M; i++){
		if(start <= vec[i].second) ans++, start = vec[i].first;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll n;
    cin>>n;
    ll ans=180*(n-2);
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<string.h>
#define ll long long
#define Start ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define fr first
#define sc second
#define M_PI           3.14159265358979323846
using namespace std;
int n;
int Dp[200200];
int A[100100];

int main()
{
    Start;

    cin>>n;
    for(int i=0;i<n;i++)
        cin>>A[i];
    for(int i=0;i<n;i++)
        Dp[i]=1e9;
    Dp[0]=0;
    for(int i=0;i<n;i++)
    for(int j=i+1;j<=i+2;j++)
        Dp[j]=min(Dp[j],Dp[i]+abs(A[j]-A[i]));
        cout<<Dp[n-1];

}


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

using ll = long long;

#define vl vector<long long>
using pll = pair<long long, long long>;
#define __ <<'\n'
#define _ << ' '
#define all(x) (x).begin(), (x).end()

void error()
{
    cout << "-1";
    exit(0);
}

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

    string s;
    cin >> s;
    string e = "keyence";
    ll prefix = 0;
    for (auto i = 0; i < 7; i++)
    {
        if (s[i] == e[i])
            prefix++;
        else
            break;
    }
    ll suf = 0;
    ll j = 6;
    for (ll i = s.size() - 1; i >= s.size() - 8; i--)
    {
        if (s[i] == e[j--])
            suf++;
        else
            break;
    }

    if (suf + prefix >= 7)
    {
        cout << "YES";
        return 0;
    }
    cout << "NO";
    return 0;
}

Measured memory_bytes: 256
use std::collections::BinaryHeap;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let m: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut abv = vec![(0i32, 0i32); n];
    for i in 0..n {
        abv[i].0 = read(&mut stdin_lock, &mut buf, b' ');
        abv[i].1 = read(&mut stdin_lock, &mut buf, b'\n');
    }

    let mut min_a_heap = BinaryHeap::new();
    for i in 0..n {
        min_a_heap.push((m as i32 - abv[i].0, abv[i].1));
    }
    let mut max_b_heap = BinaryHeap::new();
    let mut ans = 0;
    for i in 0..m {
        loop {
            match min_a_heap.peek() {
                None => break,
                Some(&(ra, b)) => {
                    if m as i32 - ra > (i + 1) as i32 {
                        break;
                    }
                    min_a_heap.pop();
                    max_b_heap.push(b);
                }
            }
        }
        match max_b_heap.pop() {
            None => continue,
            Some(b) => ans += b,
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	A, B := sc.nextInt(), sc.nextInt()
	ans := 0
	for i := 0; i < 40; i++ {
		//fmt.Fprintln(wtr, B, i, count(B, i))
		//fmt.Fprintln(wtr, A-1, i, count(A-1, i))
		if (count(B, i)-count(A-1, i))%2 != 0 {
			ans += pow(2, i)
		}
	}

	fmt.Fprintln(wtr, ans)
}

func count(n, p int) int {
	n += 1
	add := pow(2, p)
	diff := pow(2, p+1)
	q := n / diff
	res := q * add
	next := (q+1)*diff - add + 1
	if next <= n {
		res += n - next + 1
	}
	return res
}

//func count(n, p int) int {
//	cur, add := pow(2, p), pow(2, p)
//	diff := pow(2, p+1)
//	res := 0
//	for cur <= n {
//		if cur+add-1 <= n {
//			res += add
//		} else {
//			res += n - cur + 1
//		}
//		cur += diff
//	}
//	return res
//}


Measured memory_bytes: 640
h, w = map(int, input().split())
s = []
for i in range(h):
    s.append(list(input()))
lr = [[0] * w for i in range(h)]
#print(lr)
for i in range(h):
    cnt = 0
    lis = []
    for j in range(w):

        if s[i][j] == '#':
            lis.append(cnt)
            cnt = 0
        elif j == w-1:
            if s[i][j] == '.':
                cnt += 1
            lis.append(cnt)
        else:
            cnt += 1
    p = 0
    #print(lis)
    for j in range(w):
        if s[i][j] == '.':
            #print(p)
            #print(lr)
            lr[i][j] = lis[p]
        else:
            p += 1
#print(lr)

ud = [[0] * w for i in range(h)]
#print(ud)
for j in range(w):
    cnt = 0
    lis = []
    for i in range(h):
        #print(s[i][j])
        if s[i][j] == '#':
            lis.append(cnt)
            cnt = 0
        elif i == h-1:
            if s[i][j] == '.':
                cnt += 1
            lis.append(cnt)
        else:
            cnt += 1
    p = 0
    #print(lis)
    for i in range(h):
        #print(p,i,j,)
        #print(lis[p])
        #print(ud[j][i])
        if s[i][j] == '.':
            #print(p)
            #print(lr)
            ud[i][j] = lis[p]
        else:
            p += 1
        #print(p)
#print(ud)
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, lr[i][j] + ud[i][j] - 1)
print(ans)


Measured memory_bytes: 245128
n, m, x = map(int, input().split())
ca = [tuple(map(int, input().split()))for _ in range(n)]
INF = 10**18
ans = INF
for bit in range(1 << n):
    cost = 0
    proficiency = [0]*m
    for i in range(n):
        if bit >> i & 1:
            c, *A = ca[i]
            cost += c
            for j in range(m):
                proficiency[j] += A[j]
    if cost < ans and all(x <= proficiency[j]for j in range(m)):
        ans = cost
print(ans if ans != INF else -1)

Measured memory_bytes: 9228
#include <iostream>
using namespace std;
int main(void){
    int a,power=0;
    int b[50]={};
    cin>>a;
    for(int z=1;z<=a;z++){
        cin>>b[z];
    }
    for(int y=1;y<=a-1;y++){
        for(int x=y+1;x<=a;x++){
                power+=b[x]*b[y];
        }
    }
    cout<<power<<endl;
}

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

using namespace std;

int main()
{
    int inputN; // すぬけ君の持っている整数の個数
    int inputK; // すぬけ君があげる整数の個数
    
    cin >> inputN >> inputK;
    
    if (inputN < 0) {
        printf("Invalid argument N = %d¥n", inputN);
        return 1;
    }
    
    if (inputK < 0) {
        printf("Invalid argument K = %d¥n", inputK);
        return 1;
    }
    
    if (inputN < inputK) {
        printf("Invalid argument N = %d, K = %d¥n", inputN, inputK);
        return 1;
    }
    
    int i = 0;
    int selecting_count = 0;
    for (i = 0; i < inputN; i++) {
        if (inputN < i + inputK) {
            break;
        }
        selecting_count++;
    }
    
    cout << selecting_count;
}

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

int main(){
  int N;
  cin >> N;
  
  int A;
  map<int, int> mp;
  for(int i=1;i<=N;i++){
    mp[i] = 0;
  }
  
  for(int i=2;i<=N;i++){
    cin >> A;
    if(mp.count(A)){
      mp.at(A)++;
    }
  }

  for(int i=1;i<=N;i++){
    cout << mp.at(i) << endl;
  }
  return 0;
}

Measured memory_bytes: 13012
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N,K,h[100010];
int dp[100010];
int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> h[i];
        dp[i] = MM;
    }
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 0; i < N; i++){
        for(int j = 1; i+j < N && j <= K; j++){
            dp[i+j] = min(dp[i] + abs(h[i+j]-h[i]), dp[i+j]);
        }
    }
    cout << dp[N-1] << endl;
}



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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int[] task = new int[3];
		task[0] = sc.nextInt();
		task[1] = sc.nextInt();
		task[2] = sc.nextInt();
		Arrays.sort(task);
		int cost = 0;
		for (int i = 1; i < 3; i++) {
			cost += task[i] - task[i - 1];
		}
		System.out.println(cost);

	}

}


Measured memory_bytes: 21844
program prob1
    implicit none
    integer(8) :: n, a, b, c, d, e, t
    
    read(*,*) n, a, b, c, d, e
    t = min(a, min(b, min(c,min(d, e))))
    write(*,*) (n-1)/t + 5

    stop
contains
end program prob1

Measured memory_bytes: 2800
import sys

def main():
    istr = sys.stdin.read()
    wi = list(map(int,istr.splitlines()))

    for n in wi:
        """ ????????? """
        cnt = 0
        for a in range(10):
            for b in range(10):
                for c in range(10):
                     for d in range(10):
                        x = a + b + c + d
                        if x == n:
                            cnt += 1
                        elif x > n:
                            break
        print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7656
#include<bits/stdc++.h>
using namespace std;
int n,ans;
bool Check(int x){
	int res=0;
	while(x){
		x/=10;
		res++;
	}
	return res&1;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)if(Check(i))ans++;
	printf("%d\n",ans);
}

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

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int N, int[] L)
        {
            Array.Sort(L);
            return Enumerable.Range(0, N).Sum(i => L[i * 2]);
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] L = ReadInts();
            Console.WriteLine(Solve(N, L));
        }
    }
}


Measured memory_bytes: 11348
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
H = list(map(int, input().split()))

R = []
for nn in range(N):
  s = set()
  R.append(s)
for i in range(M):
  aa, bb = map(int, input().split())
  R[aa-1].add(bb)
  R[bb-1].add(aa)

good = 0
for nn in range(N):
  hh = H[nn]
  s = set()
  for mm in R[nn]:
    s.add(H[mm-1])
  if(len(s) == 0):
    good += 1
  elif(max(s) < hh):
    good += 1

print(good)


Measured memory_bytes: 45372
def floyd():
    global d
    global INF
    for k in range(n):
        for i in range(n):
            if (d[i][k] == INF):
                continue
            for j in range(n):
                if (d[k][j] == INF):
                    continue
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);


n,q=[int(x) for x in input().split()]
maxx = 110
INF = 1<< 48
d=[[INF for j in range(n+2)] for i in range(n+2)]

for i in range(n):
    d[i][i] =0
            
for i in range(q):    
    s=[int(x) for x in input().split()]
    d[s[0]][s[1]]=s[2]
    
floyd()

    # 判断是否存在负环
negative = False;
for i in range(n):
    if (d[i][i] < 0):
        negative = True;

if (negative):
    print("NEGATIVE CYCLE");
else :
    for i in range(n): 
        for j in range(n):
            if (d[i][j] == INF):
                if j==n-1:print("INF")
                else: print("INF",end=' ')
            else:
                if j!=n-1:print("%d"%(d[i][j]),end=' ')
                else: print("%d"%(d[i][j]))


Measured memory_bytes: 6292
#include<stdio.h>
#include<math.h>
#include<stdlib.h>


int main(){
    int a, b, eq=0;
    scanf("%d %d", &a, &b);
    eq= 2*b;
    if (eq < a)
    	printf("%d",a-eq);
    else
    	printf("0");
    printf("\n");
    return 0;
}


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

int main() {
    int N;
    int k, tmp, num;
    cin >> N;
    for (int i = 1; i <= N; i += 2){
        k = i;
        tmp = 0;
        for (int j = 1; j <= N; j++){
            if (k % j == 0){
                tmp += 1;
            }
        }
        if (tmp == 8){
            num += 1;
        }
    }
    cout << num;
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    cout<<N*N*N;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
string blues[101], reds[101];
int n, m, ans=-987654321;
int main() {
  ios::sync_with_stdio(false);
  
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> blues[i];
  cin >> m;
  for (int i = 0; i < m; i++)
    cin >> reds[i];
  
  for (int i = 0; i < n; i++) {
    int value = 0;
    string t = blues[i];
    for (int j = 0; j < n; j++)
      if (t == blues[j])
        value++;
    for (int k = 0; k < m; k++)
      if (t == reds[k])
        value--;
    if (ans < value)
      ans = value;
        
  }
  if (ans < 0)
    cout << 0 << endl;
  else
    cout << ans << endl;

  return 0;
}


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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  Int n;
  while(cin>>n,n){
    vector<Int> as(n),bs(n);
    for(Int i=0;i<n;i++) cin>>as[i];
    for(Int i=0;i<n;i++) cin>>bs[i];

    priority_queue<Int, vector<Int>, greater<Int> > pq;
    for(Int a:as) pq.emplace(a);

    Int add=0;
    while(!pq.empty()&&(pq.top()+add==0)) pq.pop();      

    sort(bs.rbegin(),bs.rend());
    Int flg=1;
    for(Int i=0;i<n;i++){
      //cout<<pq.size()<<" "<<bs[i]<<endl;
      if((Int)pq.size()!=bs[i]){
        flg=0;
        break;
      }
      add--;
      while(!pq.empty()&&(pq.top()+add==0)) pq.pop();
    }
    flg&=!!pq.empty();
    cout<<(flg?"Yes":"No")<<endl;
  }  
  return 0;
}



Measured memory_bytes: 3236
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	c *= 2;
	cout << (max(x, y) == x ? (x-y) * min(a, c) + min(x, y) * min(a + b, c) : (y-x) * min(b, c) + min(x, y) * min(a + b, c)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
using namespace std;
int main()
{
    vector<int> dice;
    string roll;
    int roll_len, tmp;
    dice.resize(6);
    cin >> dice[0] >> dice[1] >> dice[2] >> dice[3] >> dice[4] >> dice[5] >> roll;
    roll_len = roll.length();
    for (int i=0; i<roll_len; ++i){
        if(roll[i] == 'S'){
            tmp = dice[0];
            dice[0] = dice[4];
            dice[4] = dice[5];
            dice[5] = dice[1];
            dice[1] = tmp;
        }
        else if(roll[i] == 'N'){
            tmp = dice[0];
            dice[0] = dice[1];
            dice[1] = dice[5];
            dice[5] = dice[4];
            dice[4] = tmp;
        }
        if(roll[i] == 'W'){
            tmp = dice[0];
            dice[0] = dice[2];
            dice[2] = dice[5];
            dice[5] = dice[3];
            dice[3] = tmp;
        }
        if(roll[i] == 'E'){
            tmp = dice[0];
            dice[0] = dice[3];
            dice[3] = dice[5];
            dice[5] = dice[2];
            dice[2] = tmp;
        }
    }
    cout << dice[0] << endl;
    return 0;
}



Measured memory_bytes: 3168
{-# LANGUAGE FlexibleContexts #-}

import Control.Monad
import Control.Monad.ST
import Control.Applicative
import Data.List
import Data.Array
import Data.Array.ST
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import Data.STRef
import Text.Printf
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
listToTuple4 [a,b,c,d] = (a,b,c,d)

getWords = getLine >>= return . words

readIntBS = fst . fromJust . BS.readInt

for = flip map


main :: IO ()
main = do
  (n,m) <- listToTuple2 . map read . words <$> getLine :: IO (Int,Int)
  edges <- map ((\(a,b,c) -> (read a, read b, read c)) . listToTuple3 . words) . lines <$> getContents :: IO [(Int,Int,Int64)]

  let a = negate $ bellman_ford (1,n) (map (\(a,b,c) -> (a,b,-c)) edges) 1 n

  putStrLn $ if a == inf then "inf" else show a
  


inf = 10^18 :: Int64

type Node = Int
type Cost = Int64
type Edge = (Node, Node, Cost)

bellman_ford :: (Node,Node) -> [Edge] -> Node -> Node -> Cost
bellman_ford bound@(lower,upper) edges src dst = runST $ do
  arr <- newArray bound inf :: ST s (STUArray s Node Cost)
  negcycle <- newSTRef False :: ST s (STRef s Bool)

  writeArray arr src 0
  forM_ [1..(upper-lower+1)] $ \i -> do
    forM_ edges $ \(s,e,c) -> do
      x <- (+c) <$> readArray arr s
      y <- readArray arr e
      when (x < y) $ do
        writeArray arr e x
          
  forM_ [1..(upper-lower+1)] $ \i -> do
    forM_ edges $ \(s,e,c) -> do
      x <- (+c) <$> readArray arr s
      y <- readArray arr e
      when (x < y) $ do
        writeArray arr e x
        when (e == dst) $ do
          writeSTRef negcycle True

  ncExists <- readSTRef negcycle
  if ncExists then
    return (-inf)
    else
    readArray arr dst
  


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

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

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

// order statistics tree
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
             tree_order_statistics_node_update> indexed_set;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define rrep(i, b, a) for(int i = b; i >= a; --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

int l, r;
int main() {
  cin.tie(0); cin.exceptions(cin.failbit);
  scanf("%d%d", &l, &r);

  if(r-l+1 < 2019){
    int ans = 1e9;
    rep(i, l, r){
      rep(j, l+1, r+1){
        ans = min(ans, (i%2019)*(j%2019)%2019);
      }
    }
    printf("%d\n", ans);
  } else{
    puts("0");
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
using namespace std;
const int N = 1e5+10;

int ans[N*4];
int ff[N*4];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(m == 1 || m == n*2-1)
        printf("No\n");
    else
    {
        printf("Yes\n");
        int temp=n*2-1;
        if(temp == 3)
        {
            printf("1\n2\n3\n");
            return 0;
        }
        if(m >= n)
        {
            ans[n] = temp;
            ans[1+n] = m;
            ans[2+n] = 1;
            ans[n-1] = 2;
            int num=0;
            for(int i=1;i<=temp;i++)
            {
                if(i==temp||i==m||i==1||i==2) continue;
                ff[num++]=i;
            }
            for(int i=0;i<n-2;i++)
                printf("%d\n",ff[i]);
            for(int i=n-1;i<=n+2;i++)
                printf("%d\n",ans[i]);
            for(int i=n-2;i<num;++i)
                printf("%d\n",ff[i]);
        }
        else
        {
            ans[n] = 1;
            ans[1+n] = m;
            ans[2+n] = temp;
            ans[n-1] = temp-1;
            int num=0;
            for(int i=1;i<=temp;i++)
            {
                if(i==temp||i==m||i==1||i==temp-1) continue;
                ff[num++]=i;
            }
            for(int i=0;i<n-2;i++)
                printf("%d\n",ff[i]);
            for(int i=n-1;i<=n+2;i++)
                printf("%d\n",ans[i]);
            for(int i=n-2;i<num;++i)
                printf("%d\n",ff[i]);
        }
    }
    return 0;
}


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

long long maxValue(int capacity, const vector<int> &weight, const vector<int> &value){
    const int n = weight.size();
    vector<vector<long long> > dp(2, vector<long long>(capacity+1,0));
    for(int i = 0; i<n; i++){
        int currIndex = i&1, prevIndex = (i-1)&1;
        for(int currCapacity = 0; currCapacity<=capacity ; currCapacity++){
            if(weight[i] > currCapacity){
                dp[currIndex][currCapacity] = dp[prevIndex][currCapacity];
            }
            else{
                dp[currIndex][currCapacity] = max( dp[prevIndex][currCapacity - weight[i]] + value[i], dp[prevIndex][currCapacity]);
            }
        }
    }
    int finalIndex = (n-1)&1;
    return dp[finalIndex][capacity];
}
int main(){
    int numItems, capacity;
    cin>>numItems>>capacity;
    vector<int> weight(numItems), value(numItems);
    for(int i = 0; i<numItems ;i++){
        cin>>weight[i]>>value[i];
    }
    cout<<maxValue(capacity, weight, value)<<endl;
    return 0;
}

Measured memory_bytes: 5624
#include <iostream>
using namespace std;
int n;
#define MAX_N 1000000

int prime[MAX_N]; // i番目の素数
bool is_prime[MAX_N + 1]; // is_prime[i]がtrueならiは素数

// n以下の素数の数を返す
int sieve(int n) {
    int p = 0;
    for(int i=0;i<=n;i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for (int i=2; i<=n; i++) {
        if (is_prime[i]) {
            prime[p++] = i;
            for(int j=2*i; j <= n; j += i) is_prime[j] = false;
        }
    }
    return p;
}

main() {
    sieve(MAX_N);
    while(cin>>n) {
        int ans=0;
        for(int i=2;i<=n;i++) {
            if(is_prime[i]) ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2448
// luogu-judger-enable-o2
#include<stdio.h>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int num[100005],a[100005];
void init(int x)
{
    if(x%2==0)
        for(int i=1;i<=x;i+=2) 
        {
            a[i]=i;
            a[i+1]=a[i];
        }
    else
        for(int i=2;i<=x;i+=2)
        {
            a[i]=i;
            a[i+1]=a[i];
        }

}
int main()
{
    int n,k=1;
    scanf("%d",&n);
    init(n);
    for(int i=1;i<=n;i++)
        scanf("%d",&num[i]);
    sort(num+1,num+1+n);
    for(int i=1;i<=n;i++)
        if(a[i]!=num[i])
        {
            printf("0");
            return 0; 
        }

    long long ans=1;
    n/=2;
    while(n--)
        ans=ans*2%mod;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 896
'''A - Train
https://atcoder.jp/contests/abc107/tasks/abc107_a

>>> main(4, 2)
3
>>> main(1, 1)
1
>>> main(15, 11)
5'''


def main(n, i):
    print(n - i + 1)


if __name__ == '__main__':
    n, i = map(int, input().split(' '))
    main(n, i)


Measured memory_bytes: 2940
N=int(input())
llist=list(map(int,input().split()))

llist.sort()
answer=0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):      
      if llist[i]<llist[j]<llist[k] and llist[i]+llist[j]>llist[k]:
        #print(llist[i],llist[j],llist[k])
        answer+=1
        
print(answer)

Measured memory_bytes: 9144
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
#include<map>
using namespace std;
#define  LL long long

int ff(int x)
{
	int ans=0;
	while(x){
		ans+=x%10;
		x=x/10;
	}
	return ans;
}

void f(int x)
{
	int ans=0x3f3f3f3f;
	for(int i=1;i<x;i++){
		ans=min(ans,ff(i)+ff(x-i));
	}
	printf("%d\n",ans);
}


int main()
{
	int n;
	scanf("%d",&n);
	f(n);
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc058/tasks/abc058_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (c - b == b - a) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }

    return 0;
}


Measured memory_bytes: 256
def count(n):
  ans = 0
  for i in range(1,n+1):
    if n % i == 0:
      ans += 1
  return ans

ans = 0
N = int(input())
for i in range(1,N + 1):
  if i % 2 == 0:
  	continue
  if count(i) == 8:
    ans += 1
print(ans)


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 100005, mod = 1000000007;
int n, x, k, ind[MX], mem[MX][205], a[MX];

int dp (int x, int g) {
	if (!g && ind[x] == -1) return x;

	int &res = mem[x][g];
	if (res != -1) return res;
	res = 0;

	if (g) res = (res + 1ll * g * dp(x, g - 1)) % mod;
	for (int i = 0; i <= ind[x]; i++) {
		int to = x % a[i];

		res += dp(to, g + ind[x] - ind[to] - 1);
		if (res >= mod) res -= mod;
	}

	return res;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(mem, -1, sizeof(mem));
	
	cin >> n >> x;
	forn (i, n) {
		cin >> a[i];
		if (a[i] > x)
			k++;
	}
	sort(a, a + n);

	memset(ind, -1, sizeof(ind));
	forn (i, n) ind[a[i]] = i;
	
	for (int i = 1; i < MX; i++)
		ind[i] = max(ind[i], ind[i - 1]);

	cout << dp(x, k) << endl;

	return 0;
}


Measured memory_bytes: 80768
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
int digit(int a){
    int count = 0;
    for (int i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }     
    }
    return count;
}
//pow(x,n) == x^n

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

int n,k,sum = 0;
cin >> n >> k;
vector < int > x(n);
rep(i,n) cin >> x[i];

rep(i,n){
    sum += min(abs(x[i])*2,abs(x[i]-k)*2);
}
cout << sum << endl;

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
A, B, C, D=map(int,input().split())
while True:
    C -= B
    if (A <= 0):
        print ("No")
        break
    elif(C <= 0):
        print ("Yes")
        break
    
    A -= D
    if (A <= 0):
        print ("No")
        break
    elif(C <= 0):
        print ("Yes")
        break

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

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

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



int main() 
{
  ll N; cin>>N;
  ll ans;
  rep(i,N)
  {
    if(i==0) {cin>>ans;}
    ll A; cin>>A;
    ans=gcd(A,ans);
  }
  cout<<ans<<endl;  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>a[101010],b[101010];
int n,root1,root2,doe;
int id[101010],v[101010];
int pre[808080],son[808080],now[101010];
void add(int x,int y)
{
//	if (doe%2) printf("add : %d %d\n",x,y);
	++doe;
	pre[doe]=now[x];
	now[x]=doe;
	son[doe]=y;
}
void connect(int x,int y)
{
	x=id[x]; y=id[y];
	add(x,y); add(y,x);
}

void dfs1(int x)
{
	int len=a[x].size();
	for (int i=0;i<len;++i)
	{
		int y=a[x][i];
		dfs1(y);
		if (i%2==1) connect(a[x][i],a[x][i-1]);
	}
	if (len%2==1) id[x]=id[a[x][len-1]];
}
void dfs2(int x)
{
	int len=b[x].size();
	for (int i=0;i<len;++i)
	{
		int y=b[x][i];
		dfs2(y);
		if (i%2==1) connect(b[x][i],b[x][i-1]);
	}
	if (len%2==1) id[x]=id[b[x][len-1]];
}
void col(int x)
{
	int p=now[x];
	while (p)
	{
		int y=son[p];
		if (v[y]==0)
		{
			v[y]=-v[x];
			col(y);
		}
		p=pre[p];
	}
}
int main()
{
//	freopen("F.in","r",stdin);
//	freopen("F.out","w",stdout);

	scanf("%d",&n);
	int x;
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&x);
		if (x==-1) root1=i;
		else a[x].push_back(i);
	}
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&x);
		if (x==-1) root2=i;
		else b[x].push_back(i);
	}
	for (int i=1;i<=n;++i) if (a[i].size()%2 != b[i].size()%2)
	{
		printf("IMPOSSIBLE\n");
		return 0;
	}
	
	for (int i=1;i<=n;++i) id[i]=i;
	dfs1(root1);
	for (int i=1;i<=n;++i) id[i]=i;
	dfs2(root2);
	for (int i=1;i<=n;++i) if (a[i].size()%2==0 && v[i]==0)
	{
		v[i]=1;
		col(i);
	}
	printf("POSSIBLE\n");
	for (int i=1;i<=n;++i) printf("%d ",v[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 1000000007
#define yes cout << "Yes\n"
#define no cout << "No\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define Max 10000000

using namespace std;

bool mark[Max + 1];
int num[Max + 1];

void sieve() {
    for(int i = 2; i <= Max; i++) num[i] = i;
    for(int i = 4; i <= Max; i += 2) mark[i] = 1;

    for(int i = 3; i * i <= Max; i += 2) {
        if(!mark[i]) {
            for(int j = i * i; j <= Max; j += (2 * i)) {
                if(num[j] == j) {
                    num[j] = i;
                }
                mark[j] = 1;
            }
        }
    }
    /*for(int i = 2; i <= Max; i++) {
        if(!mark[i]) cout << i << "\n";
    }*/
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int ans = 0;
    take;
    sort(all(a));
    for(int i = 0; i < k; i++) ans += a[i];
    cout << ans << "\n";
    return 0;
}


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

using namespace std;

#define sz(c) ((int)c.size())
#define	pb push_back

typedef long long ll;
typedef pair<ll, ll> state;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

constexpr int MAX_N = 510;
constexpr ll INF = 5'000'000'000'000'000'000LL;
constexpr ll P = 9'982'443'53;
constexpr int SIGMA = 28;
constexpr double PI = 3.14159265359;
constexpr double toRad = PI/180.;

struct Edge {
    ll np, cost;

    bool operator<(const Edge & o)const{
        if(cost != o.cost){
            return cost < o.cost;
        }
        return np < o.np;
    }
};

ll N, D;
map<ll,ll> costs;
ll brute(){
    set<Edge> q;
    set<ll> vis;
    q.insert(Edge({N,0}));
    while(q.size()){
        auto e = q.begin();
        if(e->np == 0) {
            return e->cost;
        }

        if(vis.find(e->np) != vis.end()) {
            q.erase(e);
            continue;
        }

        vis.insert(e->np);
        if(D < (INF-e->cost)/e->np){
            q.insert(Edge({
                0,
                e->cost + e->np*D
            }));
        }

        for(auto c : costs){
            ll r = e->np % c.first;
            if(r == 0){
                q.insert(Edge({
                    e->np / c.first,
                    e->cost + c.second
                }));
                continue ;
            }
            q.insert(Edge({
                (e->np - r) / c.first,
                e->cost + c.second + r*D
            }));

            ll m = e->np / c.first;
            ll r2 = (m+1)*c.first - e->np;
            q.insert(Edge({
                (e->np + r2) / c.first,
                e->cost + c.second + r2*D
            }));
        }
        q.erase(e);
    }
    return -1;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin >> T;
    costs[2] = costs[3] = costs[5] = 0;
    while(T--){
        cin >> N >> costs[2] >> costs[3] >> costs[5] >> D;
        cout << brute() << "\n";
    }

    return 0;
}


Measured memory_bytes: 5088
#include <iostream>
#include <string>
#include <algorithm>

int main() {
  std::string S;
  std::cin >> S;
  std::sort(S.begin(), S.end());
  for (size_t i = 1; i < S.length(); ++i)
    if (S[i-1] == S[i])
      return (std::cout << "no" << std::endl), 0;

  std::cout << "yes" << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  ll W,H,N; cin >> W >> H >> N ;

  ll lx,rx,ly,ry;
  lx = 0, rx = W;
  ly = 0, ry = H;
  
  rep(i,N){
    ll x,y,a;
    cin >> x >> y >> a;
    switch(a){
    case 1:
      lx = max(lx, x);
      break;
    case 2:
      rx = min(rx, x);
      break;
    case 3:
      ly = max(ly, y);
      break;
    case 4:
      ry = min(ry, y);
      break;
    deafult:
      break;
    }
  }
  cerr << rx << " " << lx << " " << ry << " " << ly << endl;
  if(((rx-lx) > 0) && ((ry-ly) > 0)) cout << (rx-lx)*(ry-ly) << endl;
  else cout << 0 << endl;
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
function Main(input) {
    const args = input.split('\n');
    const a = parseInt(args[0], 10);
    const s = args[1];
    
    var res = (a >= 3200) ? s : "red";
    
    console.log(res);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import defaultdict

N = int(read())

counter = defaultdict(int)

for x in map(str,range(1,N+1)):
    head = x[0]
    tail = x[-1]
    counter[(head, tail)] += 1

answer = 0
items = list(counter.items())
for (head, tail), cnt in items:
    answer += cnt * counter[(tail, head)]

print(answer)

Measured memory_bytes: 3572
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
using namespace std;


int main(void) {
    char S[5];
    int a, b;
    int is_a, is_b;
    
    scanf("%s", S);
    a = 10*(S[0] - '0') + S[1] - '0';
    if(1<=a && a<=12){
        is_a = 1;
    }else{
        is_a=0;
    }
    b = 10*(S[2] - '0') + S[3] - '0';
    if(1<=b && b<=12){
        is_b = 1;
    }else{
        is_b=0;
    }
    
    if(is_a==0 && is_b==0){
        printf("NA\n");
    }else if(is_a==1 && is_b==0){
        printf("MMYY\n");
    }else if(is_a==0 && is_b==1){
        printf("YYMM\n");
    }else if(is_a==1 && is_b==1){
        printf("AMBIGUOUS\n");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  int x;
  cin >> x;
  if(x == 3 || x == 5 || x == 7) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


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

int main()
{
    int r;
    scanf("%d",&r);
    if(r>=0&&r<1200)
        printf("ABC");
    else if(r>=1200&&r<2800)
        printf("ARC");
    else
        printf("AGC");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define maxn 100005
using namespace std;
typedef long long ll;

vector<int>G[maxn];
int step1[maxn],step2[maxn];
int vis1[maxn],vis2[maxn];
int n,s1,s2,u,v;

void bfs(int k){
    if(k==s1){
        queue<int>q;
        q.push(k);
        step1[k]=0;
        vis1[k]=1;
        while(!q.empty()){
          int a=q.front();
          q.pop();
          for(int b:G[a]){
             if(!vis1[b]) {
                step1[b]=step1[a]+1;
                vis1[b]=1;
                q.push(b);
          }
        }
      }
    }
    else if(k==s2){
        queue<int>q;
        q.push(k);
        step2[k]=0;
        vis2[k]=1;
        while(!q.empty()){
          int a=q.front();
          q.pop();
          for(int b:G[a]){
            if(!vis2[b]) {
                step2[b]=step2[a]+1;
                vis2[b]=1;
                q.push(b);
            }
         }
      }
   }
}

int main(){
    memset(vis1,0,sizeof(vis1));
    memset(vis2,0,sizeof(vis2));
    memset(step1,0,sizeof(step1));
    memset(step2,0,sizeof(step2));
    cin>>n>>s1>>s2;
    for(int i=0;i<n-1;i++){
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    bfs(s1);
    bfs(s2);
    int ans=0;
    for(int i=1;i<=n;i++){
        if(step1[i]<step2[i]) ans=max(ans,step2[i]);
    }
    cout<<ans-1;
  return 0;
}


Measured memory_bytes: 7424
while 1:
    try:
        hand=list(map(int,input().split(",")))
        hand.sort()
        if len(list(set(hand)))==2:
            if hand.count(hand[0])==4 or hand.count(hand[4])==4:print("four card")
            else:print("full house")
        elif hand[0]+1==hand[1] and hand[1]+1==hand[2] and hand[2]+1==hand[3] and hand[3]+1==hand[4]:print("straight")
        elif hand[0]==1 and hand[1]==10 and hand[2]==11 and hand[3]==12 and hand[4]==13:print("straight")
        elif len(list(set(hand)))==3:
            if hand.count(hand[0])==3 or hand.count(hand[2])==3 or hand.count(hand[4])==3:print("three card")
            else:print("two pair")
        elif len(list(set(hand)))==4:print("one pair")
        else:print("null")        
    except:break


Measured memory_bytes: 5616
/*************************************************************************
 > File Name: B.cpp
 > Author: codecode
 > Mail: 2466734364@qq.com
 > Created Time: 2020.1.26.20:05
 ************************************************************************/
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
long long h,n,a[maxn],s;
int main(){
	cin>>h>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i],s+=a[i];
	if(s>=h)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 1024