akhauriyash/Code-Regression huggingface dataset:
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C++ (GCC 9.2.1)
*/

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

// utility of stdin,stdout
#define _CRT_SECURE_NO_WARNINGS
#define OUT cout << 
#define BR << endl
#define RET return 0
#define TLong long long
#define TBMod int(1e9+7)

int main(int argc, char const *argv[])
{
	// DON'T CHANGE
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	// here
	TLong n;
	vector<TLong> a;
	TLong in;
	TLong ans = 0;

	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> in;
		a.push_back(in);
	}
	for (int i = 1; i < n; i++)
	{
		if(a[i - 1] > a[i]){
			ans += (a[i - 1] - a[i]);
			a[i] += (a[i - 1] - a[i]);
		}
	}
	OUT(ans) BR;
	RET;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)

int main() {
    int a,b,c; cin >> a >> b >> c;

    cout << c - min(a-b, c) << endl;

    return 0;

    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;

int main() {
  vector<pair<int, int>> ab(3);
  vector<int> key(4, 0);
  for (int i = 0; i < 4; i++) {
    cin >> ab[i].first >> ab[i].second;
    key[ab[i].first]++;
    key[ab[i].second]++;
  }
  bool ans = true;
  for (int i = 1; i <= 4; i++) {
    if (key[i] > 2) ans = false;
    if (key[i] == 0) ans = false;
  }
  if (ans)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
    
     int a = sc.nextInt();
     int b = sc.nextInt();
     int c = sc.nextInt();
     
     System.out.println(Math.min(Math.min(a+b,b+c),c+a));
     
  }
}


Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.Linq;

namespace Volume0_0028
{
    class Program
    {
        static Dictionary<int, int> dic = new Dictionary<int, int>();
        static void Main(string[] args)
        {
            string input;
            while ((input = Console.ReadLine()) != null)
            {
                int num = Convert.ToInt32(input);
                if (dic.ContainsKey(num)) dic[num]++;
                else dic.Add(num, 1);
            }
            int max = dic.Values.Max();

            foreach (var keyPair in dic.Where(kp => kp.Value == max).OrderBy(kp => kp.Key))
            {
                Console.WriteLine(keyPair.Key);
            }
        }
    }
}

Measured memory_bytes: 10264
def isprime(a,kore):
    for i in range(0,len(kore)):
        if a>kore[i] and a%kore[i]==0:
            return 0
    return 1
#main
n=int(input())
cnt=0
primes=[0,]*10001
primes[2]=1
kore=[]
for i in range(2,10001):
    for j in range(i,10001,i):
        if j==i and primes[j]!=-1:
            primes[j]=1
            kore.append(j)
        else:
            primes[j]=-1
for i in range(0,n):
    a=int(input())
    cnt+=isprime(a,kore)
print(str(cnt))


Measured memory_bytes: 5720
S = input()

if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
elif S == "SAT":
    print(1)




Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

/*
   cin.tie(0);
   ios::sync_with_stdio(false);
   */

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  ll n,c;
  cin>>n>>c;
  vll x(n),v(n);
  rep(i,n){
    cin>>x[i]>>v[i];
  }
  vll r(n),l(n);
  rep(i,n){
    if(i==0){
      r[i]=v[i];
      l[n-i-1]=v[n-1];
    }else{
      r[i]=r[i-1]+v[i];
      l[n-i-1]=l[n-i]+v[n-i-1];
    }
  }

  vll R(n),L(n);
  ll ans=-LINF;
  rep(i,n){
    ans=max(ans,max(r[i]-x[i],l[n-i-1]-(c-x[n-i-1])));
    R[i]=r[i]-x[i];
    r[i]-=(x[i]*2);
    L[n-i-1]=l[n-i-1]-(c-x[n-i-1]);
    l[n-i-1]-=(c-x[n-i-1])*2;
  }
  REP(i,1,n){
    r[i]=max(r[i],r[i-1]);
    R[i]=max(R[i],R[i-1]);
    l[n-i-1]=max(l[n-i-1],l[n-i]);
    L[n-i-1]=max(L[n-i-1],L[n-i]);
  }
  
  ans=max(ans,l[0]);
  REP(i,0,n-1){
    ans=max(ans,r[i]+L[i+1]);
  }
  REP(i,1,n){
    ans=max(ans,l[i]+R[i-1]);
  }
  cout<<max(ans,(ll)0)<<endl;
  return 0;
}

