akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
	int n, a, b;

	std::cin >> n >> a >> b;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int num;
		std::cin >> num;
		if (num < a || b <= num) ans++;
	}

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

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

int main() {
  
  long long N,a,b,c,d,e;
  cin >> N >> a >> b >> c >> d >> e;
  
  long long m = min(a,b);
  m = min(m,c);
  m = min(m,d);
  m = min(m,e);
  long long count = 0;
  
  if(N % m == 0){ count = 4 + (N / m);}
  else { count = 5 + (N / m);}


  cout << count << endl;
}
  
    

Measured memory_bytes: 256
'use strict';

function Main(input) {
    const tmp = input.trim().split('\n');
    const D = Number(tmp[0]);
    const C = tmp[1].split(' ').map((v) => Number(v));
    const S = tmp
        .slice(2, 2 + D)
        .map((v) => v.split(' ').map((v) => Number(v)));

    let LastContestDays = Array(26).fill(0); // コンテストの種類ごとの最終開催日
    let currnetContestLebels = Array(26).fill(0); // ある開催日のコンテストごとの満足度
    let lebelDrops = Array(26).fill(0); // ある開催日のコンテストごとの満足低下量

    for (let i = 1; i <= D; i++) {
        for (let j = 0; j < C.length; j++) {
            lebelDrops[j] = C[j] * (i - LastContestDays[j]) * -1;
        }
        for (let k = 0; k < C.length; k++) {
            const l = [...lebelDrops];
            l[k] = S[i - 1][k];
            const lr = l.reduce((acc, cur) => acc + cur);
            currnetContestLebels[k] = lr;
            // currnetContestLebels[k] += S[i - 1][k] + drop - lebelDrops[k];
        }
        let openContestNo = 0;
        let maxLebel = 0;
        for (let m = 0; m < C.length; m++) {
            if (maxLebel < currnetContestLebels[m]) {
                maxLebel = currnetContestLebels[m];
                openContestNo = m;
            }
        }
        LastContestDays[openContestNo] = i;
        console.log(openContestNo + 1);
    }

    return;
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 35176
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var ABN = Sarray();
            var A = ABN[0];
            var B = ABN[1];
            var N = ABN[2];
            var ans = 0L;
            if (B - 1 <= N)
                ans = (A * (B - 1)) / B;
            else
                ans = (A * N) / B;
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 28196
#include <stdio.h>
int main(void){
    int N, count=0;
    scanf("%d", &N);
    int a, b=10, c;
    int i=1;
    int k=1;
    while(1){
        a = i/b;
        if(a==1){
            k*=100;
            i=k;
            b*=100;
        }
        if(i>N){
            break;
        }
        count++;
        if(i>=N){
            break;
        }
        i++;
    }
    printf("%d\n", count);
    return 0;
}

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

int func(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0, sum = 0;
    rep(i, n) {
        sum = func(i);
        if (a <= sum && sum <= b) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n-1):
 for j in range(n-i-1):
  if a[j]>a[j+1]:a[j],a[j+1]=a[j+1],a[j];c+=1
print(*a)
print(c)


Measured memory_bytes: 5604
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

type Node struct {
	Point     int
	Nodes     []int
	BranchCnt int
}

func MinInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

// SetPoint will find a node which is connected with only one node (or root node) and give it the smallest points.
func SetPoint(nodes []Node, points []int) {
	pointIndex := 0
	for index, node := range nodes {
		// node.BranchCnt == 1 means the node has only one parent node
		// node.BranchCnt == 0 means it's the root node (all children are removed already)
		if node.BranchCnt < 2 && node.Point == 0 {
			nodes[index].Point = points[pointIndex] // give the smallest points available
			for _, targetNode := range node.Nodes {
				nodes[targetNode].BranchCnt-- // reduce the number of branches from all connected nodes
			}
			pointIndex++
		}
	}

	// Continue if there's not assigned points
	if len(points) > pointIndex {
		SetPoint(nodes, points[pointIndex:])
	}
}

func main() {
	sc.Split(bufio.ScanWords)

	n := NextInt()
	nodes := make([]Node, 0)

	// create node list
	for i := 0; i < n; i++ {
		node := Node{
			Point:     0,
			Nodes:     make([]int, 0),
			BranchCnt: 0,
		}
		nodes = append(nodes, node)
	}

	// save connected nodes and number of branches
	for i := 0; i < n-1; i++ {
		start, end := NextInt(), NextInt()
		nodes[start-1].Nodes = append(nodes[start-1].Nodes, end-1)
		nodes[end-1].Nodes = append(nodes[end-1].Nodes, start-1)
		nodes[start-1].BranchCnt++
		nodes[end-1].BranchCnt++
	}

	// get all points and sort in asc
	points := make([]int, n)
	for i := 0; i < n; i++ {
		points[i] = NextInt()
	}
	sort.Sort(sort.IntSlice(points))

	// set points from the bottom of the true
	SetPoint(nodes, points)

	// calculate score
	var score int
	for i := 0; i < n; i++ {
		for _, node := range nodes[i].Nodes {
			if node > i {
				score += MinInt(nodes[i].Point, nodes[node].Point)
			}
		}
	}

	// output
	fmt.Println(score)
	for index, node := range nodes {
		fmt.Print(node.Point)
		if index != n-1 {
			fmt.Print(" ")
		} else {
			fmt.Println("")
		}
	}
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int n,l;
int main()
{
    cin>>n>>l;
    int s=n*(2*l+n-1)/2;
    cout<<(l>=0?s-l:(l+n-1<=0?s-(l+n-1):s));
    return 0;
}

Measured memory_bytes: 256
//#define		FILE_INPUT_DEFINE
#ifdef		FILE_INPUT_DEFINE
#include	<fstream>
#endif		// FILE_INPUT_DEFINE

#include	<iostream>
#include	<deque>
#include	<string>
#include	<algorithm>
#include	<cstdio>
#include	<memory>

using namespace std;

enum class Walk
{
	ePreOrder = 0,
	eInOrder,
	ePostOrder
};


struct Node
{
	shared_ptr<Node>		parent;
	shared_ptr<Node>		left;
	shared_ptr<Node>		right;
	int						key;

	Node(int k)
	{
		key = k;
	}
};

shared_ptr<Node>			root;

void insert(int key)
{
	unique_ptr<Node>		z(new Node(key));
	weak_ptr<Node>			x = root;
	weak_ptr<Node>			y;

	while (x.use_count() != 0)
	{
		y = x;
		if (z->key < x.lock()->key)
		{
			x = x.lock()->left;
		}
		else
		{
			x = x.lock()->right;
		}
	}

	if (y.use_count() != 0)
	{
		z->parent = y.lock();
	}

	if (y.use_count() == 0)
	{
		root = move(z);
	}
	else
	{
		if (z->key < y.lock()->key)
		{
			y.lock()->left = move(z);
		}
		else
		{
			y.lock()->right = move(z);
		}
	}
}

void Order(weak_ptr<Node> nd, const Walk &wk)
{
	if (wk == Walk::ePreOrder)
		cout << " " << nd.lock()->key;
	if (nd.lock()->left.use_count() != 0)
		Order(nd.lock()->left, wk);
	if (wk == Walk::eInOrder)
		cout << " " << nd.lock()->key;
	if (nd.lock()->right.use_count() != 0)
		Order(nd.lock()->right, wk);
	if (wk == Walk::ePostOrder)
		cout << " " << nd.lock()->key;
}

int main()
{
#ifdef		FILE_INPUT_DEFINE
	// input from txt
	std::ifstream in(R"(C:\Temp\input.txt)");
	std::cin.rdbuf(in.rdbuf());
#endif		// FILE_INPUT_DEFINE
	string		str;
	int			n, key;

	cin >> n;
	cin.clear();
	cin.ignore();

	for (int i = 0; i < n; ++i)
	{
		cin >> str;
		if (str == "insert")
		{
			cin >> key;
			insert(key);
		}
		else if (str == "print")
		{
			Order(root, Walk::eInOrder);
			cout << "\n";
			Order(root, Walk::ePreOrder);
			cout << "\n";
		}
		cin.clear();
		cin.ignore();
	}

	return 0;
}

Measured memory_bytes: 50060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 10e9+7;
ll mod2 = 998244353;

int main(){
	int n,m;cin>>n>>m;
    vector<int> a(n);
    rep(i,0,m){
        int l,r;cin>>l>>r;
        a[l-1]++;
        if (r<n) a[r]--;
    }
    vector<int> b(n);
    b[0] = a[0];
    rep(i,1,n) b[i] = b[i-1]+a[i];
    int ans = 0;
    rep(i,0,n){
        if (b[i]==m){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4028
var lines = [];
var N, M, Q;
var sum;

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    N = Number(lines[0].split(" ")[0])
    M = Number(lines[0].split(" ")[1])
    Q = Number(lines[0].split(" ")[2])
    sum = Array(N + 1).fill(0).map(i => i = Array(N + 1).fill(0));

    var L = Array(M), R = Array(M);

    for (var i = 0; i < M; i++) {
        var t = lines[i + 1].split(" ")
        L[i] = Number(t[0]); R[i] = Number(t[1]);
    }

    var p = Array(Q), q = Array(Q);
    for (var i = 0; i < Q; i++) {
        var t = lines[i + M + 1].split(" ");
        p[i] = Number(t[0]); q[i] = Number(t[1])
    }

    buildsumtable(L, R);


    for (var i = 0; i < Q; i++) {
        var ans = sum[q[i]][q[i]] - sum[q[i]][p[i] - 1] - sum[p[i] - 1][q[i]] + sum[p[i] - 1][p[i] - 1]
        console.log(ans);
    }

});

function buildsumtable(L, R) {

    for (var i = 0; i < M; i++) {
        sum[L[i]][R[i]]++;
    }

    for (var i = 1; i <= N; i++) {
        for (var j = 1; j <= N; j++) {
            sum[i][j] += sum[i - 1][j];
            sum[i][j] += sum[i][j - 1];
            sum[i][j] -= sum[i - 1][j - 1];
        }
    }
}

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

using namespace std;

int main()
{
	char b;
    
    cin >> b;
    
    if (b == 'A'){
		cout << 'T' << endl;
    }
    
    if (b == 'T'){
		cout << 'A' << endl;
    }
    
    if (b == 'C'){
		cout << 'G' << endl;
    }
    
    if (b == 'G'){
		cout << 'C' << endl;
    }
}

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

int n, m, z[100005], par[100005], tb, tc;
long long x[100005], y[100005], ta;
vector< int > v[100005];

int find(int a) {
	return par[a] == a ? a : par[a] = find(par[a]);
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%lld%lld", &ta, x + i);
		y[i] = max(ta - x[i], 0LL);
		z[i] = i;
	}
	sort(z + 1, z + n + 1, [](const int &a, const int &b) {return y[a] < y[b];});
	while (m--) {
		scanf("%d%d", &tb, &tc);
		v[tb].push_back(tc);
		v[tc].push_back(tb);
	}
	for (int i = 1; i <= n; i++) {
		tb = z[i];
		par[tb] = tb;
		ta = y[tb];
		for (int j: v[tb])
			if (par[j] && (j = find(j)) != tb) {
				par[j] = tb;
				x[tb] += x[j];
				y[tb] = min(y[tb], max(y[j], ta) - x[j]);
			}
		y[tb] += x[tb];
	}
	printf("%lld\n", y[z[n]]);
	return 0;
}


Measured memory_bytes: 8188
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#define _USE_MATH_DEFINES

#include<math.h>
#include<unordered_map>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int main()
{
	int N;
	int a[100];

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

	for (int k = 0; k < N; k++)
	{
		cout << a[k];
		if (k < (N - 1))
		{
			cout << " ";
		}
	}
	cout << endl;

	for (int i = 1; i<N; i++)
	{
		int key = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > key)
		{
			a[j + 1] = a[j];
			j--;
			a[j + 1] = key;
		}

		for (int k = 0; k < N; k++)
		{
			cout << a[k];
			if (k < (N - 1))
			{
				cout << " ";
			}
		}
		cout << endl;
	}

	return 0;
}

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

int main(){
  int n;
  cin>>n;
  ll ans = 0;
  unordered_map<string,int> m;
  rep(i,n){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    m[s]++;
  }
  for(auto& p:m){
    int b = p.second;
    ans += (ll)b*(b-1)/2;
  }
  cout<<ans << endl;

}

Measured memory_bytes: 10660
// Problem : C - Write and Erase
// Contest : AtCoder - AtCoder Beginner Contest 073
// URL : https://atcoder.jp/contests/abc073/tasks/abc073_c
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int n;cin>>n;
set<int> s;
while(n--)
{
	int x;cin>>x;
	if(s.count(x))
	s.erase(x);
	else
	s.insert(x);
}
cout<<size(s);
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 8200
import collections

n = int(input())
a = list(map(int,input().split()))
cnt = collections.Counter(a)
#print(cnt)
a.sort()
dp = [1]*(max(a)+1)

sum = 0
for i in range(n):
    for j in range(a[i]*2,len(dp),a[i]):
            dp[j] = 0
    if dp[a[i]] == 1 and cnt[a[i]]==1:
        sum += 1

print(sum)

Measured memory_bytes: 133192
#include<iostream>
#include<vector>
#include<algorithm>
#include<fstream>
#include<utility>
#include<string>
#include<iomanip>
#include<queue> 
#include<cmath>
#include<utility>
#include<set>
using namespace std;
char a[102][102];
int dp[102][102];
int h,w, mi = 1000000;
int dfs(int x, int y)
{
  if(x == w-1 && y == h-1)
  {
    if(a[x][y]=='.')
      return 0;
    else
      return 1;
  }
  if(dp[x][y]!=-1)
    return dp[x][y];
  dp[x][y]=100000;
  if(x+1 < w)
  {
    dp[x][y]=min(dp[x][y], dfs(x+1, y));
    if(a[x][y]=='#')
    {
      int j = x+1;
      while(j < w && a[j][y]=='#')
      {
        dp[x][y]=min(dp[x][y], dfs(j, y)-1);
        j++;
      }
    }
  }
  if(y+1 < h)
  {
    dp[x][y]=min(dp[x][y], dfs(x, y+1));
    if(a[x][y]=='#')
    {
      int j = y+1;
      while(j < h && a[x][j]=='#')
      {
        dp[x][y]=min(dp[x][y], dfs(x, j)-1);
        j++;
      }
    }
  }
  if(a[x][y]=='#')
    dp[x][y]++;
  return dp[x][y];
}
int main()
{
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  cin >> h >> w;
  for(int i = 0; i < h; i++)
  {
    for(int j = 0; j < w; j++)
    {
      cin >> a[j][i];
      dp[j][i]=-1;
    }
    cin.ignore();
  }
  cout << dfs(0, 0);
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		int[] NM = readLineInt();
		int N = NM[0];
		int M = NM[1];
		
		print(N<=M?"unsafe":"safe");
		//String[] s = readLine();
		//print(num);
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


Measured memory_bytes: 32836
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <string>

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

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int K;
	scanf("%d",&K);
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			int nm=j*i+(n-i)*(m-j);
			if(nm==K)
			{
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}


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

int main(){
    string S;
    cin>>S;

    if(S=="Sunny"){
        cout<<"Cloudy"<<endl;
        return 0;
    }
    if(S=="Cloudy"){
        cout<<"Rainy"<<endl;
        return 0;
    }
    if(S=="Rainy"){
        cout<<"Sunny"<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,x) for(int i=0,i##_len=(x);i<i##_len;++i)
#define rep(i,a,b) for(int i=(a),i##_len(b);i<i##_len;++i)
#define All(x) begin(x),end(x)
#define rAll(x) rbegin(x),rend(x)
using namespace std;
using ll = long long;

int main(){
    int N,M;cin>>N>>M;
    cout<<N*(N-1)/2+M*(M-1)/2<<endl;
}

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

int a[100005];
int dp[100005];

int f(int i, int n, int k) {
    if(dp[i] != -1) return dp[i];
    if(i == n-1) return 0;
    
    int x = INT_MAX;
    for(int j = i+1; j < n and j-i <= k; j++) {
        x = min(x, abs(a[i]-a[j]) + f(j, n, k));
    }
    
    return dp[i] = x;
}


int main() {
	// your code goes here
	int n, k;
	cin >> n >> k;
	memset(dp, -1, sizeof dp);
	for(int i = 0; i < n; i++) {
	    cin >> a[i];
	}
	cout << f(0, n, k);
	return 0;
}


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

typedef long long ll;
#define INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
const double pi = acos(-1.0);

// 2^9

int M;
int d[200010];
ll c[200010];

// d1d1d1d1d2d2d2d3d3d3d3d3
// c1's d1, c2's d2

// a+b <= 18 -> 18 ->
// 进位加和 -> 长度不变,总数-9
// 非进位加和 -> 长度-1,总数不变

int main(){
  cin>>M;
  ll len = 0;
  ll sum  =0;
  rep(i,0,M){
    scanf("%d %lld",d+i,c+i);
    len+=c[i];
    sum+=d[i]*c[i];
  }
  cout<<((len-1)+(sum-1)/9)<<endl;

  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    if (s[0] == '1') ans++;
    if (s[1] == '1') ans++;
    if (s[2] == '1') ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30 ;
struct edge{
  int pos, strong ;
  int dp[77];

  edge(int pos, int strong): pos(pos), strong(strong){
    fill_n( dp, 77, INF);
  };
  edge(){};
};

int main(){
  int n; //行数 
  int m; //ジャンプの数

  vector< edge > node[152] ;

  while(cin >> n >> m, n){
    for(int i = 0; i < n; i++){
      int k;
      cin >> k ;
      node[i].resize(k) ;
      for(int j = 0; j < k; j++){
        int x, d;
        cin >> x >> d ;
        node[i][j] = edge( x, d);
      }
    }

    for(int i = 0; i < node[0].size(); i++){ //最初は普通にジャンプ
      node[0][i].dp[0] = 0;
    }
    for(int i = 0; i < node[1].size(); i++){ //最初はジャンプする
      node[1][i].dp[1] = 0 ;
    }
    for(int i = 0; i < n; i++){
      for(int j = 0; j < node[i].size(); j++){
        for(int k = 0; k <= m; k++){
          if(node[i][j].dp[k] != INF){
            if(k != m){
              for(int l = 0; l < node[i + 2].size(); l++){
                node[i + 2][l].dp[k + 1] = min( node[i + 2][l].dp[k + 1], node[i][j].dp[k] + (node[i + 2][l].strong + node[i][j].strong) * abs(node[i + 2][l].pos - node[i][j].pos));
              }
            }
            for(int l = 0; l < node[i + 1].size(); l++){
              node[i + 1][l].dp[k] = min( node[i + 1][l].dp[k], node[i][j].dp[k] + (node[i + 1][l].strong + node[i][j].strong) * abs(node[i + 1][l].pos - node[i][j].pos));
            }
          }
        }
      }
    }
    int ret = INF ;
    for(int i = 0; i < node[n - 1].size(); i++){
      for(int j = 0; j <= m; j++){
        ret = min( ret, node[n - 1][i].dp[j]);
      }
    }
    for(int i = 0; i < node[n - 2].size(); i++){
      for(int j = 0; j < m; j++){
        ret = min( ret, node[n - 2][i].dp[j]);
      }
    }
    cout << ret << endl ;
  }
}

Measured memory_bytes: 1732
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL sx;
    LL sy;
    LL tx;
    LL ty;

    cin >> sx >> sy >> tx >> ty;

    LL diff_x=tx-sx;
    LL diff_y=ty-sy;

    for(LL i=0; i<diff_x; i++){
        cout << 'R';
    }
    for(LL j=0; j<diff_y; j++){
        cout << 'U';
    }
    for(LL i=0; i<diff_x; i++){
        cout << 'L';
    }
    for(LL j=0; j<diff_y; j++){
        cout << 'D';
    }
    cout << 'D';
    for(LL i=0; i<=diff_x; i++){
        cout << 'R';
    }
    for(LL j=0; j<=diff_y; j++){
        cout << 'U';
    }
    cout << 'L';
    cout << 'U';
    for(LL i=0; i<=diff_x; i++){
        cout << 'L';
    }
    for(LL j=0; j<=diff_y; j++){
        cout << 'D';
    }
    cout << 'R';
    cout << endl;

    return 0;
}


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

int main(){
  string s; cin >> s;
  
  if(s == "SUN") cout << 7 << endl;
  if(s == "MON") cout << 6 << endl;
  if(s == "TUE") cout << 5 << endl;
  if(s == "WED") cout << 4 << endl;
  if(s == "THU") cout << 3 << endl;
  if(s == "FRI") cout << 2 << endl;
  if(s == "SAT") cout << 1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int a[202020], b[202020];
typedef long long ll;
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)scanf("%d", &a[i]);
	for (int i = 0; i < num; i++)scanf("%d", &b[i]);
	vector<int>v;
	for (int i = 0; i < num; i++)if (b[(i + num - 1) % num] + b[(i + 1) % num] <= b[i] - a[i])v.push_back(i);
	ll ans = 0;
	for (;;)
	{
		if (v.empty())break;
		int z = v[v.size() - 1];
		v.pop_back();
		int s = (z + num - 1) % num, t = (z + 1) % num;
		if (b[s] + b[t] <= b[z] - a[z])
		{
			int x = (b[z] - a[z]) / (b[s] + b[t]);
			ans += x;
			b[z] -= (b[s] + b[t])*x;
			v.push_back(s), v.push_back(t);
		}
	}
	for (int i = 0; i < num; i++)
	{
		if (a[i] != b[i])
		{
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 2804
s = gets.chomp
t = gets.chomp

arr_s = s.chars.map(&:ord).sort
arr_t = t.chars.map(&:ord).sort.reverse

min = [s.size, t.size].min

min.times do |i|
    if arr_t[i] > arr_s[i]
        puts "Yes"
        exit
    elsif arr_t[i] < arr_s[i]
        puts "No"
        exit
    end

    if i == min - 1 && t.size == min
        puts "No"
        exit
    end
end

puts "Yes"

Measured memory_bytes: 1788
import sys
n = int(input())
lis = list(map(int,input().split()))
count = 0
mi = 0
for i,l in enumerate(lis):
    if i == 0:
        mi = l
        count += 1
    else:
        if l < mi:
            mi = l
        if mi >= l:
            count += 1
print(count)

Measured memory_bytes: 24744
# -*- coding: utf-8 -*-

N = int(input())
count = 0

for i in range(1, N + 1):
    a = []
    if i % 2 == 0:
        continue

    for j in range(1, i + 1):
        if i % j == 0:
            a.append(j)

    if len(a) == 8:
        count += 1

print(count)




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

int main() {
	long long N;
	double ANS = 0;
	pair<double, double> P[100], SUM[110] = {};
	cin >> N;
	for (int i = 0; i < N; i++) cin >> P[i].first >> P[i].second;
	sort(P, P + N, [](pair<double, double> P1, pair<double, double> P2) {return atan2l(P1.second, -P1.first) > atan2l(P2.second, -P2.first); });
	for (int i = 0; i < N; i++) {
		SUM[i + 1].first = SUM[i].first + P[i].first;
		SUM[i + 1].second = SUM[i].second + P[i].second;
	}
	for (int L = 1; L <= N; L++) {
		for (int R = 1; R <= N; R++) {
			if (L <= R) {
				double DX = SUM[R].first - SUM[L - 1].first;
				double DY = SUM[R].second - SUM[L - 1].second;
				ANS = max(ANS, sqrt(DX * DX + DY * DY));
			}
			else {
				double DX = SUM[N].first - (SUM[L - 1].first - SUM[R].first);
				double DY = SUM[N].second - (SUM[L - 1].second - SUM[R].second);
				ANS = max(ANS, sqrt(DX * DX + DY * DY));
			}
		}
	}
	printf("%.12lf\n", ANS);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;


int main(){

	int w[31];
	
	int n,m;
	int a,b;

	for(int i=0;i<31;i++)w[i]=i;

	cin>>n>>m;

	for(int i=0;i<m;i++){
		scanf("%d,%d",&a,&b);
		int temp=w[a];
		w[a]=w[b];
		w[b]=temp;
	}
	for(int i=1;i<=n;i++)cout<<w[i]<<endl;


	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    int length;
    length = S.length();
    int count = 0;
    for (int i=0,l=length-1;i<=l;i++,l--) {
        if (S[i] != S[l]) {
            count++;
        }
    }
    cout << count;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define ITR(i,x) for(auto i=(x).begin();i!=(x).end();++i)
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const ll mod = 1000000007;

ll mpow(ll x, ll n){ //x^n(mod) ←普通にpow(x,n)では溢れてしまうため，随時mod計算 2分累乗法だから早い
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}
ll inv_mod(ll a){return mpow(a,mod-2);}
template<ll mod> class modll {
 private:
  ll _num;
  modll set(ll num){ _num = num % mod; return *this; }
 public:
  modll(){ _num = 0; }
  modll(ll num){ _num = num % mod; }

  modll operator= (ll x){ return set(x % mod); }
  modll operator+ (ll x){ return modll<mod>(_num + (x % mod)); }
  modll operator- (ll x){ return modll<mod>(_num - (x % mod)); }
  modll operator* (ll x){ return modll<mod>(_num * (x % mod)); }
  modll operator+=(ll x){ return set(_num + (x % mod)); }
  modll operator-=(ll x){ return set(_num - (x % mod)); }
  modll operator*=(ll x){ return set(_num * (x % mod)); }

  explicit operator ll() { return _num; }
  friend ostream& operator<<(ostream &os, const modll<mod> &x){ os << x._num; return os; }
};
class UnionFind{//UnionFind木
 private:
    vector<int> Parent;
 public:
    UnionFind(int N){
        for(int i=0;i<N;i++) Parent.push_back(-1);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A]=root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B);
        Parent[A]-=Parent[B];
        Parent[B]=A;
    }
};
bool square(ll a){ll n=(ll)sqrt(a);return a==n*n;}
int digitsum(ll N,int a){
    if(N==0) return 0;
    int ret=0;
    ret+=digitsum(N/a,a)+N%a;
    return ret;
}
int gcd(int x,int y){return y ? gcd(y,x%y) : x;};//xとyの最大公約数
int lcm(int x,int y){return x*y/gcd(x,y);}//xとyの最小公倍数

class Factorial{//階乗とその逆元を求めて計算に利用するクラス
 private:
    vector<ll> fac;
 public:
    
    Factorial(ll N){
        fac.push_back(1);
        for(int i=0;i<N;i++) fac.push_back(fac[i]*(i+1)%mod);
    }

    ll fact(ll a){return fac[a];}
    ll ifact(ll a){return inv_mod(fac[a]);}

    ll cmb(ll a,ll b){
        if(a==0&&b==0) return 1;
        if(a<b||a<0) return 0;
        ll tmp =ifact(a-b)*ifact(b)%mod;
        return tmp*fac[a]%mod;
    }
};

int main(){
    int N,K;
    cin>>N>>K;
    if(K==1) cout<<0<<endl;
    else cout<<N-K<<endl;
}

Measured memory_bytes: 256
import sys
#input = sys.stdin.buffer.readline

def main():
    L = str(input())
    MOD = 10**9+7
    dpa = [1]
    dpb = [2]
    N = len(L)
    for i in range(1,N):
        if L[i] == "1":
            dpa.append((dpa[-1]*3+dpb[-1])%MOD)
            dpb.append((dpb[-1]*2)%MOD)
        else:
            dpa.append((dpa[-1]*3)%MOD)
            dpb.append((dpb[-1])%MOD)
            
    print((dpa[-1]+dpb[-1])%MOD)

if __name__ == "__main__":
    main()

Measured memory_bytes: 11028
#include<bits/stdc++.h>
using namespace std;
double arr[3050], dp[3050][3050];
int main()
{
	int a; cin >> a;
	for(int i=1; i<=a; i++)
		cin >> arr[i];
	dp[0][0] = 1;
	for(int i=0; i <= a; i++)
	{
		for(int j=i; j<=a; j++)
		{
			dp[i + 1][j + 1] += dp[i][j] * arr[j + 1];
			dp[i][j + 1] += dp[i][j] * (1 - arr[j + 1]);
		}
	}
//	for(int i=1; i<=a; i++)
//	{
//		for(int j=1; j<=a; j++)
//			cout << dp[i][j] << ' ';
//		cout << '\n';
//	}
	double res = 0;
	for(int i=(a + 1) / 2; i <= a; i++)
		res += dp[i][a];
	printf("%.10lf\n",res);
	return 0;
}

Measured memory_bytes: 71936
# coding: utf-8
# Here your code !
import collections
s=int(input())
deq =collections.deque()

for i in range(s):
    n=input().split()
    if n[0]=="insert":
        deq.appendleft(n[1])
    elif n[0]=="delete":
        try:
            deq.remove(n[1])
        except ValueError:
            pass
    elif n[0]=="deleteFirst":
        deq.popleft()
    elif n[0]=="deleteLast":
        deq.pop()
        
print(" ".join(list(deq)))

Measured memory_bytes: 71792
#define rep(i,n) REP(i,0,n)
#define REP(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

ll DIV = (ll)1e9+7;
ll Fibo[(ll)1e5+100];
ll GetFibo (ll id) {
   if (!Fibo[id]) {
      Fibo[id] = (GetFibo(id-2) + GetFibo(id-1))%DIV;
   }
   return Fibo[id];
}

int main(void) {
   ll N,M;
   cin>>N>>M;
   ll A[M];
   rep(i,M) {
      cin>>A[i];
   }
   rep(i,N) Fibo[i] = 0;
   Fibo[0] = 1;
   Fibo[1] = 1;
   Fibo[2] = 2;

   ll ans = 1;
   if (M == 0) ans = GetFibo(N-0);
   else {
      ans *= GetFibo(A[0]-1-0);
      ans = ans%DIV;
      ans *= GetFibo(N-A[M-1]-1);
      ans = ans%DIV;
      rep(i,M-1) {
         if (A[i+1]-A[i]<=1) ans *= 0;
         else ans *= GetFibo(A[i+1] - A[i]-2);
         ans = ans%DIV;
      }
   }
   cout<<ans%DIV<<endl;

   return 0;
}

Measured memory_bytes: 2560
// Ninjo ~ khaledalam.net@gmail.com
#include <bits/stdc++.h>
using namespace std;
#define sz(A)     (int)(A).size()
#define all(B)     (B).begin(),(B).end()
#define file       freopen("input.txt", "r", stdin)
#define ios        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main() {
//	file;
	int w, h, n;
	cin >> w >> h >> n;
	int ws=0,hs=0,we=w,he=h;
	while (n--) {
		int a, b, type;
		cin >> a >> b >> type;
		switch (type) {
		case 1: {
			ws = max(ws,a);
			break;
		}
		case 2: {
			we=min(we,a);
			break;
		}
		case 3: {
			hs=max(hs,b);
			break;
		}
		case 4: {
			he=min(he,b);
			break;
		}
		}

	}
//	cout<<ws<<" "<<we<<" "<<hs<<" "<<he<<endl;
if(ws >= we || hs >= he){
	puts("0");
	return 0;
}
	cout<<abs(ws-we)*abs(hs-he);
}


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

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

signed main() {
    vector<ll> v, dp(100001,1e10);
    v.push_back(1);
    for (ll x=6; x<=100000; x*=6) v.push_back(x);
    for (ll x=9; x<=100000; x*=9) v.push_back(x);
    dp[0]=0;
    rep(i,0,dp.size()){
        rep(j,0,v.size()){
            if(i+v[j]<dp.size())
                dp[i + v[j]] = min(dp[i + v[j]], dp[i]+1);
        }
    }

    ll n;
    cin>>n;
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=998244353;
char s[200005];
int lef[200005],rig[200005];
int main()
{
	int n,k,c;
	sc(n);sc(k);sc(c);
	getchar();scs(s+1);
	int i=1;
	while(s[i]!='o')i++;
	int end=1;
	lef[end]=i;
	for(;i<=n;i++){
		if(s[i]=='o'&&i-lef[end]>=c+1)lef[++end]=i;
	}i=n;
	if(end>k)return 0;
	while(s[i]!='o')i--;
	rig[end]=i;
	for(;i>=1;i--){
		if(s[i]=='o'&&rig[end]-i>=c+1)rig[--end]=i;
	}rep(i,1,k){
		if(lef[i]==rig[i])pf("%d\n",lef[i]);
	}
}


Measured memory_bytes: 3200
#include <stdio.h>

int main(void){
        int n, i;
        int a[100]={};

        scanf("%d", &n);

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

        for( i=n-1 ; i>=0 ; i-- ){
                printf("%d", a[i]);

                if( i!=0 )
                        putchar(' ');
        }

        putchar('\n');

        return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,q; cin >> n >> q;
    string s; cin >> s;
    char t[q],d[q];
    rep(i,q){
        cin >> t[i] >> d[i];
    }
    int res1=-1,r=n;
    while(r-res1>1){
        int mid=(res1+r)/2;
        int now=mid;
        bool ok=0;
        rep(i,q){
            if(t[i]==s[now]){
                if(d[i]=='L') now-=1;
                else now+=1;
            }
            if(now<0) ok=1;
        }
        if(ok) res1=mid;
        else r=mid;
    }
    int l=-1,res2=n;
    while(res2-l>1){
        int mid=(res2+l)/2;
        int now=mid;
        bool ok=0;
        rep(i,q){
            if(t[i]==s[now]){
                if(d[i]=='L') now-=1;
                else now+=1;
            }
            if(n<=now) ok=1;
        }
        if(ok) res2=mid;
        else l=mid;
    }
    //cout <<  res1 << " " << res2 << endl;
    int fall= min(res1+1+(n-res2),n);
    cout << n-fall << endl;
}


Measured memory_bytes: 4164
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
 
 
template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}
 
  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }
 
  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}
 
  Mint inv(){return pow(MOD-2);}
 
  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}
 
  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}
 
  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}
 
  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}
 
  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}
 
 
