akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();       
        int k = sc.nextInt();   
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = 0;
        }   

        for (int i = 0; i < k; i++) {
            int d = sc.nextInt();
            int[] A = new int[d];
            for (int j = 0; j < d; j++) {
                A[j] = sc.nextInt();
                A[j]--;
                a[A[j]]++;
            }

        }
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] == 0) cnt++;
        }
        System.out.println(cnt);   
    }
}

Measured memory_bytes: 37364
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
void insertionSort(vector<T> v) {
	int n = v.size();
	for (int i = 1; i < n; i++) {
		int x = v[i];
		int j = i - 1;
		for (; j >= 0 && v[j] > x; j--)
			v[j + 1] = v[j];
		v[j + 1] = x;
		cout << v[0]; rep(i, 1, v.size()) { cout << " " << v[i]; } cout << endl;
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> A(N); rep(i, 0, N) {
		cin >> A[i];
	}
	cout << A[0]; rep(i, 1, A.size()) { cout << " " << A[i]; } cout << endl;
	insertionSort(A);
	return 0;
}

Measured memory_bytes: 3124
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int K = stdIn.nextInt();
        stdIn.close();

        int count = 0;

        while (N != 0) {
            N = N / K;
            count++;
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 22996
h, w = map(int, input().split())
black = 0
ma = []
maa = []
go = [[0, 0]]
for i in range(h):
    ma.append(list(input()))
    black += ma[i].count("#")
    maa.append([0] * w)
maa[0][0] = 1
while go != []:
    k = go.pop(0)
    if k[0] == h - 1 and k[1] == w - 1:
        print(h * w - black - maa[h - 1][w - 1])
        break
    if k[0] != 0:  # up
        if ma[k[0] - 1][k[1]] == "." and maa[k[0] - 1][k[1]] == 0:
            maa[k[0] - 1][k[1]] = maa[k[0]][k[1]] + 1
            go.append([k[0] - 1, k[1]])
    if k[0] != h-1:  # down
        if ma[k[0] + 1][k[1]] == "." and maa[k[0] + 1][k[1]] == 0:
            maa[k[0] + 1][k[1]] = maa[k[0]][k[1]] + 1
            go.append([k[0] + 1, k[1]])
    if k[1] != 0:  # left
        if ma[k[0]][k[1]-1] == "." and maa[k[0]][k[1]-1] == 0:
            maa[k[0]][k[1]-1] = maa[k[0]][k[1]] + 1
            go.append([k[0], k[1]-1])
    if k[1] != w-1:  # right
        if ma[k[0]][k[1]+1] == "." and maa[k[0]][k[1]+1] == 0:
            maa[k[0]][k[1]+1] = maa[k[0]][k[1]] + 1
            go.append([k[0], k[1] + 1])
else:
    print(-1)


Measured memory_bytes: 3192
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int main(){
	LL K, X;
	cin >> K >> X;
	vector<LL> ans;
	for(LL i=X-K+1; i<=X+K-1; i++){
		if(-1000000 <= i && i <= 1000000) ans.PB(i);
	}
	for(int i=0; i<ans.size(); i++){
		if(i != 0) cout << " ";
		cout << ans[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 9;

int dist[maxN][maxN], oc[maxN][maxN], n;

void dfs(int i, int j)
{
	static int di[4] = {-1, 0, 1, 0};
	static int dj[4] = {0, 1, 0, -1};
	int d = dist[i][j] + oc[i][j];
	FOR(k, 0, 4)
	{
		int a = i + di[k];
		int b = j + dj[k];
		if (a >= 0 and a < n and b >= 0 and b < n and dist[a][b] > d)
			dist[a][b] = d, dfs(a, b);
	}
}

void solve()
{
	scanf ("%d", &n);
	FOR(i, 0, n) FOR(j, 0, n)
		dist[i][j] = min({i, j, n-1-i, n-1-j}), oc[i][j] = 1;
		
	long long res = 0;
	FOR(_, 0, n*n)
	{
		int a;
		scanf ("%d", &a);
		a--;
		int i = a / n, j = a % n;
		
		res += dist[i][j];
		oc[i][j] = 0;
		dfs(i, j);
	}
	
	printf("%lld\n", res);
}

int main()
{
	int t = 1;
	//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}





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

class TSort{
public:
  int V;
  vector<unordered_set<int> > in,out;
  vector<int> tp;
  TSort():V(0){}
  TSort(int V):V(V),in(V),out(V){}
  
  void add_edge(int from,int to){
    assert(from >= 0 && to >= 0);
    assert(from < V && to < V);
    out[from].insert(to);
    in[to].insert(from);
  }

  vector<int> dfs(){
    vector<int> visited(V,0);
    
    function<void(int)> dfs = [&](int pos){
      if(visited[pos]++) return;
      for(int nx:out[pos]) dfs(nx);
      tp.push_back(pos);
    };
    
    tp.clear();
    for(int i=0;i<V;i++) dfs(i);
    reverse(tp.begin(),tp.end());
    return tp;
  }

  vector<int> bfs(){
    vector<unordered_set<int> > tmp = in;
    tp.clear();
    queue<int> Q;
    for(int i=0;i<V;i++)if(in[i].empty()) Q.push(i);
    
    while(!Q.empty()){
      int v = Q.front();Q.pop();
      tp.push_back(v);
      for(int nx:out[v]){
        if(in[nx].size() == 1) Q.push(nx);
        in[nx].erase(v);
      }     
    }
    for(int i=0;i<V;i++) if(!in.empty()) tp.clear(); // exist loop
    tmp = in;
    return tp;
  }
};


int main(){
  int n,m;
  cin>>n>>m;
  TSort A(n);
  
  for(int i=0,a,b;i<m;i++)cin>>a>>b,A.add_edge(a,b);
  
  A.bfs();
  for(int i=0;i<n;i++)cout<<A.tp[i]<<endl;
  return 0;
}



Measured memory_bytes: 10660
# -*- coding: utf-8 -*-
from itertools import product
import numpy as np
def inpl(): return map(int, input().split())

N, M = inpl()

X, Y, Z = [], [], []

for _ in range(N):
    x, y, z = inpl()
    X.append(x)
    Y.append(y)
    Z.append(z)

X = np.array(X, dtype=np.int64)
Y = np.array(Y, dtype=np.int64)
Z = np.array(Z, dtype=np.int64)


ans = 0
for a, b, c in product([1, -1], repeat=3):
    S = (a*X + b*Y + c*Z)
    S.sort()
    ans = max(ans, abs(np.sum(S[:M])))

print(ans)

Measured memory_bytes: 21676
# coding: utf-8
# Your code here!


s1 = input()
s2 = input()

dp = [[0] * (len(s2) + 1) for i in range(len(s1) + 1)]

for i in range(len(s1) + 1):
    dp[i][0] = i
for i in range(len(s2) + 1):
    dp[0][i] = i

for i in range(len(s1)):
    for j in range(len(s2)):
        cost = 0
        if s1[i] != s2[j]:
            cost = 1
        dp[i+1][j+1] = min(dp[i][j] + cost, dp[i][j+1]+1, dp[i+1][j]+1)
print(dp[-1][-1])










Measured memory_bytes: 43072
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;
ll C0, C1, C2, C3;

int main()
{
    C0 = C1 = C2 = C3;
    ll N;
    cin >> N;
    for(int i = 0;i < N;i++)
    {
        string s;
        cin >> s;
        if(s == "AC"){C0++;}
        else if(s == "WA"){C1++;}
        else if(s == "TLE"){C2++;}
        else{C3++;}
    }
    cout << "AC x " << C0 << endl;
    cout << "WA x " << C1 << endl;
    cout << "TLE x " << C2 << endl;
    cout << "RE x " << C3 << endl;
    return 0;
}

Measured memory_bytes: 3224
def ABC_119_A():
    S = input()

    toshi = S[0]+S[1]+S[2]+S[3]
    tuki = S[5]+S[6]
    hi = S[8]+S[9]

    if (int(toshi) <= 2019) and (int(tuki) <= 4) and (int(hi) <= 30):
        print('Heisei')
    else:
        print('TBD')

if __name__ == '__main__':

    ABC_119_A()

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
    int N;
    std::cin >> N;
    if (N == 1) {
        std::cout << "Hello World" << std::endl;
        return 0;
    } else {
        int A, B;
        std::cin >> A >> B;
        std::cout << A + B << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
use proconio::{input, marker::Usize1};
use std::iter::once;

const ALPHA: usize = 26;

#[derive(Debug, Clone)]
struct Contest {
    pub miss: i64,
    pub happiness: Vec<i64>,
    pub schedule: Vec<bool>,
}

impl Contest {
    fn with_args(miss: i64, happiness: Vec<i64>, schedule: Vec<bool>) -> Self {
        Self {
            miss,
            happiness,
            schedule,
        }
    }

    fn day_score(&self, d: usize) -> i64 {
        if self.schedule[d] {
            self.happiness[d]
        } else {
            -(self.schedule[0..=d]
                .iter()
                .rev()
                .copied()
                .chain(once(true))
                .take_while(|x| !x)
                .count() as i64)
                * self.miss
        }
    }
}

fn main() {
    input!(
        dmax: usize,
        c: [i64; ALPHA],
        s: [[i64; ALPHA]; dmax],
        mut t: [Usize1; dmax],
        // q: usize,
        // dq: [(Usize1, Usize1); q],
    );

    let mut contests: Vec<_> = (0..ALPHA)
        .map(|i| {
            let c = Contest::with_args(
                c[i],
                s.iter().map(|row| row[i]).collect(),
                t.iter().copied().map(|j| j == i).collect(),
            );
            c
        })
        .collect();

    let mut ans = 0;
    for d in 0..dmax {
        ans += contests.iter().map(|c| c.day_score(d)).sum::<i64>();
        println!("{}", ans);
    }
}

#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn test_day_score() {
        let miss = 4;
        let happiness = vec![10, 20, -10, 20, 0];
        let schedule = vec![false, false, true, true, false];
        let contest = Contest {
            miss,
            happiness,
            schedule,
        };
        assert_eq!(contest.day_score(0), -4);
        assert_eq!(contest.day_score(1), -8);
        assert_eq!(contest.day_score(2), -10);
        assert_eq!(contest.day_score(3), 20);
        assert_eq!(contest.day_score(4), -4);
    }
}


Measured memory_bytes: 2396
#include <stdio.h>

int main(int argc, char const *argv[]) {
	char str[101];
	int n, m;

	fgets(str, 100, stdin);
	sscanf(str, "%d\n", &n);

	if (n < 1200) {
		printf("ABC\n");
	} else if (n < 2800) {
		printf("ARC\n");
	} else {
		printf("AGC\n");
	}

	return 0;
}


Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	h, w := readInt(), readInt()
	c := make([][]int, 10)
	for i := range c {
		c[i] = make([]int, 10)
		for j := range c[i] {
			c[i][j] = readInt()
		}
	}

	for k := 0; k < 10; k++ {
		for i := 0; i < 10; i++ {
			for j := 0; j < 10; j++ {
				c[i][j] = min(c[i][j], c[i][k]+c[k][j])
			}
		}
	}

	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			a := readInt()
			if a == -1 {
				continue
			}
			ans += c[a][1]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] g = buildGraph(sc, n, m);
        int[] ans = new int[n];
        ArrayDeque<Integer> q = new ArrayDeque<>();
        boolean[] used = new boolean[n];
        used[0] = true;
        q.add(0);
        while(!q.isEmpty()){
            int v = q.poll();
            for(int nv : g[v]){
                if(used[nv]) continue;
                used[nv] = true;
                ans[nv] = v;
                q.add(nv);
            }
        }
        StringBuilder sb = new StringBuilder();
        sb.append("Yes\n");
        for (int i = 1; i < n; i++) {
            int v = ans[i] + 1;
            sb.append(v + "\n");
        }
        System.out.print(sb.toString());
        sc.close();

    }

    public static int[][] buildGraph(Scanner sc, int n, int m) {
        int[][] graph = new int[n][];
        int[][] edges = new int[m][2];
        int[] deg = new int[n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            edges[i][0] = a;
            edges[i][1] = b;
            deg[a]++;
            deg[b]++;
        }
        for (int i = 0; i < n; i++) {
            graph[i] = new int[deg[i]];
        }
        for (int i = 0; i < m; i++) {
            int a = edges[i][0];
            int b = edges[i][1];
            graph[a][--deg[a]] = b;
            graph[b][--deg[b]] = a;
        }

        return graph;
    }

}


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

int main() {
    string S,T,U;
    int counts,countt;
    cin >> S >> T;
    cin >> counts >> countt;
    cin >> U;
    
    
    if(S == U){
        counts--;
        
    }
    else if (T == U){
        countt--;
    }
    
    cout << counts << " " << countt << endl;
    
}





Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s,alt="",lenm="",encm="";
	getline(cin,s);
	vector<string> vec;
	rep(i,s.size()){
		if(i==s.size()-1){
			alt+=s[i];
			vec.push_back(alt);
			alt="";
		}else if(s[i]==' '){
			vec.push_back(alt);
			alt="";
		}else alt+=s[i];
	}
	int cnt[vec.size()];
	rep(i,vec.size())cnt[i]=0;
	rep(i,vec.size()){
		if(vec[i].size()>lenm.size())lenm=vec[i];
		rep(j,vec.size()){
			if(vec[i]==vec[j])cnt[i]++;
		}
	}
	int ma=-1;
	rep(i,vec.size()){
		if(ma<cnt[i]){
			ma=cnt[i];
			encm=vec[i];
		}
	}
	cout<<encm<<" "<<lenm<<endl;
	return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int a = max(max(A, B), C);
  int b = min(min(A, B), C);
  if (C != a && C != b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

typedef long long ll;
typedef vector<vector<ll> > Adj_Mat;


bool contain(int mask, int pos){
	  return ( mask & (1<<pos) ) != 0;
}

int main(){

	  // Input Graph
	  int V,E;
	  cin >> V >> E;
	  Adj_Mat G(V,vector<ll>(V,INT_MAX));
	  for(int i=0; i<E; i++){
			int s,t,d; cin >> s >> t >> d;
			G[s][t] = d;
	  }

	  ll ans = INT_MAX;
	  // Dynamic Programming for TSP
	  for(int st=0; st<V; st++){

			ll dp[ (1<<V) ][ V ];
			for(int i=0; i<(1<<V); i++) for(int j=0; j<V; j++) dp[i][j] = INT_MAX;
			dp[ 0 ][ st ] = 0;

			for(int S=1; S<(1<<V); S++)
				  for(int v=0; v<V; v++)
						if( contain(S,v) )
							  for(int j=0; j<V; j++)
//									if( contain(S,j) and v!=j)
										  dp[S][v] = min(dp[S][v], dp[S-(1<<v)][j] + G[j][v]);
			ans = min(ans,dp[ (1<<V)-1 ][st]);
	  }
	  if( ans >= 1e+9 ) ans = -1;
	  cout << ans << endl;
}

Measured memory_bytes: 5048
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n, m;
	cin >> n >> m;
	vector <int> A(n + 1);
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		if (x == 1 || x == n) {
			A[y]++;
		}
		if (y == n || y == 1) {
			A[x]++;
		} 
	}
	for (int i = 1; i <= n; i++) {
		if (A[i] == 2) {
			cout << "POSSIBLE";
			return 0;
		}
	}
	cout << "IMPOSSIBLE";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	int n;
	cin >> n;
	vector<int> p(n);
	for(int i = 0; i < n; i++) cin >> p[i];

	int res = 0;
	for(int i = 1; i <= n-2; i++){
		if(p[i-1] < p[i] and p[i] < p[i+1]) res++;
		if(p[i-1] > p[i] and p[i] > p[i+1]) res++;
	}

	cout << res << '\n';

	return 0;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	long long ans = 0;
	for (int i = K + 1; i <= N; ++i) {
		ans += (i - K)*((1 + N) / i);
		ans += max(0, ((N + 1)%i) - K); 
		if (0 == K) {
			ans--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3596
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANT ASSIGN A VALUE OF 10^18 IT WILL ASSIGN A LOWER VALUE THAN THAT!!!
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
 #define ll long long
 #define int long long
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
//ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}n..
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
//ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}


void solve()
{
    ll n,m,x;cin>>n>>m>>x;
    ll a[n+3][m+3];
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<=m;j++)
        {
            cin>>a[i][j];
        }
    }
    ll cost=INF;
    
    for(ll i=0;i< (1<< n);i++)
    {
        ll c[m+2];
        memset(c,0,sizeof c);
        ll f=1;
        ll temp = 0;
        ll gone=0;
        for(ll j= 0 ;j<n;j++)
        {
            if((1<<j) & i)
            {
                temp+=a[j][0];f=1;gone=1;
                
                for(ll k=1;k<=m;k++)
                {
                    c[k]+=a[j][k];
                    if(c[k]<x)f=0;
                    
                }
            }
        }
        if(f && gone)cost = min(cost,temp);
        
        
        
    }
    cout<<((cost==INF)?(-1LL):(cost))<<endl;
    
}
signed main()
{
 
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }

 solve();
    return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int x, y, z;
    cin >> x >> y >> z;
    x -= z;
    cout << x / (y+z) << endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "";

    for(int i = 0 ; i < s.length() ; ++i){
      if(s.charAt(i) == '1'){
        ans += "1";
      }
      if(s.charAt(i) == '0'){
        ans += "0";
      }
      if(s.charAt(i) == 'B' && ans.length()>=1){
        ans = ans.substring(0,ans.length()-1);
      }
    }

    System.out.println(ans);
    
  }
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

typedef pair<int, int> P;

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<P, int>> cities;
    rep(i, M) {
        P p;
        cin >> p.second >> p.first;
        cities.push_back(make_pair(p, i));
    }

    sort(cities.begin(), cities.end());

    map<int, int> id;
    vector<string> ans(M);
    for (auto city: cities) {
        P p = city.first;
        id[city.first.second]++;
        stringstream ss;
        ss << setw(6) << setfill('0') << p.second;
        ss << setw(6) << setfill('0') << id[p.second];
        ans[city.second] = ss.str();
    }

    rep(i, ans.size()) cout << ans[i] << endl;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  sort(s.begin(), s.end());
  bool b = true;
  rep(i,n - 1) {
    if (s[i] == s[i + 1]) b = false;
  }
  if(b) cout << "yes" << endl;
  else cout << "no" << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  string s,t;cin>>s>>t;
  for(ll i=0;i<=n;i++){
    bool ans=true;
    rep(j,n-i){
      if(s[i+j]!=t[j])ans=false;
      //cout<<s[i+j]<<" "<<t[j]<<endl;
    }
    if(ans){
      cout<<n+i<<endl;
      return 0;
    }
  }
}

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

