akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>
#include <queue>
#include <map>

#define fir first
#define sec second
#define sz(s) (s).size()
#define pb push_back
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define rep(i,j) for(int (i)=0;(i)<(j);(i)++)
#define For(i,j,k) for(int (i)=(j);(i)<(k);(i)++)
#define repd(i,j) for(int (i)=(j);(i)>=0;(i)--)
#define Ford(i,j,k) for(int (i)=(j);i>=(k);i--)
#define vfor(c,v) for(auto (c): v)
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using ll = long long;
using pii = std::pair<int,int>;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using namespace std;

const int Mod = (1e9) + 7;
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;
const int INF = 10241024;
const ll INFL = (1ll << 62) - 1;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//_____________________________________Templates_________________________________________//

template<class T1, class T2> inline void chmin(T1 &a, T2 b){if(a > b) a = b;}
template<class T1, class T2> inline void chmax(T1 &a, T2 b){if(a < b) a = b;}

//mainly use for dynamic prog
template<class T1, class T2>
void update(T1 &a, T2 b){
  a += b;
  if(a > Mod) a %= Mod;
}

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}
//_____________________　following sorce code_________________________//
int n,m,k;
//vvll dp(400, vll(400));
string S;
vll cost(1 << 16);
int a,b,c;
int h,w;
vvi v;
vll u;

bool check(){

}

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  IN(n,k);
  vll x(n+1);
  ll mx = k;
  rep(i,n){
    IN(x[i]);
    x[i] -= k;
    chmax(mx, x[i]);
  }
  mx *= n;
  vvll dp(n+1, vll(2*mx+5));
  dp[0][mx] = 1;
  rep(i,n){
    rep(j,2*mx){
      ll nj = j + x[i];
      dp[i+1][j] += dp[i][j];
      if(nj < 0 || nj > 2*mx)continue;
      else {
        dp[i+1][nj] += dp[i][j];
      }
    }
  }
  dp[n][mx]--;
  OUT(dp[n][mx]);
  //cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

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