template<typename T>
map<T, int> factorize(T x){
  map<T, int> res;
  for(int i=2;i*i<=x;i++){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}

int main()
{
    int N;
    scanf("%d", &N);
    Int A[N];
    for(int i = 0; i < N; ++i) scanf("%lld", &A[i]);

    map<Int,Int> LCM_fct;
    for(auto a : A){
        for(auto p:factorize(a)){
            if(LCM_fct[p.first] < p.second) LCM_fct[p.first] = p.second;
        }
    }

    using M = Mint<Int>;
    M lcm = 1LL;
    for(auto p:LCM_fct) {
        lcm *= M(p.first).pow(p.second);
    }

    M ans(0);
    for(auto a:A){
        ans += lcm/M(a);
    }
    printf("%lld\n", ans.v);
    return 0;
}

Measured memory_bytes: 896
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s1 = sc.next()
    val s2 = sc.next()
    val s3 = sc.next()
    println(problem059a(s1, s2, s3))
}

fun problem059a(s1: String, s2: String, s3: String): String {
    return (s1.take(1) + s2.take(1) + s3.take(1)).toUpperCase()
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    vector<string> res;
    Int n, d;
    while (cin >> n >> d and n) {
        vector<vector<Int>> v(n);
        for (Int i = 0; i < n; i++) {
            Int m;
            cin >> m;
            for (Int j = 0; j < m; j++) {
                Int x;
                cin >> x;
                v[i].push_back(x);
            }
        }
        vector<Int> sum(n, 0);
        for (Int i = 0; i < n; i++) {
            for (Int j = 0; j < (Int)v[i].size(); j++) {
                sum[i] += v[i][j];
            }
        }
        bool update = true;
        while (update) {
            update = false;
            for (Int i = 0; i < n; i++) {
                if (v[i].empty()) continue;
                sum[i] -= v[i].back();
                Int ma = -1;
                Int mi = INF;
                for (Int j = 0; j < n; j++) {
                    ma = max(ma, sum[j]);
                    mi = min(mi, sum[j]);
                }
                if (ma - mi <= d) {
                    v[i].pop_back();
                    update = true;
                } else {
                    sum[i] += v[i].back();
                }
            }
        }
        bool check = true;
        for (Int i = 0; i < n; i++) {
            if (not v[i].empty()) {
                check = false;
            }
        }
        res.push_back(check ? "Yes" : "No");
    }
    for (Int i = 0; i < (Int)res.size(); i++) {
        dump(res[i]);
    }
    return 0;
}



