akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int h,w;
	cin >> h >> w;
	vector<vector<char>> s = vector<vector<char>>(h, vector<char>(w));
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			cin >> s[i][j];
		}
	}
	if(s[0][0] == '#' && s[0][1] == '.' && s[1][0] == '.'){
				cout << "No";
				return 0;
	}
	if(s[0][w-1] == '#' && s[0][w-2] == '.' && s[1][w-1] == '.'){
				cout << "No";
				return 0;
	}
	if(s[h-1][0] == '#' && s[h-1][1] == '.' && s[h-2][0] == '.'){
				cout << "No";
				return 0;
	}
	if(s[h-1][w-1] == '#' && s[h-1][w-2] == '.' && s[h-2][w-1] == '.'){
				cout << "No";
				return 0;
	}
	for(int i = 1;i < h-1;i++){
		for(int j = 1;j < w-1;j++){
			if(s[i][j] == '#' && s[i-1][j] == '.' && s[i][j-1] == '.' && s[i+1][j] == '.' && s[i][j+1] == '.'){
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

multiset<int> small, big;
int smallsum, bigsum, sumb;

int calc(int x) { return x * small.size() - smallsum + bigsum - x * big.size() + sumb; }

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

    int q;
    cin >> q;
    while (q--)
    {
        int f;
        cin >> f;
        if (f == 1)
        {
            int a, b;
            cin >> a >> b;
            sumb += b;
            if (small.empty() || a < *small.rbegin())
            {
                small.insert(a);
                smallsum += a;
            }
            else
            {
                big.insert(a);
                bigsum += a;
            }
            while (small.size() < big.size())
            {
                small.insert(*big.begin());
                smallsum += *big.begin();
                bigsum -= *big.begin();
                big.erase(big.begin());
            }
            while (small.size() > big.size() + 1)
            {
                big.insert(*small.rbegin());
                bigsum += *small.rbegin();
                smallsum -= *small.rbegin();
                small.erase(small.find(*small.rbegin()));
            }
        }
        else
            cout << *small.rbegin() << " " << calc(*small.rbegin()) << endl;
    }
}

Measured memory_bytes: 9600
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
  int n;
  cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++)
    cin>>s[i];
  vector<int> cou(26,1000000000);
  for(int i=0;i<26;i++)
  {
    for(int j=0;j<n;j++)
    {
      int tmp=0;
      for(int k=0;k<s[j].size();k++)
        if(s[j][k]==char('a'+i))
          tmp++;
      cou[i]=min(cou[i],tmp);
    }
  }
  for(int i=0;i<26;i++)
  {
    for(int j=0;j<cou[i];j++)
      cout<<char('a'+i);
  }
  cout<<endl;
}


Measured memory_bytes: 256
import sys
from heapq import heapify, heappop, heappush

class UFT(): #Union-find tree class
    def __init__(self, N): 
        self.tree = [int(i) for i in range(N)] 
        self.rank = [0 for i in range(N)]

    def find(self, a):
        if self.tree[a] == a: return a
        else:
            self.tree[a] = self.find(self.tree[a])
            return self.tree[a]

    def unite(self, a, b):
        a = self.find(a)
        b = self.find(b)
        if a == b: return
        if self.rank[a] < self.rank[b]: self.tree[a] = b
        else:
            self.tree[b] = a
            if self.rank[a] == self.rank[b]: self.rank[a] += 1
def solve():
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    parent = UFT(N)
    for i in range(M):
        x, y = map(int, input().split())
        parent.unite(x, y)
    totalForest = 0
    minCost = 0
    minF = dict()
    for i in range(N):
        a = parent.find(i)
        if a in minF: heappush(minF[a], A[i])
        else: 
            minF[a] = []
            heapify(minF[a])
            heappush(minF[a], A[i])
            totalForest += 1

    f = []
    heapify(f)
    sonNode = []
    heapify(sonNode) 
    if totalForest > 1:
        for key in minF: 
            minCost += heappop(minF[key])
            while minF[key]: heappush(sonNode, heappop(minF[key]))
   
    for _ in range(max(totalForest - 2, 0)):
        if not sonNode: 
            print("Impossible")
            break
        minCost += heappop(sonNode)
    else: print(minCost)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 33448
package main

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

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}
func NextIntIntMap() map[int]int {
  var s []string = strings.Split(NextLine()," ")
  var n,a int
  n = len(s)
  m := map[int]int{}
  for i:=0;i<n;i++ {
    a,_ = strconv.Atoi(s[i])
    m[i] = a
  }
  return m
}

func main() {
  var n,m1,m2 int
  var m float64
  n = NextInt()
  x := NextIntIntMap()
  y := Entries{}
  for key,val := range x {
    e := Entry{key,val}
    y = append(y,e)
  }
  sort.Sort(y)
  m1 = y[n/2-1].val
  m2 = y[n/2].val
  m = float64(m1+m2)*0.5
  for key:=0;key<n;key++ {
    val,_ := x[key]
    if float64(val) < m {
      fmt.Println(m2)
    } else {
      fmt.Println(m1)
    }
  }
}
type Entry struct {
  key int
  val int
}
type Entries []Entry
func(entries Entries) Len() int {
  return len(entries)
}
func(entries Entries) Swap(i,j int) {
  entries[i],entries[j] = entries[j],entries[i]
}
func(entries Entries) Less(i,j int) bool {
  if entries[i].val == entries[j].val {
    return entries[i].key < entries[j].key
  } else {
    return entries[i].val < entries[j].val
  }
}