int main(){
    string S,T;
    cin>>S>>T;
    for(int i=0;i<S.length();i++){
        if(S[i]!=T[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

const ll N = 50;

int main() {
  ios::sync_with_stdio(false);
  ll K;
  cin >> K;
  ll times = K / N;
  ll base = N - 1 + times - K % N;
  VL ans(N, base);
  REP(i,0,N) {
    if(i < K % N) {
      ans[i] += N;
    // } else {
    //   ans[i] -= K % N;
    }
  }
  cout << N << endl;
  FOR(a,ans) {
    cout << a << " ";
  }
  cout << endl;
  return 0;
}


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

link = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    link[u - 1].append((v - 1, w))
    link[v - 1].append((u - 1, w))

d = [-1] * N
d[0] = 0
q = [0]
while q:
  i = q.pop()
  for n, w in link[i]:
    if d[n] == -1:
      d[n] = d[i] + w
      q.append(n)

for i in d:
  print(i % 2)

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

int main() {
    int n, m; cin >>n >>m;
    vector<bool> ac_tf(n);
    vector<int> wa_count(n);
    for (int i = 0; i < m; i++) {
        int p;
        string ans;
        cin >>p >>ans;
        if (ans == "AC") {
            ac_tf.at(p-1) = true;
        }
        else {
            if (!ac_tf.at(p-1)) wa_count.at(p-1) += 1;
        }
    }
    int ac = 0, wa = 0;
    for (int i = 0; i < n; i++) {
        if (ac_tf.at(i)) {
            ac += 1;
            wa += wa_count.at(i);
        }
    }
    cout << ac << " " << wa << endl;
    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 H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		System.out.println(H * W - h * W - H * w + h * w);
	}

}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
const int N=100;
char a[N][N];
int main()
{
	int h,w;
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++){
		cin>>a[i];
	}
	bool y=true;
	int dir[4][2]={-1,0,0,1,1,0,0,-1};
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(a[i][j]=='#'){	
				bool y1=false;
				for(int k=0;k<4;k++){
					int x=i+dir[k][0];
					int y=j+dir[k][1];
					if(x==-1||x==h||y==-1||y==w) continue;
					if(a[x][y]=='#'){
						y1=true;
					}
				}
				if(y1==false) y=false;
			}
		}
	}
	printf("%s\n",y?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;



int main(void) {

    ll n,m;
    cin>>n>>m;
    vll x(n),y(m);
    rep(i,n)cin>>x[i];
    rep(i,m)cin>>y[i];
    ll xans=0;

    for(int i=1;i<=n;i++){
        ll a=(i-1)*x[i-1]%MOD;
        ll b=(n-i)*x[i-1]%MOD;
        xans+=(a-b+MOD)%MOD;
        xans%=MOD;
//        cout<<i<<" "<<xans<<endl;
    }
    ll yans=0;

    for(int i=1;i<=m;i++){
        ll a=(i-1)*y[i-1]%MOD;
        ll b=(m-i)*y[i-1]%MOD;
        yans+=(a-b+MOD)%MOD;
        yans%=MOD;
    }
    // cout<<xans<<" "<<yans<<endl;
    cout<<xans*yans%MOD<<endl;


}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int n;
    map<int, int> counts;
    repeat (i, 3) {
        cin >> n;
        counts[n] += 1;
    }

    cout << counts.size() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
const ll mod = 1000000007;
int main(){
	ll K, A, B;
	cin >> K >> A >> B;
	ll cookies = 1;
	if(B - A > 2){
		cookies += A - 1; // A-1回試行
		if((K - A + 1) % 2 == 0){
			cookies += ((K+1-A)/2)*(B-A);
		} else {
			cookies += ((K-A)/2)*(B-A);
			cookies += 1;
		}
	} else {
		cookies += K;
	}
	cout << cookies << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int x,n;
int f[1100];
int main()
{
	cin>>x>>n;
	for (int i=1;i<=n;++i)
	{
		int y;
		cin>>y;
		if (y<0)
		{
			y=abs(y)+100;
		}
		f[y]=1;
	}
	if (f[x]==0)
	{
		cout<<x<<"\n";
		return 0;
	}
	int xiao=x-1;
	while (f[xiao]==1)
	{
		if (xiao>100)
		{
			xiao++;
		}
		else
		{
			xiao--;
		}
		if (xiao<0)
		{
			xiao=abs(xiao)+100;
		}
	}
	int da=x+1;
	while (f[da]==1)
	{
		da++;
	}
	if (xiao>100)
	{
		xiao-=100;
		xiao=-xiao;
	}
	int xc=abs(xiao-x);
	int dc=abs(da-x);
	if (xc<=dc)
	{
		cout<<xiao<<"\n";
	}
	else
	{
		cout<<da<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3648
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
#x = int(input())
n, m = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

if n % 2 != 0:
    for i in range(m):
        print(i+1, n-i)
else:
    for i in range(m):
        if n-2*i-1 > int(n/2):
            print(i+1, n-i)
        else:
            print(i+2, n-i)


Measured memory_bytes: 9692
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    int n; cin >> n;
    int ans = -INF;
    FOR(i,1,n+1)FOR(j,2,n+1000)if(POW(i,j)<=n) chmax(ans,POW(i,j));
    out(ans);

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define ll long long

ll calc(int n, std::vector<ll> cnt){
    ll ans=0;
    for(int i=2; i<cnt.size(); ++i){
        if(cnt[i] >= n-1) ++ans;
    }
    return ans;
}

int main(){
    int n; std::cin >> n;
    std::vector<ll> cnt(n+1,0);

    // count primes in n!
    for(int i=2; i<n+1; ++i){
        int cur=i;
        for(int j=2; j<i+1; ++j){
            while(cur % j == 0){
                ++cnt[j];
                cur /= j;
            }
        }
    }
    ll ans=0;
    ans += calc(75,cnt);
    ans += calc(25,cnt) * (calc(3,cnt)-1);
    ans += calc(15,cnt) * (calc(5,cnt)-1);
    ans += calc(5,cnt) * (calc(5,cnt)-1) * (calc(3,cnt)-2) / 2;

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3660
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.cos
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, k) = readIntegerList()
    val max = (n - 1) * (n - 2) / 2
    if (k > max) {
        out.println(-1)
        return
    }

    val edges = mutableListOf<Pair<Int, Int>>()
    for (i in 1 until n) {
        edges += i to n
    }
    val edges2 = mutableListOf<Pair<Int, Int>>()
    for (i in 1 until n) {
        for (j in (i + 1) until n) {
            edges2.add(i to j)
        }
    }
    edges.addAll(edges2.take(max - k))
    out.println(edges.size)
    for (e in edges) {
        out.println("${e.first} ${e.second}")
    }
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 37740
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        int n=ni();
        int k=ni();
        if(n==1)
            pn("1");
        else
            pn((int)Math.ceil(Math.log(n)/Math.log(k)));
    }

    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 21716
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj

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

#define ll long long

const int N   = 2e5 + 5;

int main(){

	int a,b;
	cin>>a>>b;
	if((a+b)%2==0)cout<<(a+b)/2<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
	return 0;

}



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


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

    int n,m;
    cin>>n>>m;
    int k[n];
    vector<vector<double>> s(n),h(n);
    for(int i=0;i<n;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            int a,b;
            cin>>a>>b;
            s[i].push_back(a);
            h[i].push_back(b);
        }
    }

    double totori[n][m+1]={};
    for(int i=0;i<n;i++){
        int now = 0;
        double he = 0;
        for(int j=1;j<=m;j++){
            totori[i][j] = totori[i][j-1] + 1.0/s[i][now];
            he += 1.0/s[i][now];
            if(abs(he - h[i][now]) < 0.01){
                now++;
                he=0;
            }
            if(now == k[i]){
                for(int l=j+1;l<=m;l++){
                    totori[i][l] = totori[i][j];
                }
                break;
            }
        }
    }

    // //debag
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<=m;j++){
    //         cout<<totori[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    double dp[n+1][m+1]={};
    for(int i=0;i<n;i++){
        for(int now=0;now<=m;now++){
            for(int use=0;use+now<=m;use++){
                dp[i+1][use+now] = max(max(dp[i][use+now],dp[i+1][use+now]),dp[i][now] + totori[i][use]);
            }
        }
    }
    double ans=0;
    for(int i=0;i<=m;i++){
        ans = dp[n][i];
    }
    //cout << ans << endl;
    cout << dp[n][m] << endl;
}


Measured memory_bytes: 3868
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) ((X > Y)? X : Y)
#define MIN(X, Y) ((X < Y)? X : Y)
//　10min
int main(void){
  int ans;
  int a, b, c;
  
  scanf("%d%d%d", &a, &b, &c);

  ans = c - (a - b);
  if(ans < 0){
    ans = 0;
  }
  
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 128
/*Program from Luvwgyx*/
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=2e5+10;
int n,x,y,ans,vis[maxn];
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(int x){print(x);puts("");}
struct Heavy_Light_Decomposition{
    struct edge{int to,nxt;}e[maxn<<1];int tot,head[maxn];
    int idx,fa[maxn],dfn[maxn],dep[maxn],son[maxn],top[maxn],size[maxn];
    void add(int u,int v){e[++tot].to=v;e[tot].nxt=head[u];head[u]=tot;}
    void insert(int u,int v){add(u,v);add(v,u);}
    void build(int x){
        dep[x]=dep[fa[x]]+1;size[x]=1;int mx=0;
        for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to){
            if(v==fa[x])continue;
            fa[v]=x;build(v);size[x]+=size[v];
            if(size[v]>mx)mx=size[v],son[x]=v;
        }
    }
    void dfs(int x){
        if(!x)return ;dfn[x]=++idx;
        top[x]=son[fa[x]]==x?top[fa[x]]:x;
        dfs(son[x]);
        for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
            if(v!=fa[x]&&v!=son[x])dfs(v);
    }
    int query(int u,int v){
        while(top[u]!=top[v]){
            if(dep[top[u]]<dep[top[v]])swap(u,v);
            u=fa[top[u]];
        }if(dep[u]>dep[v])swap(u,v);
        return u;
    }
    int get_dis(int u,int v){return dep[u]+dep[v]-2*dep[query(u,v)];}
}HLD[2];
void init(int S){
    queue<int >q;
    q.push(S);vis[S]=1;
    while(!q.empty()){
        int x=q.front();q.pop();
        for(int i=HLD[0].head[x],v=HLD[0].e[i].to;i;i=HLD[0].e[i].nxt,v=HLD[0].e[i].to)
            if(!vis[v]&&HLD[0].dep[v]<HLD[1].dep[v])vis[v]=1,q.push(v);
    }
}
void solve(){
    for(int x=1;x<=n;x++){
        if(!vis[x])continue;
        ans=max(ans,HLD[1].dep[x]-1);
        for(int i=HLD[0].head[x],v=HLD[0].e[i].to;i;i=HLD[0].e[i].nxt,v=HLD[0].e[i].to)
            if(HLD[1].get_dis(v,x)>2){puts("-1");return ;}
    }write(ans<<1);
}
int main(){
    n=read();x=read();y=read();
    if(x==y){puts("0");return 0;}
    for(int i=1;i<n;i++)HLD[0].insert(read(),read());
    for(int i=1;i<n;i++)HLD[1].insert(read(),read());
    HLD[0].build(x);HLD[0].dfs(x);HLD[1].build(y);HLD[1].dfs(y);
    init(x);solve();
    return 0;
}


Measured memory_bytes: 29440
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
#define Return(x) { Cout(x); return 0; }

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n, a);
    For(i, n) if(a[i] % 2 == 1) Return("first");
    Cout("second");
    
}