Measured memory_bytes: 3172
# ABC098C
N = int(input())
S = input()

all_W_E = [0, 0]
for s in S:
    if s == "W":
        all_W_E[0] += 1
    else:
        all_W_E[1] += 1

now_W = 0
now_E = 0
ans_list = [0] * N

for i in range(N):
    if S[i] == "W":
        ans_list[i] = (now_W + all_W_E[1] - now_E)
        now_W += 1
    else:
        ans_list[i] = (now_W + all_W_E[1] - now_E - 1)
        now_E += 1

##print(ans_list)
print(min(ans_list))

Measured memory_bytes: 15304
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N, M, R;
    cin>>N>>M>>R;
    vector<int> r(R);
    for (int &t:r)
        cin>>t, t--;
    int oo = 999999999;
    vector<vector<int>> D(N, vector<int>(N, oo));
    for (int i=0; i<M; i++)
    {
        int A, B, C;
        cin>>A>>B>>C;
        D[A-1][B-1] = D[B-1][A-1] = C;
    }
    for (int i=0; i<N; i++)
    for (int j=0; j<N; j++)
    for (int k=0; k<N; k++)
        D[j][k] = min(D[j][k], D[j][i]+D[i][k]);

    int ans = 0x7ffffff;
    sort(r.begin(), r.end());
    do
    {
        int a = 0;
        for (int i=0; i<R-1; i++)
            a += D[r[i]][r[i+1]];
        ans = min(ans, a);
    }
    while (next_permutation(r.begin(), r.end()));
    cout<<ans<<endl;
}


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

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

  auto six = vector<int>(7, 6);
  auto nine = vector<int>(7, 9);
  for (int i = 1; i <= 7; ++i) six[i] = six[i - 1] * 6;
  for (int i = 1; i <= 7; ++i) nine[i] = nine[i - 1] * 9;

  vector<int> v;
  v.insert(end(v), begin(six), end(six));
  v.insert(end(v), begin(nine), end(nine));
  sort(begin(v), end(v), greater<int>());
  v.push_back(1);

  auto dp = vector<int>(N + 1, 1e9);
  dp[0] = 0;
  for (int i = 0; i <= N; ++i) {
    for (auto&& x : v) {
      if (i < x) continue;
      dp[i] = min(dp[i], dp[i - x] + 1);
    }
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int d;
  cin >> d;
  if(d==25)cout << "Christmas" << endl;
  if(d==24)cout << "Christmas Eve" << endl;
    if(d==23)cout << "Christmas Eve Eve" << endl;
      if(d==22)cout << "Christmas Eve Eve Eve" << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans = max({a * c, a * d, b * c, b * d});
  cout << ans << endl;
}

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

