akhauriyash/Code-Regression huggingface dataset:
fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val hh = readLine()!!.split(" ").map { it.toLong() }.sortedDescending()

    if (k >= hh.size) {
        println(0)
        return
    }

    val normal = hh.drop(k)
    println(normal.sum())
}

Measured memory_bytes: 83252
import java.util.*;
 
class Main {
    
	static int res=0,d,w,E[][]=new int[10][10];
	
    public static void main(String[] args) {
         
       Scanner cin=new Scanner(System.in);
       
       while(true) {
    	   int N=cin.nextInt(),M=cin.nextInt();
    	   
    	   if(N==0)break;
    	   
    	   int r=cin.nextInt();
    	   
    	   int data[][]=new int[r][4];
    	   
    	   for(int i=0;i<r;i++) {
    		   data[i][0]=cin.nextInt();data[i][1]=cin.nextInt();data[i][2]=cin.nextInt();data[i][3]=cin.nextInt();  
    	   }
    	   
    	   int q=cin.nextInt();
    	   for(int i=0;i<q;i++) {
    		   int ts=cin.nextInt(),te=cin.nextInt(),tm=cin.nextInt();
    		   int pc=0,res=0;
    		   
    		   //System.out.println("SEARCHING TARGET "+tm);
    		   
    		   List<Integer> tl=new ArrayList<>();
    		   
    		   for(int j=0;j<data.length;j++) {
    			
    			   int t=data[j][0], n=data[j][1], m=data[j][2], s=data[j][3];
    			   
    			   //System.out.printf("%d %d %d %d\n",t,n,m,s);
    			   
    			   if(m==tm && s==1) {
    				   if(pc==0)tl.add(t);
    				   pc++;
    				   //System.out.println("TARGET MEMBER LOGIN AT "+t);
    			   }
    			   else if(m==tm && s==0) {
    				   pc--;
    				   //System.out.println("TARGET MEMBER LOGOUT AT "+t);
    				   if(pc==0) {
    					   tl.add(t);
    				   }
    			   }
    		   }
    		   
    		   for(int j=0;j<tl.size()-1;j+=2) {
    			   
    			   int s=tl.get(j),e=tl.get(j+1);
    			   
    			   if(s<ts)s=ts;
    			   else if(s>te)s=0;
    			   if(e>te)e=te;
    			   else if(e<ts)e=0;
    			   
    			   int d=e-s;
    			   if(d>0 && d<=te-ts)res+=d;
    		   }
    		   
    		   System.out.println(res);
    	   }
       }
    }
}



Measured memory_bytes: 63992
#include<stdio.h>