Measured memory_bytes: 4992
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Nodes nodes = new Nodes(n);
		int[][] uvw = new int[n - 1][3];
		for(int i = 0; i < uvw.length; i++){
			for(int i2 = 0; i2 < 3; i2++){
				uvw[i][i2] = sc.nextInt();
			}
			nodes.buildBrunch(uvw[i][0], uvw[i][1], uvw[i][2]);
		}
		nodes.prepare();
		nodes.printAns();
	}
}
class Nodes{
	int num;
	Node[] nodes;
	int[] parents;
	int[] linkedNumber;
	int root;
	Boolean[] distArray;
	Nodes(int n){
		num = n;
		parents = new int[n];
		distArray = new Boolean[n];
		nodes = new Node[n];
		linkedNumber = new int[n];
		for(int i = 0; i < n; i++){
			nodes[i] = new Node(i);
		}
	}
	void buildBrunch(int u, int v, int w){
		nodes[u -1].buildBrunch(nodes[v - 1], w);
		nodes[v -1].buildBrunch(nodes[u - 1], w);
		linkedNumber[u - 1]++;
		linkedNumber[v - 1]++;
	}
	void prepare(){
		Queue<Integer> leafNode = new ArrayDeque<>();
		for(int i = 0; i < num; i++){
			int linked = linkedNumber[i];
			if(linked == 1){
				leafNode.add(i);
			}
		}
		while(true){
			Integer leaf = leafNode.poll();
			if(leaf == null){
				break;
			}
			for(int parent : nodes[leaf].brunches.keySet()) {
				parents[leaf] = parent;
				nodes[parent].brunches.remove(leaf);
				if (nodes[parent].brunches.keySet().size() == 1){
					leafNode.add(parent);
				}
				root = parent;
			}
		}
		
	}
	boolean getDist(int n){
		boolean distance;
		if(n == root){
			return false;
		}else{
			if(distArray[n] == null){
				for(int key : nodes[n].brunches.keySet()){
					distance = nodes[n].brunches.get(key) ^ getDist(key);
					distArray[n] = distance;
					return distance;
				}
			}else{
				return distArray[n];
			}
		}
		return false;
	}
	void printAns(){
		for(int i = 0; i < num; i++){
			char c = getDist(i) ? '1' : '0';
			System.out.println(c);
		}
	}
}
class Node{
	int num;
	Map <Integer, Boolean>brunches = new HashMap<>();
	Node(int n){
		num = n;
	}
	void buildBrunch(Node node, int w){
		brunches.put(node.num, (w % 2 == 1) ? true : false);
	}
}

Measured memory_bytes: 128408
#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<unordered_set>
#include<map>
#include<queue>
#include<iomanip>
#include<tgmath.h>
#include<stdlib.h>
#include<assert.h>






/*
_
_._ _..._ . - ',     _.._(`))
'-. `     ' / -._. - '    ', /
)         \            '.
/ _    _ | \
| a    a    /              |
\   . - .;
'-('' ).-', '       ;
'-;           |      .'
\           \    /
| 7.__  _. - \   \
| |  |  ``/ / `  /
/, _|  |   /, _/   /
/, _ / '`-'
*/
using namespace std;
//check if s is substring if t

int bin_search(int ele, vector<int> arr)
{
    int left = 0,mid,right=arr.size()-1;
    while (left <= right) {
        mid = left + (right - left) / 2;
        if (arr[mid] == ele) {
            return mid;
        }
        else if (arr[mid] > ele) {
            right = mid - 1;
        }
        else {
            left = mid + 1;
        }
    }
    return - 1;
}

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
    

}


Measured memory_bytes: 256
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int n,m;
	cin>>n>>m;
	int a[n+1]={0};
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		a[x]++;
		a[y]++;
	}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<endl;
	}
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


/*
vvl comb(int n, int r) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}
*/

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

	

int main(){
	ll a,b;
	cin>>a>>b;
	ll gcd=__gcd(a,b);
	int cnt=0;
	ll G=gcd;
	for(ll i=2; i*i<=G;i++){
		if(gcd%i==0)cnt++;
		while(gcd%i==0){
			gcd/=i;
		}
	}
	if(gcd!=1) cnt++;
	cout<<cnt+1<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	private int getResult(int i, int j,int n){
		int result = i - j;
		if(result < 0)
			result += n;
		if(result > (n-1) / 2)
			result = n - result;
		return result;
	}

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		TreeSet<Integer> ts = new TreeSet<Integer>();
		int len;
		while(true){
			int n = sc.nextInt();
			if(n==0)
				break;
			ts.clear();
			for(int i=1; i < n; i++){
				ts.add((i*i)%n);
			}
			ArrayList<Integer> al = new ArrayList<Integer>();
			al.addAll(ts);
			int [] list = new int[(n-1)/2 + 1];
			len = al.size();
			for(int i=0; i < len;i++){
				for(int j=i+1; j < len;j++){
					int num1 = al.get(i);
					int num2 = al.get(j);
					list[getResult(num1, num2, n)]++;
					list[getResult(num2, num1, n)]++;
				}
			}

			//print
			len = list.length;
			for(int i=1; i < len; i++)
				System.out.println(list[i]);
		}

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

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

const int MAX_N=2*1e5+4;
const int INF=1e9+7;

int x[MAX_N],s[MAX_N];
int abs(int x){
  if(x>0)return x;
  else return -1*x;
}
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i];
    s[i]=x[i];
  }
  sort(s,s+n);
  int ai=s[n-1],aj;
  int mi=INF;
  for(int i=0;i<n-1;i++){
    if(mi>abs(2*s[i]-ai)){
      mi=abs(2*s[i]-ai);
      aj=s[i];
    }
  }
  cout<<ai<<" "<<aj<<endl;
}


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