Measured memory_bytes: 31104
M=10**9+7
S=gets.chomp
dp=Array.new(S.size+1){0}
dpA=Array.new(S.size+1){0}
dpAB=Array.new(S.size+1){0}
dpABC=Array.new(S.size+1){0}
dp[0]=1
S.size.times do |i|
  if S[i]==?A || S[i]==??
    dp[i+1] += dp[i]
    dpA[i+1] += dpA[i] + dp[i]
    dpAB[i+1] += dpAB[i]
    dpABC[i+1] += dpABC[i]
  end
  if S[i]==?B || S[i]==??
    dp[i+1] += dp[i]
    dpA[i+1] += dpA[i]
    dpAB[i+1] += dpAB[i] + dpA[i]
    dpABC[i+1] += dpABC[i]
  end
  if S[i]==?C || S[i]==??
    dp[i+1] += dp[i]
    dpA[i+1] += dpA[i]
    dpAB[i+1] += dpAB[i]
    dpABC[i+1] += dpABC[i] + dpAB[i]
  end
  dp[i+1] %= M
  dpA[i+1] %= M
  dpAB[i+1] %= M
  dpABC[i+1] %= M
end
p dpABC.last


Measured memory_bytes: 5116
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}



#[allow(non_snake_case, unused_variables)]
fn main() {
    input!{
        N: usize,
        M: usize,
        K: usize,
    }
    let mut ans = "No";
    for n in 0..N+1 {
        for m in 0..M+1 {
            if n*(M-m)+m*(N-n) == K {
                ans = "Yes";
                break;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
long cnt = 0;
void merge(int A[], int left, int mid, int right)
{
	const int INF = 999999999;
	int ln = mid - left + 1;
	int rn = right - mid;
	int *L = new int[ln + 1];
	int *R = new int[rn + 1];
	for (int i = 0; i < ln; i++)
		L[i] = A[left + i];
	for (int i = 0; i < rn; i++)
		R[i] = A[mid + 1 + i];
	L[ln] = R[rn] = INF;
	int i = 0, j = 0;
	for (int k = left; k <= right; k++)
	{
		if (L[i] <= R[j])
			A[k] = L[i++];
		else
		{
			A[k] = R[j++];
			cnt += (ln - i);
		}
	}
	delete[] L;
	delete[] R;
}
void mergeSort(int A[], int left, int right)
{
	if (left >= right)
		return;
	int mid = (left + right) / 2;
	mergeSort(A, left, mid);
	mergeSort(A, mid + 1,right);
	merge(A, left, mid, right);
}
int main()
{
	int n;
	cin >> n;
	int *A = new int[n];
	for (int i = 0; i < n; i++)
		cin >> A[i];
	mergeSort(A, 0, n - 1);
	cout << cnt << endl;
	delete[] A;
}


Measured memory_bytes: 4328
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑


string h;
ll dp[100005][15], mon;
int main() {
	cin >> h;
	dp[0][0] = 1;
	for (int i = 0; i < h.length(); ++i) {
		if (h[i] == '?') { mon = -1; }
		else { mon = h[i] - '0'; }

		for (int j = 0; j < 10; ++j) {
			if (mon >= 0 && mon != j) { continue; }
			for (int k = 0; k < 13; ++k) { dp[i + 1][(10 * k + j) % 13] += dp[i][k]; }
		}

		for (int j = 0; j < 13; ++j) { dp[i + 1][j] %= MOD; }
	}

	cout << dp[h.length()][5] << endl;
}

Measured memory_bytes: 12800
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
string s;
int main()
{
	cin >> s;
	int f = 0;
	for (int i = 1; s[i]; i++)
	{
		if (s[i] > s[0])
		{
			f = 1;
			break;
		}
	}
	for (int i = 0; i < s.size(); i++)
	{	if (!f)
			printf("%c", s[0]);
		else
			printf("%c", s[0] + 1);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll r;
	cin >> r;
	cout << r * pi * 2 << endl;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n;
  cin>>n;
  map<ll,ll> memo;
  ll a[n];
  ll four=0,two_1=0,two_2=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    memo[a[i]]++;
    if(memo[a[i]]==2){
      if(a[i]>two_1){
        two_2=two_1;
        two_1=a[i];
      }
      else if(a[i]>two_2){
        two_2=a[i];
      }
    }
    if(memo[a[i]]==4){
      if(a[i]>four) four=a[i];
    }
  }
  ll ans=max(four*four,two_1*two_2);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 10556
#include <iostream>
 
int main(){
    using namespace std;
 
    int x = 0;
    int y = 0;
    while( true ){
        cin >> x >> y;
        if( x == 0 && y == 0 ) break;
        if( x >= y ){
            cout << y << " " << x << endl; 
        }else{
            cout << x << " " << y << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define int long long
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int n, limit;
	cin >> n >> limit;
	vector<vector<int>> a(4, vector<int>());
	vector<int> w(n), v(n);
	rep(i, n) {
		cin >> w[i] >> v[i];
		a[w[i] - w[0]].pb(v[i]);
	}
	rep(i, 4) sort(all(a[i]), greater<int>());
	vector<vector<int>> sum(4, vector<int>(1));
	rep(i, 4) {
		int p = 0;
		rep(j, a[i].size()) {
			p += a[i][j];
			sum[i].pb(p);
		}
	}
	int ans = 0;
	rep(i, a[0].size() + 1) {
		rep(j, a[1].size() + 1) {
			rep(k, a[2].size() + 1) {
				int cost = i * w[0] + j * (w[0] + 1) + k * (w[0] + 2);
				if (cost > limit) continue;
				int value = sum[0][i] + sum[1][j] + sum[2][k];
				int rem = limit - cost;
				rem /= (w[0] + 3);
				int r = min(rem, (ll)a[3].size());
				value += sum[3][r];
				chmax(ans, value);
			}
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
//const int inf = int(1e10);
const ll inf = ll(1e19);
const int mod = int(1e9) + 7;

ll n, a[int(1e5)], res;
//i番目までの要素に対して操作を行った時の最大値
ll dp[int(1e5)][2];
int main(){
    cin >> n;
    rep(i, n){
        cin >> a[i];
        res += a[i];
    }
    rep(i, int(1e5)){
        dp[i][0] = -inf;
        dp[i][1] = -inf;
    }
    dp[0][0] = a[0] + a[1];
    dp[0][1] = -(a[0] + a[1]);
    for(int i = 0; i < n - 2; i++){
        dp[i + 1][0] = max(dp[i + 1][0], dp[i][0] + a[i + 2]);
        dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + a[i + 2]);
        //cout << i << ' ' << dp[i + 1][0] << endl;
        dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] - 2 * a[i + 1] - a[i + 2]);
        dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + 2 * a[i + 1] - a[i + 2]);
        //cout << i << ' ' << dp[i + 1][1] << endl;
    }

    cout << max(dp[n - 2][0], dp[n - 2][1]) << endl;
}

Measured memory_bytes: 5828
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    ll N;
    cin>>N;
    vector<vector<ll>> as(N, vector<ll>(N));
    rep(i, N) {
        rep(j, N - 1) {
            ll a;
            cin>>a; a--;
            as[i][j] = a;
        }
    }

    vector<ll> is(N);
    bool contested = true;
    ll cnt = 0;
    while(contested) {
        contested = false;
        vector<bool> visited(N, false);
        rep(i, N) {
            if (is[i] == N - 1) continue;

            ll a = as[i][is[i]];
            if (visited[i]) continue;
            if (visited[a]) continue;

            if (as[a][is[a]] == i) {
                is[i]++; is[a]++;
                contested = true;
                visited[i] = true;
                visited[a] = true;
            }
        }
        if (contested) cnt++;
    }

    ll ans = cnt;
    rep(i, N) if (is[i] != N - 1) ans = -1;
    cout<<ans<<endl;
}

Measured memory_bytes: 10112
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;int M=10001,i,j,c;vector<int>s(1,0),p(M);main(){for(i=1;++i<M;)for(j=i+i;j<M;j+=i)p[j]=1;for(i=1;++i<M;)if(!p[i])s.push_back(i+s.back());for(;cin>>j,j;cout<<c<<endl){vector<int>::iterator t=s.begin();for(c=0;t!=s.end();t++)c+=count(t,s.end(),*t+j);}}

Measured memory_bytes: 1272
/*  Seventeen and we got a dream to have a family           */
/*  A house and everything in between                       */
/*  And then, oh, suddenly we turned twenty-three           */
/*  Now we got pressure for taking our life more seriously  */
/*  We got our dead-end jobs and got bills to pay           */
/*  Have old friends and know our enemies                   */
/*  Now I, I'm thinking back to when I was young            */
/*  Back to the day when I was falling in love              */
/*  He used to meet me on the Eastside                      */
/*  In the city where the sun don't set                     */

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;
ll mod=1000000007;

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

ll t=1;
//cin>>t;
while(t--)
{

ll n,p;
cin>>p>>n;
ll a[n],i;
for(i=0;i<n;i++)
cin>>a[i];

ll ma=0;
for(i=1;i<n;i++)
ma=max(ma,a[i]-a[i-1]);


ma=max(ma,p-a[n-1]+a[0]);

cout<<p-ma<<endl;
}
return 0;
}



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

using namespace std;

const int N = 105, inf = 1e9 + 7;

char grid[N][N];
int dp[N][N];

int main() {
  int n, m;
  scanf("%d %d" ,&n, &m);
  for (int i = 0; i < n; ++i)
    scanf("%s", grid[i]);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      dp[i][j] = inf;
    }
  dp[0][0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (i+1 < n) {
        dp[i+1][j] = min(dp[i+1][j], dp[i][j] + (grid[i+1][j] != grid[i][j]));
      }
      if (j+1 < m) {
        dp[i][j+1] = min(dp[i][j+1], dp[i][j] + (grid[i][j+1] != grid[i][j]));
      }
    }
  }
  int ans = dp[n-1][m-1];
  if (grid[0][0] == '#')
    ++ans;
  if (grid[n-1][m-1] == '#')
    ++ans;
  printf("%d\n", ans / 2);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)
ll vis[100005],parent[100005];
vector<ll> v[100005];
void bfs(ll top){
	queue <ll> q;
	q.push(top);
	vis[top]=1;
	ll flag=0;
	ll i,p;
	while(!q.empty()){
		p=q.front();
		q.pop();
		for(i=0;i<v[p].size();i++){
			if(vis[v[p][i]]==0){
				vis[v[p][i]]=1;
				parent[v[p][i]] = p;
				q.push(v[p][i]);
			}
		}
	}
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,k,q,x,y,l,r,z,n,flag =0,m;
    cin>>n>>m;
    rep(i,1,m){
    	cin>>x>>y;
    	v[x].pb(y);
    	v[y].pb(x);
	}
	bfs(1);
	if(v[1].size() == 0) cout<<"No";
	else{
		cout<<"Yes\n";
		rep(i,2,n) cout<<parent[i]<<endl;
	}
}

Measured memory_bytes: 13808
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

long long dp[100001][14];

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

	int prev[13][10];
	for (auto i = 0; i < 13; ++i)
	{
		for (auto k = 0; k < 10; ++k)
		{
			prev[i][k] = -1;
			for (auto j = 0; j < 13; ++j)
			{
				if ((j * 10 + k) % 13 == i)
				{
					if (prev[i][k] > 0)
					{
						prev[i][k] = j;
					}
					prev[i][k] = j;
				}
			}
		}
	}

	dp[0][0] = 1;
	auto mod = (long long)1e9 + 7;
	for (auto i = 0; i < S.length(); ++i)
	{
		for (auto j = 0; j < 13; ++j)
		{
			if (S[i] == '?')
			{
				for (auto k = 0; k < 10; ++k)
				{
					dp[i + 1][j] += dp[i][prev[j][k]];
					dp[i + 1][j] %= mod;
				}
			}
			else
			{
				auto num = (int)(S[i] - '0');
				dp[i + 1][j] = dp[i][prev[j][num]];
			}
		}
	}

	cout << dp[S.length()][5] << endl;

	return 0;
}

Measured memory_bytes: 11392
#include <iostream>
#include <stdio.h>
using namespace std;

int HelloWorld(){
	cout << "Hello World" << endl;
	return 0;
}

int XCubic(){
	int x;
	cin >> x;
	if (1 <= x && x <= 100){
		x = x*x*x;
		cout << x << endl;
		return 0;
	}
	return 1;
}

int Rectangle(){
	int a, b, area, perimeter;

	cin >> a >>b;
	if (1 <= a && b <= 100){
		area = a*b;
		perimeter = (a + b) * 2;
		cout << area << " " << perimeter << endl;
		return 0;
	}
	return 1;
}

int Watch(){
	int S;
	cin >> S;
	
	
	int D = 60;
	int s = S%D;
	int m = (S / D) % D;
	int h = (S / D) / D;
	if (0 <= S && S <= 86400){
		printf("%u:%u:%u\n", h, m, s);
		return 0;
	}
	
	return 1;
}

int SmallLargeOrEqual(){
	int a, b;
	cin >> a >> b;
	if (!(a <= a && b <= 1000)) return 1;
	if (a < b)		cout << "a < b" << endl;
	else if (a > b) cout << "a > b" << endl;
	else			cout << "a == b" << endl;
	return 0;
}

int Range(){
	int a, b,c;
	bool flag = true;

	cin >> a >> b >> c;
	if (!(0 <= a && a <= 100)) return 1;
	if (!(0 <= b && b <= 100)) return 1;
	if (!(0 <= c && c <= 100)) return 1;

	if (!(a < b)) flag=false;
	if (!(b < c)) flag = false;

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

int SortingThreeNumbers(){
	int a, b, c,temp;
	cin >> a >> b >> c;

	if (!(1 <= a && a <= 10000)) return 1;
	if (!(1 <= b && b <= 10000)) return 1;
	if (!(1 <= c && c <= 10000)) return 1;

	if (a > b){
		temp = a;
		a = b;
		b = temp;
	}
	if (b > c){
		temp = b;
		b = c;
		c = temp;
	}
	if (a > b){
		temp = a;
		a = b;
		b = temp;
	}

	printf("%u %u %u\n", a, b, c);
	
	
	return 0;
}

int CircleInARectangle(){
	int W, H, x, y, r;
	bool flag = true;
	cin >> W >> H >> x >> y >> r;
	if (!(-100 <= x && x <= 100)) return 1;
	if (!(-100 <= y && y <= 100)) return 1;
	if (!(0 <= W && W <= 100)) return 1;
	if (!(0 <= H && H <= 100)) return 1;
	if (!(0 <= r && r <= 100)) return 1;


	if ((x - r) < 0) flag = false;
	if ((y - r) < 0) flag = false;
	if (W < (x + r)) flag = false;
	if (H < (y + r)) flag = false;

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

int main(){
	//HelloWorld();
	//XCubic();
	//Rectangle();
	//Watch();
	//SmallLargeOrEqual();
	//Range();
	//SortingThreeNumbers();
	CircleInARectangle();
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int dx[8334], dy[8334], cntx, cnty;
int dpx[8334][16334], dpy[8334][16334];

void dfs1(int ind, int d){
	if(ind>=cntx || (dpx[ind+1][d+dx[ind]] && dpx[ind+1][d-dx[ind]])){
		return;
	}
	dpx[ind+1][d+dx[ind]]=1;
	dpx[ind+1][d-dx[ind]]=1;
	dfs1(ind+1, d+dx[ind]);
	dfs1(ind+1, d-dx[ind]);
	return;
}

void dfs2(int ind, int d){
	if(ind>=cnty || (dpy[ind+1][d+dy[ind]] && dpy[ind+1][d-dy[ind]])){
		return;
	}
	dpy[ind+1][d+dy[ind]]=1;
	dpy[ind+1][d-dy[ind]]=1;
	dfs2(ind+1, d+dy[ind]);
	dfs2(ind+1, d-dy[ind]);
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y;
	string s;
	cin>>s>>x>>y;
	bool f=true;
	int indx=0, indy=0, len=s.size(), i=0;
	s+='A';
	while(i<len){
		if(s[i]=='T'){
			f=!f;
			++i;
		}
		else if(f){
			int cnt=0;
			while(i<len){
				++cnt;
				++i;
				if(s[i]!='F'){
					break;
				}
			}
			dx[indx]=cnt;
			++indx;
		}
		else{
			int cnt=0;
			while(i<len){
				++cnt;
				++i;
				if(s[i]!='F'){
					break;
				}
			}
			dy[indy]=cnt;
			++indy;
		}
	}
	cntx=indx;
	cnty=indy;
	dpx[0][8000]=1;
	if(s[0]=='F'){
		dpx[1][dx[0]+8000]=1;
		dfs1(1, dx[0]+8000);
	}
	else{
		dfs1(0, 8000);
	}
	dpy[0][8000]=1;
	dfs2(0, 8000);
	cout<<(dpx[cntx][x+8000] & dpy[cnty][y+8000] ? "Yes" : "No")<<'\n';
	return 0;
}


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

int main(){
    string alth;
    char inalth;
    alth = "abcdefghijklmnopqrstuvwxyz";
    cin >> inalth;
    for (int i = 0; i < 27; i++){
        if(inalth == alth[i]){
            i += 1;
            cout << alth[i] << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int a[3];
	rep(i,3)cin>>a[i];
	sort(a,a+3);
	cout<<a[0]*a[1]/2;
}

Measured memory_bytes: 256
def main():
    from itertools import accumulate
    n, *ab = map(int, open(0).read().split())

    c = list(zip(*[iter(ab)] * 2))
    c.sort(key=lambda x: (x[1], x[0]))
    d, f = zip(*c)
    
    g = all(i <= j for i, j in zip(accumulate(d), f))
    print('Yes' if g else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 50080
a,b,i,c,k[3100];main(){for(scanf("%d%d",&a,&b);;puts("")){c=0;for(i=a;i<=b;i++)if(i%400==0||(i%100!=0&&i%4==0))k[c++]=i;if(!c)puts("NA");else for(i=0;i<c;)printf("%d\n",k[i++]);scanf("%d%d",&a,&b);if(!a)exit(0);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,T;
	cin>>A>>B>>T;
	int count = 0;
	for(int i=A;;i++)
	{
		if(i>T+0.5) break;
		if(i%A==0)
		{
			count+=B;
		}
	}
	cout<<count<<endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc086/tasks/arc089_a

#include <algorithm>
#include <cmath>   // abs() for float, and fabs()
#include <cstdlib> // abs() for integer
#include <iostream>
#include <string>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

int main() {
    signed n, t, x, y, dt, ans = 0, X = 0, Y = 0, T = 0;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> t >> x >> y;
        // 前回から移動できるか確認
        if (ans == 0) {
            dt = abs((X - x) + (Y - y));
            // 時間内にたどり着けて、余りが２の倍数の場合
            if (dt <= (t - T) && (bool)((t - T) & 1) == (bool)(dt & 1)) {
                X = x;
                Y = y;
                T = t;
            } else {
                ans = 1;
            }
        }
    }

    if (ans == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {


	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		int a,b,c,cnt;
		
		a=sc.nextInt();
		b=sc.nextInt();
		c=sc.nextInt();
		
		cnt=0;
		for(int i=a;i<=b;i++){
			if (c % i==0){
				cnt++;
			}
		}
		System.out.println(cnt);
		
	}

}

Measured memory_bytes: 17328
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;

int ans = 0;
void calc(long long int x, long long int y);


int main() {

	long long int X, Y;

	cin >> X >> Y;

	calc(X, Y);

	return 0;

}


void calc(long long int x, long long int y) {
	if (y / x >= 1) {
		ans++;
		calc(x * 2, y);
	}
	else {
		cout << ans;
	}
}

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << ( max(a, b) - min(a, b) == 1 or max(a, b) - min(a, b) == 0 ? "Yay!" : ":(" ) << endl;
}

Measured memory_bytes: 256
// AOJ 	0598: JOI Emblem
// 2018.1.26 bal4u

#include <stdio.h>
#include <string.h>

int h, w;
char s[1005][1005];
char t[3][5];

int f(int r, int c)
{
	int ans = 0;

	if (r >= 1 && c >= 1 && s[r-1][c-1] == t[0][0] && s[r-1][c] == t[0][1] && s[r][c-1] == t[1][0] && s[r][c] == t[1][1]) ans++;
	if (r >= 1 && c < w  && s[r-1][c] == t[0][0] && s[r-1][c+1] == t[0][1] && s[r][c] == t[1][0] && s[r][c+1] == t[1][1]) ans++;
	if (r < h  && c >= 1 && s[r][c-1] == t[0][0] && s[r][c] == t[0][1] && s[r+1][c-1] == t[1][0] && s[r+1][c] == t[1][1]) ans++;
	if (r < h  && c < w  && s[r][c] == t[0][0] && s[r][c+1] == t[0][1] && s[r+1][c] == t[1][0] && s[r+1][c+1] == t[1][1]) ans++;
	return ans;
}

int main()
{
	int m, n, i, r, c, t1, t2, ans, cnt;
	char buf[15], cc, a[4] = "JOI";

	fgets(buf, 15, stdin), sscanf(buf, "%d%d", &m, &n); h = m-1, w = n-1;
	for (r = 0; r < m; r++) fgets(s[r], 1005, stdin);
	for (r = 0; r < 2; r++) fgets(t[r], 5, stdin);

	ans = 0;
	for (r = 0; r < h; r++) for (c = 0; c < w; c++) {
		if (s[r][c] == t[0][0] && s[r][c+1] == t[0][1] && s[r+1][c] == t[1][0] && s[r+1][c+1] == t[1][1])
			ans++;
	}
	
	cnt = 0;
	for (r = 0; r < m; r++) for (c = 0; c < n; c++) {
		cc = s[r][c];
		t1 = f(r, c);
		for (i = 0; i < 3; i++) {
			s[r][c] = a[i], t2 = f(r, c);
			if (t2 - t1 > cnt) cnt = t2 - t1;
		}
		s[r][c] = cc;
	}

	printf("%d\n", ans + cnt);
	return 0;
}



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

int main() {
  int N, K, l=0;
  cin >> N >> K;
  vector<int>o(N);
  for(int i=0;i<K;i++){
    int d;
    cin >> d;
    for(int j=0;j<d;j++){
      int A;
      cin >> A;
      o.at(A-1)++;
    }
  }
  for(int i=0;i<N;i++){
    if(o.at(i)==0)
      l++;
  }
  cout << l << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int k; cin>>k;
  queue<ll> q;
  rep(i,9) q.push(i+1);
  int c=9;
  if(k<10){
    cout<<k<<endl;
  }else{
    while(1){
      for(int i=-1;i<=1;i++){
        ll t=q.front();
        int ls=t%10;
        // cout<<ls<<endl;
        if(ls+i<0||ls+i>9) continue;
        t*=10;
        t+=ls+i;
        q.push(t);
        c++;
        // cout<<t<<" "<<c<<endl;
        if(c==k){
          cout<<t<<endl;
          return 0;
        }
      }
      q.pop();
    }
  }

  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    string s,f,e;
    cin >> s;
    int q; cin >> q;
    bool rev = false;
    rep(itre, q){
        int t; cin >> t;
        if(t==1) rev = !rev;
        else{
            int fi; cin >> fi;
            char c;
            cin >> c;
            if(fi==1){
                if(rev){
                    e += c;
                }else{
                    f += c;
                }
            }else{
                if(rev){   
                    f += c;
                }else{
                    e += c;
                }
            }
        }
    }
    if(rev){
        reverse(all(e));
        reverse(all(s));
        cout << e << s << f << endl;
    }else{
        reverse(all(f));
        cout << f << s << e << endl;
    }

    return 0;
}

Measured memory_bytes: 960
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());

using ll = long long int;
const ll MOD = 1000000007;

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

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

ll mod_add(ll a, ll b) {
    return (a + b) % MOD;
}

ll mod_sub(ll a, ll b) {
    return (a + MOD - b) % MOD;
}

ll mod_mul(ll a, ll b){
    return (a * b) % MOD;
}

ll mod_pow(ll base, ll po) {
    if(po == 0)
        return 1;
    else if(po == 1)
        return base;
    ll new_base = mod_pow(base, po / 2);
    return mod_mul(mod_mul(new_base, new_base), po % 2 == 0 ? 1 : base);
}

ll mod_div(ll a, ll b){
    return mod_mul(a, mod_pow(b, MOD - 2));
}

int main(){
    string s, t;
    cin >> s >> t;
    int count_ = 0;
    rep(i, s.size()) {
        if(s[i] == t[i]) {
            count_++;
        }
    }
    cout << count_ << endl;
    return 0;
}


Measured memory_bytes: 256
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

cnt = 0
for l in B_C:
    for i in range(l[0]):
        A.append(l[1])
        cnt += 1
        if cnt > N:
            break
    else:
        continue
    break

A = sorted(A, reverse=True)

print(sum(A[:N]))

Measured memory_bytes: 36632
#include <bits/stdc++.h>
using namespace std;
int dp[4004000];
int main(){
    int N; cin >> N;
    const int MOD = pow(10,9)+7;
    int a[23][23]; 
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            cin >> a[i][j];
        }
    }
    int MAX_NUM=pow(2,21);

    dp[0]=1;
/*    for(int i=0; i<pow(2,N); i++){
        dp[i]=0;
    }
*/    for(int i=0; i<pow(2,N); i++){
        int digit=0;
        for(int j=0; j<N; j++){
            if( (1<<j) & i) digit++;
        }
        digit--;
        for(int j=0; j<N; j++){
            if( (1<<j) & i ){
                if( a[digit][j] ){
                    dp[i] += dp[i-(1<<j)];
                    dp[i] %=MOD;
                }
            }
        }
    }
    cout << dp[ (int) pow(2,N)-1] << endl;
}

Measured memory_bytes: 10496
#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(input())
    return np.array(x)

N = int(input())
S = int_mtx(N)

acc = np.count_nonzero(S == "AC")
wac = np.count_nonzero(S == "WA")
tlec = np.count_nonzero(S == "TLE")
rec = np.count_nonzero(S == "RE")

print("AC x "+str(acc))
print("WA x "+str(wac))
print("TLE x "+str(tlec))
print("RE x "+str(rec))


Measured memory_bytes: 36780
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n,m;
		n = sc.nextInt();
		m = sc.nextInt();
		int a[] = new int[n];
		int b[] = new int[m];
		int vote[] = new int[n];
		int max = 0;
		int answer = 0;
		for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
		}
		for(int i=0;i<m;i++){
			b[i] = sc.nextInt();
		}
		for(int i=0;i<m;i++){
			int j = 0;
			while(b[i] < a[j]){
				j++;
			}
			vote[j] ++;
		}
		for(int i=0;i<n;i++){
			if(vote[i] > max){
				max = vote[i];
				answer = i+1;
			}
		}
		System.out.println(answer);
	}

}

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

int main(){
    int N;
    cin >> N;
    int count = 0;
    int currentNum;
    bool isKnown = false;
    bool isIncreasing=true;
    for(int i=0;i<N;i++){
        if(i==0){
            cin >> currentNum;
            // cout << "setted : " << currentNum << endl;
        }else{
            int B;
            cin >> B;
            if(isKnown){
                if(isIncreasing){
                    if(B<currentNum){
                        count++;
                        isKnown=false;
                    //     cout << "it is increasing, but not increased." << endl;
                    // }else{
                    //     cout << "it is increasing, and now increased." << endl;
                    }
                }else{
                    if(B>currentNum){
                        count++;
                        isKnown=false;
                    //     cout << "it is decreasing, but not decreased." << endl;
                    // }else{
                    //     cout << "it is decreasing, and now decreased." << endl;
                    }
                }
            }else{
                if(B>currentNum){
                    isKnown=true;
                    isIncreasing=true;
                    // cout << "find it is increasing." << endl;
                }else if(B<currentNum){
                    isKnown=true;
                    isIncreasing=false;
                    // cout << "find it is decreasing." << endl;
                }
            }
            currentNum=B;
        }
        if(i==N-1) count++;
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Comparator;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        LinkedList<Integer> ls = new LinkedList<>();
        for(int i = 0;i < num;i++)
            ls.add(sc.nextInt());
        int max = ls.stream().max(Comparator.naturalOrder()).get();
        int min = ls.stream().min(Comparator.naturalOrder()).get();
        System.out.println(max - min);
    }
}

Measured memory_bytes: 27092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
int dp[600][600];
signed main(){
  int n,m,q;cin>>n>>m>>q;
  rep(i,600){
    rep(j,600){
      dp[i][j]=0;
    }
  }
  rep(i,m){
    int l,r;cin>>l>>r;
    dp[l][r]++;
  }
  for(int i=n-1;i>0;i--){
    for(int j=0;j<i;j++){
      dp[i-j][n-j]+=dp[i-j][n-j-1]+dp[i+1-j][n-j]-dp[i+1-j][n-j-1];
    }
  }
  vector<int> res(q);
  rep(i,q){
    int l,r;cin>>l>>r;
    res[i]=dp[l][r];
  }
  rep(i,q){
    cout<<res[i]<<"\n";
  }
  cout<<flush;
  /*
  rep1(i,n){
    rep1(j,n){
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }*/
  return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
	int i, n, value, max_n, total;
	vector<int>l;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> value;
		l.push_back(value);
	}

	max_n = *max_element(l.cbegin(), l.cend());
	total = accumulate(l.cbegin(), l.cend(), 0);

	if (max_n < total-max_n) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n,c,k,now=0,ans=0;
    cin>>n>>c>>k;
    Vi a(n);
    REP(i,0,n) cin>>a[i];
    
    SORT(a);
    while(1){
        ans++;
        if(now+c>=n && a[now]+k>=a[n-1]){
            break;
        }
        if(a[now]+k<a[now+1]) now++;
        else now=min(now+c,(int)(lower_bound(ALL(a),a[now]+k+1)-a.begin()));
//        cout<<"now="<<now<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(void){
    
    int n;
    int m;
 
    cin >> n >> m;
 
    int A[n][m];
    int b[m];
    int c[100] = {0};
 
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }
 
    for(int i = 0; i < m; i++) {
        cin >> b[i];
    }
    
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            c[i] += A[i][j] * b[j];  
        } 
    }
 
    for(int i = 0; i < n; i++) {
 
        cout << c[i] << endl;
 
    }
 
    return 0;
    
}