int main() {

  int N;
  cin >> N;

  vector<int> moti(N);

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

  sort(moti.begin(), moti.end());
  reverse(moti.begin(), moti.end());

  int ans = 1;
  int sitanomoti = moti.at(0);
  
  for(int i=1; i<N; i++){
    
    if(sitanomoti == moti.at(i)){
      continue;
    }else{
      sitanomoti = moti.at(i);
      ans ++;
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

class AtCoder:
    def main(self):
        X, Y = map(int, input().split())

        ans = 0
        if X == 3:
            ans += 100000
        elif X == 2:
            ans += 200000
        elif X == 1:
            ans += 300000

        if Y == 3:
            ans += 100000
        elif Y == 2:
            ans += 200000
        elif Y == 1:
            ans += 300000

        if X == 1 and Y == 1:
            ans += 400000

        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 39828
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
int main(){
    int n; cin >> n;
    int a[n];
    int ans=1;
    rep(i,n){
        cin >> a[i];
        if(a[i]==ans) ans++;
    }
    if(ans==1) cout << -1 << endl;
    else cout << n-(ans-1) << endl;
    
}



Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;


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

   if (a + b >= 10)
      cout << "error" << endl;
   else
      cout << a + b << endl;
} 


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

const int mod = 1000000007;

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

    long long dp[100001][4] = {};
    dp[0][0] = 1;
    string abc = "ABC";

    for (int i = 0; i < s.length(); i++) {
        for (int j = 0; j < 4; j++) {
            dp[i + 1][j] = dp[i][j] * (s[i] == '?' ? 3 : 1);
            if (j >= 1 && (s[i] == '?' || s[i] == abc[j - 1])) {
                dp[i + 1][j] += dp[i][j - 1];
            }

            dp[i + 1][j] %= mod;
        }
    }

    cout << dp[s.length()][3] << endl;
}

Measured memory_bytes: 3648
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
void mysort(vector<int> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int n ; cin >> n ;
	vector<int> a(n) ;
	for(int i=0;i<n;i++) cin >> a.at(i) ;
	auto b = a ;
	mysort(a) ;
	int m ; cin >> m ;
	int cnt = 0 ;
	for(int i=0;i<n;i++) if(a.at(i)!=b.at(i)) cnt++ ;
	if(cnt==0){
		cout << 0 << endl ;
		return 0 ;
	}
	for(int i=1;i<=m;i++){
		int x,y ;
		cin >> x >> y ;
		x-- ; y-- ;
		if(b.at(x)!=a.at(x)&&b.at(x)==a.at(y)) cnt-- ;
		if(b.at(x)==a.at(x)&&b.at(x)!=a.at(y)) cnt++ ;
		if(b.at(y)!=a.at(y)&&b.at(y)==a.at(x)) cnt-- ;
		if(b.at(y)==a.at(y)&&b.at(y)!=a.at(x)) cnt++ ;
		swap(b.at(x),b.at(y)) ;
		if(cnt==0){
			cout << i << endl ;
			return 0 ;
		}
	}
	cout << -1 << endl ;
}




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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/04  Problem: ABC 096 D / Link: http://abc096.contest.atcoder.jp/tasks/abc096_d  ----- */
vector<long long > make_prime(long long  N) {
	vector<long long >a;
	vector<bool> prime(N + 1);
	FOR(i, 0, N + 1) {
		prime[i] = 1;
	}prime[0] = prime[1] = 0;

	for (LL i = 2; i <= N; i++) {
		if (prime[i]) {
			a.push_back((long long)i);
			for (LL j = i * 2; j <= N; j += i)
				prime[j] = 0;
		}
	}
	return a;
}

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

	LL N; 
	cin >> N;
	auto primes = make_prime(55555);
	LL cnt = 0;
	VL ans;
	for (auto it : primes) {
		if (it % 5 == 1)cnt++,ans.push_back(it);
	}
	DD(de(cnt));
	FOR(i, 0, N) {
		cout << ans[i] << " \n"[i == N - 1];
	}

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int p=a[1],ans=0;
	int temp;
	while(ans<=n)
	{
		if(p==2)
		{
			break;
		}
		temp=p;
		p=a[temp];
		ans++;
	}
	if(ans>n)
	{
		cout<<"-1";
		return 0;
	}
	cout<<ans+1;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int r = 0;
        int g = 0;
        int b = 0;
        for (int i=0;i<n;i++){
            if (s.charAt(i)=='R')r++;
            else if (s.charAt(i)=='G')g++;
            else b++;
        }
        long ans = r*g*(long)b;
        for (int i=0;i<n-2;i++){
            for (int j=i+1;j<n-1;j++){
                if (j+j-i<n&&s.charAt(i)!=s.charAt(j)&&s.charAt(j)!=s.charAt(j+j-i)&&s.charAt(j+j-i)!=s.charAt(i))ans--;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 37140
require 'scanf'

n = STDIN.gets.to_i

for i in 0..n-1 do
    out,score = 0,0
    f=[0,0,0]
    while out < 3 
        str = STDIN.gets
        if str == "HOMERUN\n" then
            score = score+f[0]+f[1]+f[2]+1
            f=[0,0,0]
        elsif str == "HIT\n" then
            score = score+f[2]
            f[2] = f[1]
            f[1] = f[0]
            f[0] = 1
        elsif str == "OUT\n" then
            out = out+1
        end
    end
    print score, "\n"
end

Measured memory_bytes: 6164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) {
    cin >> a[i];
  }

  rep(i, n) {
    if (a[i]%2 == 0 and (a[i]%3 != 0 and a[i]%5 != 0)) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using Graph = vector<vector<LL>>;

long long gcd(long long a, long long b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
long long chmax(long long a,long long b){
  a = max(a,b);
}
long long chmin(long long a, long long b){
  a = min(a,b);
}
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;

    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v);
    }
}



int main() {
  LL n,k,sum=0,a=0,b=0,c=0,d=0,ans=0;
  LL MOD = 1000000007;
  LL INF = 1LL << 60;
  string S="";
  cin >> S;
  if(S=="AAA" || S=="BBB") S = "No";
  else S = "Yes";
  cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector <ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <vector<ll>> vv;
typedef vector <string> vs;
typedef vector <char> vc;


ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl


/*--------------------template--------------------*/

ll a[100] = { 0 };

int main() {
    cin >> n;
    a[0] = 2;
    a[1] = 1;
    REP(i, n) {
        a[i + 2] = a[i + 1] + a[i];
    }
    cout << a[n] << endl;
}

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

int main() {
	int n,a,b,s=0,t=0,u;
	std::cin >> n>>a>>b;

	std::vector<int> v(n);

	for (int& x : v) {
		std::cin >> x;
	}

	std::sort(v.begin(), v.end());

	for (int i = 0; i < n; i++) {
		if (v[i] <= a) {
			s++;
		}
		else if (v[i] <= b) {
			t++;
		}
	}

	u = n - t - s;

	std::cout << std::min({ s, t, u }) << std::endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

s_len = len(S)
t_len = len(T)
R = s_len - t_len
ans = 1000

for i in range(R + 1):
  s_new = S[i : t_len + i]
  count = 0
  for j in range(t_len):
    if s_new[j] != T[j]:
      count += 1
  ans = min(ans, count)

print(ans)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

    vector<int> cost;
    cost.push_back(1);

    int six = 1;
    while(six*6 <= N){
        six *= 6;
        cost.push_back(six);
    }

    int nine = 1;
    while(nine*9 <= N){
        nine *= 9;
        cost.push_back(nine);
    }
    sort(ALL(cost));


    vector<vector<int>> dp(cost.size(), vector<int>(N+1, INF));
    dp[0][0] = 0;

    REP(i,cost.size()){
        REP(j,N+1){
            //同種
            if(j+cost[i] <= N){
                dp[i][j+cost[i]] = min(dp[i][j+cost[i]], dp[i][j]+1);
            }

            //下に移動
            if(i!=cost.size()-1){
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    cout << dp[cost.size()-1][N] << endl;

    return 0;
}

Measured memory_bytes: 8276
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		sc.close();

		if(2 * B == A + C) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int ar[n],ar1[n];
    for(int i=0;i<n;i++)
    {

        int x;
        cin>>x;
        ar[i]=x;
        ar1[i]=x;
    }
    sort(ar,ar+n);
    int count=0;
    for(int i=0;i<n;i++)
    {

        if(ar[i]!=ar1[i]) count++;
    }
    if(count<=2) cout<<"YES";
    else cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a[200001]={0};
	int n,m,x,y,i;
	scanf("%d%d",&n,&m);
	int flag=0;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		if(x==1&&y!=n)
		{
			a[y]++;
		}
		if(y==n&&x!=1)
		{
			a[x]++;
		}
		if(a[x]==2||a[y]==2)
		{
			flag=1;
		}
	}
	if(flag==1) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
} 

Measured memory_bytes: 896
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 500;
const int maxc = 30;

int n, c;
ll cost[maxn][maxn];
ll sum[maxn][maxn];
ll ans = INF;
vector<vector<int>> gr(3);


ll cal(int e,int c) {
	ll s = 0;
	rep(i, gr[e].size()) {
		s += cost[gr[e][i]][c];
	}

	return s;
}

int main() {

	cin >> n >> c;

	rep(i, c) {
		rep(j, c) {
			cin >> cost[i][j];
		}
	}

	rep(i, n) {
		rep(j, n) {
			int x; cin >> x; x--;
			gr[(i + j) % 3].push_back(x);
		}
	}

	rep(i,3){
		rep(j, c) {
			sum[i][j] = cal(i, j);
		}
	}

	for (int i = 0; i < c; i++) {
		for (int j = 0; j < c; j++) {
			for (int k = 0; k < c; k++) {
				if (i != j && j != k && k != i) {
					ans = min(ans, sum[0][i] + sum[1][j] + sum[2][k]);
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1648
#include <stdio.h>

int main(){
	int H,W,i,j;
	while(scanf("%d %d",&H,&W),H>0&&W>0){
		for(i=0;i<H;++i){
			for(j=0;j<W;++j){
				if(i%2==1){
					if(j%2==0){
						printf(".");
					}else if(j%2==1){
					    printf("#");
					}
				}else if(i%2==0){
					if(j%2==0){
						printf("#");
					}else if(j%2==1){
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

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


Measured memory_bytes: 3552
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] s = str.split(" ");
        int N = Integer.parseInt(s[0]);
        int Q = Integer.parseInt(s[1]);
        String str1 = "0" + br.readLine() + "0";
        String[][] td = new String[Q][2];
        for (int i=0;i<Q;i++){
            str = br.readLine();
            td[i] = str.split(" ");
        }
        System.out.println(B_search.b_search(N, str1, td, "R")-B_search.b_search(N, str1, td, "L"));
    }
}

class B_search{
    public static int b_search(int N,String str1,String[][] TD,String LR){
        int index = 0;
        int s = 0;
        int e = N+1;
        char c;
        String str;
        while (s!=e){
            index = (s+e)/2;
            for (int i=0;i<TD.length;i++){
                c = str1.charAt(index);
                str = String.valueOf(c);
                if (str.equals(TD[i][0])){
                    if (TD[i][1].equals("L")){
                        index--;
                    } else {
                        index++;
                    }
                }
                if (index<=0 || index>N){
                    break;
                }
            }
            if (LR.equals("L")){
                if (index<=0){
                    s = (s+e)/2+1;
                } else {
                    e = (s+e)/2;
                }
            } else {
                if (index>N){
                    e = (s+e)/2;
                } else {
                    s = (s+e)/2+1;
                }
            }
        }
        return s;
    }
}

Measured memory_bytes: 121976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p.at(i);
    }
    int ans=0;
    for(int i=1; i<n-1; i++){
        if(p[i-1] < p[i] and p[i] < p[i+1]){
          ans++;
        }else if(p[i+1] < p[i] and p[i] < p[i-1]){
          ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#!python3.8
# -*- coding: utf-8 -*-
# abc174/abc174_c
import sys
 
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
 
def main():
    K = i2n()
    a = 0
    if K % 7:
        L = 9 * K
    else:
        L = 9 * K // 7
    a = 1
    for i in range(1, K + 10):
        a = (a * 10) % L
        if a == 1:
            print(i)
            return
    print('-1')
    return

main()

Measured memory_bytes: 9168
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int n; cin >> n;
  if(n <= 999) cout << "ABC\n";
  else cout << "ABD\n";
  return;
}
int main(){
  solve();
  return 0;
}


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

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

Measured memory_bytes: 3672
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  map<string,int> mp;
  int n;
  cin >> n;
  REP(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  int m;
  cin >> m;
  REP(i,m){
    string t;
    cin >> t;
    mp[t]--;
  }
  int max = 0;
  for(auto v : mp){
    if(v.second > max) max = v.second;
  }
  cout << max << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int m1, d1;
    int m2, d2;
    scanf("%d%d", &m1, &d1);
    scanf("%d%d", &m2, &d2);
    if(m1 == m2){
        printf("0");
    }else{
        printf("1");
    }

    return 0;
}

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

int main(){
    int x;
    scanf("%d", &x);
    x = x%10;
    if(x == 2 || x == 4 || x == 5 ||x == 7 || x == 9){
        printf("hon");
    }
    if(x == 0 || x == 1 || x == 6 ||x == 8){
        printf("pon");
    }
    if(x == 3)
        printf("bon");
    return 0;
}

Measured memory_bytes: 1736
from sys import stdin

n,t = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))

point = 0

lin = []

for i in range(1,n):
    lin.append(li[i]-li[i-1])

for i in lin:
    if i <= t:
        point += i
    else:
        point += t

point += t

print(point)

Measured memory_bytes: 26708
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from bisect import bisect_left


class BIT:  # 0-indexed
    def __init__(self, n):
        self.tree = [0] * (n + 1)
        self.tree[0] = None

    def sum(self, i):  # a_0 + ... + a_{i} #閉区間
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def range(self, l, r):  # a_l + ... + a_r 閉区間
        return sum(r) - sum(l - 1)

    def add(self, i, x):
        i += 1
        while i <= n:
            self.tree[i] += x
            i += i & -i


n, k = map(int, readline().split())
a = list(map(int, readline().split()))
s_a = sorted(a)
mod = 10 ** 9 + 7
bit = BIT(n)
res = [0] * n
ans = 0
for i, b in enumerate(a):
    j = bisect_left(s_a, b)
    res[i] = i - bit.sum(j)
    bit.add(j, 1)
for i, b in enumerate(a):
    ans += k * res[i]
    ans %= mod
    j = bisect_left(s_a, b)
    ans += (k * (k - 1) // 2 % mod) * (n - bit.sum(j))
    ans %= mod
print(ans)


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e2, mod = 1e9 + 7;
int n, h[nsz + 5], dp[nsz + 5], f[nsz + 5][nsz + 5];

num inline qpow(num a, int p) {
    num res = 1;
    for (; p > 0; p >>= 1) {
        if (p & 1) {
            res *= a;
            res %= mod;
        }
        a *= a;
        a %= mod;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    cont (i, n) {
        cin >> h[i];
    }
    dp[1] = qpow(2, h[1]);
    cont (i, n) {
        f[1][i] = 2 * qpow(2, h[1] - h[i]) % mod;
    }
    circ (i, 2, n) {
        dp[i] = (dp[i - 1] + f[i - 1][i]) * qpow(2, h[i] - h[i - 1]) % mod;
        cont (j, n) {
            if (h[i] <= h[i - 1]) {
                f[i][j] = h[i] > h[j] ? f[i - 1][j] : f[i - 1][i];
            } else {
                if (h[i] > h[j]) {
                    f[i][j] = f[i - 1][j] * qpow(2, h[i] - (h[j] > h[i - 1] ? h[j] : h[i - 1])) % mod;
                } else {
                    f[i][j] = f[i - 1][j];
                }
            }
            f[i][j] += f[i - 1][i] * qpow(2, h[i] - max(h[i - 1], h[j])) % mod;
            f[i][j] %= mod;
        }
    }
    cout << dp[n] << ln;
}


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

using namespace std;
int main(){
	string S;
	cin >> S;
	int N;
	N = S.size()-1;
	long long sum;
	long long ans = 0;
	for (int bit = 0; bit < (1 << N); bit++) {
		sum = S[0] - '0';
		
		for (int i = 0; i < N; i++) {
			if ((1<<i) & bit) {
				ans += sum;
				sum = 0;
				sum += S[i + 1] - '0';
			}
			else { sum = sum * 10 + S[i + 1] - '0'; }
		}
		ans += sum;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
//B - Resale
int main(void){
    int n;
    std::cin >> n;
    int v[50],c[50];
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> c[i];
    }
    int ans=0;
    for (int i = 0; i < n; i++) {
        if(v[i]>c[i]){
            ans+=v[i]-c[i];
        }
    }   
    
    std::cout << ans << std::endl;
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int H = scanner.nextInt();
			int W = scanner.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W - 1; j++) {
					System.out.print("#");
				}
				System.out.println("#");
			}
			System.out.println("");
		}
	}
}


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

int main(){
  string S;
  cin >> S;
  reverse(S.begin(), S.end());
  int N = S.length();
  const long long INF = 1e18;
  vector<long long> dp(2,INF);
  dp[0] = 0;
  for(auto c : S){
    vector<long long> dp_(2,INF);
    for(int i = 0; i < 2; ++i){
      int d = c-'0'+i;
      dp_[1] = min(dp_[1],dp[i]+10-d);
      dp_[d/10] = min(dp_[d/10],dp[i]+d%10);
    }
    swap(dp,dp_);
  }
  ++dp[1];
  cout << min(dp[0],dp[1]) << endl;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n+1);
    vector<int> b(n+1);
    a[0]=99999;
    b[0]=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=2;i<=n;i++)
    {
        b[i]=min(abs(a[i]-a[i-1])+b[i-1],abs(a[i]-a[i-2])+b[i-2]);
        //cout<<b[i]<<endl;
        //cout<<abs(a[i]-a[i-1])<<endl;
        //cout<<abs(a[i]-a[i-2])<<endl;
    }
    cout<<b[n];
}


Measured memory_bytes: 1024