typedef long long ll;

int main() {
    int N, D, maxD = -1;
    cin >> N;
    vector<int> A(N, 0);
    rep(i, N) {
        cin >> D;
        if (i == 0 && D != 0) {
            cout << 0 << endl;
            return 0;
        }
        A[D]++;
        maxD = max(maxD, D);
    }
    if (A[0] > 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1, MOD = 998244353;
    for (int i = 1; i <= maxD; i++) {
        if (A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
        rep(j, A[i]) {
            ans = (ans * A[i - 1]) % MOD;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int a[100];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }

    for (int k = 0; k < n; k++){
        if (k != 0){cout << ' ';}
        cout << a[k];
    }
    cout << endl;

    for (int i = 1; i < n; i++){
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;

        for (int k = 0; k < n; k++){
            if (k != 0){cout << ' ';}
            cout << a[k];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
int main() {
    int ans, length;
    string s;
    while(cin >> s) {
        length = s.size();
        ans = 0;
        for(int i = 2; i < length; i++) {
            if(s[i] == 'I' && s[i - 1] == 'O' && s[i - 2] == 'J') ans++;
        }
        cout << ans << endl;
        ans = 0;
        for(int i = 2; i < length; i++) {
            if(s[i] == 'I' && s[i - 1] == 'O' && s[i - 2] == 'I') ans++;
        }
        cout << ans << endl;
        ans = 0;
    }
}


Measured memory_bytes: 3088
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a > b {
		a, b = b, a
	}
	var ans string
	if a > 0 && b > 0 {
		ans = "Positive"
	}else if a < 0 && b < 0 {
		if (a-b+1)%2 == 0 {
			ans = "Positive"
		}else {
			ans = "Negative"
		}
	}else if a < 0 && b >0 {
		ans = "Zero"
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512