int main(void){
	int a,b;
	char c;
	while(1){
		scanf("%d %c %d",&a,&c,&b);
		switch(c){
		case '+':
			printf("%d\n",a+b);
			continue;
		case '-':
			printf("%d\n",a-b);
			continue;
		case '*':
			printf("%d\n",a*b);
			continue;
		case '/':
			printf("%d\n",a/b);
			continue;
		case '?':
			break;
		}
		break;
	}
	return 0;
	
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N; cin >> N;

    bool ans = true;
    for(int i=0; i<N; i++){
        int A; cin >> A;

        if(A%2 == 0){
            if(A%3 != 0 && A%5 != 0){
                ans = false;
            }
        }
    }

    if(ans){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
}

Measured memory_bytes: 256
from sys import stdin


def input():
    return stdin.readline()[:-1]


def intput():
    return int(input())


def sinput():
    return input().split()


def intsput():
    return map(int, sinput())


# Code

t1, t2 = intsput()

a1, a2 = intsput()

b1, b2 = intsput()

leap1 = a1 * t1 + a2 * t2
leap2 = b1 * t1 + b2 * t2

if leap1 == leap2:
    print('infinity')
    exit()


if leap2 < leap1:
    a1, a2, b1, b2 = b1, b2, a1, a2
    leap1, leap2 = leap2, leap1

lag = leap2 - leap1

# 1 is always slower
if a1 < b1 and a2 < b2:
    print(0)
    exit()

if a1 > b1:
    gap = (a1 - b1) * t1
    q = gap // lag
    ans = q * 2 + 1
    if lag * q == gap:
        ans -= 1
    print(ans)
    exit()

print(0)


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

using namespace std;

#define MAX 300
#define INF (1<<29)
typedef long long ll;

bool ok(int x){
  return (0 <= x && x < 10000);
}

ll getNum(int *idx,string &str){
  ll res = 0;
  while(isdigit(str[*idx])){
    res *= 10;
    res += str[*idx]-'0';
    (*idx)++;
  }
  return res;
}

ll calc(int idx,string &str){
  ll num,num2;
  if(str[idx] == '-'){
    idx++;
    num = -getNum(&idx,str);
    if(!ok(num)){ return INF; }
  }else if(str[idx] == '+'){
    idx++;
    num = getNum(&idx,str);
    if(!ok(num)){ return INF; }
  }else{
    num = getNum(&idx,str);
    if(!ok(num)){ return INF; }
  }
  while(str[idx] != '='){
    switch(str[idx]){
    case '+':
      idx++;
      num2 = getNum(&idx,str);
      if(!ok(num2)){ return INF; }
      num += num2;
    break;
    case '-':
      idx++;
      num2 = getNum(&idx,str);
      if(!ok(num2)){ return INF; }
      num -= num2;
      break;
    case '*':
      idx++;
      num2 = getNum(&idx,str);
      if(!ok(num2)){ return INF; }
      num *= num2;
      break;
    }
    if(!ok(num)){ return INF; }
  }
  if(!ok(num)){ return INF; }
  return num;
}

int main(){
  string str;
  while(cin >> str){
    string nstr;
    int len = str.size();
    for(int i = 0 ; i < len-1 ; i++){
      nstr += str[i];
      if(!isdigit(str[i]) && !isdigit(str[i+1])){
        nstr += '0';
      }
    }
    nstr += '=';
    int res = calc(0,nstr);
    if(res == INF){
      cout << "E" << endl;
    }else{
      cout << res << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1188
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n, r := nextInt(), nextInt()
	var ans int
	if n >= 10 {
		ans = r
	} else {
		ans = r + 100*(10-n)
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
S=input()
n=len(S)
ans=0
for i in range(1<<(n-1)):
    k=0
    for j in range(n):
        if 1&(i>>j):
            ans+=int(S[k:j+1])
            k=j+1
    ans+=int(S[k:])
        
print(ans)


Measured memory_bytes: 3064
X = int(input())
num = [105, 104, 103, 102, 101, 100]

dp = [0 for _ in range(X+1)]
dp[0] = 1
f = 1

for i in range(X+1):
    for j in num:
        if i-j >= 0:
            if dp[i-j]:
                dp[i] = 1

print(dp[X])

Measured memory_bytes: 3864
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

ans = []
while 1:
	n, m = MAP()
	if n == 0 and m == 0:
		break
	A = LIST()
	B = LIST()
	C = LIST()

	A = A[1:]
	B = B[1:]
	C = C[1:]
	goal = defaultdict(int)
	for i in A:
		goal[n-i] = 0
	for i in B:
		goal[n-i] = 1
	for i in C:
		goal[n-i] = 2
	# print(goal)
	p = 0  # Aにすべての円盤あり
	x = 0
	for i in range(n-1, -1, -1):
		d = abs(p-goal[i])
		x += d*(3**i)
		if d == 1:
			p = 2-p
	tmp = min(x, 3**n-1-x)
	if tmp <= m:
		ans.append(tmp)
	else:
		ans.append(-1)

for i in ans:
	print(i)



Measured memory_bytes: 7092
#include<iostream>
#include<functional>
#include<algorithm>
#include<queue>
#define LL long long
LL N;
LL sumf[100010], sumb[100010];
LL m[100010];
LL ans = -100000000000000000;

int main() {
	std::cin >> N;
	std::priority_queue<LL, std::vector<LL>, std::greater<LL>> F;
	for (int i = 0; i < N; i++) {
		LL tmp;
		std::cin >> tmp;
		F.push(tmp);
		sumf[0] += tmp;
	}
	for (int i = 1; i <= N; i++) {
		std::cin >> m[i];
	}

	std::priority_queue<LL> B;
	for (int i = 0; i < N; i++) {
		LL tmp;
		std::cin >> tmp;
		B.push(tmp);
		sumb[0] += tmp;
	}
	for (int i = 1; i <= N; i++) {
		sumf[i] = sumf[i - 1];
		LL l = F.top();
		if (l < m[i]) {
			sumf[i] += m[i] - l;
			F.pop();
			F.push(m[i]);
		}
	}
	for (int i = 1; i <= N; i++) {
		sumb[i] = sumb[i - 1];
		LL l = B.top();
		if (l > m[N - i + 1]) {
			sumb[i] += m[N - i + 1] - l;
			B.pop();
			B.push(m[N - i + 1]);
		}
	}
	for (int i = 0; i <= N; i++) {
		ans = std::max(sumf[i] - sumb[N - i],ans);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace  std;
const int max_n=2e5+10;
int a[max_n];
int main() 
{
    int n;
    cin>>n;
    for(int i=1;i<=n;++i) 
      cin>>a[i];
    int max_h=a[1];
    long long sum=0;
    for(int i=2;i<=n;++i){
        if(a[i]<max_h) sum+=max_h-a[i];
        else max_h=a[i];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 4372
x,n = list(map(int,input().split()))
if n > 0:
  arr = list(map(int,input().split()))

ans = x
diff = 10**3

for i in range(101,-2,-1):
  if n > 0:
    if not i in arr:
      if abs(x-i) <= diff:
        diff = abs(x-i)
        ans = i
print(ans)

Measured memory_bytes: 9152
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 30;

double dp[110][110];
int event[110];

int main(void){
	int n,t,l,b;
	while(cin >> n,n){
		cin >> t >> l >> b;
		rep(i,110) event[i]=0;
		rep(i,l){
			int in;
			cin >> in;
			event[in]=1;
		}
		rep(i,b){
			int in;
			cin >> in;
			event[in]=2;
		}
		rep(i,110)rep(j,110) dp[i][j]=0.0;
		dp[0][0]=1.0;

		rep(i,t+1)rep(j,n+1)rep(k,6){

			if(j==n){
				dp[i+1][j]+=dp[i][j]/6.0;
				continue;
			}

			int next=j+k+1;
			if(next>n)
				next=n-(next-n);
			
			int turn=1;
			if(event[next]==1)
				turn=2;
			if(event[next]==2)
				next=0;

			dp[i+turn][next]+=dp[i][j]/6.0;
		}
		cout.precision(9);
		cout << fixed << dp[t][n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1332
#include <bits/stdc++.h>
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define ll long long
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int kazu[n][2];
  for (int i=0; i<n; i++){
    kazu[i][1]=0;
    kazu[i][0]=0;
  }
  for (int i=0; i<m; i++){
    int c,s;
    cin>>s>>c;
    kazu[s-1][1] += 1;
    if (kazu[s-1][1]!=1 && kazu[s-1][0]!=c){cout << "-1" <<endl; exit(0);}
    kazu[s-1][0] = c;
  }
  if(kazu[0][0]==0 && kazu[0][1]&&n!=1){cout << "-1" <<endl; exit(0);}
  if(n==1&&kazu[0][0]==0){cout<<'0'<<endl;exit(0);}
  if(kazu[0][0]==0){kazu[0][0]=1;}
  int ans=0;
  for (int i=0; i<n; i++){
    ans += pow(10,n-i-1)*kazu[i][0];
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<vector<pii>> xy(N);
    REP(i, N){
        int Ai;
        cin >> Ai;
        REP(j, Ai){
            int x,y;
            cin >> x >> y;
            x--;
            xy[i].push_back(make_pair(x,y));
        }
    }

    //全探索
    int ans = 0;
    for (int i = 0; i < (1<<N); i++) {
        bool flag = true;
        for(int j = 0; j < N; j++){
            if(i & (1<<j)){
                for(auto && xyi : xy[j]){
                    if(!!(i & (1<<xyi.first)) == xyi.second){

                    }else{
                        flag = false;
                        break;
                    }
                }
                if(flag == false) break;
            }
        }
        if(flag == false) continue;
        //正直者の数をカウント
        int tmp = 0;
        REP(j, N){
            if(i & (1<<j))tmp++;
        }
        ans = max(ans, tmp);
    }
    pr(ans);
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int H,W;
  cin>>H>>W;
  map<char,int> m;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++) {
      char c;
      cin>>c;
      m[c]++;
    }
  }
  bool can = true;
  if(H%2==0&&W%2==0){
    for(auto x:m){
      if(x.second%4!=0)can = false;
    }
  }
  else if(H%2==0&&W%2!=0){
    int cnta=0,cntb=0;
    for(auto x:m){
      if(x.second%2==1)cntb++;
      if(x.second%4==2)cnta++;
    }
    if(cntb!=0||cnta>H/2) can = false;
  }
  else if(H%2!=0&&W%2==0){
    int cnta=0,cntb=0;
    for(auto x:m){
      if(x.second%2==1)cntb++;
      if(x.second%4==2)cnta++;
    }
    if(cntb!=0||cnta>W/2) can = false;
  }
  else {
    int cnta = 0,cntb=0,tb=0;
    for(auto x:m){
      if(x.second%2==1){
        cntb++;
        tb+=x.second;
      }
      if(x.second%4==2){
        cnta++;
      }
    }
    if(cntb!=1) can = false;
    else{
      if(tb%4==2)cnta++;
      if(cnta>H/2+W/2) can = false;
    }
  }
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;


int main() {
	int age;
	cin >> age;
	if(age==1) {
		cout << "Hello World" << endl;
	} else {
		int A, B;
		cin >> A >> B;
		cout << A+B << endl;
	}

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inputs[0], a = inputs[1], b = inputs[2];

            var trainCost = n * a;
            var answer = trainCost < b ? trainCost : b;

            // 解答の出力
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	int N, K, R, S, P; string T;string W=""; cin >> N >> K >> R >> S >> P >> T;
	int D = 0;
	for (int X = 0; X < N; X++) {
		if (X < K) {
			if (T[X] == 'r') {
				D += P;
				W.push_back('p');
			}
			else if (T[X] == 's') {
				D += R;
				W.push_back('r');
			}
			else {
				D += S;
				W.push_back('s');
			}
		}
		else if (T[X] != T[X - K]) {
			if (T[X] == 'r') {
				D += P;
				W.push_back('p');
			}
			else if (T[X] == 's') {
				D += R;
				W.push_back('r');
			}
			else {
				D += S;
				W.push_back('s');
			}
		}
      else{
        T[X]='a';
      }
	}
	cout << D << endl;
}

Measured memory_bytes: 3760
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue<int>
#define PQR priority_queue<int,VE,greater<int>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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;
}

using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}
const long long MOD = 1000000007;
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	VE num(n); rep(i, n)num[i] = 1;
	vector<bool>red(n); red[0] = true;
	rep(i, m) {
		int x, y; cin >> x >> y; x--; y--;
		if (red[x])red[y] = true;
		num[x]--; num[y]++;
		if (num[x] == 0)red[x] = false;
	}
	int ans = 0;
	rep(i, n) {
		if (red[i])ans++;
	}
	cout << ans << endl;
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ll long long unsigned
#define pii pair<int,int>
#define tii tuple <int,int,int>
#define N 1000005
#define mod 2000003
#define X first
#define Y second
#define eps 0.0000000001
#define all(x) x.begin(),x.end()
#define tot(x) x+1,x+n+1
using namespace std;
int sol,sc,i,n;
string s,t;
int main() {
    cin.sync_with_stdio(0);
    cout.sync_with_stdio(0);
    cin>>s;
    n=s.size();
    for(i=n-1; i>=0;) {
        while(i&&s[i]==s[i-1])
            i--;
        sol++;
        i--;
    }
    sol--;
    for(i=0; i<n;) {
        while(i<n-1&&s[i]==s[i+1])
            i++;
        sc++;
        i++;
    }
    sc--;
    cout<<min(sc,sol);
    return 0;
}




Measured memory_bytes: 512
N = gets.to_i
Ss = gets.chomp.chars.map{_1=="R" ? 1 : ((_1=="G") ? 2 : 4)}

counts = {1=>[0], 2=>[0], 4=>[0]}

Ss.reverse.each_with_index do |s,i|
    prev = [i-1,0].max
    [1,2,4].each do |key|
        counts[key][i] = counts[key][prev] + ((s==key) ? 1 : 0)
    end
end

counts.each{_2.reverse!}


ans = 0
(N-2).times do |i|
    ((i+1)..(N-2)).each do |j|
        s = Ss[i] ^ Ss[j]
        next if s==0
        key = ~s & 7
        ans += counts[key][j]
        ans -= 1 if Ss[2*j-i]==key
    end
end
p ans

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

int main(){
    int total=0;
    string companies;
    cin >> companies;
    for(int i=0; i<3; i++){
        if(companies[i]=='A')total++;
    }
    if(total == 3 || total == 0) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;

    for(int i=1;i<=9;i++)
    {
        for(int j=i;j<=9;j++)
        {
            if(i*j==n)
            {
                cout<<"Yes\n";
                return 0;
            }


        }

    }
    cout<<"No\n";


    return 0;







}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int n;
	cin >> n;

	map<int ,int> mp;

	for (int i = 0;i < n*(n-1)/2;i++){
		int a,b,c,d; cin >> a >> b >> c >> d;
		a--; b--;
		if(c > d) mp[a] += 3;
		else if(c < d) mp[b] += 3;
		else if(c == d){
			mp[a]++; mp[b]++;
		}
	}

	vector<P> t1(n);

	for (int i = 0;i < n;i++){
		t1[i] = P(mp[i],i);
	}

	sort(t1.begin(),t1.end());
	reverse(t1.begin(),t1.end());

	vector<int> t2(n);

	for (int i = 0;i < n;i++){
		t2[t1[i].second] = i+1;
		if(i!=0){
			if(t1[i-1].first == t1[i].first) t2[t1[i].second] = t2[t1[i-1].second];
		}
	}

	for (int i = 0;i < n;i++){
		cout << t2[i] << endl;	
	}

	return 0;

}



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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string a, b, c;

int main() {
	cin >> a >> b >> c;
	char d = 'A' - 'a';
	printf("%c%c%c", a[0]+d, b[0]+d, c[0]+d);
}

Measured memory_bytes: 256
import Data.Array

main::IO()
main=do
  solver_loop
  return ()

solver_loop::IO()
solver_loop= do
  input<-getLine
  if input == [] then return () else do
    let val = read input ::Int
    let ans = solver val
    if val == 0
      then do
        return ()
      else do
        print ans
        solver_loop

solver:: Int -> Int
solver n = let dparr = array (0,(max n 3)) ((0,1):(1,1):(2,2):[(k,(dparr!(k-1))+(dparr!(k-2))+(dparr!(k-3)))|k<-[3..(max n 3)]]) in
              (div (dparr!n) 3650) + 1

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

#define YES(condition) if(condition) cout << "YES" << endl; else cout << "NO" << endl
#define Yes(condition) if(condition) cout << "Yes" << endl; else cout << "No" << endl
#define POSS(condition) if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl
#define Poss(condition) if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl
#define First(condition) if(condition)cout << "First" << endl; else cout << "Second" << endl
#define negative(condition, num) if(condition)cout << -1 << endl; else cout << num << endl
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define bitcount(n) __builtin_popcount(n)

struct range{
    int size;
    long number;
};

int main(){
    int N;
    cin >> N;
    long ans;
    cin >> ans;
    long sum = ans;
    vector<range> minimum_ranges{{1, ans}};
    for(int i = 1; i < N; i++){
        long num;
        cin >> num;
        sum += num;
        if(minimum_ranges.back().number <= num){
            ans += sum;
            minimum_ranges.push_back({1, num});
            continue;
        }
        int left = -1, right = int(minimum_ranges.size()) - 1; // (left, right]
        while(left + 1 < right){
            int middle = (left + right) / 2;
            if(minimum_ranges[middle].number > num){
                right = middle;
            }else{
                left = middle;
            }
        }
        int size_sum = 0;
        int minimum_ranges_size = int(minimum_ranges.size());
        for(int j = 0; j < minimum_ranges_size - right; j++){
            sum -= minimum_ranges.back().size * (minimum_ranges.back().number - num);
            size_sum += minimum_ranges.back().size;
            minimum_ranges.pop_back();
        }
        ans += sum;
        minimum_ranges.push_back({size_sum + 1, num});
    }
    cout << ans << endl;
}



Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  for(int i = 0; i <= 10; i++){
    int C = (i*1000) - N;
    if(C < 0) {
      continue;
    }
    else if(C == 0) {
      cout << 0 << endl;
      break;
    }
    else {
      cout << C << endl;
      break;
    }
  }
}

Measured memory_bytes: 3524
#include <iostream>
#include <cstdio>
#define MN 200000
#define mod 1000000007

int fac[MN + 5], Inv[MN + 5], inv[MN + 5];
int n, m, k;

int C(int a, int b) {if(a < b) return 0; return 1ll * fac[a] * inv[b] % mod * inv[a - b] % mod;}

int solve(int n, int m)
{
	int ans = 0;
	int w = 0;
	for(int b = 1; b <= std::min(n, k); b++) w = (w + 1ll * b * (k - b) % mod * C(n * (m - 1), k - b) % mod * C(n, b)) % mod;
	for(int a = 1; a <= m; a++)
	{
		int P = 1ll * Inv[m - 1] * (a - 1 - (m - a) + mod) % mod;
		ans = (ans + 1ll * w * P % mod * a) % mod;
	}
	return ans;
}

int main()
{
	scanf("%d%d%d", &n, &m, &k);
	
	fac[0] = Inv[0] = Inv[1] = inv[0] = 1;
	for(int i = 1; i <= MN; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	for(int i = 2; i <= MN; i++) Inv[i] = 1ll * (mod - mod / i) * Inv[mod % i] % mod;
	for(int i = 1; i <= MN; i++) inv[i] = 1ll * Inv[i] * inv[i - 1] % mod;
	
	printf("%d\n", (solve(n, m) + solve(m, n)) % mod);
	
}

Measured memory_bytes: 2560
import kotlin.math.abs

fun main(args: Array<String>) {
    val (x, k, d) = readLongList()

    val t = abs(x) / d

    if (t >= k) {
        val ans = abs(x) - k * d
        println(ans)
        return
    }

    val tt = k - t
    if (tt % 2L == 0L) {
        val ans = abs(x) - t * d
        println(ans)
        return
    }

    val ans = abs(abs(x) - (t + 1) * d)
    println(ans)
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 36424
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[5000001], invf[5000001];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
ll solve(int r, int c){
    ll ans=0;
    for(int i=0; i<=r; i++){
        (ans+=comb(i+c+1, i+1))%=MOD;
    }
    return ans;
}
int main()
{
    int r1, c1, r2, c2;
    cin>>r1>>c1>>r2>>c2;
    fac(2000002);
    cout<<(solve(r2, c2)-solve(r2, c1-1)-solve(r1-1, c2)+solve(r1-1, c1-1)+2*MOD)%MOD<<endl;
    return 0;
}


Measured memory_bytes: 33024
from itertools import chain

from math import sqrt
from collections import Counter

def prime_factorization(n):
    counter = Counter()
    for i in range(2, int(sqrt(n)) + 1):
        while n % i == 0:
            n //= i
            counter[i] += 1
    
    if n != 1:
        counter[n] += 1

    return counter.items()

def get_prime_facts(n):
    return set(map(lambda x: x[0], prime_factorization(n)))

def solution(A, B):
    s = get_prime_facts(A) & get_prime_facts(B) | {1}
    return len(s)

if __name__ == '__main__': 
    A, B = map(int, input().split())
    a = solution(A, B)

    print(a)



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

public class Main {

	static int mod = 998244353;
	
	Map<String, Integer> memo = new HashMap<>();
	Map<String, Integer> compMemo = new HashMap<>();
	static int[] pow2 = new int[200];
	static {
		pow2[0] = 1;
		for (int i = 1; i < 200; i++) {
			pow2[i] = pow2[i - 1] * 2 % mod;
		}
	}
	
	int go(String s) {
		if (memo.containsKey(s)) {
			return memo.get(s);
		}
		if (s.length() == 0) {
			return 1;
		}
		int result = 0;
		for (int len = 2; len <= s.length(); len++) {
			result += (1L * compress(s.substring(0, len)) * go(s.substring(len)) % mod);
			if (result >= mod){ 
				result -= mod;
			}
		}
		result += go(s.substring(1)) * (s.charAt(0) - '0' + 1) % mod;
		if (result >= mod){
			result -= mod;
		}
		memo.put(s, result);
		return result;
	}
	
	int compress(String s) {
		int result = 0;
		if (compMemo.containsKey(s)) {
			return compMemo.get(s);
		}
		for (int k = 2; k <= s.length(); k++) {
			if (s.length() % k == 0) {
				char[] a = new char[s.length() / k];
				Arrays.fill(a, '1');
				for (int j = 0; j < s.length(); j++) {
					if (s.charAt(j) == '0') {
						a[j % a.length] = '0';
					}
				}
				result += go(new String(a));
				if (result >= mod) {
					result -= mod;
				}
			}
		}
		compMemo.put(s, result);
		return result;
	}
	
	void solve() {
		out.println(go(in.nextToken()));
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

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


Measured memory_bytes: 97752
package main

import "fmt"

var pfm = make(map[int]int)

func prmFac(x int) map[int]int {
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			x /= i
			pfm[i]++
		}
	}
	if x > 1 {
		pfm[x]++
	}
	return pfm
}

func p(val int) int {
	pc := 0
	for _, v := range pfm {
		if v >= val-1 {
			pc++
		}
	}
	return pc
}

func main() {
	var n int
	fmt.Scan(&n)

	for i := 1; i <= n; i++ {
		prmFac(i)
	}
	fmt.Println(p(75) + p(25)*(p(3)-1) + p(15)*(p(5)-1) + p(5)*(p(5)-1)*(p(3)-2)/2)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>       // ヘッダファイルインクルード
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
int N;
int a[110];
cin>>N;
  for (int i=0;i<N;i++){
    cin>>a[i];}
  sort(a,a+N,greater<int>());
  int Alice =0;
  int Bob = 0;
  for (int i=0;i<N;i++){
  if (i%2==0) {Alice+=a[i];}
  else {Bob+=a[i];}
  }
cout<<Alice-Bob<<endl;

}


Measured memory_bytes: 256
n=int(input())
d=list(map(int,input().split()))
a=int(0)
i=int(0)
while i<n:
	a=a+d[i]
	i=i+1
a=a*a
i=int(0)
while i<n:
	a=a-d[i]*d[i]
	i = i+1
a=a/2
a=int(a)
print(a)

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

namespace tes
{
	class contest
	{
		static void Main(string[] args)
		{
			int input = int.Parse(Console.ReadLine());
            int ans = 0;
			
			for(int i =1; i<=input; i++)
			{
				ans += i;
			}


            Console.WriteLine(ans);


            
		}

	}
}

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

int main(){
	int a,b,n,m;
	
	while(cin>>a>>b){
	n = a+b;
	m = 0;
		while(n!=0){
			m++;
			n /= 10;
			
		}
			
	cout<<m<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
class Solution:
    def solve(self, H, n, moves):
        moves.sort(reverse=True)

        health = H

        for move in moves:
            health -= move

            if health <= 0:
                return True

        return False


sol = Solution()

[H, n] = list(map(int, input().strip().split()))
moves = list(map(int, input().strip().split()))

print("Yes" if sol.solve(H, n, moves) else "No")


Measured memory_bytes: 14132
N=int(input())
S=input()
s=list()
for i in S:
  temp=ord(i)+N
  if temp<=ord("Z"):
    s.append(chr(temp))
  else:
    s.append(chr(temp-(ord("Z")-ord("A"))-1))
for i in s:
  print(i,end="")


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

N, A, B = (map(int, input().split(' ')))
S = input()
Nc = 0
Ac = 0
Bc = 0

for s in S:
    if s is 'a':
        Ac += 1
        if Ac+Bc <= A+B:
            print('Yes')
        else:
            print('No')
            Ac -= 1

    elif s is 'b':
        Bc += 1
        if Ac+Bc <= A+B and Bc <= B:
            print('Yes')
        else:
            print('No')
            Bc -= 1
    else:
        print('No')



Measured memory_bytes: 4016
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>


template<class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

int main(void) {
	int N;
	std::cin >> N;
	//std::cout << N / 2 << std::endl;
	int odd, even;
	if (N % 2 == 0) {
		odd = even = N / 2;
	}
	else {
		odd = N / 2 + 1;
	}
	float res;
	res = static_cast<float>(odd) / static_cast<float>(N);
	std::cout << res;
	return 0;
}


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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int n,m,i,j,x,y,sum=0;
    cin>>n>>m;
    long long int A[n];
    bool result[n]={false};
    for(i=0;i<n;i++){
        cin>>A[i];
    }
    for(i=0;i<m;i++){
        cin>>x>>y;
        if(A[x-1]<A[y-1])
            result[x-1]=true;
        else if(A[x-1]==A[y-1]){
            result[x-1]=true;
            result[y-1]=true;
        }
        else
            result[y-1]=true;
    }
    for(i=0;i<n;i++){
        if(result[i]==false)
            sum+=1;
    }
    cout<<sum;
    return 0;
}


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

ans = 0
for i in range(N):
    ans += min(A[i], B[i])
    B[i] = max(B[i] - A[i], 0)

    ans += min(A[i+1], B[i])
    A[i+1] = max(A[i+1] - B[i], 0)

print(ans)
#

Measured memory_bytes: 24200
#include<iostream>
#include<cstdlib>

using namespace std;

typedef struct{
	int xl;
	int xr;
	int yl;
	int yr;
	int zl;
	int zr;
} fish_t;

int comp(const void *c1, const void *c2);

int main(){
	int N;
	int K;

	//魚の種類数と数える種類数を入力
	cin >> N >> K;

	int *X = new int[2*N];
	int *Y = new int[2*N];
	int *Z = new int[2*N];

	//座標を入力
	for(int i=0; i<N; i++){ cin >> X[2*i] >> Y[2*i] >> Z[2*i] >> X[2*i+1] >> Y[2*i+1] >> Z[2*i+1]; }


	fish_t *fish = new fish_t[N];
	
	//各魚の生息領域を代入
	for(int i=0; i<N; i++){
		int L = 2*i;
		int R = 2*i+1;

		fish[i].xl = X[L];
		fish[i].xr = X[R];
		fish[i].yl = Y[L];
		fish[i].yr = Y[R];
		fish[i].zl = Z[L];
		fish[i].zr = Z[R];
	}

	//座標を小さい順に並べ替える
	qsort(X, 2*N, sizeof(int), comp);
	qsort(Y, 2*N, sizeof(int), comp);
	qsort(Z, 2*N, sizeof(int), comp);

	int dim = 2*N - 1;

	//各ブロックの魚の種類を数え、K種類以上の体積を求める
	unsigned long long V = 0;

	for(int z=0; z<dim; z++){
		for(int y=0; y<dim; y++){
			for(int x=0; x<dim; x++){
				int k = 0;

				for(int i=0; i<N; i++){
					if( (fish[i].xl > X[x]) || (fish[i].xr < X[x+1]) || (fish[i].yl > Y[y]) || (fish[i].yr < Y[y+1]) || (fish[i].zl > Z[z]) || (fish[i].zr < Z[z+1]) ){ continue; }
					else{ k++; }
				}
				
				if(k < K){ continue; }
				else{
					V += (unsigned long long) (X[x+1] - X[x]) * (Y[y+1] - Y[y]) * (Z[z+1] - Z[z]);
				}
			}
		}
	}

	cout << V << endl;
	
	delete[] X;
	delete[] Y;
	delete[] Z;
	delete[] fish;

	return 0;
}

int comp(const void *c1, const void *c2){
	int tmp1 = *(int*)c1;
	int tmp2 = *(int*)c2;

	return tmp1 - tmp2;
}

Measured memory_bytes: 1200
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
const int N=205,M=1e5+5;
const int mod=1e9+7;
int dp[N][M],a[N],n,X;
int dfs(int u,int x) {
    if(!u) return x%a[u];
    if(dp[u][x]!=-1) return dp[u][x];
    return dp[u][x]=(dfs(u-1,x%a[u])+1LL*u*dfs(u-1,x))%mod;
}
int main() {
    scanf("%d%d",&n,&X);
    for(int i=0;i<n;i++) scanf("%d",a+i);
    std::sort(a,a+n);
    memset(dp,-1,sizeof(dp));
    printf("%d\n",dfs(n-1,X));
    return 0;
}


Measured memory_bytes: 80384
/* ex 9_1
   Sagzar1993 */

#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 1000

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk){
    char latest;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

int main(void){
    stack stk;
    int i;
    char inputKey;
    //スタックを初期化（ポインタ渡しで関数にわたすこと）
    initialize_stack(&stk);

    //\0まで調べる
    while(1){
        scanf("%c", &inputKey);
        if(inputKey == '\n'){
            //文字列の最後に来たら終了
            break;
        }else if(inputKey != 'B'){
            //0か1ならスタックに文字を追加
            push(&stk, inputKey);
        }else if(stk.count > 0){
            //Bのとき、スタックが空でなければ最後に追加した文字を取り出し
            pop(&stk);
        }
    }
    //スタックの古い方から出力
    for(i = 0; i < stk.count; i++){
        printf("%c", stk.data[SIZE - 1 - i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1528
#include "bits/stdc++.h"
using namespace std;

int main(int argc, char **argv) {
  int i;
  long N;
  cin >> N;
  vector<long> A(N);
  long long sumA = 0;

  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sumA += A[i];
  }
  sumA = sumA;

  long ans = sumA;
  for (int i = 0; i < N / 2; i++) {
    ans -= 2 * A[i * 2 + 1];
  }

  for (int i = 0; i < N; i++) {
    cout << ans << " ";
    ans = 2 * A[i] - ans;
  }
  cout << endl;

  return 0;
}


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

#define llint long long int

using namespace std;

int main(){
    int N;

    cin >> N;

    vector<llint> A(N);

    for(int i = 0; i < N; i ++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i ++){
        if(A[i] == 0){
            cout << 0 << endl;

            return 0;
        }
    }
    llint ans = A[0];

    for(int i = 1; i < N; i ++){
        if((double) ans * A[i] <= 1e+19){
            ans *= A[i];

            if(ans > 1000000000000000000L){
                cout << -1 << endl;

                return 0;
            }
        }else{
            cout << -1 << endl;

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

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

using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[5]==s[4])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}
 

Measured memory_bytes: 256
import numpy as np
N, M, C = map(int, input().split())
b = np.array(list(map(int, input().split())))

ans = 0
for n in range(N):
  a = np.array(list(map(int, input().split())))
  if sum(a * b) + C > 0:
    ans += 1
print(ans)

Measured memory_bytes: 12504
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<list>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll p=924844033;
const ll g=5;
ll fp(ll a,ll b)
{
	ll s=1;
	while(b)
	{
		if(b&1)
			s=s*a%p;
		a=a*a%p;
		b>>=1;
	}
	return s;
}
namespace ntt
{
	ll w1[1000010];
	ll w2[1000010];
	int rev[1000010];
	int n;
	void init()
	{
#ifdef DEBUG
		n=16;
#else
		n=524288;
#endif
		int i;
		for(i=1;i<=n;i<<=1)
		{
			w1[i]=fp(g,(p-1)/i);
			w2[i]=fp(w1[i],p-2);
		}
		rev[0]=0;
		for(i=1;i<n;i++)
			rev[i]=(rev[i>>1]>>1)|(i&1?n>>1:0);
	}
	void ntt(ll *a,int t)
	{
		int i,j,k;
		ll u,v,w,wn;
		for(i=0;i<n;i++)
			if(rev[i]<i)
				swap(a[i],a[rev[i]]);
		for(i=2;i<=n;i<<=1)
		{
			wn=(t==1?w1[i]:w2[i]);
			for(j=0;j<n;j+=i)
			{
				w=1;
				for(k=j;k<j+i/2;k++)
				{
					u=a[k];
					v=a[k+i/2]*w%p;
					a[k]=(u+v)%p;
					a[k+i/2]=(u-v)%p;
					w=w*wn%p;
				}
			}
		}
		if(t==-1)
		{
			ll inv=fp(n,p-2);
			for(i=0;i<n;i++)
				a[i]=a[i]*inv%p;
		}
	}
};
ll b[1000010];
ll c[1000010];
ll a[1000010];
ll inv[1000010];
ll fac[1000010];
ll ifac[1000010];
int s[1000010];
int n;
list<int> l[200010];
ll num[1000010];
void dfs(int x,int fa)
{
	s[x]=1;
	for(auto v:l[x])
		if(v!=fa)
		{
			dfs(v,x);
			s[x]+=s[v];
			num[s[v]]--;
			num[n-s[v]]--;
		}
}
int main()
{
	scanf("%d",&n);
	int i,x,y;
	for(i=1;i<=n-1;i++)
	{
		scanf("%d%d",&x,&y);
		l[x].push_back(y);
		l[y].push_back(x);
	}
	inv[0]=inv[1]=fac[0]=fac[1]=ifac[0]=ifac[1]=1;
	for(i=2;i<=n;i++)
	{
		inv[i]=-(p/i)*inv[p%i]%p;
		fac[i]=fac[i-1]*i%p;
		ifac[i]=ifac[i-1]*inv[i]%p;
	}
	dfs(1,0);
	num[n]=n;
	for(i=0;i<=n;i++)
		b[i]=num[n-i]*fac[n-i]%p;
	for(i=0;i<=n;i++)
		c[i]=ifac[i];
//	for (int i = 0; i <= n; i++)
//		printf("%lld ", c[i]);
//	puts("");
//	for (int i = 0; i <= n; i++)
//		printf("%lld ", b[i]);
//	puts("");
	ntt::init();
	ntt::ntt(b,1);
	ntt::ntt(c,1);
	for(i=0;i<ntt::n;i++)
		a[i]=b[i]*c[i]%p;
	ntt::ntt(a,-1);
	for(i=1;i<=n;i++)
	{
		ll ans=a[n-i]*ifac[i]%p;
		ans=(ans+p)%p;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 78080
#include<iostream>
using namespace std;
int main(){
	int N,K,Q,An,A[100000]={0};
	cin>>N>>K>>Q;
	for(int i=0;i<Q;i++){
		cin>>An;
		A[An-1]++;
	}
	for(int i=0;i<N;i++){
		if(A[i]-Q+K<=0)cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const int mod = 998244353, N = 210000;

int n;
char s[N];

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for (R int i = 1; i <= n; ++i) {
		if (s[i] == '?') s[i] = 'D';
	}
	cout << s + 1 << endl;
	return 0;
}

Measured memory_bytes: 3964
n = int(input())
A = list(map(int, input().split()))

count_4 = len([a for a in A if a % 4 == 0])
count_2 = len([a for a in A if a % 2 == 0]) - count_4
others = n - (count_4 + count_2)

ans = ""
if count_2 == 0:
    ans = "Yes" if others <= count_4 + 1 else "No"
else:
    ans = "Yes" if others <= count_4 else "No"
print(ans)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
#define MAX 100000

int parent(int);
int left(int);
int right(int);

//int B;

int main(){
  int i,B;
  int A[MAX+1];
  cin >> B;
  for(i = 1; i <= B; i++){
    cin >> A[i];
  }
  for(i = 1; i <= B; i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(1 <= parent(i)){
      printf("parent key = %d, ",A[parent(i)]);
    }
    if(left(i) <= B){
      printf("left key = %d, ",A[left(i)]);
    }
    if(right(i) <= B){
      printf("right key = %d, ",A[right(i)]);
    }
    printf("\n");
  }
  return 0;
}

int parent(int i){
  return (i/2);
}
int left(int i){
  return 2*i;
}
int right(int i){
  return (2*i)+1;
}

Measured memory_bytes: 3088