akhauriyash/Code-Regression huggingface dataset:
/*input
20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	int n,m;
	cin>>n>>m;
	string s[n];
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
	
	}
	ll dp[n][m];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			dp[i][j]=0;
		}
	}
	ll mod=1000000007;
	dp[0][0]=1;
    for(int i=0;i<n;i++)
    {
    	for(int j=0;j<m;j++)
    	{
    		if(i==0 && j==0)
    		{
    			continue;
    		}
    		ll temp=0;
    		if(i==0)
    		{
    			if(s[i][j-1]=='.'){
    				
    				temp+=dp[i][j-1];
    				temp%=mod;
    			}
    		}
    		else if(j==0)
    		{
    			if(s[i-1][j]=='.')
    			{
    				
    				temp+=dp[i-1][j];
    				temp%=mod;
    			}
    		}
    		else 
    		{
    			if(s[i][j-1]=='.'){
    				temp+=dp[i][j-1];
    				temp%=mod;
    			}
    			if(s[i-1][j]=='.')
    			{
    				temp+=dp[i-1][j];
    				temp%=mod;
    			}
    			

    		}
    		if(s[i][j]=='.')
    			{
    				dp[i][j]=temp;
    			}

    	}
    }

    cout<<dp[n-1][m-1];
 }


Measured memory_bytes: 9088
#include <stdio.h>
#include <algorithm>

#define BUF 200002
#define LIM_N 100001

char str[BUF];

int c[3][3];

void receive_input() {
	for (size_t i = 0; i < 3; i++) {
		fgets(str, sizeof(str), stdin);
		sscanf(str, "%d %d %d", &c[i][0], &c[i][1], &c[i][2]);
	}
}

void set(int a[], int b[], int i, int j, int x) {
	int y = c[i][j] - x;
	a[0] = c[0][0] - x; // y
	a[1] = c[1][0] - x;
	a[2] = c[2][0] - x;

	b[0] = c[0][0] - y; // x
	b[1] = c[0][1] - y;
	b[2] = c[0][2] - y;
}

int check(int a[], int b[]) {
	for (size_t n = 0; n < 3; n++) {
		if (a[n] < 0 || b[n] < 0) {
			return 0;
		}
	}

	for (size_t i = 0; i < 3; i++) {
		for (size_t j = 0; j < 3; j++) {
			if (c[i][j] != a[i] + b[j]) {
				return 0;
			}
		}
	}
	return 1;
}

int solve() {
	int a[3] = {};
	int b[3] = {};

	for (int x = 0; x <= c[0][0]; x++) {
		set(a, b, 0, 0, x);
		// printf("%d %d %d %d %d %d\n", a[0], a[1], a[2], b[0], b[1], b[2]);
		if (check(a, b)) {
			return 1;
		}
	}

	return 0;
}

int main(void) {
	receive_input();

	printf("%s\n", solve() ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin

#define lset(h, n) memset(h, n, sizeof(h));
    

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------

    ll n;
    cin >> n;
    ll a[n];
    rep(i,n){
        cin >> a[i];
    }
    ll cnt=0;
    ll ans=0ll;
    ll p = -1ll;
//    if(a[0]<=0ll) p=1ll;
//    pri2("ok",cnt);
    rep(i,n){
        cnt+=a[i]; 
        ll g =0;
        if(cnt*p<=0ll){
             g = cnt*-1ll+p;
            ans+=(g*p);
            cnt=cnt+g;
        //    pri2(i,g);
        }
        //pri3(cnt,ans,g);
        g=0;
        p*=-1ll;
    }
    ////////////////////////////////////////////////////////
    ll cnt2=0;
    ll ans2=0ll;
    ll p2 = 1ll;
//    pri2("ok",cnt);
    rep(i,n){
        cnt2+=a[i]; 
        ll g2 =0;
        if(cnt2*p2<=0ll){
             g2 = cnt2*-1ll+p2;
            ans2+=(g2*p2);
            cnt2=cnt2+g2;
            //pri2(i,g);
        }
        //pri3(cnt2,ans2,g2);
 //       pri3(ans,g,cnt);
        g2=0;
        p2*=-1ll;
    }
        pri(min(ans,ans2));
}












Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

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

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:

    Int N = -1;

    void init() {
        cin >> N;
    }

    bool query(Int n) {
        string S;
        if (N == -1) {
            cout << "? " << n << endl;
            cin >> S;
        } else {
            bool ret = (n <= N) ^(to_string(n) <= to_string(N));
            if (!ret) {
                S = "Y";
            } else {
                S = "N";
            }
        }

//        cerr << "? " << n << endl;
//        cerr << S << endl;
//        cerr << " --- " << endl;

        return S == "Y";
    }

    void solve() {
        Int d = 11;
        while (d > 0) {
            bool f = query(static_cast<Int>(round(floor(pow(10ll, d - 1)))));
            if (f) {
                break;
            }
            d--;
        }
        if (d == 11) {
            while (d > 0) {
                bool f = query(2 * static_cast<Int>(round(floor(pow(10ll, d - 1)))));
                if (!f) {
                    break;
                }
                d--;
            }
            d++;
            Int ans = static_cast<Int>(round(floor(pow(10ll, d - 1))));
            cout << "! " << ans << endl;
            return;

        }

        Int ub = round(floor(pow(10, d)));
        Int lb = ub / 10;
        while (ub - lb > 1) {
            Int mid = (ub + lb) / 2;
            Int n = static_cast<Int>(mid * round(floor(pow(10, 9))));
            bool f = query(n);
            if (f) {
                ub = mid;
            } else {
                lb = mid;
            }
        }

        cout << "! " << lb + 1 << endl;
    }
};


int main() {
//    cin.tie(0);
//    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(10);

    Solve solve;
//    solve.init();
    solve.solve();

//    Solve().solve();


    return 0;
}


Measured memory_bytes: 596
#include <stdio.h>
int main(){
     
    int m, f, r, som;
     
    while(1){   
    scanf("%d", &m);
    scanf("%d", &f);
    scanf("%d", &r);
     
    som = m + f;
     
    if(m == -1 && f == -1 && r == -1)
        return 0;
     
    if(m == -1 || f == -1)
        printf("F\n");
    else if(som >= 80)
        printf("A\n");
    else if(80 > som && som >= 65)
        printf("B\n");
    else if(65 > som && som >= 50)
        printf("C\n");
    else if(50 > som && som >= 30){
        if(r >= 50)
            printf("C\n");
        else
            printf("D\n");
    }else if(r >= 50)
        printf("C\n");
    else if(30 > som)
        printf("F\n");
    }
 
  return 0;
}

Measured memory_bytes: 584
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define ll long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	cin >> n;
	vector<ll>a(n);
	vector<ll>b(n+1,0);

	rep(i, n) {
		int input;
		cin >> input;
		a[i] = input;
		b[input]++;
	}
	ll ans = 0;
	rep(i, n+1) {
		ll m = b[i];
		ans += m * (m - 1) / 2;
	}
	//print(ans);
	rep(i, n) {
		ll m = b[a[i]];
		println(ans - m + 1);
	}
}

Measured memory_bytes: 5760
while True:
    exam=list(map(int,input().split()))
    if exam[0]==-1 and exam[1]==-1 and exam[2]==-1: break
    
    if exam[0]==-1 or exam[1]==-1:print('F')
    else:
        sum=exam[0]+exam[1]
        
        if sum>=80:print('A')
        elif sum>=65:print('B')
        elif sum>=50:print('C')
        elif sum>=30:
            if exam[2]>=50:print('C')
            else:print('D')
        else: print('F')


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

int main() {
  int n,a,count=0;
  cin >> n;
  r(i,n){
    cin >> a;
    if(a%2==1)count++;
  }
  if(count%2==0)cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

Measured memory_bytes: 256
/*
ID: alec3
LANG: C++14
PROG:
*/
/*
Just use the ModInt struct to take care of the mod
operations and compute the sum exactly as is stated by the
problem.
*/


