akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

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

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

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

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

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

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

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	a, b, x := nextInt(), nextInt(), nextInt()

	var ans float64
	if a*a*b >= x*2 {
		ans = math.Atan(float64(a*b*b) / float64(2*x))
	} else {
		ans = math.Atan(float64(2*(a*a*b-x)) / float64(a*a*a))
	}
	ans *= 180.0 / math.Pi

	puts(ans)
}


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

#define debug(args...) \
cout << "#" << __LINE__ << ": "; \
__dbg(split(#args, ',').begin(), args);
vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}
template<typename T, typename... Args>
inline string to_str(T x) {
	stringstream ss; ss << "[";
	for (auto it = x.begin(); it != x.end(); it++) {
		if (it != x.begin()) ss << " ";
		ss << (*it);
	}
	ss << "]";
	return ss.str();
}
template<typename T, typename... Args>
inline string to_str(stack<T> x) {
	stringstream ss; ss << "[";
	bool first = 1;
	while (!x.empty()) {
		if (!first)
			ss << " ";
		ss << x.top();
		x.pop();
		first = 0;
	}
	ss << "]";
	return ss.str();
}
template<typename T> inline void __dbg_var(vector<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(list<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(set<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(unordered_set<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(stack<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(T val) { cout << val; }
inline void __dbg(vector<string>::iterator it) { cout << endl; }
template<typename T, typename... Args>
inline void __dbg(vector<string>::iterator it, T a, Args... args) {
	cout << it->substr((*it)[0] == ' ', it->length()) << "=";
	__dbg_var(a);
	cout << " ";
	__dbg(++it, args...);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
			
	unordered_map<int,list<int>> mp;
	int n,k;
	cin >> n >> k;
	int sn, s;
	//int size = mp.size();
	//debug(size);
	for (int i = 0; i < k; i++) {
		cin >> sn;
		for (int j = 0; j < sn; j++) {
			cin >> s;
			mp[s].push_back(sn);
		}
	}
	//size = mp.size();
	//debug(size);
	cout << (n-mp.size()) << "\n";
	return 0;
}



Measured memory_bytes: 3784
import java.util.*;
import java.util.ArrayList;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        int N = sc.nextInt();
        int[] a = new int[N];
        ArrayList<Integer> list = new ArrayList<>();

        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
            for(int j=0; j<a[i]; j++){
                list.add(i + 1);
            }
        }
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(i%2==0){
                    if(j==W-1){
                        System.out.println(list.get(i * W + j));
                    }
                    else{
                        System.out.print(list.get(i * W + j) + " ");
                    }
                }
                else{
                    if(j==W-1){
                        System.out.println(list.get(i * W + W - 1 - j));
                    }
                    else{
                        System.out.print(list.get(i * W + W - 1 - j) + " ");
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 33768
w = input()
beau = {}
for i in range(len(w)):
    if not w[i] in beau:
        beau[w[i]] = 1
    else:
        beau[w[i]] += 1
num = sum(list(map(lambda x: x%2,list(beau.values()))))
if num == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9052
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      s: String,
      _k: usize
   }
   let mut k = _k;
   for c in s.chars() {
      k -= 1;
      if k == 0 || c != '1' {
         println!("{}", c);
         break;
      }
   }
}


Measured memory_bytes: 4352
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int a = Integer.parseInt(scanner.nextLine());
		int b = Integer.parseInt(scanner.nextLine());
		int c = Integer.parseInt(scanner.nextLine());
		
		System.out.println((a+b)*c/2);


	}
}


Measured memory_bytes: 35620
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 300010
#define M 3
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int f[N][M][M];
int n;
char s[N];
const int mod=1e9+7;
inline int Z(int x){return x>=mod?x-mod:x;}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",s+1);n=strlen(s+1);
	f[0][0][0]=1;
	for(register int i=0;i<n;i++)
	{
		for(register int j=0;j<3;j++)
		{
			for(register int k=0;k<3;k++)
			{
				if(!f[i][j][k])continue;
				if(s[i+1]!='0')
				{
					if(k){f[i+1][j][k-1]=Z(f[i+1][j][k-1]+f[i][j][k]);}
					else f[i+1][min(j+1,2)][k]=Z(f[i+1][min(j+1,2)][k]+f[i][j][k]);
				}
				if(s[i+1]!='1')
				{
					if(k==2){f[i+1][j][1]=Z(f[i+1][j][1]+f[i][j][k]);}
					else f[i+1][j][k+1]=Z(f[i+1][j][k+1]+f[i][j][k]);
				}
			}
		}
	}
	int ans=0;
	for(register int i=0;i<3;i++)
	{
		for(register int j=0;j<=i;j++)ans=Z(ans+f[n][i][j]);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 14668
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s; cin >> s;
    bool ok = true;
    rep(i, s.size()) {
        if (i % 2 == 0) {
            if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') continue;
            else {
                ok = false;
                break;
            }
        }
        if (i % 2 == 1) {
            if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') continue;
            else {
                ok = false;
                break;
            }
        }
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static char[] s;
	static int idx,p,q,r;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			s=(cin.next()+"     ").toCharArray();
			if(s[0]=='.')break;
			int ans=0;
			
			for(p=0;p<=2;p++){
				for(q=0;q<=2;q++){
					for(r=0;r<=2;r++){
						idx=0;
						if(formula()==2){
							ans++;
						}
					}
				}
			}
			System.out.println(ans);
		}
	}
	static int formula(){
		if(s[idx]=='0'){
			idx++;
			return 0;
		}
		else if(s[idx]=='1'){
			idx++;
			return 1;
		}
		else if(s[idx]=='2'){
			idx++;
			return 2;
		}
		else if(s[idx]=='P'){
			idx++;
			return p;
		}
		else if(s[idx]=='Q'){
			idx++;
			return q;
		}
		else if(s[idx]=='R'){
			idx++;
			return r;
		}
		else if(s[idx]=='-'){
			idx++;
			return minus(formula());
		}
		else if(s[idx]=='('){
			idx++;
			int a=formula();
			if(s[idx]=='*'){
				idx++;
				a=mult(a,formula());
				idx++;
				return a;
			}
			else{
				idx++;
				a=add(a,formula());
				idx++;
				return a;
			}
		}
		System.out.println("aaaaaaaa");
		return 0;
	}
	static int mult(int a,int b){
		if(a==0||b==0)return 0;
		if(a+b==4)return 2;
		return 1;
	}
	static int add(int a,int b){
		if(a==2||b==2){
			return 2;
		}
		if(a+b==1){
			return 1;
		}
		if((a|b)==1){
			return 1;
		}
		if((a|b)==0){
			return 0;
		}
		return 0;
	}
	static int minus(int a){
		if(a==0){
			return 2;
		}
		else if(a==2){
			return 0;
		}
		else{
			return 1;
		}
	}

}

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

using namespace std;


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

    int N = S.size();
    bool flag = true;

    for(int i = 0; i < N; i++)
    {
        if(i % 2 == 0 && S.at(i) == 'L' )
        {
            flag = false;
        }
        else if(i % 2 == 1 && S.at(i) == 'R' )
        {
            flag = false;
        }
        if(flag == false) break;
    }

if(flag) cout << "Yes" << endl;
else cout << "No" << endl;
}
    

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] a = ReadIntArray();
	int[] b = ReadIntArray();

	long m = 0;
	for (int i = 0; i < n; i++)
	{
	    int b1 = Math.Min(a[i], b[i]);
	    m += b1;
	    a[i] -= b1;
	    b[i] -= b1;
	    int b2 = Math.Min(a[i+1], b[i]);
	    m += b2;
	    a[i+1] -= b2;
	    b[i] -= b2;
	}

	WriteLine(m);
    }
}


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

