akhauriyash/Code-Regression huggingface dataset:
package main

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

const mod = 998244353
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	N := sc.i()
	firstHarf := make([]Bar, 0, N)
	secondHarf := make([]Bar, 0, N)
	up := '('
	down := ')'
	for i := 0; i < N; i++ {
		s := sc.s()
		m := 0
		p := 0
		//b := 0
		for _, r := range s {
			if r == up {
				p += 1
			} else if r == down {
				p -= 1
			}
			m = min(p, m)
		}

		if p == 0 && m == 0 {
			continue
		}
		if p >= 0 {
			b := Bar{-1 * m, p - m}
			firstHarf = append(firstHarf, b)
		} else {
			b := Bar{-1 * m, p - m}
			secondHarf = append(secondHarf, b)
		}
	}
	// sort
	sort.Slice(firstHarf, func(i, j int) bool {
		return firstHarf[i].A < firstHarf[j].A
	})
	sort.Slice(secondHarf, func(i, j int) bool {
		return secondHarf[i].B > secondHarf[j].B
	})
	h := 0
	for len(firstHarf) > 0 {
		bar := firstHarf[0]
		firstHarf = firstHarf[1:]
		h -= bar.A
		if h < 0 {
			fmt.Println("No")
			return
		}
		h += bar.B
	}
	for len(secondHarf) > 0 {
		bar := secondHarf[0]
		secondHarf = secondHarf[1:]
		h -= bar.A
		if h < 0 {
			fmt.Println("No")
			return
		}
		h += bar.B
	}
	if h != 0 {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}

type Bar struct {
	A int // -
	B int // +
}

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

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

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

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

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

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

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

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

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

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

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}


Measured memory_bytes: 18564
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

bool isNumber(char c) {
	return (c - '0') >= 0 && (c - '0') <= 9;
}

int main() {

	string s;
	cin >> s;
	reverse(allof(s));
	int n = (int)s.size();

	//dp[i][j] := i番目までの数字を見たときに，13で割ったあまりがjとなる場合の数
	vector<vector<ll>> dp(n + 1, vector<ll>(13, 0));

	// 各桁を13で割った時の余りを先に表にする
	vector<ll> modTable(n);
	modTable[0] = 1;
	Rep(i, 1, n) { // 0は1
		modTable[i] = (modTable[i - 1] * 10) % 13;
	}

	// 今のところの暫定の余りを求める
	int sum = 0;
	rep(i, n) {
		int value = s[i] - '0';
		if (value >= 0 && value <= 9) {
			sum += value * modTable[i];
		}
		sum %= 13;
	}

	dp[0][sum] = 1;

	rep(i, n) {
		rep(j, 13) {
			// ? なら 0 ~ 9の好きな数字が入る
			if (!isNumber(s[i])) {
				rep(num, 10) {
					dp[i + 1][(j + num * modTable[i]) % 13] += dp[i][j];
					dp[i + 1][(j + num * modTable[i]) % 13] %= mod;
				}
			}
			else { // ?じゃない
				dp[i + 1][j] += dp[i][j];
				dp[i + 1][j] %= mod;
			}
		}
	}

	cout << dp[n][5] << endl;

	return 0;
}


Measured memory_bytes: 14464
N, K = map(int, input().split(" "))
H = list(map(int, input().split(" ")))

costs = [0]*(N+10)
for i in range(1, N):
    j = max(0, i-K)
    h_i = H[i]
    costs[i] = min(cost+abs(h_i-h) for cost, h in zip(costs[j:i], H[j:i]))

print(costs[N-1])


Measured memory_bytes: 13980
#include<iostream>
using namespace std;
int main(){
    long long n,m,l,a[100][100],b[100][100],c[100][100]={};
    cin>>n>>m>>l;
    
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];
            
    for(int i=0;i<m;i++)
        for(int j=0;j<l;j++)
            cin>>b[i][j];
            
    for(int i=0;i<n;i++)
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++)
                c[i][j]+=a[i][k]*b[k][j];
            if(j==l-1)
                cout<<c[i][j]<<endl;
            else
                cout<<c[i][j]<<" ";
        }
}


Measured memory_bytes: 3328
import Control.Applicative
import qualified Control.Monad as Monad

main = loopPutNumbers

loopPutNumbers :: IO ()
loopPutNumbers = do
    [x,y] <- map (read :: String -> Int) . words <$> getLine
    Monad.when (x /= 0 || y /= 0) $ do
        putStrLn $ if (x < y)
                    then unwords $ show <$> [x,y]
                    else unwords $ show <$> [y,x]
        loopPutNumbers