Measured memory_bytes: 640
import java.math.*

fun main(args: Array<String>) {
    readInputLine()
    val A = readInputLine().split(" ").map { it.toInt() }
    
    var min = Int.MAX_VALUE
    var max = Int.MIN_VALUE
    
    for (a in A) {
        min = Math.min(min, a)
        max = Math.max(max, a)
    }
    
    println(max - min)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37872
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int> Pi;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()

int N, M, X[100010];
vector <int> R[100010];
int p[100010];

void solve(){
	scanf("%d%d", &N, &M);
	for(int i=1;i<=N;i++)scanf("%d", X+i);
	for(int i=1;i<=N;i++)R[X[i] % M].pb(X[i]);
	for(int i=0;i<M;i++)sort(all(R[i]));
	rep(i, M){
		for(int j=0;j<sz(R[i]);){
			if(j < sz(R[i]) - 1 && R[i][j] == R[i][j+1])p[i]++, j += 2;
			else j++;
		}
	}
	int ans = 0;
	for(int i=1;M-i>i;i++){
		int c = min(sz(R[i]), sz(R[M-i]));
		int x = sz(R[i]) - c, y = sz(R[M-i]) - c;
		ans += min(x/2, p[i]) + min(y/2, p[M-i]);
		ans += c;
	}
	ans += sz(R[0]) / 2;
	if(M % 2 == 0){
		ans += sz(R[M/2]) / 2;
	}
	printf("%d", ans);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 6144
n, a, b, c = [int(e) for e in input().split()]
L = [int(input()) for i in range(n)]

def dfs(A, B, C, O, lst, mi):
    if len(lst) == 0:
        if len(A) == 0 or len(B) == 0 or len(C) == 0:
            return mi

        mp = 0
        mp += (len(A) - 1)*10 + abs(a - sum(A))
        mp += (len(B) - 1)*10 + abs(b - sum(B))
        mp += (len(C) - 1)*10 + abs(c - sum(C))
        return min(mp, mi)

    l = lst.pop()
    mi = dfs(A + [l], B.copy(), C.copy(), O.copy(), lst.copy(), mi)
    mi = dfs(A.copy(), B + [l], C.copy(), O.copy(), lst.copy(), mi)
    mi = dfs(A.copy(), B.copy(), C + [l], O.copy(), lst.copy(), mi)
    mi = dfs(A.copy(), B.copy(), C.copy(), O + [l], lst.copy(), mi)

    return mi

def main():
    print(dfs([], [], [], [], L.copy(), float('inf')))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ull unsigned long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define mod (1000*1000*1000+7)
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
ll modPow(ll x,ll n,ll m)
{
    if(n==0)
    return 1%m;
    ll u = modPow(x,n/2,m);
    u=u*u%m;
    if(n%2==1)
    u=u*x%m;
    return u;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
ll seive[1000000];
void seiveForm()
{
    ll i,j;
    seive[0]=seive[1]=1;
    f(i,2,100000)
    {
        if(seive[i]==0)
            for(j=i*i;j<1000000;j+=i)
                seive[j]=1;
    }
}
bool isPerfectSquare(ll num)
{
    double n = sqrt(num);
    return n==(ll)n?true:false;
}
ll countSetbits(ll num)
{
    ull temp=0;
    while(num){
        num=num&(num-1);
        temp++;
    }
    return temp;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll w,h,n,i,j,k,l,temp,t1,t2,ans;
    temp=t1=t2=ans=0;
    cin>>w>>h>>n;
    ll x[n],y[n],a[n];
    rep(i,n)
    cin>>x[i]>>y[i]>>a[i];
    rep(i,n)
    {
        if(a[i]==1)
        t1=max(x[i],t1);
        else if(a[i]==2)
        w=min(x[i],w);
        else if(a[i]==3)
        t2=max(y[i],t2);
        else
        h=min(y[i],h);
    }
    if((w-t1)<0 || (h-t2)<0)
        cout<<"0\n";
    else
        cout<<(w-t1)*(h-t2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	char a[1205];
	scanf("%[^\n]",a);
	int p=0;
	while(a[p]!='\0'){
		p++;
	}
	for(int i=0;i<p;i++){
		if(a[i]>='a'&&a[i]<='z'){
			a[i]=a[i]-32;
		}
		else if(a[i]>='A'&& a[i]<='Z'){
			a[i]=a[i]+32;
		}
	}
	printf("%s",a);
	printf("\n");

return 0;
}


Measured memory_bytes: 2092
#include "algorithm"
#include "cmath"
#include "iostream"
#include "map"
#include "string"
#include "unordered_map"
#include "vector"
constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9;
using namespace std; // std::を省略して書くことができる

int ans[100000]{};
int main() {
  string S;
  cin >> S;
  int N = S.size();
  vector<int> cum_sum;
  vector<int> cum_sum_R;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'L') {
      cum_sum.push_back(1);
      cum_sum_R.push_back(0);
    } else {
      cum_sum.push_back(0);
      cum_sum_R.push_back(1);
    }
  }
  for (int i = 0; i < N - 1; i++) {
    cum_sum[i + 1] = cum_sum[i] + cum_sum[i + 1];
    cum_sum_R[i + 1] = cum_sum_R[i] + cum_sum_R[i + 1];
  }
  for (int i = 0; i < N; i++) {
    if (S[i] == 'R') {
      auto iter = lower_bound(cum_sum.begin(), cum_sum.end(), cum_sum[i] + 1);
      int ind = distance(cum_sum.begin(), iter);
      if ((ind - i) % 2 == 0) {
        ans[ind] += 1;
      } else {
        ans[ind - 1] += 1;
      }
    } else {
      auto iter =
          lower_bound(cum_sum_R.begin(), cum_sum_R.end(), cum_sum_R[i]);
      int ind = distance(cum_sum_R.begin(), iter);
      if ((i - ind) % 2 == 0) {
        ans[ind] += 1;
      } else {
        ans[ind + 1] += 1;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 9;
int p[N];
int main() {
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
    int res = 0, cur = 0;
    for (int i = 1; i <= n; i++) {
        if (p[i] == i) cur++;
        else {
            res += (cur + 1) / 2;
            cur = 0;
        }
    }
    res += (cur + 1) / 2;
    return 0 * printf("%d\n", res);
}


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

#define ll long long

int main()
{
    ll i, n, ans;
    cin >> n;

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

    sort(a, a+n);
    reverse(a, a+n);

    ans=a[0];
    i=1;
    n-=2;
    while(n>1)
    {
        ans+=2*a[i];
        i+=1;
        n-=2;
    }
    if(n==1)
        ans+=a[i];

    cout << ans << endl;
}

Measured memory_bytes: 5168
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

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<class T> bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1;}
    return 0;
}
template<class T> bool chmin(T & a, const T & b) { if (a > b) { a = b; return 1;}
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;
    char pre = '-';
    int ans = 0;
    REP(i,N){
        if(S[i] != pre){
            ans++;
            pre = S[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
n, k = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
d = [-1] * n
d[0] = 0
x = 0
while d[a[x]] == -1:
    d[a[x]] = d[x] + 1
    x = a[x]
    if k == d[x]:
        print(x + 1)
        exit(0)
x = a[x]
k -= d[x]
d1 = [-1] * n
d1[x] = 0
t = x
m = 1
while d1[a[x]] == -1:
    m += 1
    d1[a[x]] = d1[x] + 1
    x = a[x]
for i in range(n):
    if k % m == d1[i]:
        print(i + 1)


Measured memory_bytes: 91812
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define pii pair<int,int>
#define pi acos(-1.0)
using namespace std;

int main()
{
    string fw;
    string s;
    int co=0;
    cin>>fw;
    transform(fw.begin(),fw.end(),fw.begin(),::tolower);
    while(cin>>s)
    {
        if(s == "END_OF_TEXT"){
            break;
        }
        transform(s.begin(),s.end(),s.begin(),::tolower);

        if(s == fw)
            co++;
    }
    printf("%d\n",co);
    return 0;
}



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

int main() {
  int r, g, b, S;
  cin >> r >> g >> b;
  S = 100*r + 10*g + b;
  if ( S%4 == 0 ){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  
}

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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll n, m;
  cin >> n >> m;
  cout << (n - 1) *(m - 1) << endl;
}


Measured memory_bytes: 3640
a=input()
if a=="SUN":
    print(7)
elif a=="MON":
    print(6)
elif a=="TUE":
    print(5)
elif a=="WED":
    print(4)
elif a=="THU":
    print(3)
elif a=="FRI":
    print(2)
elif a=="SAT":
    print(1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define Int int64_t
using namespace std;

Int N;

int main()
{
   Int A,B,C;
   cin>>A>>B>>C;
   cout<<(A+B+C>=22 ? "bust\n":"win\n");
}

Measured memory_bytes: 3592
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	while (true) {
		int n = -1, k = -1;
		cin >> n >> k;
		if (n <= 0 || k <= 0) break;
		vector<int> p(n + 1, n), conseq(n);
		for (int i = 0; i < n; ++i) {
			cin >> p[i];
		}
		int cnt = 0, ans = 0;
		for (int i = n - 1; i >= 0; --i) {
			if (p[i] >= p[i + 1]) {
				cnt = 0;
			}
			conseq[i] = ++cnt;
			if (conseq[i] >= k) {
				ans = 1;
			}
		}
		set<int> s(p.begin(), p.begin() + k);
		ans += conseq[0] < k;
		for (int i = k; i < n; ++i) {
			int low = *(s.begin());
			s.erase(p[i - k]);
			int high = *(s.rbegin());
			if ((low != p[i - k]) || (p[i] < high)) {
				if (conseq[i - k + 1] < k) {
					++ans;
				}
			}
			s.insert(p[i]);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 11136
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(); //住人
        int K = sc.nextInt(); //菓子の種類
        ArrayList<Integer> array = new ArrayList<>();
        for(int i = 0; i < K; i++){
          int a = sc.nextInt();
          for(int j = 0; j < a; j++){
            int num = sc.nextInt();
            if(!array.contains(num))
              array.add(num);
          }
        }
        System.out.println(N-array.size());
        //System.out.println(array);
    }
}

Measured memory_bytes: 46060
#include "bits/stdc++.h"
#define rep(i,cc,n) for(int i=cc;i<(n);++i)
#define drep(i,cc,n) for(int i=cc;i>(n);--i)
using namespace std;
using ll = long long;
 
int main()
{
	int N, M, Q,count = 0;
	string S;
	cin >> S;
	if (S == "ABC")
	{
		cout << "ARC" << endl;
	}
	else
		cout << "ABC" << endl;
	//vector<int> A(N);
	
	//cout << "" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(var) var.begin(), var.end()
#define input freopen("input", "r", stdin)
#define output freopen("output", "w", stdout)
#define Fast ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;
using namespace std;

int dr[] = {0, 0, -1, +1, -1, -1, +1, +1, 0, 0, -2, +2, -2, -2, +2, +2, +2, +2, -2, -2, +1, -1, +1, -1};
int dc[] = {-1, +1, 0, 0, -1, +1, -1, +1, -2, +2, 0, 0, -2, +2, -2, +2, +1, -1, +1, -1, +2, +2, -2, -2};

const int M = 1001;
char grid[M][M];
int h,w;

bool valid(int i, int j){
    return i >= 0 && i < h && j >= 0 && j < w;
}

struct Tupple{
    int f, s, cost;
    bool operator < (const Tupple& temp) const{
        return cost > temp.cost;
    }
};

int dijkstra(int s, int ss, int d, int dd){
    priority_queue<Tupple> pq;
    vector<vector<ll>> dis(M, vector<ll>(M, LONG_MAX));
    pq.push({s, ss, 0});
    dis[s][ss] = 0;
    
    while(!pq.empty()){
        auto u = pq.top(); pq.pop();
        for(int i = 0; i < 24; i++){
            int vr = u.f+dr[i];
            int vc = u.s+dc[i];
            if(valid(vr, vc) && grid[vr][vc] == '.'){
                int vcost = u.cost + (i >= 4);
                if(dis[vr][vc] > vcost){
                    dis[vr][vc] = vcost;
                    pq.push({vr,vc,vcost});
                }
            }
        }
    }
    return dis[d][dd] == LONG_MAX ? -1 : dis[d][dd];
}


int main(){
    int s,ss,d,dd;
    cin >> h >> w >> s >> ss >> d >> dd;
    s--, ss--, d--, dd--;
    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
            cin >> grid[i][j];

    cout << dijkstra(s, ss, d, dd) << endl;
}



Measured memory_bytes: 12236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int h,w; cin>>h>>w;
    vector<string> s(h);
    rep(i,0,h) cin>>s[i];
    vector<vector<int>> left(h,vector<int>(w,0));
    vector<vector<int>> right(h,vector<int>(w,0));
    vector<vector<int>> up(h,vector<int>(w,0));
    vector<vector<int>> down(h,vector<int>(w,0));

    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j]=='#') continue;
            else if(j==0) left[i][j]=1;
            else left[i][j]=left[i][j-1]+1;
        }
    }

    rep(i,0,h){
        for(int j=w-1; j>=0; j--){
            if(s[i][j]=='#') continue;
            else if(j==w-1) right[i][j]=1;
            else right[i][j]=right[i][j+1]+1;
        }
    }

    rep(i,0,w){
        rep(j,0,h){
            if(s[j][i]=='#') continue;
            else if(j==0) up[j][i]=1;
            else up[j][i]=up[j-1][i]+1;
        }
    }

    rep(i,0,w){
        for(int j=h-1; j>=0; j--){
            if(s[j][i]=='#') continue;
            else if(j==h-1) down[j][i]=1;
            else down[j][i]=down[j+1][i]+1;
        }
    }
    int ans=0;
    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j]=='#') continue;
            ans=max(ans,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3);
        }
    }
    cout<<ans<<endl;
}

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

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

    vector<pair<int, int>> work;

    for (auto i = 0; i < n; i++)
    {
        int a_i, b_i;
        cin >> a_i >> b_i;
        pair<int, int> p;
        p.first = b_i;
        p.second = a_i;
        work.push_back(p);
    }

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

    long long sum = 0;
    string ans = "Yes";

    for (auto i = 0; i < n; i++)
    {
        sum += work[i].second;
        if(sum > work[i].first){
            ans = "No";
            break;
        }
    }

    cout << ans << endl;

}

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