int main(){
    int n;
    cin >> n;
    cout << (n + 1) / 2 << endl;
    return 0;
}

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

int main() {
    int n, m;
    while (cin >> n >> m, n|m) {
        vector<int> ps(n);
        for (int i = 0; i < n; i++) {
            cin >> ps[i];
        }
        sort(ps.begin(), ps.end(), greater<int>());
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if ((i+1) % m != 0) {
                ans += ps[i];
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    char S[10], T[10];
    ll A, B;
    char U[10];

    //input
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if(strcmp(U, S) == 0){
        cout << A - 1 << ' ' << B << endl;
    }else{
        cout << A << ' ' << B - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int N,M,P,i,sum,sum1=0;
  int X[1000];

  while(1){
    scanf("%d%d%d",&N,&M,&P);
    if(N==0&&M==0&&P==0)break;
    sum=0;sum1=0;
    for(i=0;i<N;i++){
      scanf("%d",&X[i]);
      sum+=X[i]*100;
    }
    sum1=sum;
    sum1*=P;
    sum1/=100;
    sum-=sum1;

    if(X[M-1]!=0)printf("%d\n",sum/X[M-1]);
    else printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 612
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

template <typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T>>> &G) {
    const T INF = numeric_limits<T>::max();
    using P     = pair<T, int>;
    int n       = G.size();
    vector<T> d(n, INF);
    vector<int> b(n, -1);
    priority_queue<P, vector<P>, greater<P>> q;
    d[s] = 0;
    q.emplace(d[s], s);
    while (!q.empty()) {
        P p = q.top();
        q.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for (auto &e : G[v]) {
            int u = e.first;
            T c   = e.second;
            if (d[u] > d[v] + c) {
                d[u] = d[v] + c;
                b[u] = v;
                q.emplace(d[u], u);
            }
        }
    }
    return d;
}

int main() {
    int n;
    cin >> n;
    vector<vector<pii>> edges(n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edges[a].emplace_back(b, 1);
        edges[b].emplace_back(a, 1);
    }
    auto dist = dijkstra(0, edges);
    int idx   = 0;
    int maxi  = 0;
    for (int i = 0; i < n; ++i) {
        if (chmax(maxi, dist[i]))
            idx = i;
    }
    auto dist2 = dijkstra(idx, edges);
    int diag   = 0;
    for (int i = 0; i < n; ++i) {
        chmax(diag, dist2[i]);
    }
    if (diag % 3 == 1)
        cout << "Second"
             << "\n";
    else
        cout << "First"
             << "\n";

    return 0;
}

Measured memory_bytes: 18644
import java.util.Scanner;
import java.lang.*;

public class Main {

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

        String s = scanner.nextLine();

        int longestCount = 0;
        String longestACGT = "";
        int cnt = 0;

        for (int i = 0; i < s.length(); i++) {

          char char1 = s.charAt(i);
          if (char1 == 'A' || char1 == 'G' || char1 == 'T' || char1 == 'C'){
            cnt = 1;
            for (int j = i+1; j < s.length(); j++) {
              char char2 = s.charAt(j);
              if (char2 == 'A' || char2 == 'G' || char2 == 'T' || char2 == 'C') {
                cnt++;
                } else {
                break;
                }
              }
            }
          if (cnt > longestCount) {
            longestCount = cnt;
          }
        }

        System.out.println(longestCount);
        scanner.close();
    }
}


Measured memory_bytes: 23636
import java.util.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int u = sc.nextInt();
			int v = sc.nextInt();
			int m = sc.nextInt();
			int [][] hash = new int[2][1000000 + 1];
			for(int i = 0; i < 2; i++){
				Arrays.fill(hash[i], -1);
			}
			for(int i = 0; i < 2; i++){
				for(int j = 0; j < n; j++){
					for(int k = 0; k < n; k++){
						int num = sc.nextInt();
						hash[i][num] = j * n +  k;
					}
				}
			}
			int [] count = new int[2];
			int [][] hcount = new int[2][n];
			int [][] wcount = new int[2][n];
			int [][] crossC = new int[2][2];
			boolean flg = false;
			while(m-- > 0){
				int mi = sc.nextInt();
				for(int i = 0; i < 2; i++){
					int pos = hash[i][mi];
					if(pos == -1) continue;
					int xpos = pos % n;
					int ypos = pos / n;
					hcount[i][ypos]++;
					if(hcount[i][ypos] == n){
						count[i]++;
					}
					wcount[i][xpos]++;
					if(wcount[i][xpos] == n){
						count[i]++;
					}
					if(xpos == ypos){
						crossC[i][0]++;
						if(crossC[i][0] == n){
							count[i]++;
						}
					}
					if(xpos + ypos == n-1){
						crossC[i][1]++;
						if(crossC[i][1] == n){
							count[i]++;
						}
					}
					if(n == 1 && count[i] >= 2){
						count[i] = 1;
					}
				}
				
				if(count[0] >= u && count[1] >= v){
					System.out.println("DRAW");
					flg = true;
					break;
				}
				else if(count[0] >= u){
					System.out.println("USAGI");
					flg = true;
					break;
				}
				else if(count[1] >= v){
					System.out.println("NEKO");
					flg = true;
					break;
				}
			}
			if(! flg){
				System.out.println("DRAW");
			}
			while(m-- > 0){
				sc.next();
			}
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 113376
import sys
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

x = int(input())

for i in range(x, 10**5+4):
    if is_prime(i):
        print(i)
        sys.exit()

Measured memory_bytes: 38936
n = [int(x) for x in input()]
o = len(n) - 1

op = []
for i in range(2**o):
    op = ["-", "-", "-"]
    for j in range(o):
        if (i >> j) & 1:
            op[o - 1 - j] = "+"
    
    sum = n[0]
    for m, s in zip(n[1:], op):
        if s == "+":
            sum += m
        else:
            sum -= m

    if sum == 7:
        break

ns = [str(x) for x in n]
res = ns[0]
for x,y in zip(op, ns[1:]):
    res += x + y

print(res + "=7")


Measured memory_bytes: 3064
H, W, K = map(int, input().split())
MOD = 10 ** 9 + 7

if W == 1:
  print(1)
  exit()

root = []
for i in range(2 ** (W - 1)):
  flag = 1
  for j in range(1, W - 1):
    if ((i >> j) & 1) & (i >> (j - 1) & 1):
      flag = 0
      break
  if flag:
    root.append(i)

swap = [[j for j in range(W)] for _ in range(len(root))]
for i in range(len(root)):
  for j in range(W - 1):
    if (root[i] >> j) & 1:
      swap[i][j], swap[i][j + 1] =  swap[i][j + 1], swap[i][j]
#for i in range(len(root)):
#  print(swap[i])
  
dp = [[0 for _ in range(W)] for _ in range(H + 1)]
dp[0][0] = 1

for i in range(H):
  for s in swap:
    for j in range(W):
      dp[i + 1][s[j]] = (dp[i + 1][s[j]] + dp[i][j]) % MOD
#for i in range(H + 1):
#  print(dp[i])

print(dp[-1][K - 1])

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

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

    int a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    
    sort(a, a+N);
    cout << a[N-1] - a[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 200003
#define MOD 1000000007

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

  ll ans=0;
  for(ll i=K;i<=N+1;i++){
    ans+=(N+1-i)*i+1;
    ans%=MOD;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
typedef long long ll;
int x,n,y,cnt[maxn]; 
int dis(int a,int b) {
	return min(b - a,abs(a - x) + abs(b - y) + 1);
}
int main() {
	scanf("%d%d%d",&n,&x,&y);
	if (x > y) swap(x,y);
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			cnt[dis(i,j)]++;
		}
	}
	for (int i = 1; i < n; i++)
		printf("%d\n",cnt[i]);
	return 0;
}

Measured memory_bytes: 256
def read_valus():
    return map(int, input().split())


def read_list():
    return list(read_valus())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    A = read_list()
    print("win" if sum(A) <= 21 else "bust")   

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <cstdio>
#define ll long long
using namespace std;
inline ll read(){
	ll x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return x*f;
}
int a[20],c[20][20],q[20];
int tot;
ll ans;
void init(){
	for (int i(0);i<=10;++i) c[0][i]=c[i][i]=1;
	for (int i(2);i<=10;++i)
		for (int j(1);j<i;++j)
			c[i][j]=c[i-1][j]+c[i-1][j-1];
}

signed main(){
	init();
	ll b=read();
	while (b){
		q[++tot]=b%10;
		b/=10;
	}
	for (int i(1);i<=tot;++i) a[i]=q[tot-i+1];
	for (int l(1);l<=tot;++l)
		for (int i(1);i+l-1<=tot;++i){
			ll num=0;
			for (int j(i);j<=i+l-1;++j) num*=10,num+=a[j];
			//printf("%lld ",num);
			if (i==1||i+l-1==tot){
				for (int i(1);i<=tot-l-1;++i) num*=2;
				ans+=num;
			}
			else {
				for (int i(1);i<=tot-l-2;++i) num*=2;
				ans+=num;
			}
		}
	printf("%lld",ans);
	return 0; 
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());
//int rnd(int x) { return mrand()%x;}
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
int a[150];int s=0,qs=0;int n;
int calc(int p){
	return n*p*p-2*p*s+qs;
}
int main(){
	
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	
	for(int i=1;i<=n;i++){
		s+=a[i];
		qs+=a[i]*a[i];
	}
	int p=s/n,pp=p+1,ppp=p-1;
	printf("%d\n",min(min(calc(p),calc(pp)),calc(ppp)));
	return 0;
}


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

int main() {
  int n; cin >> n;
  vector<int> t(n);
  int tot = 0;
  rep(i,n) {
    cin >> t[i];
    tot += t[i];
  }
  int m; cin >> m;
  rep(i,m) {
    int p, x; cin >> p >> x;
    cout << tot - t[p-1] + x << endl;
  }
  return 0;
}

Measured memory_bytes: 3536
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

using ll = long long;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int64_t mpow(int64_t x, int64_t y){
  if(y < 0){
    return 0;
  }
  else if(y == 0){
    return 1;
  }
  int64_t ans = x;
  int64_t z = floor(log2(y));
  rep(i, z){
    ans *= ans;
    ans %= 1000000007;
  }
  rep(i, y - pow(2, z)){
    ans *= x;
    ans %= 1000000007;
  }
  return ans;
}

int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> C(N);
  rep(i, N){
    cin >> C.at(i);
  }
  sort(all(C));
  mint cost = 0;
  vector<mint> two(N+1);
  two.at(0) = 1;
  rep(i, N){
    two.at(i+1) = two.at(i) * 2;
  }
  rep(i, N){
    mint tcost = 0;
    if(i != N - 1){
      tcost += two.at(N - i - 2);
      tcost *= (N - i - 1);
    }
    tcost += two.at(N - i - 1);
    tcost *= C.at(i);
    tcost *= two.at(i);
    cost += tcost;
  }
  cost *= two.at(N);
  cout << cost.x << endl;
}

Measured memory_bytes: 3456
n = int(input())
XL = [list(map(int,input().split())) for i in range(n)]

XL.sort(key = lambda x:sum(x))
ans = 0
f = -1000000001
for x,l in XL:
    if x - l >= f:
        ans += 1
        #print(f)
        f = x + l
print(ans)

Measured memory_bytes: 65752
#include<stdio.h>

  int a[100100];
  int n1;
int binarySearch(int key){
  int left =0;
  int right=n1;
  int mid;
  while(left<right){
    mid=(left+right)/2;
    if(a[mid]==key){
      return 1;
    }else if(key<a[mid]){
      right=mid;
    }else{
      left=mid+1;
    }
  }
  return 0;
}

int main(){
  int n2,b,cnt=0;
  int i=0,j=0;

  scanf("%d",&n1);
  while(i!=n1){
    scanf("%d",&a[i]);
    i++;
  }
  scanf("%d",&n2);

  while(j!=n2){
    scanf("%d",&b);
    if(binarySearch(b))cnt++;
    j++;
  }


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

}



Measured memory_bytes: 2144
// https://atcoder.jp/contests/abc142/tasks/abc142_c

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

int main()
{
    long n;
    cin >> n;
    vector<long> a(n);
    for (long i = 1; i <= n; i++)
    {
        long x;
        cin >> x;
        a[--x] = i;
    }
    for (long i = 0; i < n; i++)
        cout << a[i] << " ";
    cout << endl;
}


Measured memory_bytes: 4020
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
 
public class Main{
	public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        List<String> output = new ArrayList<String>();
        while (scan.hasNext()) {
            String input = scan.nextLine();
            String[] inarr = input.split(" ");
            int x = Integer.parseInt(inarr[0]);
            int y = Integer.parseInt(inarr[1]);
            if (x >= 0 && x <= 10000 && y >= 0 && y <= 10000) {
                if (x == 0 && y == 0) {
                    break;
                } else {
                    if (x < y) {
                        String inVal = String.valueOf(x) + " " + String.valueOf(y);
                        output.add(inVal);
                    } else if (x > y) {
                        String inVal = String.valueOf(y) + " " + String.valueOf(x);
                        output.add(inVal);
                    } else {
                        output.add(input);
                    }
                }
            }
        }
        if (output.size() <= 3000) {
            for (String out : output) {
                System.out.println(out);
            }
        }
    }
 
}

Measured memory_bytes: 38216
#include<stdio.h>
#include<string.h>
int main(void)
{
	char na[10][21],x[21];
	int n,w[10],l[10],d[10],a[10],i,j,y,flg;
	flg=1;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%s %d %d %d",na[i],&w[i],&l[i],&d[i]);
			l[i]=w[i]*3+d[i];
			a[i]=i;
		}
		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				if(l[i]<l[j] || l[i]==l[j] && a[i]>a[j]){
					y=l[i];  l[i]=l[j];  l[j]=y;
					y=a[i];  a[i]=a[j];  a[j]=y;
					strcpy(x,na[i]);  strcpy(na[i],na[j]);  strcpy(na[j],x);
				}
			}
		}
		if(flg==0)  printf("\n");
		for(i=0;i<n;i++)  printf("%s,%d\n",na[i],l[i]);
		flg=0;
		scanf(" %d",&n);
	}
	return 0;
}