Measured memory_bytes: 4092
#include <stdio.h>
int l[6] = {60, 80, 100, 120, 140, 160};
int g[6] = {2, 5, 10, 15, 20, 25};
int m[7] = {600, 800, 1000, 1200, 1400, 1600, 0};
int main() {
	int x, y, h, w, N, I, i, ans;
	while(1) {
		scanf("%d", &N);
		if(N == 0) break;
		ans = 0;
		for(I = 0; I < N; ++ I) {
			scanf("%d %d %d %d", &x, &y, &h, &w);
			for(i = 0; i < 6; ++ i) {
				if(x + y + h <= l[i] && w <= g[i]) {
					break;
				}
			}
			ans += m[i];
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << a * b / 2 << endl;
}


Measured memory_bytes: 256
package main

import . "fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	n,s,r,w :=0,"",0,0
	Scan( &n, &s)
	for _, c := range s {
		if c == 'R' {
			r++
		}
	}
	for _, c := range s[:r] {
		if c == 'W' {
			w++
		}
	}
	Print(w)
}


Measured memory_bytes: 3184
#include <cstdio>
#include <utility>
#include <algorithm>

using namespace std;

int main(){
  int N;
  int M;
  pair<int, int> ab[100001];  //first is end, second is start

  scanf("%d %d", &N, &M);
  

  for(int i=0; i < M; i++){
    int a, b;
    scanf("%d %d", &a, &b);
    ab[i].first = b;
    ab[i].second = a;
  }

  sort(ab, ab + M);

  int res = 0;
  int right = -1; // the left island of the newest bridge
  for(int i=0; i < M; i++){
    int a, b;
    a = ab[i].second;
    b = ab[i].first;

    // is shut?
    if(a <= right){
      // already shut
      continue;
    }

    right = b - 1;
    res++;
  }
  printf("%d\n", res);
  
  return 0;
}
  


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <climits>
#include <cfloat>

using namespace std;
using ll = long long int;

const ll MOD = 1000000007;

template<typename T>
int cin_vec(vector<T> &vec) {
    for (auto &i : vec) {
        cin >> i;
    }
    return 0;
}

template<typename T>
int cout_vec(vector<T> vec, bool insertNewLine = true) {
    if (insertNewLine) {
        for (const auto &i : vec) {
            cout << i << endl;
        }
    } else {
        for (const auto &i : vec) {
            cout << i << flush;
        }
    }
    return 0;
}

template<typename T>
ll min_vec(std::vector<T> vec) {
    auto iter = min_element(vec.begin(), vec.end());
    ll index = distance(vec.begin(), iter);
    return index;
}

template<typename T>
ll max_vec(std::vector<T> vec) {
    auto iter = max_element(vec.begin(), vec.end());
    ll index = distance(vec.begin(), iter);
    return index;
}

int main() {
    string s;
    cin >> s;
    string a = "00", b = "00";
    a[0] = s[0]; a[1] = s[1]; b[0] = s[2]; b[1] = s[3];
    int m, u;
    m = stoi(a); u = stoi(b);
    if (m == 0 || m > 12) {
        if (u == 0 || u > 12){
            cout << "NA" << endl;
            return 0;
        } else {
            cout << "YYMM" << endl;
            return 0;
        }
    } else {
        if (u == 0 || u > 12){
            cout << "MMYY" << endl;
            return 0;
        } else {
            cout << "AMBIGUOUS" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b;
 cin >> a >> b;
 if (a*2<=b&&a*4>=b&&b%2==0){
   cout << "Yes" << endl;
 }
 else{
   cout<< "No" << endl;
 }
}
 


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

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

Measured memory_bytes: 256
let a, b, k, f = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c, Printf.printf "%d\n"
let _ = if k >= (b - a + 2) / 2 then for i = a to b do f i done else (for i = a to a + k - 1 do f i done; for i = b - k + 1 to b do f i done)

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,cnt=100;
	cin>>a;
	for (int i=0;;i++)
	{
		cnt=cnt+cnt/100;
		if (cnt>=a)
		{
			cout<<i+1;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3676
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

class Edge {
public:
	long long int to;
	long long int max_flow;
	long long int rev;
};

class Dinic {
	int V;
public:
	vector<vector<Edge>>edge;
	vector<int>depth;
	vector<int>index;
	Dinic(int n) {
		n++;
		V = n;
		edge.resize(V);
		depth.resize(V);
		index.resize(V);
		return;
	}
	void Add_Edge(int l, int r, int max_flow) {
		edge[l].push_back({ r,max_flow,(int)edge[r].size() });
		edge[r].push_back({ l,0,(int)edge[l].size() - 1 });
		return;
	}
	void Check_Depth(int s) {
		for (int i = 0; i < V; i++) {
			depth[i] = INT_MAX;
		}
		depth[s] = 0;
		queue<int>Q;
		Q.push(s);
		while (!Q.empty()) {
			int cn = Q.front();
			Q.pop();
			for (auto i : edge[cn]) {
				if (i.max_flow > 0 && depth[i.to] == INT_MAX) {
					depth[i.to] = depth[cn] + 1;
					Q.push(i.to);
				}
			}
		}
		return;
	}
	long long int max_flow(int v, int g, long long int ret) {
		if (v == g) {
			return ret;
		}
		for (int i = index[v]; i < edge[v].size(); i++) {
			if (edge[v][i].max_flow > 0 && depth[v] < depth[edge[v][i].to]) {
				long long int d = max_flow(edge[v][i].to, g, min(ret, edge[v][i].max_flow));
				if (d > 0) {
					edge[v][i].max_flow -= d;
					edge[edge[v][i].to][edge[v][i].rev].max_flow += d;
					return d;
				}
			}
		}
		return 0;
	}
	long long Solve(int s, int g) {
		long long int ret = 0;
		while (1) {
			Check_Depth(s);
			if (depth[g] == INT_MAX) {
				return ret;
			}
			for (int i = 0; i < V; i++) {
				index[i] = 0;
			}
			long long int add = 0;
			while ((add = max_flow(s, g, INT_MAX)) > 0) {
				ret += add;
			}
		}
		return ret;
	}
};

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

	cin >> N >> M >> K;
	int ans = 0;
	vector<int>a(N);
	vector<int>b(N);
	vector<bool>flag(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
		if (abs(a[i] - b[i]) <= M || (abs(a[i] - b[i]) >= K&&abs(a[i] - b[i]) <= M * 2)) {
			flag[i] = false;
			ans++;
		}
		else {
			flag[i] = true;
		}
	}
	Dinic d(N + 2);
	for (int i = 0; i < N; i++) {
		if (!flag[i]) {
			continue;
		}
		if (a[i] - b[i] < 0) {
			d.Add_Edge(N, i, 1);
		}
		else {
			d.Add_Edge(i, N + 1, 1);
		}
		for (int j = i + 1; j < N; j++) {
			if (!flag[j]) {
				continue;
			}
			int box = abs(a[i] - b[i] + a[j] - b[j]);
			if (box <= M || (box >= K&&box <= M * 2)) {
				if (a[i] - b[i] < 0) {
					d.Add_Edge(i, j, 1);
				}
				else {
					d.Add_Edge(j, i, 1);
				}
			}
		}
	}
	ans += d.Solve(N, N + 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int [] occ = new int[(int)1e5+1];
		for (int i = 0; i < n; ++i) {
			++occ[sc.nextInt()];
		}
		int cnt = n/2, i = 0;
		while(cnt > 0) {
			int val = Math.min(cnt, occ[i]);
			cnt -= val;
			occ[i] -= val;
			++i;
		}
		--i;
		// i contains (n/2)th element
		int k = 0;
		while(i < occ.length && occ[i++] == 0) ++k;
		out.println(k);
		out.flush();
		out.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

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

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

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
	}
}


Measured memory_bytes: 34024
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int solve(int N){
	const int INF = 1000000000;
	vector<int> dist(N+1, INF);
	dist[N] = 0;
	priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> qu;
	qu.emplace(0, N);
	while(!qu.empty()){
		auto p = qu.top(); qu.pop();
		int start = (p.second == N ? 1 : 0);
		for(int i=start;i<10;i++){
			int next = (10 * p.second + i) % N;
			int ndist = p.first + i;
			if(ndist < dist[next]){
				dist[next] = ndist;
				qu.emplace(ndist, next);
			}
		}
	}
	return dist[0];
}

int main(){
	int N;
	while(cin >> N) cout << solve(N) << endl;
}


Measured memory_bytes: 2804
def main():
  h, w, k = map(int, input().split())
  s = [input() for _ in range(h)]
  ans = 0
  for i in range(2**h):
    for j in range(2**w):
      if z(s, b(j, w), b(i, h)) == k:
        ans += 1
  print(ans)


def z(s, row, col):
  return sum(
    sum(0 if s[i][j] == '.' or c or r else 1 for j, r in enumerate(row))
    for i, c in enumerate(col)
  )

def b(n, digit):
  return [n // (2**i) % 2 for i in range(digit)]

main()

Measured memory_bytes: 71840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
P s2p(string s){
  return P(stoi(s.substr(0,2)),stoi(s.substr(3,2)));
}
bool contain(string c,string p){
  P stc=s2p(c.substr(0,5));
  P enc=s2p(c.substr(6,5));
  P stp=s2p(p.substr(0,5));
  P enp=s2p(p.substr(6,5));
  //cout<<stc.first<<" "<<stc.second<<endl;
  //cout<<enc.first<<" "<<enc.second<<endl;
  //cout<<stp.first<<" "<<stp.second<<endl;
  //cout<<enp.first<<" "<<enp.second<<endl;
  return stp<=stc&&enc<=enp;
}
int main(){
  int k,n,m;
  cin>>k;
  string c[k];
  for(int i=0;i<k;i++) cin>>c[i];
  cin>>n;
  vector<string> t[n];
  for(int i=0,j;i<n;i++){
    string tmp;
    cin>>j;
    for(int a=0;a<j;a++){
      cin>>tmp;
      t[i].push_back(tmp);
    }
  }
  cin>>m;
  vector<string> s[m];
  for(int i=0,j;i<m;i++){
    string tmp;
    cin>>j;
    for(int a=0;a<j;a++){
      cin>>tmp;
      s[i].push_back(tmp);
    }
  }
  int ans=0;
  for(int i=0;i<k;i++){
    int a=0,b=0;
    for(int l=0;l<n;l++){
      bool f=0;
      for(int j=0;j<(int)t[l].size();j++){
    f|=contain(c[i],t[l][j]);
      }
      if(f) a++;
    }
    for(int l=0;l<m;l++){
      bool f=0;
      for(int j=0;j<(int)s[l].size();j++){
    f|=contain(c[i],s[l][j]);
      }
      if(f) b++;
    }
    //cout<<a<<" "<<b<<endl;
    ans+=min(a,b);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4684
#include <stdio.h>

int main(void)
{
    long int x, y, s;
    int n;

    scanf("%ld%ld", &x, &y);

    s=x;
    n=0;
    while (s<=y) {
        n++;
        s*=2;
    }

    printf("%d\n", n);

    return 0;
}

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

int main() {
  int old;
  cin >> old ;
  
  if ( old == 1 ) {
    cout << "Hello World" ;
  }
  
  else if ( old == 2 ) {
    int a,b;
    cin >> a >>b;
    cout << a+b;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main(){
	char a[3];
	cin>>a[0]>>a[1]>>a[2];
	for(int i=0;i<3;i++){
		if(a[i]=='1'){
			a[i]='9';
		}else{
			a[i]='1';
		}
	} 
	cout<<a[0]<<a[1]<<a[2]<<endl;
}

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

int main() {

  int n;
  while ( cin >> n ) {

    int cnt = 0;
    for ( int a = 0; a < 10; a++ ) {
      for ( int b = 0; b < 10; b++ ) {
	for ( int c = 0; c < 10; c++ ) {
	  for ( int d = 0; d < 10; d++ ) {
	    if ( a+b+c+d == n ) cnt++;
	  }
	}
      }
    }

    cout << cnt << endl;

  }

  return 0;

}

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

int num[100],top=0;

void push(int);
int pop(void);

int main(){
  int x,y;
  char S[100];

  while((scanf(" %s", S)) != EOF){
    if(S[0] == '+'){
    y = pop();
      x = pop();
      
      push(x + y);
    }
    else if(S[0] == '-'){
      y = pop();
      x = pop();
      
      push(x - y);
    }
     else if ( S[0] == '*' ){
       y = pop();
       x = pop();
       
       push(x * y);
     }
    /*  else if(S[0] == '/'){
       y = pop();
       x = pop();
       
       push(x / y);
     }
     else if(S[0] == '%'){
       y = pop();
       x = pop();
       
       push(x % y);
       }*/
     else push(atoi(S));
  }
  
    printf("%d\n",pop());
    
    return 0;
  }

  void push(int x){
    num[top] = x;
    top++;
  }

  int pop(){
    top--;
    
    return num[top];
  }
  
  



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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) {
        cin >> a[i];
    }
    int m;
    cin >> m;
    int p, x;
    REP(i, m) {
        cin >> p >> x;
        int t = 0;
        REP(j, n) {
            if (p == j + 1) {
                t += x; 
            } else {
                t += a[j];
            }
        }
        cout << t << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) {return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1;}
ll nck(int n, int k) { ll ret = 1; rep(i, k) {ret *= n - i; ret /= i + 1; } return ret; } // n <= 60
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n, m;
    cin >> n >> m;
    list<int> li[n];
    map<pii, int> mp; // あるスポーツ消したとき、O(1)で表のその人の消したい
    rep(i, n) rep(j, m) { int a; cin >> a; li[i].eb(a); mp[pii{i, a}] = j; }
    
    int deleted[n][m];
    fill_n(*deleted, n * m, 0);
    
    int ans = inf;
    rep(i, m) {
        int table[m + 1];
        fill_n(table, m + 1, 0);
        rep(j, n) table[*li[j].begin()]++;
        // rep(j, m) cout << table[j + 1] << " "; cout << endl;
        int tmp = 0;
        rep(j, m) chmax(tmp, table[j + 1]);
        chmin(ans, tmp);
        
        int mmax = -1, id = 0;
        rep(j, m) {
            if (mmax < table[j + 1]) {
                mmax = table[j + 1];
                id = j + 1;
            }
        }
        
        if (i == m - 1) continue;
        rep(j, n) deleted[j][mp[pii{j, id}]] = 1;
        rep(j, n) while (deleted[j][mp[pii{j, *li[j].begin()}]]) li[j].erase(li[j].begin());
        
    }
    out(ans);
}



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

int main(){
	char str[1000]={'\0'};
	char kai1[1000]={'\0'},kai2[1000]={'\0'};
	int i,ans=0,j;
	
	while(fgets(str,sizeof(str),stdin)!=NULL){
		if((strlen(str)-1)%2!=0){
			for(i=0;i<(strlen(str)-2)/2;i++)kai1[i]=str[i];
			for(i=strlen(str)-2,j=0;i>(strlen(str)-2)/2;i--,j++)kai2[j]=str[i];
			if(strcmp(kai1,kai2)==0)ans++;
		}
		else {
			for(i=0;i<=(strlen(str)-2)/2;i++)kai1[i]=str[i];
			for(i=strlen(str)-2,j=0;i>(strlen(str)-2)/2;i--,j++)kai2[j]=str[i];
			if(strcmp(kai1,kai2)==0)ans++;
		}
		for(i=0;i<1000;i++){
		str[i]='\0';
		kai1[i]='\0';
		kai2[i]='\0';
		}
	}
	printf("%d\n",ans);
return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    ll x;
    cin >> x;
    for (ll i=-1e3; i<=1e3; ++i) {
        for (ll j=-1e3; j<=1e3; ++j) {
            if (i*i*i*i*i - j*j*j*j*j == x) {
                cout << i << ' ' << j << '\n';
                return;
            }
        }
    }
    assert(false);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int n;cin>>n&&n;){
		vl a(n),b(n);
		rep(i,n) cin>>a[i]>>b[i];
		ll res=0;
		per(i,n){
			a[i]+=res;
			ll x=(a[i]+b[i]-1)/b[i]*b[i];
			res+=x-a[i];
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 1792
fun main() {
    val N = readLine()!!.split("").toMutableList()
    N.removeAt(N.size-1)
    N.removeAt(0)
    val total = N.map { it.toLong() }.sum()
    if (total % 9L == 0L) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 66996
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
ll N;

vector<char> calc(ll N) {
  vector<char> ret;
  while(N>0) {
    ll i = N%26ll;
    if (i==0) {
      ret.push_back('z');
      N-=26;
    }
    else {
      char c = i+'`';
      ret.push_back(c);
    }  
    N/=26;
  }
  return ret;
}

int main() {
  INCANT;
  cin >> N;
  vector<char> vec = calc(N);
  for (int i=vec.size()-1; i>=0; i--) {
    cout << vec[i];
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int s,w; cin >> s >> w;
    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

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

int linearSearch(int, int [], int);

int main(){
  int n,q,i,key,count=0;
  int S[100001];

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

  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&key);
    if(linearSearch(n, S, key) != -1) count++;
  }

  printf("%d\n",count);
  
  return 0;
}

int linearSearch(int n, int A[], int key){
  int i=0;

  A[n] = key;

  while(A[i] != key) i++;
  if(i == n) return -1;
  else return i;
}



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

static const double pi = 3.141592653589793;

int main(){
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double ans_sq;
  ans_sq = A * A + B * B - 2 * A * B * cos(abs(H / 12.0 +(M / 60.0) / 12.0 - M / 60.0) * 2.0 * pi);
  cout << fixed << setprecision(20);
  cout << sqrt(ans_sq) << endl;
}


Measured memory_bytes: 4180
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define PB push_back
#define MP make_pair

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

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
  int N, left, mid, right;
  bool left_male, mid_male, right_male;
  string str;
  cin >> N;
  left = 0; right = N-1;
  cout << left << endl;
  cin >> str;
  if (str[0] == 'V') return 0;
  left_male = (str[0]=='M') ? true : false;

  cout << right << endl;
  cin >> str;
  if (str[0] == 'V') return 0;
  right_male = (str[0]=='M') ? true : false;

  while (true) {
    mid = (right + left) / 2;
    // cout << left << " " << mid << " " << right << endl;
    // cout << (left_male?"M ":"F ") << (mid_male?"M ":"F ") << (right_male?"M ":"F ") << endl;
    cout << mid << endl;
    cin >> str;
    if (str[0] == 'V') return 0;
    mid_male = (str[0]=='M') ? true : false;

    if ((mid-left)&1) {
      if (left_male == mid_male) {
        right = mid;
        right_male = mid_male;
      } else {
        left = mid;
        left_male = mid_male;
      }
    } else {
      if (left_male == mid_male) {
        left = mid;
        left_male = mid_male;
      } else {
        right = mid;
        right_male = mid_male;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 852
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, m, a, b ] <- readInts
	ds <- takeWhile ( a <= ) <$> readInts
	print $ if m <= n - length ds
		then length ds
		else length $ dropWhile ( <= b ) $ reverse $ ds

Measured memory_bytes: 4308
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <numeric>
#include <sstream>

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


int main() {

	while(true){		
		int a0,L;cin >> a0 >> L;
		if(a0==0 && L ==0)break;


		int i=0,a=a0;
		vector<int> prev(1000050, -1);
		prev[a]=i;
		while(true){
			stringstream ss;ss << a;
			string stra;ss>> stra;
			while(stra.size()<L)stra='0'+stra;
			sort(stra.begin(),stra.end());
			
			int ma=atoi(stra.c_str());
			//ss.str("");ss << stra; ss>> ma;
			reverse(stra.begin(),stra.end());
			int Ma=atoi(stra.c_str());
			//ss.str("");ss << stra; ss >> Ma;

			a=Ma-ma;
			i++;
			if(prev[a]!=-1){
				cout << prev[a] <<" "<< a <<" "<<i-prev[a]<<endl;
				break;
			}
			prev[a]=i;
		}
	}

	return 0;
}

Measured memory_bytes: 5156
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val A, B = ni()
    if (B % A == 0) out.println(A + B)
    else out.println(B - A)
  }


  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  def debug(num: Long): Unit = {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}


Measured memory_bytes: 27080
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    int s_long, t_long, min_long; 
    std::string s, t;

    std::cin >> s >> t;
    s_long = s.length();
    t_long = t.length();
    min_long = std::min(s_long, t_long);

    int cnt, tmp;
    while(1){
        cnt = 0;
        for(int i = 0;i < s_long - 1;i++){
            if(s[i] > s[i + 1]){
                tmp = s[i];
                s[i] = s[i + 1];
                s[i + 1] = tmp;
            
                cnt++;
            }
        }
        if(cnt == 0){
            break;
        }
    }

    
    while(1){
        cnt = 0;
        for(int i = 0;i < t_long - 1;i++){
            if(t[i] < t[i + 1]){
                tmp = t[i];
                t[i] = t[i + 1];
                t[i + 1] = tmp;
            
                cnt++;
            }
        }
        if(cnt == 0){
            break;
        }
    }

    cnt = 0;
    if(s_long < t_long){
        for(int i = 0;i < min_long;i++){
            if(s[i] == t[i]){
                cnt++;
            }
            else{
                break;
            }
        }

        if(cnt == min_long){
            std::cout << "Yes";

            return 0;
        }
    }
    
    for(int i = 0;i < min_long;i++){
        if(s[i] < t[i]){
            std::cout << "Yes";

            return 0;
        }
        else if(s[i] != t[i]){
            break;
        }
    }

    std::cout << "No";


    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

int dp[3010][3010];
string x,y;

void chk(string a,string b)
{
	int l1=a.size();
	int l2=b.size();
	
	for(int i=1;i<l1;i++)
	{
		for(int j=1;j<l2;j++)
		{
			if(a[i]==b[j]) dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
}

void print(int i,int j)
{
	if(i==0 || j==0) return;
	if(x[i]==y[j])
	{
		print(i-1,j-1);
		cout<<x[i];
	}
	else if(dp[i-1][j]==dp[i][j]) print(i-1,j);
	else if(dp[i][j-1]==dp[i][j]) print(i,j-1);
}

int main()
{
	cin>>x>>y;
	x="2"+x;
	y="1"+y;
	chk(x,y);
	
	print(x.size()-1,y.size()-1);
		
	cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}


Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(1){
    Int n;
    cin>>n;
    if(n == 0) break;
    vector<Int> cycle(n);
    cin>>cycle;

    Int m;
    cin>>m;

    vector<Int> task(110, INF);
    for(Int i=0;i<m;i++){
      Int d, m;
      cin>>d>>m; d--;
      Min(task[d], m);
    }

    vector<vector<Int> > dp(111, vector<Int>(n, INF));
    dp[0][0] = 0;
    for(Int i=0;i<110;i++) //day
      for(Int j=0;j<n;j++){ // cycle
        if(dp[i][j] == INF) continue;
        if(cycle[j] > task[i]) continue;
        Min(dp[i+1][(j+1)%n], dp[i][j]);
        Min(dp[i+1][0], dp[i][j] + 1);
      }
    Int ans = INF;
    for(Int i=0;i<n;i++) Min(ans, dp[110][i]);
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3132
main(c,t){double*p=t,v,atof();for(;t=0,~scanf("%s%c",&t,&c);c&2&&printf("%f\n",*p))t<48?v=*p--,*p=t&1?t&2?t&4?*p/v:*p+v:*p-v:*p*v:(*++p=atof(&t));}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define setbits __builtin_popcount 
#define big 1e9+7
using namespace std;
ll n,k,m,flag = 1,mod,cnt;
ll a[500005],dp[3005][3005],arr[2];
string s;
int main()
{
	IOS
	cin>>n;
	ll x = 0,y = n-1;
	if((n+1)%2)
		flag = -1;
	for(int i = 0; i < n; ++i)
		cin>>a[i],dp[0][i] = a[i]*(flag);
	for(int i = 1; i < n; ++i)
	{
		for(int j = 0; j < n-i; ++j)
		{
			if((n+i+1)%2)
				dp[i][j] = min(dp[i-1][j+1]-a[j],dp[i-1][j]-a[j+i]);
			else dp[i][j] = max(dp[i-1][j+1]+a[j],dp[i-1][j]+a[i+j]);
			// cout<<dp[i][j]<<" "<<j<<" "<<i<<" "<<dp[i-1][j+1]<<" "<<dp[i-1][j]<<endl;
		}
	}
	cout<<dp[n-1][0]<<endl;
    return 0;
}

Measured memory_bytes: 71936
#include <iostream>
#include <algorithm>
int main(){
    int seq[10];
    for(int i = 1; i <= 5; i ++){
        std::cin >> seq[i];
    }
    int k;
    std::cin >> k;
    std::sort(seq + 1, seq + 1 + 5);
    int tmp = seq[5] - seq[1];
    if (tmp <= k) std::cout << "Yay!";
    else std::cout << ":(";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
#define N (int)1e6+10
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
using namespace std;



void solve()
{
	int k;
	cin>>k;
	
	int n,m;
	cin>>n>>m;
	
	for(int i=n;i<=m;i++)
	{
		if(i%k==0)
		{
			cout<<"OK"<<endl;
			return ;
		}
	}
	
	cout<<"NG"<<endl;
	return ;
	
	
	
		
	
}
signed main()
{
    
	nuenxfiu
	//TT
	solve();
     return 0;
}

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

int main(){
  int n;
  cin>>n;
  while(n--){
    int y,m,d;
    cin>>y>>m>>d;
    int sum=0;
    if(y%3==0){
      sum=201-(m-1)*20-d;
    }else{
      for(int i=m+1;i<=10;i++){
	sum+=19+i%2;
      }
      sum+=20-d+m%2;
    }
    for(int i=y+1;i<1000;i++){
      if(i%3==0){
	sum+=200;
      }else{
	sum+=195;
      }
    }
    cout<<sum<<endl;
  }
}

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

using namespace std;

struct sushi_t {
  int d;
  int t;
};

static int n, k;
static std::array<sushi_t, 100000> sushis{};
static std::array<int, 100000> worstSushis{0};
static std::array<int, 100000> replaceables{};

int64_t solve() {
  int64_t ret0 = 0;
  int64_t nn = 0;
  int replaceableIdx = 0;
  int i = 0;
  for (; i < k; ++i) {
    const auto& s = sushis[i];
    int const prev = worstSushis[s.t];
    worstSushis[s.t] = i + 1;
    ret0 += int64_t(s.d);
    if (!prev) {
      nn++;
    } else {
      replaceables[replaceableIdx++] = s.d;
    }
  }
  int64_t ret = ret0 + nn * nn;

  replaceableIdx--;
  for (++nn; nn <= k && replaceableIdx >= 0; ++nn, --replaceableIdx) {
    int replacement = 0;
    for (; i < n; ++i) {
      const auto& s = sushis[i];
      int const prev = worstSushis[s.t];
      worstSushis[s.t] = i + 1;
      if (!prev) {
        replacement = s.d;
        ++i;
        break;
      }
    }
    if (!replacement) {
      break;
    }
    ret0 -= int64_t(replaceables[replaceableIdx]);
    ret0 += int64_t(replacement);
    if (ret0 + int64_t(k) * int64_t(k) <= ret) {
      break;
    }
    ret = std::max(ret0 + nn * nn, ret);
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    auto& s = sushis[i];
    std::cin >> s.t >> s.d;
    s.t--;
  }
  std::sort(sushis.begin(), sushis.begin() + n,
            [](const auto& lhs, const auto& rhs) { return lhs.d > rhs.d; });
  std::cout << solve() << std::endl;
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>

int main () {
    int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N);
  vector<int> d(N);
  vector<pair<int,int>> red(N);
  vector<pair<int,int>> blue(N);
  for(int i = 0; i < N; i++){
    cin >> a[i] >> b[i];
    red[i] = make_pair(a[i],b[i]);
  }
 
  for(int i = 0; i < N; i++){
    cin >> c[i] >> d[i];
    blue[i] = make_pair(c[i],d[i]);
  }
 
  int num = 0;
  int ans = 0;
  sort(red.begin(),red.end());
  sort(blue.begin(),blue.end());
  int aka[N],ao[N];
 
  for(int i = 0; i < N; i++){
    aka[i] = 0;
    ao[i] = 0;
  }
  int flag = 0;
  for(int i = 0; i < N; i++){
    flag = 0;
    int max = -1;
    int mita = 0;
    for(int j = 0; j < N; j++){
      if(red[j].first < blue[i].first && red[j].second < blue[i].second && aka[j] == 0 && ao[i] == 0 ){
 
      if(red[j].second > max){ max = red[j].second; flag = j; mita = 1; }
    }
    }
    if(mita == 1){
    aka[flag] = 1;
    ao[i] = 1;
    ans++;
    }
    }
  cout << ans << endl;
    return 0 ;
}

 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
typedef long long ll;
using namespace std;

const ll INF = 10000000000000;

bool is_prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		// 素数ではない
		if (num % i == 0) return false;
	}

	// 素数である
	return true;
}

bool is_square_num(ll num) {
	double rest = fmod(sqrt(num), 1.0);

	if (rest > 0) return false;

	return true;
}

int main() {
	ll N; scanf("%lld", &N);
	ll ans;

	if (is_prime(N)) ans = N - 1;
	else if (is_square_num(N)) ans = 2 * (sqrt(N) - 1);
	else {
		ll min_sum = INF;
		for (ll num = 1; num < sqrt(N); ++num) {
			if (N % num == 0) min_sum = min(min_sum, N / num + num);
		}
		ans = min_sum - 2;
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;

    int odd = (N/2 + 1) / 2;
    int even = N/2 / 2;
    for(int i=1; i<=N/2; i++) {
        if(i%2 == 0) {
            cout << N-even-i/2 << ' ' << N-even+i/2 << endl;
        } else {
            cout << odd-i/2 << ' ' << odd+(i+1)/2 << endl;
        }
        if(--M == 0) break;
    }
    return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr ll INF = numeric_limits<int>::max() / 2;
constexpr ll MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    ll ma = -INF, mi = INF, sum = 0;
    for (int i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        ma = max(ma, a);
        mi = min(mi, a);
        sum += a;
    }
    cout << mi << " " << ma << " " << sum << endl;
}



Measured memory_bytes: 3128