int main()
{
    long long a, b;
    cin >> a >> b;
    string ans;

    if (0 < a )
    {

        ans = "Positive";
    }
    else if (a <= b && b < 0)
    {
        if ((b - a + 1) % 2 == 0)
        {
            ans = "Positive";
        }
        else
        {
            ans = "Negative";
        }
    }
    else if (a <= 0 && 0 <= b){

        ans = "Zero";
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
var
	i,j,k,b,t:Longint;
	n:int64;
	dp:array[0..60,0..2]of int64;
begin
	read(n);
	dp[60][0]:=1;
	for i:=59 downto 0 do begin
		b:=(n>>i)and 1;
		for j:=0 to 2 do for k:=0 to 2 do begin
			t:=j*2+b-k;
			if t>=0 then begin
				if t>2 then t:=2;
				dp[i][t]:=(dp[i][t]+dp[i+1][j])mod 1000000007;
			end;
		end;
	end;
	writeln((dp[0][0]+dp[0][1]+dp[0][2])mod 1000000007);
end.


Measured memory_bytes: 128
from collections import defaultdict
n = int(input())
dic = defaultdict(int)
for i in range(n):
    dic[input()] += 1
tmp = [(key, value) for key, value in dic.items()]
tmp.sort(key=lambda x: (x[1], x[0]))
m = tmp[-1][1]
for i in range(len(dic)):
    if tmp[i][1] == m:
        print (tmp[i][0])

Measured memory_bytes: 62296
from collections import Counter
import sys
INF = 10 ** 18
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def MI(): return map(int, sys.stdin.readline().split())


N, K = MI()
# 美味しさ降順寿司
sushi = sorted([LI() for _ in range(N)], key=lambda x:x[1], reverse=True)
# 美味しい寿司を貪欲に取る
delicious_sushi = sushi[:K]
# 余った寿司
soudemonai_sushi = sushi[K:]

syurui_counter = Counter()
deliciousness = 0

f = [-INF for _ in range(K+1)]

for x in delicious_sushi:
    syurui_counter[x[0]] += 1
    deliciousness += x[1]

f[len(syurui_counter)] = deliciousness

# print(delicious_sushi)
# print(soudemonai_sushi)
# print(syurui_counter)
# print("==========")

delicious_sushi = delicious_sushi[::-1]

i = 0
j = 0
while len(syurui_counter) < K and 0 < len(soudemonai_sushi):
    # print("len(syurui_counter) = " + str(len(syurui_counter)))
    while i < K:
        # print("i = " + str(i))
        if syurui_counter[delicious_sushi[i][0]] >= 2:
            # print(delicious_sushi[i])
            break
        i += 1
    while j < N - K:
        # print("j = " + str(j))
        if syurui_counter[soudemonai_sushi[j][0]] == 0:
            # print(soudemonai_sushi[j])
            break
        j += 1
    if j == N - K:
        break
    deliciousness -= delicious_sushi[i][1]
    deliciousness += soudemonai_sushi[j][1]
    syurui_counter[delicious_sushi[i][0]] -= 1
    syurui_counter[soudemonai_sushi[j][0]] += 1
    # print(syurui_counter)
    f[len(syurui_counter)] = deliciousness
    i += 1
    j += 1
    # print("==========")

# print(f)
for i in range(len(f)):
    f[i] += (i * i)
# print(f)
print(max(f))


Measured memory_bytes: 72924
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	int k;
	vector<int> heights;
	cin >> n >> k;
	vector<int> dp(n + 1, INT_MAX);

	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		heights.push_back(x);
	}

	dp[0] = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j <= i + k; j++) {
			if(j < n)
			dp[j] = min(dp[j], dp[i] + abs(heights[i] - heights[j]));
		}
	}

	cout << dp[n - 1];
	return 0;
}


Measured memory_bytes: 1276
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    for (auto c : s)
        if (c == 'o')
            cnt++;

    cout << 700 + 100 * cnt << endl;
    return 0;
}

Measured memory_bytes: 256
M, D = map(int, input().split())

cnt = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        if d<10: continue
        d1 = d%10
        d2 = int(d/10)
        if d1>=2 and d2>=2 and m==d1*d2: cnt+=1
print(cnt)

Measured memory_bytes: 3060
n, a, b = gets.split.map(&:to_i)

def solve(n, a, b)
  return 0 if a > b
  if n == 1
    return 0 if a != b
    return 1
  end
  return (b - a) * (n - 2) + 1
end

puts solve(n, a, b)
  


Measured memory_bytes: 3836
n = int(input())
al = []
bl = []
for _ in range(n):
    a,b= map(int, input().split())
    al.append(a)
    bl.append(b)

al.sort()
bl.sort()