Measured memory_bytes: 2744
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 10000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
typedef pair<P, int> PI;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

vector<int> ps;
string s;
int cur = 0;

char letter() {
  int c;
  int pl = 0;
  while(cur < s.size()) {
    c = s[cur++];
    if(c == '+' || c == '-') {
      pl += (c == '+' ? 1 : -1);
    } else {
      // alphabet
      break;
    }
  }
  if(c == '?') return '?';
  c += pl;
  while(c < 'A') c += 26;
  while('Z' < c) c -= 26;
  return c;
}

string cipher() {
  char c;
  string res = "";
  while(cur < s.size()) {
    c = s[cur];
    if(c == '[') {
      ++cur;
      string rev = cipher();
      repr(i, rev.size()) res += rev[i];
    } else if(c == ']') {
      ++cur;
      break;
    } else {
      res += letter();
    }
  }
  return res;
}

int main() {
  while(cin >> s && s[0] != '.') {
    cur = 0;
    string res = cipher();
    rep(i, res.length()) {
      if(res[i] == '?') res[i] = 'A';
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";

ll MAX = 1e5 + 1;
ll MOD = 1e9 + 7;
vector<ll> step(MAX + 10, -1);

int calc() {
    step[0] = 1;
    step[1] = 1;
    for (int i = 2; i < MAX + 5; i++) {
        step[i] = (step[i - 1] + step[i - 2]) % MOD;
    }
    return 0;
}

int main() {

    CIN(int, N);
    CIN(int, M);
    vector<ll> a(M + 10);

    a[0] = 0;
    a[M + 1] = N;
    bool check = false;
    for (int i = 1; i <= M; i++) {
        cin >> a[i];
        if ( i > 1 && a[i] == a[i-1]+1 ) check = true;
    }
    if (check) {
        cout << 0 << "\n";
        return 0;
    }

    calc();

    if (M == 0) {
        cout << (step[N] % MOD) << "\n";
        return 0;
    }

    ll ans = 1;
    ans = (ans * step[a[1] - 1]) % MOD;
    for (int i = 2; i <= M; i++) {
        ans = (ans * step[a[i] - a[i - 1] - 2]) % MOD;
    }
    ans = (ans * step[N - a[M] - 1]) % MOD;

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

int main(){
	int X, Y, Z;

	cin >> X >> Y >> Z;

	int swap;
	swap = X;
	X = Y;
	Y = swap;

	swap = X;
	X = Z;
	Z = swap;

	cout << X << " " << Y << " " << Z << endl;

	return 0;



}







Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let s: Vec<char> = input::<String>().chars().collect();

    let mut ans = 0;
    let n = s.len();
    for i in 1..n {
        if (n - i) % 2 > 0 {
            continue;
        }
        let l: String = s[0..(n - i) / 2].iter().cloned().collect();
        let r: String = s[(n - i) / 2..n - i].iter().cloned().collect();
        if l == r {
            ans = n - i;
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a , b[9] = {} , x = 0;
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> a;
        if( a >= 3200 ) b[8]++;
        else b[a / 400] = 1;
    }
    for ( int i = 0 ; i < 8 ; i++ ) x += b[i];
    cout << max( x , 1 ) << ' ' << x + b[8];
}


Measured memory_bytes: 256
#n = (m*k+1)*k**t
def divisors(n):
    ans = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            ans.append(i)
            if i != n // i:
                ans.append(n//i)
    return ans
n = int(input())
ans = 0

#t = 0
ans += len(divisors(n-1)) - 1

#t > 0
for k in divisors(n):
    if k == 1:
        continue
    temp_n = n
    while temp_n % k == 0:
        temp_n /= k
    if temp_n % k == 1:
        ans += 1
print(ans)

Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int x;
	cin >> x;
	for(long long int i = 0; i <= x; i++) {
		if(((i * (i + 1)) / 2) >= x) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

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

const int mod=1e9+7;

char s[11][N];

int sum[11][N],a[11][N];

int get(int x1,int y1,int x2,int y2){
    return sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
}

int main(){
    int n,m,ss;
    cin>>n>>m>>ss;
    for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i][j]=='1') sum[i][j]=1;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            sum[i][j]=sum[i][j]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
        }
    }
    int all=1<<(n-1);
    int ans=1e9;
    for(int mask=0;mask<all;mask++){
        int num=__builtin_popcount(mask);
        vector<int> v;
        v.push_back(1);
        for(int i=0;i<n-1;i++){
            if(mask&(1<<i)) v.push_back(i+2);
        }
        v.push_back(n+1);
        int sz=(int)v.size();
        int last=0; bool f=1;
        for(int i=1;i<=m;i++){
            for(int j=0;j<=sz-2;j++){
                int up=v[j];
                int down=v[j+1]-1;
                //cout<<up<<" "<<down<<endl;
                if(get(up,i,down,i)>ss){
                    f=0; break;
                }
                if(get(up,last+1,down,i)>ss){
                    num++; last=i-1;
                }
            }
        }
        //cout<<mask<<" "<<f<<" "<<num<<endl;
        if(f) ans=min(ans,num);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define ull unsigned long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pul pair<ull,LL> 
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
using namespace std;
const int N=(1<<14)-1,mod=998244353;
const LL inf=1e18;
template<typename T> void chkmin(T &x,T y) {if(y<x) x=y;}
template<typename T> void chkmax(T &x,T y) {if(y>x) x=y;}
template<typename T> void upd(T &x,T y) {if((x+=y)>=mod) x-=mod;}
int n,K,sl,fh,ans,a[mxn];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	ios::sync_with_stdio(false);
	K=rd();n=rd();
	for(int i=1;i<=n;++i) a[i]=rd();
	a[n+1]=a[1]+K;
	for(int i=1;i<=n;++i) chkmax(ans,a[i+1]-a[i]);
	printf("%d\n",K-ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++)
        for(int j=0;j<3;j++)
            cin>>a[i][j];
    int dp[n][3];
    for(int i=0;i<n;i++)
        for(int j=0;j<3;j++)
            dp[i][j]=0;
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        for(int x=0;x<3;x++)
        {
            for(int y=0;y<3;y++)
            {
                if(x!=y)
                {
                    dp[i][y]=max(dp[i][y],dp[i-1][x]+a[i][y]);
                }
            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


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

using namespace std;

typedef long long LL;

const LL mod=1000000007;
LL n,ans=1,a[120000];

int main(){
	scanf("%lld",&n);
	for (LL i=1;i<=n;++i) scanf("%lld",a+i);
	for (LL i=1,j=1;i<=n;++i){
		for (;j<=n&&a[j]>=(j-i+1)*2-1;++j);
		ans=ans*(j-(j>n)-i+1)%mod;
	}
	printf("%lld\n",ans);
	
	return 0;
}
			

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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int p, q, r;
    cin >> p >> q >> r;
    cout << p + q + r - max({p, q, r}) << ln;
    return 0;
}


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

typedef long long int ll;

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

int main()
{
  fast;
  ll n,m,i,a[10000],sum=0;
  cin>>n>>m;
  for(i=0;i<m;i++)
  {
  	cin>>a[i];
    sum+=a[i];
  }
  
  if(sum<=n)
  	cout<<abs(sum-n)<<endl;
  else
  	cout<<"-1"<<endl;
  
  
  return 0;
}


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

int main() {
  int N;
  int l = 0;
  int r = 0;
  int sum = 0;
  
  cin >> N;
  
  rep(i, N){
  	cin >> l >> r;
    sum += r - l + 1;  
  }
  
  cout << sum;
}

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

int main(){
  int N; cin >> N;
  int p[60];
  for(int i=0; i<N; i++) cin >> p[i];
  int diff=0;
  for(int i=0; i<N; i++) if(i+1!=p[i]) diff++;
  cout << (diff<=2?"YES":"NO") << endl;
}

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

int main() {
	
	int n;
	string s;
	cin >> n >> s;
	int cnt = 0;
	for(int i=0; i<1000; i++){
		int flg = 0;
		for(int j=0; j<n; j++){
			if(flg==0){
				if(i/100 == s.at(j) - '0') {
					flg++;
					continue;
				}
			}
			if(flg==1){
				if((i-i/100*100)/10==s.at(j)-'0'){
					flg++;
					continue;
				}
			}
			if(flg==2){
				if(i%10==s.at(j)-'0'){
					flg++;
					break;
				}
			}
		}
		if(flg==3) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> p(N);
    int ans = 0;
    rep(i, 0, N)
    {
        cin >> p.at(i);
    }
    rep(i, 0, N - 2)
    {
        if (((p.at(i) < p.at(i + 1)) && (p.at(i + 1) < p.at(i + 2))))
        {
            ans++;
        }
        else if (((p.at(i + 2) < p.at(i + 1)) && (p.at(i + 1) < p.at(i))))
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

#define MAXN 100010

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n; cin >> n;
	int h[MAXN];
	int dp[MAXN];
	for(int i = 1; i <= n; i++){
		int x; cin >> x;
		h[i] = x;
	}
	
	dp[n] = 0;
	dp[n-1] = abs(h[n-1] - h[n]);
	for(int i = n-2; i > 0; i--){
		dp[i] = min( 
			abs(h[i+1] - h[i]) + dp[i+1],
			abs(h[i+2] - h[i]) + dp[i+2]
			);
	}
	/*
	for(int i = 1; i <= n; i++){
		cout << dp[i] << " ";
	}
	cout << "\n";
	*/
	cout << dp[1] << "\n";
}


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

int main(int argc, char const *argv[]) {
    int N, sum=0;
    cin >> N;
    vector<int> order(N);
    vector<int> point(N);
    vector<int> extra(N-1);

    for (int i=0; i<N; i++) {
        cin >> order.at(i);
    }
    
    for (int i=0; i<N; i++) {
        cin >> point.at(i);
        sum += point.at(i);
    }

    for (int i=0; i<N-1; i++) {
        cin >> extra.at(i);

    }

    for (int i=0; i<N-1; i++) {
        if (order.at(i) == order.at(i+1)-1) {
            sum += extra.at(order.at(i)-1);
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<int>nums(10000);
		for (int i = 0; i < N; ++i) {
			int a; cin >> a; nums[a]++;
		}
		for (int i = 0; i < 10; ++i) {
			if (nums[i]) {
				for (int j = 0; j < nums[i]; ++j) {
					cout << '*';
				}
			}
			else {
				cout << '-';
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3096
//#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define ll long long
using namespace std;
const int maxn = 40005;
const double eps = 1e-8;


int main()
{
    double l; cin >> l;
    cout << fixed << setprecision(12) << l*l*l/3/3/3 << endl;
}


Measured memory_bytes: 256
def ok(m):
    c = 1
    tmp = m
    for w in W:
        if tmp > w:
            tmp -= w
        else:
            c += 1
            tmp = m - w
    return k >= c

n, k = map(int, input().split())
W = [int(input()) for i in range(n)]

left = max(W)
right = sum(W)+1
while left+1 < right:
    mid = (left+right) // 2
    if ok(mid):
        right = mid
    else:
        left = mid
print(left)


Measured memory_bytes: 9560
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

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

int main(){
    int n, p = 2019, a[200010], pow10[200010] = {1};
    string s;
    cin >> s;
    n = s.length();
    rep(i, n) a[i] = s[i] - '0';
    for ( int i = 1; i <= n; ++i ) {
        pow10[i] = pow10[i-1] * 10 % p;
    }
    map<int, int> cnt;
    ++cnt[0];
    int ans = 0, sum = 0;
    rep(i, n) {
        sum = (sum * 10 + a[i]) % p;
        int tmp = sum * pow10[n - i - 1] % p;
//        cout << i << " " << p << " " << sum << " " << tmp << " " << a[i] << endl;
//        if ((p != 2 && p != 5) || a[i] % p == 0 ) ans += cnt[tmp];
//        if ((p != 2 && p != 5)) ans += cnt[tmp];
        ans += cnt[tmp];
        ++cnt[tmp];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5208
s = str(input())
ss = s[:2]
sss = s[2:]

if "01" <= sss <= "12":
    if "01" <= ss <= "12":
        print("AMBIGUOUS")
        exit()
    else:
        print("YYMM")
        exit()
if "01" <= ss <= "12":
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 2940
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int prev = 0;
		int count = 0;
		int max = 0;
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    if (prev >= x) {
		        count++;
		        max = Math.max(max, count);
		    } else {
		        count = 0;
		    }
		    prev = x;
		}
		System.out.println(max);
   }
}


Measured memory_bytes: 48196
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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(){
    ll a,v,b,w;cin >> a >> v >> b >>w;
    ll t;cin >> t;
    ll l=abs(b-a);
    if((v-w)*t>=l) cout <<"YES" <<endl;
    else cout <<"NO" <<endl;
}   


Measured memory_bytes: 3676