Measured memory_bytes: 3140
#include<stdio.h>
 
int main(){
    int a;
    scanf("%d",&a);
    for(int i=0;i<a;i++){
        double x1,x2,x3,x4,y1,y2,y3,y4;
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        if(x1==x2&&x3==x4)printf("YES\n");
        else{
            if((y1-y2)/(x1-x2)==(y3-y4)/(x3-x4))printf("YES\n");
            else printf("NO\n");
        }
    }
}

Measured memory_bytes: 1048
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(auto &i:a){cin>>i;}
    vector<vector<ll>> dp(n+1,vector<ll>(k+1,0));
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int t=1;t<=k;t++){
            (dp[i][t]+=dp[i][t-1])%=MOD;
        }
        for(int t=0;t<=k;t++){
            dp[i+1][t]=dp[i][t]-(t-a[i]<=0?0LL:dp[i][t-a[i]-1]);
        }
    }
    dp[n][k]%=MOD;
    if(dp[n][k]<0){dp[n][k]+=MOD;}
    cout<<dp[n][k]<<endl;
    
    
    return 0;
}


Measured memory_bytes: 80256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;

int N;
int A[111111], B[111111];
int diff[111111];

int main(){
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", &A[i]);
	for(int i = 0; i < N; i++) scanf("%d", &B[i]);
	ll sum_a = 0LL, sum_b = 0LL;
	for(int i = 0; i < N; i++){
		diff[i] = A[i] - B[i];
		sum_a += (ll)A[i];
		sum_b += (ll)B[i];
	}
	if(sum_b > sum_a){
		printf("-1\n");
		return 0;
	}
	sort(diff, diff + N);
	ll sum_need = 0LL;
	int cnt = 0;
	for(int i = 0; i < N; i++){
		if(diff[i] < 0){
			sum_need += (ll)diff[i];
			cnt++;
		}
	}
	reverse(diff, diff + N);
	int res = 0;
	ll sum_diff = 0LL;
	for(int i = 0; i < N; i++){
		if(sum_diff >= -sum_need) break;
		res++;
		sum_diff += diff[i];
	}
	res += cnt;
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>

int judge(int ,int );

int  n,A[20];

int main(){
  int q,M,i,flag=0;

  scanf("%d",&n);

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

  for(i=0;i<q;i++){
    scanf("%d",&M);

    flag=judge(0,M);

    if(flag==1)
      printf("yes\n");

    if(flag==0)
      printf("no\n");
  }

  return 0;
}

int judge(int i,int m){
  int res;
  if(m==0)
    return 1;
  if(i>n)
    return 0;
  
  res= judge(i+1,m)||judge(i+1,m-A[i]);
  return res;
}

    



Measured memory_bytes: 2112
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	
	int n;
	cin >> n;
	int t = 0;
	while (n) {
		if (n % 10 == 2)t++;
		n /= 10;
	}
	cout << t << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXN 100001
ll a[3 * MAXN];
multiset<ll> big;
multiset<ll> small;
ll M[3 * MAXN];
ll m[3 * MAXN];
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= 3 * n; i++) {
        cin >> a[i];
    }
    ll now1 = 0;
    for (int i = 1; i <= n; i++) {
        now1 += a[i];
        big.insert(a[i]);
    }
    M[n] = now1;
    for (int i = n + 1; i <= 2 * n; i++) {
        big.insert(a[i]);
        now1 = now1 + a[i] - *big.begin();
        big.erase(big.begin());
        M[i] = now1;
    }
    ll now2 = 0;
    for (int i  = 3 * n; i >= 2 * n + 1; i--) {
        now2 += a[i];
        small.insert(a[i]);
    } 
    m[2 * n + 1] = now2;
    for (int i = 2 * n; i >= n + 1; i--) {
        small.insert(a[i]);
        now2 = now2 + a[i] - *small.rbegin();
        small.erase(small.find(*small.rbegin()));
        m[i] = now2;
    }
    ll ret = M[n] - m[n + 1];
    for (int i = n + 1; i <= 2 * n; i++) {
        if (ret < M[i] - m[i + 1]) ret = M[i] - m[i + 1];
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 16884