if n%2 == 1:
    minv = al[n//2]
    maxv = bl[n//2]
    print(maxv-minv+1)

else:
    minv2 = al[n//2] + al[n//2-1]
    maxv2 = bl[n//2] + bl[n//2-1]
    print(maxv2-minv2+1)

Measured memory_bytes: 104680
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());

        String[] input_array = br.readLine().split(" ");

        Set<Integer> notSet = new HashSet<>();

        for(int i = 0; i < M; i++) {
            String[] str_array = br.readLine().split(" ");

            int a = Integer.parseInt(str_array[0]);
            int b = Integer.parseInt(str_array[1]);

            if(Integer.parseInt(input_array[a-1]) > Integer.parseInt(input_array[b-1])) {
                notSet.add(b);
            } else if(Integer.parseInt(input_array[a-1]) < Integer.parseInt(input_array[b-1])) {
                notSet.add(a);
            } else {
                notSet.add(a);
                notSet.add(b);
            }
        }
        
        pw.print(N - notSet.size());
        br.close();
        pw.close();
    }
}

Measured memory_bytes: 64892
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000  // スタックの最大値

typedef struct{
  int top;         // スタックポインタ(一番上の位置)
  int S[MAX];
}Stack;


// スタック st の初期化
void initialize(Stack *st)
{
  st->top = 0;
  st->S[st->top] = 0;
}

// スタック st が空かどうかを確認
int isEmpty(Stack *st)
{
  return st->top == 0;
}

// スタック st が一杯かどうかを確認
int isFull(Stack *st)
{
  return st->top >= MAX - 1;
}

// スタック st に要素 x をプッシュ(一番上に要素を追加)
void push(int x, Stack *st)
{
  if (isFull(st))
    exit(1);

  st->top++;
  st->S[st->top] = x;
}

// スタック st から要素をポップ(一番上の要素を取り出す)
int pop(Stack *st) {
  if (isEmpty(st))
    exit(1);

  st->top--;
  return st->S[st->top+1];
}


int main(void)
{
  Stack st1;     // '\' の開始位置を格納するスタック
  Stack st2_j;   // 各水たまりの最も左の'\' の位置を格納するスタック
  Stack st2_a;   // 各水たまりの水量を格納するスタック

  // スタック初期化
  initialize(&st1);
  initialize(&st2_j);
  initialize(&st2_a);

  char c;
  int sum = 0;  // 水たまりの総水量
  int j;

  // 地形を読み込み，各水たまりの水量を計算
  for (int i = 0; (c = getchar()) != EOF; i++) {
    if (c == '\\') {                                 // '\' が出た時の処理
      // 位置 i を st1 にプッシュ(write your code)
      push(i,&st1);
    }else if (!isEmpty(&st1) && c == '/') {          // '/' が出た時の処理
      // 水たまりの総水量 sum を更新(write your code)
      j=pop(&st1);
      // st2_j と st2_a を用いて水たまりの水量を更新
      int a = i - j;   // 更新する水たまりの水量を a に格納していく
      sum+=a;
      while (!isEmpty(&st2_j) && st2_j.S[st2_j.top] > j) {  // 最も左の '\' の位置が j よりも大きい場合，以下を繰り返す
        // 水たまりの水量を求めていく (write your code)
        a+=pop(&st2_a);
        pop(&st2_j);

      }
      // 更新した水たまりの「最も左の'\' の位置」および「水量」を更新 (write your code)
      push(j,&st2_j);
      push(a,&st2_a);

    }
  }

  printf("%d\n", sum);       // 水たまりの総水量を出力
  printf("%d", st2_a.top);   // 水たまりの個数を出力

  // 各水たまりの水量を断面図の左から出力(スタックの底から出力)
  for (int i = 1; i <= st2_a.top; i++)
    printf(" %d", st2_a.S[i]);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std; using ll=int_fast64_t; using ld=long double; using pll=pair<ll,ll>; using pld=pair<ld,ld>;
void solve(); int main(){cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(10); solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
    ll n,m; cin>>n>>m;
  const ll INF=1LL<<60;
  auto A=make_v(n,n,INF);
  // input
  rep(_,m){
    ll a,b; cin>>a>>b;
    --a;--b;
    A[a][b]=1;
  }
  auto next=make_v(n,n,0);
  rep(i,n)rep(j,n) next[i][j]=j;
  // Warshall-Floyd
  rep(k,n)rep(i,n)rep(j,n){
    if(chmin(A[i][j],A[i][k]+A[k][j])){
      next[i][j]=next[i][k];
    }
  }
  // output
  ll len=n+1;
  ll v=-1;
  rep(i,n) if(chmin(len,A[i][i])) v=i;
  if(v==-1){
    cout<<-1<<"\n";
    return;
  }
  // path restoration
  cout<<len<<"\n";
  cout<<v+1<<"\n";
  ll u=next[v][v];
  while(u!=v){
    cout<<u+1<<"\n";
    u=next[u][v];
  }
}

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

#define PEOPLE 100001  //最大出場者数

int a[PEOPLE];
int **b;        //各人の勝った相手一覧
int num;        //出場者数
int d[PEOPLE];  //各人の勝数
int count[PEOPLE];
/*
void mergesort(int *array, int left, int right) {
  if(left+1<right){}
  int mid = (left+rught) / 2;
  mergesort(array, left, mid);
  mergesort(array, mid , right);
  merge(array, left, mid, right);
 }
 */
int int_cmp(const int *a, const int *b) {
  if (*a > *b)
    return (-1);
  else if (*a < *b)
    return (1);
  return (0);
}

int saiteikaisou(int n) {  //再帰を使って最小深さを求める
  int max =
      -1;  //敗者の中でその段階までの階層数が最大のもの→maxの階層数を持つ敗者を最後に対戦させる。
  int i = 0;
  int *temp;
  temp = (int *)malloc(sizeof(int) * d[n]);
  int c = 0;  // maxの階層数を持つ敗者の数

  if (b[n][i] == 0) {
    return 0;
  }

  while (b[n][i] != 0) {
    temp[i] = saiteikaisou(b[n][i]);
    i++;
  }
  qsort(temp, d[n], sizeof(int), (int(*)(const void*, const void*))int_cmp);

  for (i = 0; i < d[n]; i++) {
    if (max < i + temp[i] + 1) {
      max = i + temp[i] + 1;
    }
  }

  return max;
}

int main() {
  int i, j;

  int ans;

  for (i = 0; i < PEOPLE; i++) {  //初期化
    a[i] = 0;
    d[i] = 0;
    count[i] = 0;
  }

  scanf("%d", &num);
  for (i = 2; i <= num; i++) {
    scanf("%d", &a[i]);
    d[a[i]]++;
  }

  b = (int **)malloc(sizeof(int *) * (num + 1));  //各人の
  for (i = 0; i < num + 1; i++) {
    b[i] = (int *)calloc((d[i] + 2),
                         sizeof(int));  //勝った相手の番号を入れる入れ物
  }

  for (i = 2; i <= num; i++) {  //勝った相手のリストを作成
    b[a[i]][count[a[i]]] = i;
    count[a[i]]++;
  }

  ans = saiteikaisou(1);
  printf("%d", ans);

  return 0;
}


Measured memory_bytes: 13056
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s[1001][5],d,f,g,h,i,j,k;
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		f=0;
		for(i=0;i<=a;i++){
			for(j=0;j<4;j++){
				scanf("%d",&s[i][j]);
			}
		}
		for(i=0;i<a;i++){
			d=s[i][1]*4+s[i][2]*9+s[i][3]*4;
			if(s[i][1]<=s[a][0]&&s[i][2]<=s[a][1]&&s[i][3]<=s[a][2]&&d<=s[a][3]){
				f=1;
				printf("%d\n",s[i][0]);
			}
		}
		if(f==0) printf("NA\n");
	}
	return 0;
}

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