typedef long long ll;
#define mp make_pair
#define pb push_back
#define pi pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

struct an{
	int sy,sx,gy,gx;
};

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

	int t=1;
//	cin>>t;
	while(t--){
	int h,w;
	cin>>h>>w;
	int a[h+5][w+5];

	for(int i=0;i<h;i++)
	{
	   for(int j=0;j<w;j++)
	   cin>>a[i][j];
	}
	w--;
	vector<an>ans;

	for(int i=0;i<h;i++)
	{
		 for(int j=0;j<w;j++)
		 {
		 	if(a[i][j]%2==0) continue;
		 	a[i][j+1]++;
		 	ans.pb({i+1,j+1,i+1,j+2});
		 }
		 if(i>=h-1 || a[i][w]%2==0) continue;
		 a[i+1][w]++;
		 ans.pb({i+1,w+1,i+2,w+1});
	}


	cout<<ans.size()<<endl;
	for(auto i:ans)
	{
		cout<<i.sy<<" "<<i.sx<<" "<<i.gy<<" "<<i.gx<<endl;
	}
	}
}





/*#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,i,j,k=0;
        cin>>n;
        int ar[n];
        for(i=0;i<n;i++)
            cin>>ar[i];
            for(i=1;i<n-1;i++)
            {
                if(ar[i-1]>ar[i]&&ar[i]<ar[i+1])
                    k=i;
            }
            cout<<k<<endl;
    }
}*/


