akhauriyash/Code-Regression huggingface dataset:
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

void solve()
{
    IN(n);
    ll m = INF;
    ll count = 0;
    rep(i, n)
    {
        IN(p);
        if (m >= p) ++count;
        chmin(m, p);
    }
    cout << count << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

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

using namespace std;

int main() {
  int n,m;
  cin >> n >> m;
  int a[m];
  int b[m];
  int c[n];
  for(int i = 0; i < n; i++) {
    c[i] = 0;
  }
  for(int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i < m; i++) {
    c[a[i]-1]++;
    c[b[i]-1]++;
  }
  for(int i = 0; i < n; i++) {
    cout << c[i] << endl;
  }
}


Measured memory_bytes: 256
class BinaryTree
  class Node
    attr_accessor :key, :left, :right, :parent

    def initialize(key)
      @key = key
      @left = nil
      @right = nil
      @parent = nil
    end

    def add_left(node)
      @left = node
      node.parent = self
    end

    def add_right(node)
      @right = node
      node.parent = self
    end
  end

  attr_accessor :count

  def initialize
    @count = 0
    @root = nil
  end

  def insert(z)
    y = nil
    x = @root
    while x != nil do
      y = x
      if z.key < x.key then
        x = x.left
      else
        x = x.right
      end
    end
    
    if y == nil then
      @root = z
    elsif z.key < y.key
      y.add_left(z)
    else
      y.add_right(z)
    end
  end

  def find(z)
    x = @root
    while x != nil do
      if z == x.key then
        return true 
      elsif z < x.key then
        x = x.left
      elsif z > x.key then
        x = x.right
      end
    end
    return false
  end

  def print
    print_inorder
    print_preorder
  end

  def print_inorder
    node = @root
    array = []
    do_print_inorder(node, array) unless node == nil
    puts " #{array.join(' ')}"
  end

  def print_preorder
    node = @root
    array = []
    do_print_preorder(node, array) unless node == nil
    puts " #{array.join(' ')}"
  end

  private

  def do_print_inorder(node, array)
    do_print_inorder(node.left, array) if node.left != nil
    array << node.key
    do_print_inorder(node.right, array) if node.right != nil
  end

  def do_print_preorder(node, array)
    array << node.key
    do_print_preorder(node.left, array) if node.left != nil
    do_print_preorder(node.right, array) if node.right != nil
  end
end


# main
tree = BinaryTree.new
n = gets.chomp.to_i
(n).times do
  command, key = gets.chomp.split
  if command == "insert" then
    tree.insert(BinaryTree::Node.new(key.to_i))
  elsif command == "find" then
    puts "#{tree.find(key.to_i) ? "yes" : "no"}"
  elsif command == "print" then
    tree.print
  end
end

Measured memory_bytes: 75128
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
num=0
for s in range(3):
    num1=0
    for t in range(3):
        if A[s][t] in B:
            num1+=1
    if num1==3:
        num+=1
for a in range(3):
    num4=0
    for b in range(3):
        if A[b][a] in B:
            num4+=1
    if num4==3:
        num+=1
num2=0
for u in range(3):
    if A[u][u] in B:
        num2+=1
if num2==3:
    num+=1
num3=0
for v in range(3):
    if A[2-v][v] in B:
        num3+=1
if num3==3:
    num+=1
if num>0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 62168
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    string s;
    cin >> s;
    string ans;
    for(int i=0;i<s.size();i++){
        if(s[i]=='B'){
            if(ans.size()>0){
                ans.pop_back();
            }
            continue;
        }
        ans+=s[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int r[20000];
int main() {
	int n, s;
	while (cin >> n >> s&&n != 0 && s != 0) {
		for (int i = 0; i < n; i++) {
			cin >> r[i];
		}
		sort(r,r+n);
		reverse(r, r + n);
		int sum = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (r[i] + r[j] > s) sum++;
				else break;
			}
			if (r[i] + r[i] <= s) break;
		}
		cout << sum << endl;
	}
}

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

int main() {
  int n, m, ans = 0; cin >> n >> m;
  vector<int> h(n); rep(i, n) cin >> h[i];
  vector<vector<int>> g(n);
  rep(i, m) {
    int a, b; cin >> a >> b; a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  rep(i, n) {
    bool f = true;
    rep(j, g[i].size()) {
      if (h[i] <= h[g[i][j]])
        f = false;
    }
    if (f) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct SegmentTree {
private:
    int n;
    vector<ll> node;
 
public:
    SegmentTree() {
        int sz = 100050;
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);
        for(int i=0; i<sz; i++) node[i+n-1] = 0;
        for(int i=n-2; i>=0; i--) node[i] = max(node[2*i+1], node[2*i+2]);
    }
 
    void update(int x, ll val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = max(node[2*x+1], node[2*x+2]);
        }
    }
    // hannkaikukann 
    ll getmax(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];
 
        ll vl = getmax(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getmax(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};

ll N;
ll x[105000];
ll xsum;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    SegmentTree seg;
    for(int i = 0; i < N; i++) {
        cin >> x[i];
        xsum += x[i];
        ll val = seg.getmax(0, x[i]);
        seg.update(x[i], val + x[i]);
    }
    cout << xsum - seg.getmax(0, N + 1) << endl;
    return 0;
}


Measured memory_bytes: 5712
import sys
from pprint import pprint

R,C,K=map(int,input().split())

grid=[[0]*C for _ in range(R+1)]
for _ in range(K):
    r,c,v=map(int,input().split())
    grid[r][c-1]=v

for i in range(1,R+1):
    cell=[0]*4
    for j in range(C):
        cell[0]=max(cell[0],grid[i-1][j])
        for k in range(2,-1,-1):
            cell[k+1]=max(cell[k+1],cell[k]+grid[i][j])
        grid[i][j]=max(cell)

print(grid[-1][-1])


Measured memory_bytes: 146828
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a, b;
    cin >> a >> b;
    a += b;
    int c = stoi(a);
    for (int i = 3; i < 318;i++){
        if(i*i==c){
            cout << "Yes" << endl;
            break;
        }
        if(i==317){
            cout << "No" << endl;
        }
    }
        return 0;
}

Measured memory_bytes: 3580
R, G, B, N = map(int, input().split())

i = 0
cnt = 0

while i*R <= N:
  j = 0
  while i*R + j*G <= N:
    if (N - i*R - j*G) % B == 0:
      cnt += 1
    j += 1
  i += 1
  
print(cnt)

Measured memory_bytes: 66664
def solve():
  while(1):
    n = int(raw_input())
    if n == 0:
      break
    score_a, score_b = 0, 0
    while(n > 0):
      a, b = map(int, raw_input().split())
      if a > b:
        score_a += a + b
      elif b > a:
        score_b += a + b
      else:
        score_a += a
        score_b += b
      n -= 1
    print score_a, score_b

if __name__ == '__main__':
  solve()

Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;




int main() {
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> team(N), food(N);
    for (int i = 0; i < N; i++) {
        cin >> team.at(i);
    }
    for (int i = 0; i < N; i++) {
        cin >> food.at(i);
    }
    sort(ALL(team));
    sort(rALL(food));

    
    int64_t left = -1, right = 1000000000001, ans;

    while(right - left > 1) {
        int64_t mid = (left + right) / 2, sum = 0;
        for (int i = 0; i < N; i++) {
            sum += max(int64_t(0), team.at(i) - mid / food.at(i));
        }
        if (sum >  K) {
            left = mid;
        }
        else {
            right = mid;
        }
        ans = right;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int q, i, a, b;
		StringBuilder str = new StringBuilder();
		String order;
		try (Scanner sc = new Scanner(System.in)) {
			str = str.append(sc.next());
			q = sc.nextInt();
			for(i = 0; i < q; i++) {
				order = sc.next();
				a = sc.nextInt();
				b = sc.nextInt();
				StringBuilder a_b = new StringBuilder();
				a_b = a_b.append(str.substring(a,b + 1));
				if(order.equals("print")) {
					System.out.println(a_b);
				}else if(order.equals("reverse")){
					a_b.reverse();
					str = str.replace(a, b + 1, a_b.toString());
				}else if(order.equals("replace")) {
					str = str.replace(a, b + 1, sc.next());
				}
			}
		}
	}
}



Measured memory_bytes: 29488
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


MOD = int(1e09) + 7
# INF = int(1e15)


def solve():
    MAX = 2 * 10 ** 5 + 10
    fac = [0] * MAX
    inv = [0] * MAX
    finv = [0] * MAX
    fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1]*i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    def cmb(n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
    N, K = Scanner.map_int()
    ans = 0
    for i in range(min(N - 1, K) + 1):
        ans += cmb(N, i) * cmb(N - 1, i)
        ans %= MOD
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


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

int main(){

	int N,M,p;
	cin >> N >> M >> p;

	int d[10001];
	d[0] = p;

	for (int i = 1; i <= M; i++){
		cin >> d[i];
	}

	sort(d, d + M + 1);

	int c_min = N - 1;

	for (int i = 0; i < M + 1; i++){
		int q = d[i];
		int r1 = d[(i - 1 + M + 1) % (M + 1)];
		int r2 = d[(i + 1) % (M + 1)];

		int c1 = ((p - q + N) % N) * 2 + (r1 - p + N) % N;
		int c2 = ((q - p + N) % N) * 2 + (p - r2 + N) % N;

		c_min = min(c_min, min(c1, c2));
	}
	cout << c_min * 100 << endl;

	return 0;
}

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


int main(){

	char x[1001];
	int i, v;

	while(1){

		scanf( "%s", x );
		
		if( atoi(x) == 0) break;

		v = 0;
		for( i=0; i<strlen(x); i++)
			v += x[i]-0x30;

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

	return 0;

}

Measured memory_bytes: 544
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define FOR(i,x,y) for(int (i)=(x); (i)<(y);(i++))
#define INT long long
#define MOD 1000000007
#define oo 978654321
#define OO 9999999987654321ll
using namespace std;
INT n, a[55], p, dt[55][3];
INT dp(int x, int y)
{
    if( x == n ) return y==p;
    if( ~dt[x][y] ) return dt[x][y];
    INT &ret = dt[x][y] = 0;
    return ret = dp(x+1, (y+a[x])%2) + dp(x+1, y);
}
int main()
{
    ios::sync_with_stdio(false);
    memset(dt, -1, sizeof(dt));
    cin>>n>>p;
    for(int i = 0 ; i < n ; i++ ) cin>>a[i];
    cout<<dp(0, 0)<<endl;
    return 0;
}


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

bool query(VS& vs){
  cout << vs[0] << endl << vs[1] << endl;
  char c; cin >> c;
  return c == 'T';
}

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

  int N; cin >> N;
  int len = 0;
  string ch = ".#";
  VS vs(2);
  bool up = true;
  while(up && len < N){
	up = false;
	VS qs = vs;
	qs[0] += "x";
	qs[1] += "x";
	REP(i,2) REP(j,2){
	  qs[0][len] = ch[i];
	  qs[1][len] = ch[j];
	  if(query(qs)){
		i = j = 2;
		vs = qs;
		++len;
		up = true;
	  }
	}
  }

  up = true;
  while(up && len < N){
	up = false;
	VS qs(2);
	qs[0] = "x" + vs[0];
	qs[1] = "x" + vs[1];
	REP(i,2) REP(j,2){
	  qs[0][0] = ch[i];
	  qs[1][0] = ch[j];
	  if(query(qs)){
		i = j = 2;
		vs = qs;
		++len;
		up = true;
	  }
	}
  }
  
  return 0;
}


Measured memory_bytes: 724
def solve():
    N,M,X = map(int,input().split())
    C = []
    A = []
    for _ in range(N):
        CA = list(map(int,input().split()))
        C.append(CA[0])
        A.append(CA[1:])
    
    ans = float('inf')
    for i in range(1<<N):
        cost_sum = 0
        power = [0] * M
        for j in range(N):
            if (i >> j) & 1:
                cost_sum += C[j]
                for k in range(M):
                    power[k] += A[j][k]
        
        isOk = True
        for j in range(M):
            if power[j] < X:
                isOk = False
                break
        
        if isOk:
            ans = min(ans, cost_sum)
    
    print(ans if ans != float('inf') else -1)
        
if __name__ == '__main__':
    solve()


Measured memory_bytes: 74284
#include<stdio.h>
#include<string.h>
#define it register int
#define ct const int
#define il inline
using namespace std;
typedef long long ll;
#define rll register ll
#define cll const ll
const int N=1000005;
int n,T,s[N],mx[N];
char S[N]; 
il int Min(ct p,ct q){return p<q?p:q;}
int main(){
	scanf("%s",S+1),n=strlen(S+1);it i;
	for(i=1;i<=n;++i) s[i]=s[i-1]+(S[i]=='1'?1:-1);
	auto cal = [&] (ct x){
		for(it i=1,p=0;i<=n;++i){
			if(S[i]!='?') s[i]=s[i-1]+(S[i]=='1'?1:-1);
			if(S[i]=='?') mx[i]+(p+1<<1)<=x?s[i]=s[i-1]+1,++p:s[i]=s[i-1]-1;
		}
		it mn=s[0];
		for(it i=1;i<=n;++i) mn=(s[i]<mn?s[i]:mn);
		return mn;
	};
	for(i=n-1,mx[n]=s[n];~i;--i) mx[i]=(mx[i+1]>s[i]?mx[i+1]:s[i]);
	printf("%d\n",Min(mx[0]-cal(mx[0]),mx[0]+1-cal(mx[0]+1)));
	return 0;
}


Measured memory_bytes: 10524
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<int> A(N),B(N),C(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  for(int i=0; i<N; i++){
    cin >> B[i];
  }
  for(int i=0; i<N; i++){
    cin >> C[i];
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  ll ans = 0;
  for(int i=0; i<N; i++){
    ll up,down;
    up = lower_bound(A.begin(),A.end(),B[i]) - A.begin();
    down = upper_bound(C.begin(),C.end(),B[i]) - C.begin();
    down = N - down;
    ans += up*down;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

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

  vector<ll> A = {2, 3, 25};

  ll cnt = 5;
  while (A.size() < N)
  {
    if (N - A.size() == 1)
      A.push_back(30000);
    else
    {
      while (cnt == 25 || !(cnt % 2 == 0 || cnt % 3 == 0 || cnt % 5 == 0))
      {
        cnt++;
      }
      A.push_back(cnt);
      A.push_back(30000 - cnt);
      cnt++;
    }
  }

  for (ll i = 0; i < N; i++)
  {
    cout << A.at(i) << ((i == N - 1) ? '\n' : ' ');
  }

  /*
  ll S = accumulate(A.begin(), A.end(), 0LL);
  map<ll, ll> mp;
  for (ll i = 0; i < N; i++)
  {
    ll a = A.at(i), b = S - a;
    if (!(a % 2 == 0 || a % 3 == 0 || a % 5 == 0))
    {
      cerr << "No_0" << endl;
      return 0;
    }
    mp[a]++;
  }
  cerr << mp.size() << endl;
  cerr << ((mp.size() == N) ? "Yes" : "No_1") << endl;

  for (auto x : mp)
  {
    if (x.second == 2)
      cerr << x.first << endl;
  }
  */
}

Measured memory_bytes: 576
#include <stdio.h>
int main(void) {
	int a[9999], i;
	i = 0;
	while (1) {
		i = i + 1;
		scanf("%d", &a[i]);
		if (a[i] == 0) {
			break;
		}
	}
	i = 0;
	while (1) {
		i=i +1;
		if (a[i] == 0) {
			break;
		}
		printf("Case %d: %d\n", i, a[i]);
	}
	return 0;
}

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

using namespace std;


#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d %d", &a, &b)
#define siii(a, b, c) scanf("%d %d %d", &a, &b, &c)

#define sl(a) scanf("%I64d", &a)
#define sll(a, b) scanf("%I64d %I64d", &a, &b)
#define slll(a, b, c) scanf("%I64d %I64d %I64d", &a, &b, &c)

#define outi(a) printf("%d\n", a)
#define outii(a, b) printf("%d %d\n", a, b)
#define outiii(a, b, c) printf("%d %d %d\n", a, b, c)

#define outl(a) printf("%I64d\n", a)
#define outll(a, b) printf("%I64d %I64d\n", a, b)
#define outlll(a, b, c) printf("%I64d %I64d %I64d\n", a, b, c)

#define cel(n, k) ((n-1)/k+1)
#define sets(a) memset(a, -1, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))


#define fr(i, n) for(ll i=0; i<n;i++)
#define fr1(i, n) for(ll i=1; i<=n;i++) 

#define readf(f) freopen(f, "r", stdin)
#define writef(f) freopen(f, "w", stdout)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()

template< class T > T sq(T x) { return x * x; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

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


int main()
{
	map<string, int> day;

	day["SAT"] = 1;
	day["SUN"] = 2;
	day["MON"] = 3;
	day["TUE"] = 4;
	day["WED"] = 5;
	day["THU"] = 6;
	day["FRI"] = 7;

	string s;

	cin>>s;

	int ans = (2-day[s]+7)%7;

	if(!ans)
		puts("7");
	else
		outi(ans);


    return 0;
}


Measured memory_bytes: 256
x = int(input())

if (400 <= x <= 599):
  print(8)
elif (600 <= x <= 799):
  print(7)
elif (800 <= x <= 999):
  print(6)
elif (1000 <= x <= 1199):
  print(5)
elif (1200 <= x <= 1399):
  print(4)
elif (1400 <= x <= 1599):
  print(3)
elif (1600 <= x <= 1799):
  print(2)
elif (1800 <= x <= 1999):
  print(1)

Measured memory_bytes: 9196
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const dist = (y,z) => {
    let sum = 0
    for(let i = 0; i<y.length; i++){
        sum += (y[i]-z[i])**2
    }
    return Math.sqrt(sum)
}
const Main = () => {
    const [N, D] = nextIntArray()
    let x = []
    while(hasNext()){
        x.push(nextIntArray())
    }
    let cnt = 0
    for(let i =0;i<x.length;i++){
        for(let j = i+1; j<x.length;j++){
            if(i == j) continue
            if(Number.isInteger(dist(x[i], x[j]))) cnt++
        }
    }
    console.log(cnt)
}
Main()


Measured memory_bytes: 29676
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>?5*8},'ruby',$0)
require 'set'
def dfs(z,c)
	f=S[c]
	r=[0,c]
	G[c].each{|e|
		next if e==z
		t=dfs(c,e)
		r=[r,[t[0]+f,t[1]]].max
	}
	r
end
N=gets.to_i
G=Hash.new{|h,k|h[k]=Set.new}
(N-1).times{
	a,b=gets.split.map(&:to_i)
	G[a-1]<<b-1
	G[b-1]<<a-1
}
A=gets.chomp
(p A.count(?W);exit) if A.count(?W)<2
r=N-1
Q=N.times.select{|i|G[i].size==1&&A[i]==?B}
while !Q.empty?
	c=Q.shift
	r-=1
	G[c].each{|e|
		G[e].delete c
		Q<<e if G[e].size==1&&A[e]==?B
	}
	G.delete c
end
r*=2
S={}
G.keys.each{|k|
	if G[k].empty?
		G.delete k
	else
		r+=S[k]=((A[k]==?B?0:1)+G[k].size)%2
	end
}
p r-dfs(-1,dfs(-1,G.each_key.first)[1])[0]*2

Measured memory_bytes: 371756
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
double a,b;
bool f(double cnt)
{
    if(floor(cnt*0.08)==a&&floor(cnt*0.1)==b)
    {
        return 1;
    }
    return 0;
}
int main()
{
    //IOS;
    cin>>a>>b;
    for(int i=1;i<=100000;i++)
    {
        if(f(i))
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str_scan = scan.nextLine();
    // スペース区切りで分ける
    var str = str_scan.split(" ");
    var N = Integer.parseInt(str[0]);
    var D = Integer.parseInt(str[1]);

    double Distance = Math.pow(D,2);

    int ans = 0;
    double x = 0;
    double y = 0;
    double z = 0;

    // read X,Y

    for (var i=0; i<N; i++){
      str_scan = scan.nextLine();
      str = str_scan.split(" ");
      x = Math.pow(Double.parseDouble(str[0]),2);
      y = Math.pow(Double.parseDouble(str[1]),2);

      z = x + y;

      if ( z <= Distance ) {
        ans++;
      }
    }

    System.out.println(ans);
    scan.close();
  }
}

Measured memory_bytes: 64744
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>   //?????????????????????????????????C???scanf????????¨????????????
using namespace std;

struct Node {
	int key;
	Node *prev, *next;
};

Node* nil;

void init() {
	nil = (Node*)malloc(sizeof(Node));
	nil->next = nil;   //->???????????????????????????????????¢?????????
	nil->prev = nil;
}

void insert(int key) {
	Node* x = (Node*)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next=x;
	x->prev = nil;
}

Node* listSearch(int key) {
	Node* cur = nil->next;
	while (cur != nil&&cur->key!=key) {
		cur = cur->next;
	}
	return cur;
}

//???????????¨?????????????????????????\???????
void deleteNode(Node* t) {
	if (t == nil) return;   //t??????????????¨?????????
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);   //?????¨????????????????????¬??????????????????????§£???
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);   //?????????????????????????°?
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void Print() {
	Node* n = nil->next;
	int ifs = 0;
	while(1){
		if (n == nil) break;
		if (ifs++>0) printf(" ");
		printf("%d", n->key);
		n = n->next;
	}
	printf("\n");
}

int main() {
	int n,data;
	scanf("%d",&n);
	char command[20];
	init();        //?±???????????????????????????????
	for (int i = 0;i < n;i++) {
		scanf("%s%d",command,&data);
		if (command[0]=='i') {
			insert(data);
		}
		else if(strlen(command)==6) {
			deleteKey(data);
		}
		else if(command[6]=='F') {
			deleteFirst();
		}
		else {
			deleteLast();
		}
	}

	Print();

}

Measured memory_bytes: 34360
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int n;
    cin>>n;
    ll arr[n];
    loop(n,i,0)
        cin>>arr[i];
    ll res=0;
    loop(n,i,1){
        if(arr[i]<arr[i-1])
            res+=(arr[i-1]-arr[i]),arr[i]=arr[i-1];
    }
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


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

int main() {

    int a, b, c;
    cin >> a >> b >> c;
    if(a+b+c<22){
        cout << "win" << endl;
    }else{
        cout << "bust" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int a , b;
   cin>>a>>b;
   if(a>=0 && a<=5)
    cout<<0;
   else if(a>=6 && a<=12)
    cout<<b/2;
   else if(a>=13)
    cout<<b;
    return 0;
}


Measured memory_bytes: 256
INF = 1 << 60
n = int(input())
ans = INF
for a in range(1, n):
    b = str(n - a)
    a = str(a)
    total_a = 0
    total_b = 0
    for i in a:
        total_a += int(i)
    for i in b:
        total_b += int(i)
    ans = min(ans, total_a + total_b)
print(ans) 

Measured memory_bytes: 73324
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static int max = 0;

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

		int n = getInt(sc);
		int[][] candies = new int[2][n];
		for (int i = 0; i < 2; i++) {
			candies[i] = getIntArray(sc);
		}
		ArrayDeque<Status> que = new ArrayDeque<>();
		que.add(new Status(0, 0, 0));

		move(candies, n - 1, que);
		System.out.println(max);
		max = 0;
	}

	private static void move(int[][] candies, int end, ArrayDeque<Status> statusQue) {
		while (!statusQue.isEmpty()) {
			Status status = statusQue.poll();
			if (status.row == 1 && status.col == end) {
				max = Math.max(max, status.candies + candies[status.row][status.col]);
				continue;
			}
			status.candies += candies[status.row][status.col];
			if (status.row < 1) {
				statusQue.add(new Status(status.row + 1, status.col, status.candies));
			}
			if (status.col < end) {
				statusQue.add(new Status(status.row, status.col + 1, status.candies));
			}
		}
	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}

class Status {
	int row = 0;
	int col = 0;
	int candies = 0;

	public Status(int row, int col, int candies) {
		this.row = row;
		this.col = col;
		this.candies = candies;
	}
}


Measured memory_bytes: 22996
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> v(n-1);
    FOR(i,0,n-1)cin>>v[i];
    ll ans = v[0] + v[n-2];
    FOR(i,1,n-1) ans += min(v[i-1], v[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int three_max(int a, int b, int c){
    int max = a;
    if(max < b){
        max = b;
    }
    if(max < c){
        max = c;
    }
    return max;
}

int main(void){
    int N;
    cin >> N;
    int a[N], b[N], c[N];
    for(int i=0; i<N; i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    int happy[N+1][3];
    for(int i=0; i<N+1; i++){
        for(int j=0; j<3; j++){
            happy[i][j] = 0;
        }
    }

    for(int i=1; i<N+1; i++){
        chmax(happy[i][0], happy[i-1][1]+a[i-1]);
        chmax(happy[i][0], happy[i-1][2]+a[i-1]);
        chmax(happy[i][1], happy[i-1][0]+b[i-1]);
        chmax(happy[i][1], happy[i-1][2]+b[i-1]);
        chmax(happy[i][2], happy[i-1][0]+c[i-1]);
        chmax(happy[i][2], happy[i-1][1]+c[i-1]);
    }

    cout << three_max(happy[N][0], happy[N][1], happy[N][2]);

    return 0;

}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define maxn 190
#define maxc 18
using namespace std;
int mp[maxn][maxn], f[2][maxn][maxn][maxn], cur[maxn], suf[maxn][maxn][maxn], pre[maxn][maxn][maxn];
char s[maxn];
int check(int tx1, int ty1, int tx2, int ty2)
{
	return mp[tx2][ty1] + mp[tx1 - 1][ty1 - 1] - mp[tx1 - 1][ty2] - mp[tx2][ty1 - 1];
}
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
	{
		scanf("%s", s + 1);
		for (int j = 1; j <= m; j++)
			if (s[j] == '#') mp[i][j] = 1;
	}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			mp[i][j] = mp[i][j] + mp[i - 1][j] + mp[i][j - 1] - mp[i - 1][j - 1];
	for (int i = 1; i <= n; i++)
		for (int j = i; j <= n; j++)	
		{
			for (int k = 1; k <= m; k++)
			{
				int tmp = check(i, k, j, k);
				if (tmp == j - i + 1) cur[k] = 1;
				else if (tmp == 0) cur[k] = 0;
				else cur[k] = -1;
			}
			int sum = 0;
			for (int k = m; k >= 1; k--)
			{
				if (cur[k] == -1) sum = 0;
				else if (cur[k] == cur[k + 1]) sum++;
				else sum = 1;
				f[0][k][i][j] = sum;
			}
		}
	int q = 0, p = 1;
	if (f[q][1][1][n] == m) {puts("0"); return 0;}
	for (int c = 1; c <= 16; c++)
	{
		p ^= 1; q ^= 1;
		for (int l = 1; l <= m; l++)
			for (int i = 1; i <= n; i++)
			{
				int cur = i;
				for (int j = i; j <= n; j++)
				{
					f[q][l][i][j] = max(f[q][l][i][j], f[p][l][i][j]);
					int tmp = l + f[p][l][i][j];
					if (tmp <= m) f[q][l][i][j] = max(f[q][l][i][j], f[p][l][i][j] + f[p][tmp][i][j]);
					while (cur > 1 && f[p][l][cur - 1][i - 1] >= f[p][l][i][j]) cur--;
					pre[l][cur][j] = max(pre[l][cur][j], f[p][l][i][j]);
				}
			}
		for (int l = 1; l <= m; l++)
			for (int j = 1; j <= n; j++)
			{
				int cur = j;
				for (int i = j; i >= 1; i--)
				{
					while (cur < n && f[p][l][j + 1][cur + 1] >= f[p][l][i][j]) cur++;
					suf[l][i][cur] = max(suf[l][i][cur], f[p][l][i][j]);
				}
			}
		for (int l = 1; l <= m; l++)
			for (int i = 1; i <= n; i++)
				for (int j = n; j >= i; j--)
				{
					suf[l][i][j] = max(suf[l][i][j], suf[l][i][j + 1]);
					f[q][l][i][j] = max(f[q][l][i][j], suf[l][i][j]);
				}
		for (int l = 1; l <= m; l++)
			for (int j = 1; j <= n; j++)
				for (int i = 1; i <= j; i++)
				{
					pre[l][i][j] = max(pre[l][i][j], pre[l][i - 1][j]);
					f[q][l][i][j] = max(f[q][l][i][j], pre[l][i][j]);
				}
		if (f[q][1][1][n] == m) {printf("%d\n", c); return 0;}
		for (int l = 1; l <= m; l++)
			for (int i = 1; i <= n; i++)
				for (int j = i; j <= n; j++)
					f[p][l][i][j] = pre[l][i][j] = suf[l][i][j] = 0;
	}
}

Measured memory_bytes: 106880
#include<bits/stdc++.h>
using namespace std;pair<int,int>p[200100];int N,i,c,n[200100],d[200100];main(){cin>>N;for(;i<N;i++)cin>>p[i].first>>p[i].second;sort(p,p+N);d[N]=1;for(;i--;){c=i+1;while(c<N&&p[c].first<p[i].first+p[i].second)c=n[c];d[i]=(d[i+1]+d[n[i]=c])%998244353;}cout<<d[0];}

Measured memory_bytes: 3456
#include <stdio.h>
#include<string.h>
int main(int argc, char *argv[])
{
	char s[100],t[100];
	 while(scanf("%s",s)!=EOF){
 		scanf("%s",t);
 		int n=strlen(s),flag=0;
 		for(int i=0;i<n;i++)
 		{
		 	if(strcmp(s,t)==0){
	 		flag=1;break;	
	 		}
	 		char ch=s[0];
	 		for(int j=0;j<n-1;j++)
	 		 s[j]=s[j+1];
	 		 s[n-1]=ch;
		 }
		if(flag==1)printf("Yes\n");
		else printf("No\n"); 
 	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
using namespace std;
bool debug=false;

int a[10000000];

int main(){
  int n;
  while(1){
    cin>>n;
    int mini=INF;
    if(n==0)break;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n-1;i++){
      mini=min(mini,a[i+1]-a[i]);
    }
    cout<<mini<<endl;
  }
  return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define ll long long
string lp(string a){
	if(a.size()<=1) return a;
	int maxlen=1,start=0;
	for(int i=0;i<a.size();i++){
		int j=i,k=i;
		while(k<a.size()-1 && a[k]==a[k+1]) k++;
		while(j>0 && k<a.size()-1 && a[j-1]==a[k+1]){
			j--;
			k++;
		}
		if(k-j+1 > maxlen){
			maxlen=k-j+1;
			start=j;
		}
	}
	return a.substr(start,maxlen);
}
string s;
int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie();

	cin>>s;
	string t="";
	ll ans=0;
	while(s.size()!=0){
		string now="";
		for(int i=s.size()-1;i>=0;i--){
			now.push_back(s[i]);
			reverse(now.begin(),now.end());
			s.pop_back();
			if(now!=t){
				t=now;
				ans++;
				break;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 720
#include<iostream>
#include<vector>
#include<list>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
long long dp[100][21];
int main() {
	int n;
	cin >> n;
	long long a[100];
	for (int i = 0; i< n; i++) {
		cin >> a[i];
	}
	n--;
	for (int i = 0; i < n; i++)fill(dp[i], dp[i] + 21, 0);
	dp[0][a[0]]++;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= 20; j++) {
			if (j <= 20-a[i]) {
				dp[i][j] += dp[i - 1][j + a[i]];
			}
			if (j >= a[i]) {
				dp[i][j] += dp[i - 1][j - a[i]];
			}
		}
	}
	cout << dp[n - 1][a[n]] << endl;
	cin >> n;
}

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

using namespace std;
typedef long long ll;

ll n,k,arr[105];
bool dp[100005];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    cin>>n>>k;
    for(ll i=0;i<n;i++)cin>>arr[i];
    for(ll i=1;i<=k;i++){
        for(ll j=0;j<(int)n;j++){
            if((i-arr[j])<0)break;
            if(!dp[i-arr[j]])dp[i]=true;
        }
    }
    if(dp[k])cout<<"First";
    else cout<<"Second";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF=1001001001;

int main() {
    string s;
    cin>>s;
    int x=0;
    int y=0;
    rep(i,3) {
        if(s[i]=='A') x++;
        if(s[i]=='B') y++;
    }
    if(x!=0&&y!=0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
main = do
  [a,b,c] <- map read . words <$> getLine
  putStrLn $ f a b c

f :: Int -> Int -> Int -> String
f a b c 
  | a == b && b /= c = "Yes"
  | a == c && c /= b = "Yes"
  | b == c && c /= a = "Yes"
  | otherwise = "No"

Measured memory_bytes: 508
#include<stdio.h>

int main (){
	int num1, num2, num3;
	num1, num2, num3>=1;
	num1, num2, num3<=13;
	
	
	scanf ("%d %d %d", &num1, &num2, &num3);
	if (num1+num2+num3<=21){
		printf("win");
		
	}else {
		printf ("bust");
	    }
	
	return 0;
}


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

using ll = long long;

int main() {
    int k, n, m = 0; cin >> k >> n;
    vector<int> a(n);
    for (int &ai : a) {
        cin >> ai;
    }

    m = a[0] + k-a[n-1];
    for (int i = 1; i < n; i++) {
        m = max(m, a[i]-a[i-1]);
    }
    cout << k-m;
}


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

int d1[4][2] = {
	{0, -1},
	{1, 0},
	{0, 1},
	{-1, 0}
};

int d2[4][2] = {
	{-1, -1},
	{1, -1},
	{-1, 1},
	{1, 1}
};

void func(int **a, int x, int y, int n, int d[4][2])
{
	int i, s, t;
	
	for(i = 0; i < 4; i++){
		s = x+n*d[i][0];
		t = y+n*d[i][1];
		if(s >= 0 && s <= 9 && t >= 0 && t <= 9){
			a[s][t]++;
		}
	}
	
	return ;
}

int main(int argc, char **argv)
{
	int **a = (int **)calloc(10, sizeof(int));
	int i, j, x, y, s;
	
	for(i = 0; i < 10; i++){
		a[i] = (int *)calloc(10, sizeof(int));
	}
	
	while(scanf("%d,%d,%d",&x,&y,&s) != EOF){
		a[x][y]++;
		
		func(a, x, y, 1, d1);
		if(s > 1){
			func(a, x, y, 1, d2);
			if(s > 2){
				func(a, x, y, 2, d1);
			}
		}
	}
	
	x = y = 0;
	for(i = 0; i < 10; i++){
		for(j = 0; j < 10; j++){
			if(a[i][j] == 0){
				x++;
			} else if(a[i][j] > y){
				y = a[i][j];
			}
		}
	}
	printf("%d\n%d\n", x, y);
	
	for(i = 0; i < 10; i++){
		free(a[i]);
	}
	free(a);
	
	return 0;
}

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    const int start = max(A, C);
    const int stop = min(B, D);

    if (start <= stop) {
        cout << stop - start << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int n, m;
	cin >> n >> m;
	vector<string> arr(n), brr(m);
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	for(int j = 0; j < m; j++)
		cin >> brr[j];
	bool ans = 0;
	for(int i = 0; i <= n-m; i++) {
		for(int j = 0; j <= n-m; j++) {
			bool check = true;
			for(int k = 0; k < m; k++)
				check &= (arr[i+k].substr(j, m)==brr[k]);
			ans |= check;
		}
	}
	cout << (ans?"Yes":"No");

	return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
ans = 0
if a * b < 0:
    ans += 1
elif (a > 0 and b == 0) or (a == 0 and b < 0):
    ans += 1
elif b < a:
    ans += 2

ans += abs(abs(a) - abs(b))
print(ans)

Measured memory_bytes: 9032