class MainClass
{
    public static void Main()
    {
        while (true)
        {
            string[] str = Console.ReadLine().Split(' ');
            int h = int.Parse(str[0]);
            int w = int.Parse(str[1]);

            if (h == 0 && w == 0)
            {
                break;
            }

            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
                    {
                        Console.Write("#");
                    }
                    else
                    {
                        Console.Write(".");
                    }
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8860
N, M = map(int, input().split())
x, y, z = [], [], []
a = [[] for _ in range(8)]

for idx in range(N):
    x, y, z = map(int, input().split())
    a[0].append(x + y + z)
    a[1].append(x + - y + z)
    a[2].append(x + y + - z)
    a[3].append(x - y - z)
    a[4].append(-x + y + z)
    a[5].append(-x + - y + z)
    a[6].append(-x + y + - z)
    a[7].append(-x - y - z)

max_v = 0
for e in a:
    tmp = sum(sorted(e, reverse=True)[:M])
    if max_v < tmp:
        max_v = tmp

print(max_v)

Measured memory_bytes: 3316
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    S = SI()
    T = SI()
    
    
    ord_S = [0 for _ in range(26)]
    ord_T = [0 for _ in range(26)]
    
    for n in range(len(S)):
        ord_S[ord(S[n])-97] += 1
        ord_T[ord(T[n])-97] += 1
    
    
    s_ord_S = sorted(ord_S)
    s_ord_T = sorted(ord_T)
    
    for p in range(26):
        if s_ord_S[p] != s_ord_T[p]:
            print("No")
            sys.exit()
    print("Yes")
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 68668
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int c=sc.nextInt();
        int[]b=new int[m];
        int output=0;
        for(int i=0;i<m;i++){
            b[i]=sc.nextInt();
        }
        int tmp;
        for(int i=0;i<n;i++){
            tmp=0;
            for(int j=0;j<m;j++){
                tmp+=b[j]*sc.nextInt();
            }
            tmp+=c;
            if(tmp>0){
                output++;
            }
        }
        System.out.println(output);

    }

}

Measured memory_bytes: 22740
#include <iostream>
#include <cstdio>
#include <sstream>
using namespace std;

int company[1000001]={0};
int cc[1000001]={0};
int bb[1000001]={0};

int main(){

  string ss;
  int a,b;

  while(getline(cin,ss)&&ss.size() > 0){
    sscanf(ss.c_str(),"%d,%d",&a,&b);
    company[a]++;  
    cc[a]=1;
  }
  while(getline(cin,ss)&&ss.size() > 0){
    sscanf(ss.c_str(),"%d,%d",&a,&b);
    company[a]++;  
    bb[a]=1;
  }
  for(int i = 0 ; i <= 1000 ; i++){
    if(cc[i] == 1 && bb[i] == 1)cout << i << " " << company[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 5332
object Main extends App {
	val N = scala.io.StdIn.readInt
	
	val cnt = Array(0,0,0,0,0)

	for(i<-0 until N){
		val temp = scala.io.StdIn.readLine.toList

		temp.head match {
			case 'M' => cnt(0) += 1
			case 'A' => cnt(1) += 1
			case 'R' => cnt(2) += 1
			case 'C' => cnt(3) += 1
			case 'H' => cnt(4) += 1
			case _ =>  
		}
	}

	var ans = 0L
	val cntl = cnt.map(_.toLong)

	ans += cntl(0)*cntl(1)*cntl(2)
	ans += cntl(0)*cntl(1)*cntl(3)
	ans += cntl(0)*cntl(1)*cntl(4)
	ans += cntl(0)*cntl(2)*cntl(3)
	ans += cntl(0)*cntl(2)*cntl(4)
	ans += cntl(0)*cntl(3)*cntl(4)
	ans += cntl(1)*cntl(2)*cntl(3)
	ans += cntl(1)*cntl(2)*cntl(4)
	ans += cntl(1)*cntl(3)*cntl(4)
	ans += cntl(2)*cntl(3)*cntl(4)

	println(ans)

}

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

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, pll> ppll;

#define MOD 1000000007
#define f(a, b, c) for (ll(a) = (b); (a) < (c); ++(a))
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define rep(i, n) f(i, 0, n)
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(), v.end()
#define wh(t) while (t--)
#define inf (ll)1e18
#define modd 998244353
#define pp(var) cout<<var<<"\n";
#define pm(var1, var2) cout<<var1<<" "<<var2<<"\n";
#define pv(i,v) rep(i,v.size()) cout<<v[i]<<" "; pp("");
#define pa(i,n,v) rep(i,n) cout<<v[i]<<" "; pp("");
#define K 1001
const ll N = 2e5 + 5;

ll pow(ll a, ll n, ll m)
{
	ll i = 1;
	while (n > 0)
	{
		if (n & 1)
			i = (i * a) % m;
		a = (a * a) % m;
		n = n >> 1;
	}
	return i % m;
}

ll isprime(ll n)
{
	if (n == 0 || n == 1)
		return n;
	if (n % 2 == 0)
		return (ll)2;
	if (n % 3 == 0)
		return (ll)3;
	else
	{
		for (ll i = 5; i * i <= n; i += 6)
		{
			if (n % i == 0)
				return i;
			if (n % (i + 2) == 0)
				return (i + 2);
		}
		return n;
	}
}

ll solve(ll n1, ll n2, ll check) {
	if (check == 1) {
		return max(n1, n2);
	}
	else return min(n1, n2);
}

int main() {
	fast;
	ll l, r, n, m, i, j, k, x, y, t, q;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> n;
	ll a[n];
	for (auto &e : a) cin >> e;
	sort(a, a + n, greater<ll>());
	ll ans = 0;
	priority_queue<ll> pq;
	pq.push(a[0]);
	for (i = 1; i < n; ++i) {
		ans += pq.top(); pq.pop();
		pq.push(a[i]);
		pq.push(a[i]);
	}
	pp(ans);
}

Measured memory_bytes: 6880
# AOJ 2199 - 差分パルス符号変調
# 配るDP
import sys


def main():
    inf = float('inf')
    error_list = tuple(tuple((i - j) ** 2 for i in range(256)) for j in range(256))

    while True:
        N, M = map(int, sys.stdin.readline().strip().split())

        if N == 0:
            break

        C = tuple(int(sys.stdin.readline()) for _ in range(M))

        decode_list = tuple(tuple(255 if j + c > 255 else 0 if j + c < 0 else j + c for c in C) for j in range(256))

        # dp 初期化 ---------------------------------------------------------
        dp1 = [inf] * 256
        dp1[128] = 0

        # dp 計算 ---------------------------------------------------------
        for _ in range(N):
            x = int(sys.stdin.readline())
            error_list_x = error_list[x]
            dp2 = [inf] * 256

            for decode_list_j, dp1_j in zip(decode_list, dp1):
                for x_decode in decode_list_j:

                    new_sum_error = dp1_j + error_list_x[x_decode]

                    if new_sum_error < dp2[x_decode]:
                        dp2[x_decode] = new_sum_error

            dp1 = dp2[:]

        print(min(dp1))


if __name__ == '__main__':
    main()




Measured memory_bytes: 8748
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int X=scan.nextInt(),A=scan.nextInt(),B=scan.nextInt();
        int money;
        money = (X-A) % B;
    	System.out.println((X-A) % B);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
 
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(int i=n;i<=N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define pllll pair<pll,pll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 1e6+5;
const ll MAX2 = 11;
const ll MOD = 998244353;
const ll MOD2 = 1000000006;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 316;
 
int n,dp[MAX][2],x[MAX];
char c;

int f(int pos,bool st){
	if(pos>n)return 0;
	if(dp[pos][st]!=-1)return dp[pos][st];
	
	if(st)return dp[pos][st] = min(f(pos+1,0)+x[pos],f(pos+1,1)+9-x[pos]);
	return dp[pos][st] = min(f(pos+1,0)+x[pos],f(pos+1,1)+11-x[pos]);
}

int main(){
//	cout<<fixed<<setprecision(2);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    while(cin>>c)x[++n] = c-'0';
    memset(dp,-1,sizeof dp);
    cout<<f(1,0)<<endl;
    return 0;
}

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

int func(int x) {
	if (x % 2 == 0) return 0;
	else return 1;
}

int main() {

	int n; cin >> n;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	vector<int> b(n + 1, 0);
	int cnt = 0;
	for (int i = n; i >= 1; i--) {
		int sum = 0; // 0 or 1
		for (int j = i + i; j <= n; j += i) {
			sum += b[j];
		}
		sum = func(sum);
		if (sum != a[i]) {
			b[i] = 1;
			cnt++;
		}
	}
	cout << cnt << endl;
	for (int i = 1; i <= n; i++) {
		if (b[i] == 1) cout << i << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 4768
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int sum=0;
  for(int i=0;i<4;i++){
    if(S.at(i)=='+'){
      sum=sum+1;
    }
    else{
      sum=sum-1;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	int n,x,cnt;
  while(true){
    scanf("%d %d", &n,&x);
    if (n==0 && x==0) break; 
    cnt = 0;
    repn(i,n){
      repn(j,n){
        repn(k,n){
          if (i+j+k==x && i!=j && j!=k && i!=k) cnt++;  
        }
      }
    }
    printf("%d\n",cnt/6);
  }
  
}


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


int main(){

	int n;
	cin >> n;
	vector<int> odd(100010), even(100010);
	int o1 = 0, o2 = 0, e1 = 0, e2 = 0;	

	int num = n/2;
	for(int i = 0; i < num; i++)
	{
		int s, t;
		cin >> s >> t;
		odd[s]++;
		even[t]++;
		if(odd[s] > odd[o1]) o1 = s;
		if(even[t] > even[e1]) e1 = t;
	}
	

	for(int i = 0; i < 100001; i++)
	{	
		if(odd[o2] < odd[i] && i != o1) o2 = i;
		if(even[e2] < even[i] && i != e1) e2 = i;
	}

	int ans=n-odd[o1]-even[e1];
	if(o1 == e1){
		ans = min(n-odd[o1]-even[e2], n-odd[o2]-even[e1]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,y=0;
	cin>>n;
	int a[n],b[n+1];
	for(int i=0;i<n;i++){
		cin>>a[i];
		(i+1==a[i]) ? (b[i]=1):(b[i]=0);
	}
	b[n]=0;
	for(int i=0;i<n;i++){
		if(b[i]){
			y++;
			b[i]=0;
			b[i+1]=0;
		}
	}
	cout<<y;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<sqrt(n);i++)
    {
        if(n%i==0)
        {
          c++;
        }
    }
    c=c*2;
    if(pow(sqrt(n),2)==(sqrt(n)*sqrt(n)))
        c++;
    return  c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
 int n,m;
 cin>>n>>m;
 set<int> s;
 while(m--)
 {  
   int t;
   cin>>t;
   while(t--)
   {
    int h;
    cin>>h;
    s.insert(h);
   }
 }
 cout<<n-s.size();

 return 0;
}








Measured memory_bytes: 3688
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	int s;
	cin >> s;
	syc(s,1,100);
	int a[1000000];
	
	for(int i=0;i<10000000;i++){
		if(i==0){
			a[i]=s;
		}else if(i>0){
			if(a[i-1]%2==0){
				a[i]=a[i-1]/2;
			}else if(a[i-1]%2!=0){
				a[i]=3*a[i-1]+1;
			
			}
		}
		
		for(int j=0;j<i;j++){
				if(a[i]==a[j]){
					cout << i+1 << endl;
					return 0;
				}
		}	
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

/**
 * B Main
 *
 * @date 2020.09.19
 * @author 焼き鮭 <yaki-shake@up-tri.me>
 */

public class Main {
  Scanner sc;

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

  public void execute() {
    this.sc = new Scanner(System.in);
    long a = this.sc.nextInt();
    long b = this.sc.nextInt();
    long c = this.sc.nextInt();
    long d = this.sc.nextInt();

    long[] p = new long[4];
    p[0] = a * c;
    p[1] = b * c;
    p[2] = a * d;
    p[3] = b * d;

    Arrays.sort(p);
    System.out.println(p[3]);
  }
}


Measured memory_bytes: 27000
#include <stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int a, b, i, j;
	while (1) {
		cin >> a >> b;
		if (a == 0 && b == 0) { break; }
		else {
			for (j = 1;j <= a;j++) {
				{ for (i = 1;i <= b;i++) { printf("#"); }
				printf("\n");
				}
			}
			printf("\n");
		}
	}
		return 0;
	
}


Measured memory_bytes: 3072
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

const long mod = 1_000_000_007;

void solve(){
	
	int n = read.to!int;
	int m = read.to!int;
	
	bool[] isBroken = new bool[](n + 1);
	foreach(i; 0 .. m){
		int a = read.to!int;
		isBroken[a] = 1;
	}
	
	int[] xs;
	foreach(i; 0 .. n + 1){
		if(i == 0) xs ~= 1;
		else if(i == 1) xs ~= (isBroken[1]? 0: 1);
		else{
			if(isBroken[i]) xs ~= 0;
			else xs ~= (xs[i -2] + xs[i - 1]) % mod;
		}
	}
	
	log("xs:", xs);
	xs[n].writeln;
	
}


Measured memory_bytes: 1916
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for a in range(A+1):
    if 500*a == X:
        ans += 1
    elif 500*a < X:
        for b in range(B+1):
            if 500*a + 100*b == X:
                ans += 1
            elif 500*a + 100*b < X:
                for c in range(C+1):
                    if 500*a + 100*b + 50*c == X:
                        ans += 1
                    
print(ans)

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

typedef struct {
	int x, y;
} POINT;

int main(void)
{
	POINT p;
	char field[21][21];
	int n, m;
	
	while (1){
		memset(field, 0, sizeof(field));
		scanf("%d", &n);
		if (!n) break;
		for (int i = 0; i < n; i++){
			int x, y;
			
			scanf("%d%d", &x, &y);
			field[x][y] = 1;
		}
		p.x = p.y = 10;
		if (field[10][10] == 1){
			n--;
		}
		field[10][10] = 0;
		
		scanf("%d", &m);
		for (int i = 0; i < m; i++){
			char d[2];
			int step;
			
			scanf("%s%d", d, &step);
			for (int i = 0; i < step; i++){
				switch (d[0]){
				  case 'N': p.y++; break;
				  case 'E': p.x++; break;
				  case 'S':	p.y--; break;
				  case 'W': p.x--; break;
				}
				if (field[p.x][p.y] == 1){
					n--;
					field[p.x][p.y] = 0;
				}
			}
		}
		
		printf("%s\n", n == 0 ? "Yes" : "No");
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
     char S[4];
     rep(i, 4) {
         cin >> S[i];
     }
     rep(i, 3) {
         if(S[i] == S[i + 1]) {
             cout << "Bad" << endl;
             return 0;
         }
     }
     cout << "Good" << endl;
	return 0;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

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

const int MOD = 998244353;

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

	string s; cin >> s;
	string t; cin >> t;

	int cnt = 0;
	int n = s.size();
	FOR(i, n) cnt += (s[i] != t[i]);

	cout << cnt << '\n';

	return 0;
}


Measured memory_bytes: 3736
import java.util.Scanner;

public class Main {
    static int MODULUS = 2019;

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

        int L = sc.nextInt();
        int R = sc.nextInt();

        System.out.println(solve(L, R));

        sc.close();
    }

    static long solve(int L, int R) {
        long result = Long.MAX_VALUE;
        for (int i = L; i < R && i - L < MODULUS; ++i) {
            for (int j = i + 1; j <= R && j - L < MODULUS; ++j) {
                result = Math.min(result, (long) i * j % MODULUS);
            }
        }

        return result;
    }
}

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

#define ran 101101

int n, k;
int v[555];
char s[ran];

int main() {
	scanf("%d%d", &n, &k);
	scanf("%d%d%d", &v['s'], &v['p'], &v['r']);
	
	int ans = 0;
	scanf("%s", s);
	for(int i=0;i<n;i++) {
		if(i<k) ans += v[s[i]];
		else
		if (s[i] != s[i-k]) ans += v[s[i]];
		else s[i] = 'x';
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 384
w=input()+"X"
n=len(w)
a=[];i=j=0
while True:
  while w[i]=="R":
    i+=1
  a+=[0]*(i-j-1)
  r=(i-j+1)//2;l=(i-j)//2
  j=i
  while w[j]=="L":
    j+=1
  r+=(j-i)//2;l+=(j-i+1)//2
  a+=[r,l]+[0]*(j-i-1)
  if j==n-1:
    break
  i=j
for b in a:
  print(b,end=" ")

Measured memory_bytes: 4856
#include<cstdio>
#include<utility>
#include<queue>
using namespace std;int i,n,L,t,z[100002],s;int main(){typedef pair<int,int>y;priority_queue<y>q;y p;for(scanf("%d%d",&n,&L);i++<n;)scanf("%d",z+i);for(;--i;)z[i]>z[i-1]&z[i]>z[i+1]?q.push(y(z[i]-L,i)),z[i]=L:0;for(;!q.empty();n&&n!=L&n>z[s+2]?q.push(y(t-L+n,s+1)),z[s+1]=L:0)p=q.top(),q.pop(),t=p.first,z[s=p.second]=0,n=z[s-1],n&&n!=L&n>z[s-2]?q.push(y(t-L+n,s-1)),z[s-1]=L:0,n=z[s+1];printf("%d\n",-t);}

Measured memory_bytes: 1580
#include<bits/stdc++.h>
using namespace std;
int main(){
    #define int long long
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin >> n;
    vector<int>a(n);
    map<int,int>cnt,t,ans;
    for(auto &x:a){
        cin >> x;
        cnt[x]++;
    }
    
    int sum = 0;
    for (auto i :cnt){
            sum += (i.second*(i.second-1)/2);
    }
    for (int i = 0 ; i < n; i++){
        int ans = sum;
        int t = cnt[a[i]]-1;
        ans += (t*(t-1)/2);
        ans -= (cnt[a[i]]*(cnt[a[i]]-1) / 2);
        cout << ans << "\n";
    }
}

Measured memory_bytes: 11136
#include <iostream>
#include <cassert>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main (void){ 
    string s;
    string result = "";
    vector <string> v(10);
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        v[i] += s[i];
        if (v[i] == "0") {
            result += "0";
        } else if (v[i] == "1") {
            result += "1";
        } else {
            if (result.empty()) {

            } else {
                 result.erase(result.end()-1);
            }
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
//F6編譯，右上三角形執行，ctrl+c強制停止執行  F5開啟exe
#define ll long long
#define maxn 100005
#define mod 1000000007
using namespace std;

typedef pair<int, int> P;
string s1, s2;
int a, b;

int main()
{
    cin >> s1 >> s2;
    cin >> a >> b;
    string s;
    cin >> s;
    if (s == s1)
        a -= 1;
    if (s == s2)
        b -= 1;
    printf("%d %d\n", a, b);
    return 0;
}

Measured memory_bytes: 768
#include<cstdio>
#include<cmath>
using namespace std;
int a[200];
int main()
{
	int n,l;int sum=0;
	int check=9999,ans;
	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;i++)
	{
		a[i]=l+i-1;
	//	printf("%d\n",a[i]);
		if(a[i]==0) check=1;
		sum+=a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(abs(a[i])<=check) check=abs(a[i]),ans=a[i];
	} 
	printf("%d",sum-ans);
	return 0;
}

Measured memory_bytes: 128
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>

#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
    for (T x : s)
        cout << x << " ";
    cout << endl;
}

void solve(){

}

int main(){
    srand(17);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("a.in", "r", stdin);
    string s;
    cin >> s;
    map<char, int> cnt;
    for (int i = 0; i < 4; i++)
        cnt[s[i]]++;
    for (int i = 0; i < 4; i++){
        if (cnt[s[i]] != 2){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

ll a[100001];
ll b[100001] = {};
int main() {
	ll N; cin >> N;
	repe(i, 1, N) {
		cin >> a[i];
	}

	ll cnt = 0;
	ll i = 1;
	while (1) {
		if (b[i]) {
			cout << -1 << endl;
			return 0;
		}
		b[i] = true;
		i = a[i];
		cnt++;
		if (i == 2) {
			cout << cnt << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1792