Measured memory_bytes: 6244
#include<bits/stdc++.h>
using namespace std;
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

const long long MOD = 998244353;

int n;
long long a, b, k, ans, fact[300055], finv[300055];

long long nCr(int n, int r) {
	return fact[n] * finv[r] % MOD * finv[n - r] % MOD;
}

long long solve(int x, int y) {
	
//	printf(">> %d %d\n", x, y);
	
	return nCr(n, x) * nCr(n, y);
}

long long myPow(long long x, long long p) {
	if (p == 0)
		return 1;
	if (p == 1)
		return x;
	
	long long ret = myPow(x, p / 2);
	
	ret = ret * ret % MOD;
	
	if (p % 2)
		ret = ret * x % MOD;
	
	return ret;
}

int main() {
	
	fact[0] = 1;
	
	for (int i = 1; i <= 300000; i++) {
		fact[i] = fact[i - 1] * i % MOD;
		finv[i] = myPow(fact[i], MOD - 2);
	}
	
	finv[0] = finv[1];
	
	scanf("%d%lld%lld%lld", &n, &a, &b, &k);
	
	for (int i = 0; i <= n; i++) {
		long long j = (k - a * i) / b;
		if (a * i + b * j != k)
			continue;
		
		if (j > n || j < 0)
			continue;
		
		ans += solve(i, j);
		ans %= MOD;
	}
	
	printf("%lld\n", ans);
		
	
	return 0;
}

Measured memory_bytes: 4992