#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ld long double
#define all(c) (c).begin(), (c).end()
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;

int pct(int x) { return __builtin_popcount(x); }

using namespace std;

//ifstream fin("maze1.in");
//ofstream fout("maze1.out");
template< int mod >

struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt& operator+=(const ModInt& p) {
        if ((x += p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt& operator-=(const ModInt& p) {
        if ((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt& operator*=(const ModInt& p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt& operator/=(const ModInt& p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt& p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt& p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt& p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt& p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt& p) const { return x == p.x; }

    bool operator!=(const ModInt& p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while (n > 0) {
            if (n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream& operator<<(ostream& os, const ModInt& p) {
        return os << p.x;
    }

    friend istream& operator>>(istream& is, ModInt& a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using mint = ModInt< 1000000007 >;


int main()
{
    int n;
    cin >> n;
    mint sum = 0;
    mint sumsq = 0;
    for (int i = 0; i < n; i++) {
        mint x;
        cin >> x;
        sum += x;
        sumsq += (x * x);
    }
    cout << (sum * sum - sumsq) / 2 << endl;

}


Measured memory_bytes: 3632
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
m = {}
ml = set()

for i in range(n):
    a, b = map(int, input().split())
    ml.add(a)
        
    if m.get(a):
        m[a] += b
    else:
        m[a] = b

mm = list(ml)
mm.sort()
for v in mm:
    if k > m[v]:
        k -= m[v]
    else:
        print(v)
        break

Measured memory_bytes: 12604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int R = sc.nextInt();

		// N >= 10 R == 内R
		// N < 10  R == 内R - 100 * (10-K)

		if(N>=10) {
			System.out.println(R);
		} else {
			System.out.println(R + 100*(10-N));
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define SZ(i) int(i.size())
#define eb emplace_back
#define ALL(i) i.begin(),i.end()
#define X first
#define Y second
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"#%d: %s = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
template<typename It> ostream& _printRng(ostream &os,It bg,It ed)
{
    os<<"{";
    for(It it=bg;it!=ed;it++) {
        os<<(it==bg?"":",")<<*it;
    }
    os<<"}";
    return os;
}
template<typename T> ostream &operator << (ostream &os,vector<T> &v){return _printRng(os,v.begin(), v.end());}
template<typename T> void pary(T bg, T ed){_printRng(cerr,bg,ed);cerr<<endl;}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#define pary(...)
#endif

const int MAXN = 100005;
const ll MOD = 1000000007;

int n, a[MAXN], b[MAXN];

int res[MAXN], lim[MAXN];
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n;

    int bst = 0;

    memset(lim, 0x3f, sizeof(lim));
    REP (i, n) {
        cin >> a[i];
        if (a[i] > bst) {
            res[i] = a[i];
            bst = a[i];
        } else {
            lim[i] = bst;
        }
    }

    pary(res, res+n);
    bst = 0;

    REP (i, n) {
        cin >> b[i];
    }
    for (int i=n-1; i>=0; i--) {
        if (b[i] > bst) {
            if (res[i] == 0 || res[i] == b[i]) {
                res[i] = b[i];
                bst = b[i];
            } else {
                cout << 0 << endl;
                return 0;
            }
        } else {
            lim[i] = min(lim[i], bst);
        }
    }

    pary(res, res+n);
    pary(lim, lim+n);
    ll ans = 1;
    REP (i, n) {
        if (res[i] == 0) {
            ans = ans * lim[i] % MOD;
        } else if (res[i] > lim[i]) {
            ans = 0;
        }
    }

    cout << ans << endl;


}


Measured memory_bytes: 1792
n = int(input())
a = []
prem = 0
m = 0
j = 0
for i in range(n):
    a.append(int(input()))
for i in range(n):
    if a[i] > m:
        prem = m
        m = a[i]
    elif a[i] > prem:
        prem = a[i]
for i in range(n):
    if a[i] == m:
        print(prem)
    else:
        print(m)


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

int main(){
  string T, S, U;
  int A, B;
  cin >> T >> S;
  cin >> A >> B;
  cin >> U;
  if(U == T){
    A -= 1;
  }else if(U == S){
    B -= 1;
  }
  cout << A << " " << B << "\n";
  
 return 0; 
}

Measured memory_bytes: 256
#define _GIBCXX_DEBUG
#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 namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
  ll N, a;
  ll ans = 0;
  cin >> N;
  rep(i, N) {
    cin >> a;
    while (a % 2 == 0) {
      a /= 2;
      ans++;
    }
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N, M, A;
    cin >> N >> M;
    int sum = 0;
    for (int i = 0; i < M; i++){
        cin >> A;
        sum += A;
    }
    if(N < sum)
        cout << -1 << endl;
    else
        cout << N - sum <<endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

int minimum_k(int* w, int n, long int P) {
    int res = P, k=1;
    for (int i=0; i<n; i++) {
        if (res >= w[i]) {
            res -= w[i];
        } else {
            k++;
            res = P-w[i];
        }
    }
    return k;
}

long int binary(int k, int* w, int n, long int P_min, long int P_max) {
    //std::cout << P_min << " " << P_max << " " << minimum_k(w, n, (P_min+P_max)/2) << std::endl;
    if (P_max-P_min <= 1) {
        if (minimum_k(w, n, P_min) <= k) {
            return P_min;
        } else {
            return P_max;
        }
    }
    if (minimum_k(w, n, (P_min+P_max)/2) <= k) {
        return binary(k, w, n, P_min, (P_min+P_max)/2);
    } else {
        return binary(k, w, n, (P_min+P_max)/2, P_max);
    }
}

int main() {
    int n, k, w_max=0;
    long int w_sum=0;
    int w[100001] = {};
    std::cin >> n >> k;
    for (int i=0; i<n; i++) {
        std::cin >> w[i];
        w_sum += w[i];
        if (w[i] > w_max) {
            w_max = w[i];
        }
    }
    // P_min = w_min, P_max = w_sum
    std::cout << binary(k, w, n, w_max, w_sum) << std::endl;

    return 0;
}


Measured memory_bytes: 3480
n = int(input())
*A, = map(int, input().split())
DP = [[0 for j in range(n+1)] for i in range(n+1)]
for l in range(1, n+1):
    for i in range(n-l+1):
        j = i+l
        DP[i][j] = max(A[i]-DP[i+1][j], A[j-1]-DP[i][j-1])
print(DP[0][n])

Measured memory_bytes: 120156
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
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 (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll X,Y,Z;
    in >> X >> Y >> Z;
    ll tmp;
    //vector<ll> X(N);
    //string s;
    //in >> s;
    //vector<string> s;
    //s.resize(N);

    out << Z << " " << X << " " << Y << endl;

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	double n,m,s;
	while(cin>>n>>m>>s,n){
		int ans=0;
		n+=100;
		m+=100;
		for(int i=1;i<=s/2;i++){
			for(int j=1,x,y;j<s;j++){
				x=i*n/100;
				y=j*n/100;
				if(x+y==s){
					x=i*m/100;
					y=j*m/100;
					ans=max(ans,x+y);
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
using namespace std;
int main(){
  string str;
  cin >> str;
  int i,j,k,o,r,b;
  char right[]={'y','u','i','o','p','h','j','k','l','n','m'};
  while(str[0]!='#'){
    o=0;
    r=0;
    for(j=0;j<11;j++){
      if(str[0]==right[j]) r=1;
    }
    b=r;
    for(i=0;i<str.size();i++){
      r=0;
      for(j=0;j<11;j++){
	if(str[i]==right[j]) r=1;
      }
      if(b!=r){
	o++;
	
      }
      b=r;
    }
    cout << o << endl;
    cin >> str;
  }
  return 0;
}

Measured memory_bytes: 1180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder line = new StringBuilder(br.readLine());

    String[] input = line.toString().split(" ");
    int a = Integer.parseInt(input[0]);
    int b = Integer.parseInt(input[1]);
    int c = Integer.parseInt(input[2]);

    if(a < b && b < c) {
      System.out.println("Yes");
    }
    else {
      System.out.println("No");
    }
  }
}



Measured memory_bytes: 24344
#include<stdio.h>
#include<math.h>
int main()
{
  long long a,b,c,d,ans;
  scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
  if(a*c>b*d)ans=a*c;
  else ans=b*d;
  if(a*d>ans)ans=a*d;
  if(c*b>ans)ans=c*b;
  printf("%lld\n",ans);
}

Measured memory_bytes: 1732
import sys

def small(paper, x, y):
    paper[x][y] += 1
    paper[x-1][y] += 1
    paper[x][y-1] += 1
    paper[x][y+1] += 1
    paper[x+1][y] += 1

def medium(paper, x, y):
    small(paper, x, y)
    paper[x-1][y-1] += 1
    paper[x-1][y+1] += 1
    paper[x+1][y-1] += 1
    paper[x+1][y+1] += 1

def large(paper, x, y):
    medium(paper, x, y)
    paper[x-2][y] += 1
    paper[x][y-2] += 1
    paper[x][y+2] += 1
    paper[x+2][y] += 1

def drop(paper, x, y, size):

    if size == 1:
        small(paper, x, y)
    elif size == 2:
        medium(paper, x, y)
    else:
        large(paper, x, y)

    return paper


paper = [[0 for i in range(14)] for j in range(14)]
for s in sys.stdin:
    x, y, size = map(int, s.split(','))
    paper = drop(paper, x+2, y+2, size)

empty = 0
deep = 0

for i in range(10):
    for j in range(10):
        if paper[i+2][j+2] == 0:
            empty += 1
        elif paper[i+2][j+2] > deep:
            deep = paper[i+2][j+2]

print(empty)
print(deep)

Measured memory_bytes: 6780
import math

s = input()

cnt = 1
list = []
for i in range(1, len(s)):
    if s[i-1] == "R" and s[i] == "L":
        list.append(cnt)
        cnt = 1
    elif s[i-1] == "L" and s[i] == "R":
        list.append(cnt)
        cnt = 1
    else:
        cnt += 1
list.append(cnt)

ans = []
for i in range(len(list)//2):
    r = list[2*i]
    l = list[2*i + 1]
    ans.extend([0]*(r-1))
    ans.extend([math.ceil(r / 2) + math.floor(l / 2)])
    ans.extend([math.floor(r / 2) + math.ceil(l / 2)])
    ans.extend([0]*(l-1))

print(" ".join(map(str, ans)))

Measured memory_bytes: 11260
//////////////////////////
//      _        ____   //
//  U  /"\  u U /"___|  //
//   \/ _ \/  \| | u    //
//   / ___ \   | |/__   //
//  /_/   \_\   \____|  //
//   \\    >>  _// \\   //
//  (__)  (__)(__)(__)  //
//  Compro by NULL_CT©  //
//////////////////////////
// STL libs
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(I, LIM) for (int I = 0; I < (LIM); I++)
#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;

typedef long long ll;

const int MOD = pow(10,9)+7;

vector<long> divisor(long &_n) {
  vector<long> head, tail;
  for (long i = 1; i * i <= _n; i++) {
    if (_n % i == 0) {
      head.push_back(i);
      if (i * i != _n) tail.push_back(_n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return head;
}

long kadanes(vector<long> &_ls) {
  long highestMax = 0, currentMax = 0, length = _ls.size();
  for (long i = 0; i < length; i++) {
    currentMax = max(_ls[i], currentMax + _ls[i]);
    highestMax = max(highestMax, currentMax);
  }
  return highestMax;
}

struct init {
  init() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // cout<<fixed<<setprecision(20);
  }
} init;

/*----------------------------*/

int main() {
  string s, t;
  cin >> s >> t;
  int ans = INT_MAX;
  for (int i = 0; i < s.size()-t.size()+1;i++){
    int cnt = 0;
    for (int j = 0; j < t.size();j++){
      if(s[i+j] != t[j]){
        cnt++;
      }
    }
    ans = min(ans, cnt);
  }
  cout << ans << "\n";
  ;
}


Measured memory_bytes: 3164
#![allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   rand::Rng,
   std::collections::BTreeSet,
};

#[fastout]
fn main() {
   let start = std::time::Instant::now();
   let time_limit = std::time::Duration::from_millis(1950);

   let n = 26;
   input! {
      dn: usize,
      c: [i64; n],
      s: [[i64; n]; dn],
   }

   let mut score = 0i64;
   let mut set = vec![BTreeSet::new(); n];
   for i in 0..n {
      set[i].insert(0);
      set[i].insert(dn + 1);
   }

   let mut t = vec![0; dn];
   for i in 0..dn {
      let mut diff = vec![];
      let mut mx = 0;
      for j in 0..n {
         diff.push(c[j] * (i + 1 - set[j].range(..=i + 1).rev().next().unwrap()) as i64);
         if s[i][j] + diff[j] >= s[i][mx] + diff[mx] {
            mx = j;
         }
      }
      t[i] = mx;
      for j in 0..n {
         if j == mx {
            score += s[i][j];
         }
         score -= diff[j];
      }
   }

   let calc = |d: usize, q: usize, set: &BTreeSet<usize>| {
      c[q]
         * (d + 1 - set.range(..=d).rev().next().unwrap()) as i64
         * (set.range(d + 2..).next().unwrap() - (d + 1)) as i64
         + s[d][q]
   };

   let mut ans = t.clone();
   let mut mn = score;
   let mut rng = rand::thread_rng();
   loop {
      let elapsed = start.elapsed();
      if elapsed > time_limit {
         break;
      }
      let dt = elapsed.as_micros() as f64 / time_limit.as_micros() as f64;
      let dt = 1.0 / ((10.0 * dt - 5.0).exp() + 1.0);
      let d = rng.gen_range(0, dn);
      let q = rng.gen_range(0, n);
      let diff = calc(d, q, &set[q]) - calc(d, t[d], &set[t[d]]);

      if diff > 0 || rng.gen_range(0f64, 1f64) <= (diff as f64 / 10000.0 / dt).exp() {
         set[t[d]].remove(&(d + 1));
         set[q].insert(d + 1);
         t[d] = q;
         score += diff;
      } else if mn > score {
         ans = t.clone();
         mn = score;
      }
   }
   for t in ans.iter() {
      println!("{}", t + 1);
   }
}


Measured memory_bytes: 3352
#include <stdio.h>
#include <math.h>

int main(){
  long long  n, c, i, res;
  while(scanf("%lld", &n) && n != -1){
    res = c = 0;

    while(n){
      res += (n % 4) * pow(10, c);
      n /= 4;
      c++;
    }

    printf("%lld\n", res);
  }
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int x, t;
    cin >> x >> t;

    cout << max(0, x - t) << endl;

    return 0;
}



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

CSF = []
for i in range(N-1):
    tmp = list(map(int, input().split()))
    CSF.append(tmp)
    
for i in range(N-2):
    time = CSF[i][0] + CSF[i][1]
    #print("time1", time)
    for j in range(i+1, N-1):
        if time <= CSF[j][1]:
            time = CSF[j][1] + CSF[j][0]
        else:
            if time % CSF[j][2] == 0:
                time += CSF[j][0]
            else:
                time += CSF[j][2] - (time % CSF[j][2]) + CSF[j][0]
                #print("time", time)
    print(time)

print(CSF[N-2][0] + CSF[N-2][1])
print(0)

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int n,m;
vector<P> g[100000];
int d[100000];
bool used[100000];

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

	cin>>n>>m;
	REP(i,m) {
		int l,r,D;cin>>l>>r>>D;l--,r--;
		g[l].pb(P(r,D));g[r].pb(P(l,-D));
	}
	REP(i,n) d[i]=-INF;
	REP(i,n) {
		if(used[i]) continue;
		used[i]=true;
		queue<int> q;
		q.push(i);
		d[i]=0;
		while(!q.empty()) {
			int v=q.front();q.pop();
			for(auto u:g[v]) {
				if(d[u.fi]!=-INF) {
					if(d[u.fi]!=d[v]+u.se) {
						cout<<"No"<<endl;
						return 0;
					}
				}
				else {
					used[u.fi]=true;
					d[u.fi]=d[v]+u.se;
					q.push(u.fi);
				}
			}
		}
	}
	cout<<"Yes"<<endl;

	return 0;
}


Measured memory_bytes: 9472
import java.util.*;
public class Main {

	static long dp[][]=new long[109][100009];
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int maxw=sc.nextInt();
		int w[]=new int[n];
		int v[]=new int[n];
		int maxv=0;
		for(int i=0;i<n;i++)
		{
			w[i]=sc.nextInt();
			v[i]=sc.nextInt();
		maxv+=v[i];
		}
		 solve(w,v,maxv,maxw);
		
			
	}

	private static void solve(int[] w, int[] v, int maxv, int maxw) {
		// TODO Auto-generated method stub
		int n=v.length;
		
		for(int i=maxv;i>=1;i--)
		{
			
		long wr=helper(w,v,i,0);
		//System.out.println(wr);
		if(wr<=maxw)
		{
			System.out.println(i);
			return;
		}
		}
		System.out.println(0);
	}

	private static long helper(int[] w, int[] v, int maxv, int ind) {
		
		// TODO Auto-generated method stub
		if(maxv==0)
		{
			return 0;
		}
		
		if(ind==v.length)
		{
			return Integer.MAX_VALUE;
		}
		if(dp[ind][maxv]!=0)
		{
			return dp[ind][maxv];
		}
		long opt1=helper(w,v,maxv,ind+1);
		long opt2=Integer.MAX_VALUE;
		if(maxv>=v[ind])
		{
			opt2=w[ind]+helper(w,v,maxv-v[ind],ind+1);

		}
		dp[ind][maxv]=Math.min(opt1, opt2);;
				return Math.min(opt1, opt2);
	}
}


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

int main() {
    int N;
    int a, b, c, d;

    cin >> N;

    a = N / 1000;
    b = N % 1000 / 100;
    c = N % 1000 % 100 / 10;
    d = N % 1000 % 100 % 10;

    bool ABC, ACD, BCD, ABD;

    ABC = (a == b) && (b == c);
    BCD = (b == c) && (c == d);

    if(ABC || BCD){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

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

// 整数 n の各桁の和を求める関数
int calc_sum_digits(int n) {
    stringstream ss;
    ss << n;
    string str = ss.str();
    int res = 0;
    for (char c : str) res += c - '0';
    return res;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int result = 0; // 答えを格納する変数
    for (int n = 1; n <= N; ++n) {
        // 整数 n の「各桁の和」を求める
        int sum = calc_sum_digits(n);

        // 「各桁の和」が A 以上 B 以下である場合は答えに加算
        if (sum >= A && sum <= B) result += n;
    }
    cout << result << endl;
}

Measured memory_bytes: 3628
S,N,A,K,i,T;
main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d%d",&A,&K);
		while(T=A/K+1,(A-(T-1)*K)%T)A=(T-1)*K-T+(A-(T-1)*K)%T;
		S^=T-1;
	}
	puts(S?"Takahashi":"Aoki");
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    string S;
    cin >> S;
    int cnt = 0;
    REP(i, S.length()) {
        if(S[i] == '1') { cnt++; }
    }
    printf("%lld\n", cnt);
    return 0;
}


Measured memory_bytes: 256
#ALDS1_8_A
class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None

class Tree:
    def __init__(self):
        self.root = None
        self.list = []
    
    def insert(self, node_tobe_added):
            y = None #「xの親」って書いてあるけど、「zの親」では？
            x = self.root
            while x != None:
                #ここで親を設定する。xを一つずつ葉に進めて、yに代入する。yがｚの親になる。
                y = x
                if node_tobe_added.key < x.key:
                    x = x.left
                else:
                    x = x.right
            #ここでyがzの親に設定される。
            node_tobe_added.parent = y 
            
            #yがNoneなら何もないということなのでzがrootになる。
            if y == None:
                self.root = node_tobe_added
            elif node_tobe_added.key < y.key:
                #node_tobe_addedをyの左の子にする
                y.left = node_tobe_added
            else:
                #node_tobe_addedをyの右の子にする
                y.right = node_tobe_added
                
    def preParse(self, node):
        if node == None:
            return
        self.list.append(node.key)
        self.preParse(node.left)
        self.preParse(node.right)
    
    def inParse(self, node):
        if node == None:
            return
        self.inParse(node.left)
        self.list.append(node.key)
        self.inParse(node.right)

T = Tree()

N = int(input())
for i in range(N):
        order, *key = input().split() #printの場合はkeyがないので、*をつけて配列として扱う。
        if order == "print":
            T.list = []
            T.inParse(T.root)
            print(" " + " ".join(map(str, T.list)))
            T.list = []
            T.preParse(T.root)
            print(" " + " ".join(map(str, T.list)))
        else:#insertの場合
            T.insert(Node(int(key[0])))
            


Measured memory_bytes: 143796
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorders
{
	public class Program
	{
		static long P = (long)(1e9 + 7);
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

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

			var b = a.Select(x => Math.Abs(x)).ToArray();
			Array.Sort(b);
			long ans = b.Sum();
			if (cnt % 2 == 1) {
				ans -= b[0] * 2;
			}

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 27868
#include<iostream>
#include<algorithm>
#include<iterator>
#include<vector>
#include<string>
#include<map>

using namespace std;


#define mod(cans) cans%10**9+7
#define cin_pl(x,y) for(int i=0;i<x;i++){cin>>y[i];}
#define pl_twin(x,y,z) for(int i=0;i<x;i++){cin>>y[i]>>z[i];}
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define st(s) size_t size = s.length()
#define prians(Answer) cout<<Answer<<"\n"
#define make_pair mp;
#define com_div(x,Co) for(int i=1;i<x+1;i++){if(x%i==0){Co++;}}
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int>> matrix;
typedef pair<int,int> pr;
typedef vector<pr> vpt;
typedef greater<int> gi;

int main()
{
    int n;
    cin>>n;
    n=180*(n-2);
    prians(n);
}

Measured memory_bytes: 256
n=int(input())
lst=[]
for i in range(n):
    lst.append([int(i) for i in input().split()])
dp=[[0,0,0] for i in range(n)]
dp[0]=lst[0]

for i in range(1,n):
    for j in range(3):
        dp[i][j]=lst[i][j]+max(dp[i-1][k] for k in range(3) if k!=j)
print(max(dp[n-1]))


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

int main(){
string a,b,ans1,ans2;
cin>>a>>b;

for (int i = 0; i < stoi(b); i++)
{
    /* code */
    ans1+=a;
}
for (int i = 0; i < stoi(a); i++)
{
    /* code */
    ans2+=b;
}

if (stoi(a)<stoi(b))
{
    /* code */
    cout<<ans1<<endl;
}
else
{
    cout<<ans2<<endl;
}



}

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

int main()
{
	int N;
	cin >> N;
	double ans = 0;
	for (int i = 0; i < N; i++)
	{
		double tmp;
		cin >> tmp;
		ans += 1/ tmp;
	}
	cout << 1 / ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a<=b){
        for(int i=0;i<b;i++){
            cout << a;
        }
    }else{
        for(int i=0;i<a;i++){
            cout << b;
        }
    }
    return 0;
}

Measured memory_bytes: 256
def partition(A, p, r):
    x = A[r][1]
    i = p-1
    for j in range(p,r):
        if A[j][1] <= x:
            i = i+1
            A[i],A[j]=A[j],A[i]
    A[i+1],A[r]=A[r],A[i+1]
    return i+1

def quickSort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q-1)
        quickSort(A, q+1, r)

def merge(A, left, mid, right):
    L=A[left:mid]+[["X",10000000000]]
    R=A[mid:right]+[["X",10000000000]]
    i = 0
    j = 0

    for k in range(left,right):
        if L[i][1] <= R[j][1]:
            A[k] = L[i]
            i = i + 1
        else:
            A[k] = R[j]
            j = j + 1

def mergeSort(A, left, right):
    mid=0
    if left+1 < right:
        mid = int((left + right)/2)
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
import copy
n=int(input())
A=[]
for i in range(n):
    Astr=input().split( )
    A.append([Astr[0],int(Astr[1])])

B=A.copy()
#print(id(A))      # ID: 4315448960
#print(id(B))      # ID: 4315448960

quickSort(A,0,n-1)

mergeSort(B,0,n)
#print(*B)
flag=0
for i in range(n):
    if A[i]!=B[i]:
        flag=1
        break
    else:
        pass
if flag==1:
    print("Not stable")
else:
    print("Stable")

#print(*A)
#print(*B)
for i in range(n):
    print(*A[i])



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

#define ff first
#define ss second
#define ins insert
#define ll long long
#define ld long double
#define vl vector<ll>
#define sz(c) (ll) c.size()
#define all(c) begin(c), end(c)
#define trv(x,c) for(auto &x : c)
#define tc ll t; cin >> t; while(t--)
#define rep(i,a,n) for(ll i = a; i < n; ++i)
#define per(i,a,n) for(ll i = n-1; i >= a; --i)
#define godspeed cin.tie(0) -> sync_with_stdio(0)

int main() {
    godspeed;
    string s; cin >> s;
    if(s[sz(s)-1] == 's') cout << s << "es";
    else cout << s << "s";
}

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

int main() {
  int n;
  cin >> n;
  string ans = "Three";
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "Y") {
      ans = "Four";
    }
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N;
ll east[300005];
ll west[300005];
ll ans=mod;
string S;

int main(){

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

cin>>N>>S;

if(S[0]=='E') east[0]++;
else west[0]++;
rep1(i,S.size()){
	if(S[i]=='E'){
		east[i]=east[i-1]+1;
		west[i]=west[i-1];
	}else{
		west[i]=west[i-1]+1;
		east[i]=east[i-1];
	}
}

rep(k,N){
	if(k>0){
		ans=min(ans,west[k-1]+east[N-1]-east[k]);
	}else{
		ans=min(ans,east[N-1]-east[k]);
	}
}

cout<<ans<<endl;

}
	


Measured memory_bytes: 5396
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 998244353
#define ll long long
using namespace std;
ll leng[214514],used[214514],mi[214514],ma[214514];
signed main(){
	int n,k;
	cin>>n>>k;
	int ans = n-k+1;
	vector<int> a;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
	}
	set<int> s;
	for(int i=0;i<k;i++){
		s.insert(a[i]);
	}
	leng[n-1] = 1;
	for(int i=n-2;i>=0;i--){
		if(a[i]<a[i+1])leng[i]=leng[i+1]+1;
		else leng[i]=1;
	}
	for(int i=1;i<=n+1-k;i++){
		s.erase(a[i-1]);
		s.insert(a[i+k-2]);
		set<int>::iterator it=s.begin();
		mi[i]=*it;
		it=s.end();it--;
		ma[i]=*it;
	}
	for(int i=0;i<n-k;i++){
		int cmi = mi[i+1];
		int cma = ma[i+1];
		//cout<<a[i]<<" "<<cmi<<" "<<cma<<" "<<a[i+k]<<endl;
		if( a[i] < cmi && cma < a[i+k]){ ans--; used[i]=1;}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		//cout<<leng[i]<<endl;
		if(leng[i]>=k && used[i]==0)cnt++;
	}
	if(cnt>=2)ans -= cnt-1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15728
package main

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

func main() {

	A := nextInt()
	B := nextInt()
	C := nextInt()

	if A == B && A != C || A == C && A != B || A != B && B == C {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

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

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
#include<iostream>
//#include<algorithm>
#include<cmath>
//#include<string>
//#include<set>
//#include<vector>
//#include<iomanip>
using namespace std;
int main(){

    int n,t,s;
    cin>>n>>t>>s;
    if(t*s>=n){cout<<"Yes";}
    else{cout<<"No";}
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int INF = 1e9;
const int MAXN = 1000005;
#define ll long long

set<int> colsInRows[MAXN];
set<int> rowsInCols[MAXN];

class TaskF {
private:
	Debugger debugger;
	int n;
	ll get(int x, int y){
		int deltax = x+1;
		int deltay = n-y;
		return (ll)deltax * deltay;
	}

public:
	void solveOne(int it){
		cin >> n;
		ll ans = 0;
		for(int i = 0; i < n-1; i++){
			int x, y;
			cin >> x >> y;
			if(x > y){
				swap(x, y);
			}
			x--; y--;
			ans -= get(x, y);
		}
		for(int i = 0; i < n; i++){
			ans += get(i, i);
		}
		cout << ans << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskF solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 97384
N = int(input())
A = ['A', 'C', 'G', 'T']
dp = [[0]*64 for _ in range(N+1)]
MOD = 10**9+7

for i in range(4):
    for j in range(4):
        for k in range(4):
            if A[i]+A[j]+A[k] in ['AGC', 'ACG', 'GAC']:
                continue

            dp[3][16*k+4*j+i] = 1
    
for i in range(3, N):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                for m in range(4):
                    if A[k]+A[l]+A[m] in ['AGC', 'ACG', 'GAC']:
                        continue
                    
                    if A[j]+A[l]+A[m]=='AGC':
                        continue
                    
                    if A[j]+A[k]+A[m]=='AGC':
                        continue
                    
                    dp[i+1][16*m+4*l+k] += dp[i][16*l+4*k+j]
                    dp[i+1][16*m+4*l+k] %= MOD

print(sum(dp[N])%MOD)

Measured memory_bytes: 41584
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, minI, maxI int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
		if a[i] < a[minI] {
			minI = i
		} else if a[i] > a[maxI] {
			maxI = i
		}
	}
	ans := [][]int{}
	d := 1
	if a[minI] < 0 && a[maxI] > 0 {
		if a[maxI] > -a[minI] {
			for i, v := range a {
				if v < 0 {
					ans = append(ans, []int{maxI + 1, i + 1})
				}
			}
		} else {
			for i, v := range a {
				if v > 0 {
					ans = append(ans, []int{minI + 1, i + 1})
				}
			}
			d = 0
		}
	} else if a[maxI] <= 0 {
		d = 0
	}
	if d == 1 {
		for i := 1; i < n; i++ {
			ans = append(ans, []int{i, i + 1})
		}
	} else {
		for i := n; i > 1; i-- {
			ans = append(ans, []int{i, i - 1})
		}
	}
	Fprintln(out, len(ans))
	for _, p := range ans {
		Fprintln(out, p[0], p[1])
	}
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 1868
x, y, z, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

A = A[::-1]
B = B[::-1]
C = C[::-1]

anslist = []

for i in range(len(A)):
    if i > k:
        break
    for j in range(len(B)):
        if i * j > k:
            break
        for l in range(len(C)):
            if (i + 1) * (j + 1) * (l + 1) > k:
                break
            anslist.append(A[i] + B[j] + C[l])

anslist.sort()

anslist = anslist[::-1]

for i in range(k):
    print(anslist[i])


Measured memory_bytes: 9152
#include <bits/stdc++.h>
#define int long long
#define gcd            __gcd
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x,y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main()
{
    nitin;
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    cout<<maxe(v.begin(),v.end())-mine(v.begin(),v.end())<<endl;
    return 0;
}

Measured memory_bytes: 3512