akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n, k; cin >> n >> k;
  vector<int> h(n); rep(i, n) cin >> h[i];
  sort(h);
  int ans = __INT_MAX__;
  for (int i = k - 1; i < n; i++) {
    // debug2(i, i - k + 1);
    ans = min(ans, h[i] - h[i - k + 1]);
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define inp(a) int a; cin>>a;
#define inpa(a,n) vector<int>a(n+1); FOR(i,1,n) cin>>a[i];
#define PI 3.141592653589793238
#define vec(x) vector<x>
#define pii pair<int,int>
#define mem(a,b) memset(a, b, sizeof a)
#define FOR(i,j,n) for(int i= j; i<=n; i++)
#define CASE int t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define print(x) for(auto c : x) cout << c << " ";
#define dbg(x) cerr << #x << " :: "<< x << endl;
#define dbg2(x,y) cerr << #x << " :: "<<x <<"\t" << #y << " :: "<<y <<endl;
const int INF = 1e9 + 7;
const int maxn = 1e6 + 3;
const int MOD = 1e9 + 7; 
//////////// template ends here //////////////////////////



void solve(){

	inp(h); inp(w);
	vec(vec(char))grid(1001, vec(char)(1001));
	vec(vec(int))dp(1001, vec(int)(1001, 0));

	for(int i = 1; i <= h; i++)
		for(int j = 1; j <=w; j++)
			cin>>grid[i][j];
		
    dp[1][0] = 1;

	for(int i = 1; i <=h; i++){
		for(int j = 1; j <=w; j++){
			
			if(grid[i][j] == '#')
				continue;
			
			dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;	
		}
	}

	cout << dp[h][w] << endl;
}


int32_t main(){
	#ifndef ONLINE_JUDGE 
		freopen ("input.txt","r",stdin);
		freopen ("output.txt","w",stdout);
	#endif	
	 ios::sync_with_stdio(0); 
	 cin.tie(0); cout.tie(0);
	//CASE{
		solve();
	//}

	cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
}

Measured memory_bytes: 8224
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001L;

void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(long[]);
    a = [inf] ~ a ~ [-inf];

    long mon = 1000;
    long kb = 0;

    foreach (i; 1 .. n + 1) {
        if (a[i - 1] >= a[i] && a[i] < a[i + 1]) {
            long t = (mon / a[i]);
            mon = mon - t * a[i];
            kb += t;
        }
        else if (a[i - 1] <= a[i] && a[i] > a[i + 1]) {
            mon += kb * a[i];
            kb = 0;
        }
    }

    writeln(mon);
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }


const string YES = "Yes";
const string NO = "No";

void func(std::string s, std::string t){

    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());

    if(s<t)cout<<YES<<endl;
    else cout<<NO<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    std::string s;
    std::cin >> s;
    std::string t;
    std::cin >> t;
    func(s, t);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_ll.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Bll = mp::cpp_ll; //任意長整数 
using Real32 = mp::number<mp::cpp_dec_float<32>>;
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
using Rat = boost::rational<Bll>;//有理数*/
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define size(v) (ll)(v).size()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

map<ll,ll> ma;//map 初期値０
vector<ll> v(0);

signed main(){
    ll n,m,x=0,ans=0;
    cin>>n>>m;
    ma.emplace(0,1);
    for(ll i=0;i < n;i++)
    {
        ll in;cin>>in;
        x+=in;x%=m;    
        if(ma.count(x)) ma.at(x)++;
        else ma.emplace(x,1); 
        ans+=ma.at(x)-1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4224
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

int solve() {
	ll n;
	cin >> n;

	vector<ll> as(n);
	for (ll i = 0; i < n; ++i) {
		cin >> as[i];
	}

	ll target = 0;
	for (ll i = 2; i < n; ++i) {
		target ^= as[i];
	}

	ll res = (1LL << 60LL);

	ll lower_a0 = as[0] & ((1LL << 20LL) - 1LL);
	ll lower_a1 = as[1] & ((1LL << 20LL) - 1LL);

	bool decrease_upper_digit_in_a1 = false;
	bool increase_upper_digit_in_a2 = false;
	bool can_candidate = true;
	vector<ll> candidates;
	for (ll i = 0; i < (1LL << 20LL); ++i) {
		if (i < as[0]) {
			if (decrease_upper_digit_in_a1 ^ (lower_a0 < i)) {
				decrease_upper_digit_in_a1 = lower_a0 < i;
				can_candidate = true;
			}
			if (increase_upper_digit_in_a2 ^ (lower_a1 + i >= (1LL << 20LL))) {
				increase_upper_digit_in_a2 = lower_a1 + i >= (1LL << 20LL);
				can_candidate = true;
			}
			if ((((as[0] - i) ^ (as[1] + i) ^ target) & ((1LL << 20LL) - 1LL)) == 0LL) {
				if (can_candidate) {
					candidates.emplace_back(i);
					can_candidate = false;
				}
			}
		}
	}

	for (auto candidate : candidates) {
		for (ll i = candidate; i < as[0]; i += (1LL << 20LL)) {
			if (((as[0] - i) ^ (as[1] + i) ^ target) == 0LL) {
				res = min(res, i);
				break;
			}
		}
	}

	cout << (res != (1LL << 60LL) ? res: -1LL) << endl;

	return 0;
}

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

	solve();

	return 0;
}


Measured memory_bytes: 3668
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string.h>
#include <queue>
using namespace std;

typedef pair<int, int> P;

const int size = 1000;
bool fld[size * 4][size * 4];
int n, w, h;
int x1[size], x2[size], y1[size], y2[size];

bool I(int lb, int ub, int x){
	return lb <= x && x < ub;
}

int comp(int* a1, int* a2, int s){
	vector<int> as;
	for(int i = 0; i < n; i++){
		for(int d = 0; d < 2; d++){
			if(I(0, s, a1[i] - d)) as.push_back(a1[i] - d);
			if(I(0, s, a2[i] + d)) as.push_back(a2[i] + d);
		}
	}
	
	sort(as.begin(), as.end());
	as.erase(unique(as.begin(), as.end()), as.end());
	
	for(int i = 0; i < n; i++){
		a1[i] = find(as.begin(), as.end(), a1[i]) - as.begin();
		a2[i] = find(as.begin(), as.end(), a2[i]) - as.begin();
	}
	
	return as.size();
}

int main(){
	int ans;
	bool update;
	queue<P> que;
	P p;
	int X, Y;
	
	while(true){
		scanf("%d%d", &w, &h);
		if(w == 0 && h == 0) break;
		scanf("%d", &n);
		for(int i = 0; i < n; i++){
			scanf("%d%d%d%d", x1 + i, y1 + i, x2 + i, y2 + i);
			x2[i]--; y2[i]--;
		}
		
		w = comp(x1, x2, w);
		h = comp(y1, y2, h);
		
		memset(fld, true, sizeof(fld));
		for(int i = 0; i < n; i++){
			for(int y = y1[i]; y <= y2[i]; y++){
				for(int x = x1[i]; x <= x2[i]; x++){
					fld[y][x] = false;
				}
			}
		}
		
		ans = 0;
		for(int y = 0; y < h; y++){
			for(int x = 0; x < w; x++){
				if(fld[y][x]){
					ans++;
					
					que.push(P(y, x));
					fld[y][x] = false;
					while(!que.empty()){
						p = que.front(); que.pop();
						X = p.second; Y = p.first;
						if(X + 1 < w && fld[Y][X + 1]){
							que.push(P(Y, X + 1));
							fld[Y][X + 1] = false;
						}
						if(Y + 1 < h && fld[Y + 1][X]){
							que.push(P(Y + 1, X));
							fld[Y + 1][X] = false;
						}
						if(X - 1 >= 0 && fld[Y][X - 1]){
							que.push(P(Y, X - 1));
							fld[Y][X - 1] = false;
						}
						if(Y - 1 >= 0 && fld[Y - 1][X]){
							que.push(P(Y - 1, X));
							fld[Y - 1][X] = false;
						}
					}
				}
			}
		}
		
		printf("%d\n", ans);
	}
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))
template<typename T> inline bool __max__(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool __min__(T &x, const T &y) { return x > y ? x = y, 1 : 0; }

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

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

    char x, y;

    cin >> x >> y;

    if (x < y) cout << '<' << '\n';
    else if (y < x) cout << '>' << '\n';
    else cout << '=' << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7;

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == '?'){
            if(s[i-1] == 'P')
                s[i] = 'D';
            else if(s[i+1] == 'D' || s[i+1] == '?')
                s[i] = 'P';
            else
                s[i] = 'D';
        }
    }
    cout << s;
    return 0;
}
 

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

int main(){
    int N,M,C,A[30][30],B[30],sum=0,ans=0,i,j;
    cin>>N>>M>>C;
    for(j=0;j<M;j++){
        cin>>B[j];
    }
    for(i=0;i<N;i++){
        for(j=0;j<M;j++){
            cin>>A[i][j];
            sum=sum+A[i][j]*B[j];
        }
        if(sum+C>0){
        ans++;
        }
        sum=0;
    }
 
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from math import factorial
N, M = map(int, input().split())
if N == M:
    print(2 * factorial(N) * factorial(M) % (10 ** 9 + 7))
elif abs(N - M) == 1:
    print(factorial(N) * factorial(M) % (10 ** 9 + 7))
else:
    print(0)

Measured memory_bytes: 5192
n,k = map(int,input().split())
count = 0
for i in range(k,n+1):
    count += n*(n+1) // 2 - (n-i)*(n-i+1) // 2 - i*(i-1) // 2 + 1
    count %= 10**9 + 7
count += 1
print(count)

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int64_t N, K; cin >> N >> K;
  int64_t ans=0;
  
  for(int i=K; i<=N+1; i++){
    ans += (N+1-i)*i + 1;
  }
  
  cout << ans % 1000000007 << endl;
  
}

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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'

int mat[25][25];
int dp[21][1 << 21];

const int MOD = 1e9 + 7;
int mod(int n) {
	return n % MOD;
}

int f(int ind, int mask) {

	if(ind < 0) {
		return 1;
	}

	int &ret = dp[ind][mask];
	if(ret != -1) 
		return ret;

	ret = 0;
	for(int j = 0; j < 21; j++) {
		if(mat[ind][j] && ((mask >> j) & 1) == 0) {
			ret += f(ind - 1, mask | (1 << j));
			ret = mod(ret);
		}
	}

	return ret;
}

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

  memset(dp, -1, sizeof dp);

  int n;

  cin >> n;

  for(int i = 0; i < n; i++) {
  	for(int j = 0; j < n; j++) {
  		cin >> mat[i][j];
  	}
  }

  cout << f(n - 1, 0) << endl;
}

Measured memory_bytes: 344320
#include <stdio.h>
typedef long long ll;
ll abs(ll x){
	return x >= 0 ? x : -x;
}
int main(){
  ll a, b, c, n, j, tmp1, tmp2, tmp3,ans;
	ll k, i;
  scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
 /* for (i = 0; i < k; i++){
  	tmp1 = a, tmp2 = b; tmp3 = c;
		a = tmp2 + tmp3;
		b = tmp1 + tmp3;
		c = tmp1 + tmp2;
  }*/
	ans = (k % 2 ? b - a : a - b);
	if(abs(a - b) > 10e18) printf("Unfair/n");
	else printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int asc(void *c, void *d){

    long *C = (long *)c;
    long *D = (long *)d;

    if (*C > *D){

        return -1;
    }
    if (*D > *C){

        return 1;
    }

    return 0;
}

int main(void){

    long N = 0;
    long K = 0;
    long tmp = 0;
    long count = 0;

    scanf("%ld %ld", &N, &K);

    long A[N];
    long Max[K];

    for (int i = 0; i < N; i++){
        scanf("%ld", &A[i]);
    }

    if (N <= K){
        count = 0;

    } else{

        qsort(A, N, sizeof(long), asc);

        for (long i = K; i < N; i++){
            
            count += A[i];
        }
    }

    printf("%ld", count);

    return 0;
}

Measured memory_bytes: 3324
// Bulati hai, Par Jana Nhi
/*i-=-1*/
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define in(n) for(int i=0;i<n;i++)
#define inj(n) for(int j=0;j<n;j++)
#define itn int
#define ll long long 
#define ull unsigned ll
#define int ll int
#define S second 
#define F first 
#define mod 1000000007
#define globalbool 2000000
#define pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
using namespace std::chrono;
bool dp[globalbool]={0};
vi A(globalbool,0);
int n;
void solve(int k)
{
	for(int i=1;i<=k;i++)
	{
		inj(n)
		{
			if(i-A[j]>=0)
			{
				dp[i]=max(dp[i],bool(dp[i-A[j]] xor 1));
			}
		}
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	auto start = high_resolution_clock::now();
	int k;
	cin>>n>>k;
	//vi A(n);
	in(n)
		cin>>A[i];
	sort(A.begin(),A.begin()+n);
	solve(k);
	if(dp[k])
		cout<<"First";
	else
		cout<<"Second";
	auto stop = high_resolution_clock::now();
    //auto duration = duration_cast<microseconds>(stop - start); 
  
    //cout << "Time taken by function: "
    //<< duration.count() << " microseconds" << endl;
}

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

typedef long long ll;
using namespace std;
int main()
{
  int n;
  cin>>n;

  string s="ABC";
  cout<<s<<n<<endl;
  return 0;
}


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

int main() {
    int N , i , T = 0 , m = 1000000;
    cin >> N;
   vector<int> omosa(N);
   for(i = 0;i<N;i++){
       cin >> omosa.at(i);
    }
   for(T = 0;T<N;T++){
      int count1 = 0 , count2 = 0 , d = 0;
     for(i = 0;i<T;i++){
        count1 += omosa.at(i);
    }
     for(i = T;i<N;i++){
        count2 += omosa.at(i);
    }
     if(count1>count2){
         d = (count1 - count2);
    }
     else {
         d = (count2 - count1);
    }
     if(d<m){
         m = d;
    } 
     else{}
   }
cout << m << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

string s, t;
bool used[26], used2[26];
ll nx[210000][26];
int main() {
	cin >> s >> t;
	ll n = s.size();
	
	//-1判定
	REP(i, s.size()) used[s[i] - 'a'] = true;
	REP(i, t.size()) used2[t[i] - 'a'] = true;
	REP(i, 26) {
		if (used2[i] and !used[i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	s = s + s;
	REPR(i, s.size() - 1) {
		REP(j, 26) {
			nx[i][j] = nx[i + 1][j];
			if (i != s.size() - 1) {
				nx[i][s[i + 1] - 'a'] = i + 1;
			}
		}
	}
	ll ans = 0, now = n - 1;
	REP(i, t.size()) {
		ans += nx[now][t[i] - 'a'] - now;
		now = nx[now][t[i] - 'a'] % n;
	}
	cout << ans << endl;
}
	

Measured memory_bytes: 41728
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char a,b;
  cin>>a>>b;
  if(a==b)
  {
    cout<<'H'<<endl;
	return 0;	
  }	
  else
  {
  	cout<<'D'<<endl;
  	return 0;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
inputs = sys.stdin.readlines()
 
N, K = map(int, inputs[0].split())
X = list(map(int, inputs[1].split()))
 
if N == 1:
    print(X[0])
else:
    ans = 10 ** 9
    for i in range(N-K+1):
        x1, x2 = X[i], X[i+K-1]
        if x1 <= 0 and x2 <= 0:
            ans = min(ans, -x1)
        elif x1 <= 0 and 0 < x2:
            if -x1 < x2:
                ans = min(ans, -2*x1 + x2)
            else:
                ans = min(ans, -x1 + 2*x2)
        else:
            ans = min(ans, x2)
            break
    print(ans)

Measured memory_bytes: 15140
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
while (arr.shift() != 0) {
    var a = arr.shift().split(" ").map(Number);
    var min = Infinity;
    for (var i = 0; i < a.length; i++) {
        for (var j = i + 1; j < a.length; j++) {
            min = Math.min(min, Math.abs(a[i] - a[j]));
        }
    }
    console.log(min);
}

Measured memory_bytes: 20124
<?php
$numbers = fgets(STDIN);
$number = array_map('intval', explode(" ", $numbers));

if ($number[1] > $number[2]) {
  exit('0');
} elseif ($number[1] == $number[2]) {
  exit('1');
} elseif ($number[0] == 1) {
  exit('0');
}

echo($number[2] - $number[1]) * ($number[0] - 2) + 1;

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(num) scanf("%d",&num)
#define sff(num1,num2) scanf("%d %d",&num1,&num2)
#define sfff(num1,num2,num3) scanf("%d %d %d",&num1,&num2,&num3)
#define sl(num) scanf("%lld",&num)
#define sll(num1,num2) scanf("%lld %lld",&num1,&num2)
#define slll(num1,num2,num3) scanf("%lld %lld %lld",&num1,&num2,&num3)
#define rep(i,n) for(i=1;i<=n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define pb push_back
#define mpp make_pair
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define TIME cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<"s\n";
typedef long long int ll;
using namespace std;
int ara[N],dp[N];
int main()
{
    int i,j,n,k;
    sff(n,k);
    rep0(i,n)
    {
        sf(ara[i]);
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    for(i=1;i<n;i++)
    {
        for(j=1;j<=k;j++)
        {
            if(i-j>=0)
                dp[i]=min(dp[i],dp[i-j]+abs(ara[i]-ara[i-j]));
        }
    }
    pf("%d",dp[n-1]);
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

typedef double Weight;
struct Edge{
    int from, to;
    Weight wei;
    Edge(int from_, int to_, Weight wei_):from(from_),to(to_),wei(wei_){}
};
typedef vector<Edge> Edges;
const Weight INFW = numeric_limits<Weight>::max();
struct Graph : public vector<Edges>{
    Graph(){ }
    Graph(int V): vector<Edges>(V){ }
    /*
    有向辺を追加する
    */
    void addEdge(int from, int to, Weight wei=1){
        (*this)[from].push_back(Edge(from, to, wei));
    }
    /*
    無向辺を追加する
    */
    void addUEdge(int u, int v, Weight wei=1){
        (*this)[u].push_back(Edge(u, v, wei));
        (*this)[v].push_back(Edge(v, u, wei));
    }
};

/*
ダイクストラで使うのはこっち
*/
bool operator>(const Edge &a, const Edge &b){
    return a.wei>b.wei;
}
vector<Weight> dijkstra(const Graph &G, int src){
    typedef pair<Weight, int> pwi;
    priority_queue<pwi, vector<pwi>, greater<pwi>> pq;
    pq.push(mp(0, src));
    int V = (int)G.size();
    vector<Weight> res(V, -1);
    while(pq.size()){
        auto p = pq.top(); pq.pop();
        Weight d = p.first;
        int v = p.second;
        if(res[v] > -0.5)continue;
        res[v] = d;
        for(const auto &edge : G[v]){
            int to = edge.to;
            Weight wei = edge.wei;
            pq.push(make_pair(d + wei, to));
        }
    }
    return res;
}


double X[1002], Y[1002], R[1002];

double f(int i, int j) {
    double d = hypot(X[i] - X[j], Y[i] - Y[j]);
    return max(0.0, d - R[i] - R[j]);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    double xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;

    int N;
    cin >> N;
    rep(i, N) {
        cin >> X[i] >> Y[i] >> R[i];
    }
    X[N] = xs;
    Y[N] = ys;
    X[N + 1] = xt;
    Y[N + 1] = yt;

    Graph G(N+2);
    rep(i, N+2)rep(j, i) {
        G.addUEdge(i, j, f(i, j));
    }

    auto dis = dijkstra(G, N);
    cout << setprecision(20) << dis[N + 1] << endl;
}

Measured memory_bytes: 32892
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

ll l, r;

void solve()
{
    ll ans = 2019;
    if(r >= l+2019){
        cout << 0 << endl;
        return;
    }
    l %= 2019;
    r %= 2019;
    //if(l >= r) cout << 0 << endl;
    //else{
        FOR(i, l, r+1){
            FOR(j, i+1, r+1){
                ans = min(ans, i*j%2019);
            }
        }
        cout << ans << endl;
    //}
}

void solve2()
{
    r=min(r,l+2019);

	  ll mi=2019;
	  for(ll a=l;a<=r;a++) for(ll b=a+1;b<=r;b++) mi=min(mi,a*b%2019);
	  cout<<mi<<endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> l >> r;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
// typedef pair<ll,ll> P;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int A[100010];
ll plus_sum[100010];
ll Ksum[100010];
int main() {
    int N,K; cin>>N>>K;

    plus_sum[0]=0LL;
    rep(i,N){
        cin >> A[i];
        if(A[i]>0){
            plus_sum[i+1]+=A[i]+plus_sum[i];
        }else{
            plus_sum[i+1]=plus_sum[i];
        }
    }

    ll sum=0LL;
    for(int i=0; i<K; i++){
        sum+=A[i];
    }
    Ksum[0]=sum;
    for(int i=0; i<=N-K; i++){
        Ksum[i+1]=Ksum[i]-A[i]+A[i+K];
    }

    ll maximum=0LL;
    for(int i=0; i<=N-K; i++){
        maximum=max(maximum, plus_sum[i]+max(0LL,Ksum[i])+plus_sum[N]-plus_sum[i+K]);
    }

    cout << maximum << endl;

    return 0;
}


Measured memory_bytes: 2176
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    s = input()
    n = len(s)

    cnt = 0
    cf = False
    cnts = list()

    for i in range(n):
        if s[i] in ['A', 'C', 'G', 'T']:
            cf = True
            cnt += 1
        
        elif cf:
            cf = False
            cnts.append(cnt)
            cnt = 0
        
        if cf and i == n-1:
            cnts.append(cnt)

    if cnts:
        print(max(cnts))
    else:
        print(0)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 5072
function Main(input) {
  const inputArr = input.toString().split(" ");
  const K = inputArr[0];
  const X = inputArr[1];

  // console.log(K, X);
  console.log(500 * K >= X ? "Yes" : "No")
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
n = int(input())
t, a = map(int, input().split())
h = [int(x) for x in input().split()]
req_h = int(-(a-t)/0.006)

ans = 0
for i in range(1, n):
    if abs(h[ans] - req_h) > abs(h[i] - req_h):
        ans = i

print(ans+1)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

typedef long long ll;

int main(){
  ll N, M, K;
  std::cin >> N >> M >> K;
  std::vector<ll> A_acc(N + 1);
  std::vector<ll> B_acc(M + 1);
  for(int i = 1 ; i <= N  ; i++){
    std::cin >> A_acc[i];
    A_acc[i] += A_acc[i - 1];
  }
  for(int i = 1 ; i <= M  ; i++){
    std::cin >> B_acc[i];
    B_acc[i] += B_acc[i - 1];
  }
  ll max= 0;
  ll time;
  ll j_best = M;
  for(int i = 0 ; i <= N ; i++){
    for(int j = j_best ; j >= 0 ; j--){
      time = A_acc[i] + B_acc[j];
      if(time > K){
	continue;
      }else{
	j_best = j;
	if(max <= j + i) max = j + i;
	break;
      }
    }
  }
  std::cout << max << std::endl;
  return 0;
}


Measured memory_bytes: 6432
#include<bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define vpii vector<pair<int,int> >
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back   
#define PB pop_back
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;

void solve(){
    char c;
    cin>>c;
    if(c >= 'A' && c <= 'Z')cout<<"A";
    else cout<<"a";
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
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; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    
    int cnt = 0;
    rep(l, n) {
        int r = l + 1;
        while (r < n && p[r - 1] < p[r]) r++;
        if (r - l >= k) cnt++;
        if (r != l) l = r - 1;
        // cout << l << endl;
    }
    if (cnt) cnt--;
    // cout << cnt << endl;
    
    vector<int> mmin(n);
    vector<int> deq(n);
    auto slide_min = [&]() {
        int s = 0, t = 0;
        rep(i, n) {
            while (s < t && p[deq[t - 1]] >= p[i]) t--;
            deq[t++] = i;
            if (i - k + 1 >= 0) {
                mmin[i - k + 1] = p[deq[s]];
                if (deq[s] == i - k + 1) {
                    s++;
                }
            }
        }
    };
    
    vector<int> mmax(n);
    deq.clear();
    deq.resize(n);
    auto slide_max = [&]() {
        int s = 0, t = 0;
        rep(i, n) {
            while (s < t && p[deq[t - 1]] <= p[i]) t--;
            deq[t++] = i;
            if (i - k + 1 >= 0) {
                mmax[i - k + 1] = p[deq[s]];
                if (deq[s] == i - k + 1) {
                    s++;
                }
            }
        }
    };
    
    slide_min();
    // rep(i, n - k + 1) cout << mmin[i] << " "; cout << endl;
    
    slide_max();
    // rep(i, n - k + 1) cout << mmax[i] << " "; cout << endl;
    
    rep3(i, 1, n - k + 1) { // i - 1, i
        if (p[i - 1] == mmin[i - 1] && p[i - 1 + k] == mmax[i]) {
            cnt++;
        }
    }
    
    cnt = (n - k + 1) - cnt;
    cout << cnt << endl;
}


Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL INF=1e18;
const int MAXN=2e5+100;
const double eps=1e-10;
bool vis[MAXN];

int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int u,v;
        bool flag=false;
        for(int i=1;i<=n;i++)
            vis[i]=false;
        for(int i=1;i<=m;i++)
        {
            scanf("%d%d",&u,&v);
            if(u==1)
            {
                if(vis[v])
                {
                    flag=true;
                }
                vis[v]=true;
            }else if(v==n)
            {
                if(vis[u])
                {
                    flag=true;
                }
                vis[u]=true;
            }
        }
        if(flag) printf("POSSIBLE\n");
        else printf("IMPOSSIBLE\n");
    }
	return 0;
}


Measured memory_bytes: 384
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
#MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
# from collections import deque
# from collections import defaultdict
# from collections import Counter
# from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	h,w=map(int,input().split())
	S=[input().rstrip().decode('utf-8') for _ in range(h)]
	L=[[0]*w for _ in range(h)]
	R=[[0]*w for _ in range(h)]
	U=[[0]*w for _ in range(h)]
	D=[[0]*w for _ in range(h)]
	
	for i in range(h):
		for j in range(w):
			if j==0:
				if S[i][j]==".":
					L[i][j]=1
			else:
				if S[i][j] == ".":
					L[i][j]=L[i][j-1]+1
	
	for i in reversed(range(h)):
		for j in reversed(range(w)):
			if j==w-1:
				if S[i][j]==".":
					R[i][j]=1
			else:
				if S[i][j] == ".":
					R[i][j]=R[i][j+1]+1
	
	for j in range(w):
		for i in range(h):
			if i==0:
				if S[i][j]==".":
					U[i][j]=1
			else:
				if S[i][j] == ".":
					U[i][j]=U[i-1][j]+1
	
	for j in reversed(range(w)):
		for i in reversed(range(h)):
			if i==h-1:
				if S[i][j]==".":
					D[i][j]=1
			else:
				if S[i][j] == ".":
					D[i][j]=D[i+1][j]+1
	
	ans=0
	for i in range(h):
		for j in range(w):
			ans=max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)
	
	print(ans)
	
	
	
	
	
	
	
	
	
	
	



if __name__ == '__main__':
	main()


Measured memory_bytes: 178440
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		sc.close();

		List<TreeSet<Integer>> list = new ArrayList<>();
		for (int i = 0; i < 26; i++) {
			list.add(new TreeSet<>());
		}
		for (int i = 0; i < s.length; i++) {
			int c = s[i] - 'a';
			list.get(c).add(i);
			list.get(c).add(i + s.length);
		}

		long a = 0;
		int now = -1;
		for (int i = 0; i < t.length; i++) {
			int c = t[i] - 'a';
			Integer next = list.get(c).higher(now);
			if (next == null) {
				System.out.println(-1);
				return;
			}
			if (next >= s.length) {
				a++;
				next -= s.length;
			}
			now = next;
		}
		System.out.println(a * s.length + now + 1);
	}
}


Measured memory_bytes: 53312
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N,M,X;
    cin >> N >> M >> X;
    vec<int> C(N);
    vec<vec<int>> A(N,vec<int>(M,0));
    rep(i,N){
        cin >> C[i];
        rep(j,M) cin >>A[i][j];
    }
    
    int ans = 1e9 + 9;
    for(int i=0;i<(int)pow(2,N);++i){
        vec<int> skill(M,X);
        int tmpyen = 0;
        rep(j,N){
            if(i&(1<<j)){
                rep(k,M) skill[k]-=A[j][k];
                tmpyen+=C[j];
            }
        }
        bool flag = true;
        for(auto e:skill){
            if(e>0)flag = false;
        }
        if(flag) ans=min(ans,tmpyen);
    }
    if(ans == (int)1e9 + 9){
        cout << -1 << endl;
    }else {
    cout << ans << endl;
    }

}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi h(n);
    rep(i, n) cin >> h[i];
    int ans = 0, mx = 0;
    rep(i, n) {
        if (h[i] >= mx) {
            ++ans;
            mx = h[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  int dp[n];
  dp[0]=0;
  for(int i=1;i<n;i++)
  {	dp[i]=abs(a[i]-a[i-1])+dp[i-1];
    for(int j=2;j<=k;j++)
    {
      if(j<=i){
        dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));}
                  }}
                  cout <<dp[n-1]<<endl;}

Measured memory_bytes: 4360
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n,k,q; cin >> n >> k >> q;
  vi a(n, k-q);
  rep(i,q) {
    int foo; cin >> foo;
    foo--;
    a[foo]++;
  }
  rep(i,n) {
    string out;
    if (a[i] <= 0) out = "No";
    else out = "Yes";
    cout << out << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
import java.lang.*;
import java.io.*;
import java.util.*;


public class Main {
	
	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {
	
	public void solve(InputReader in, PrintWriter out) {
		int w = in.nextInt(), h = in.nextInt(), n = in.nextInt();
		int lx = 0, rx = w;
		int ly = 0, ry = h;
		int x, y, a;
		
		for (int i=0; i<n; ++i) {
			x = in.nextInt();
			y = in.nextInt();
			a = in.nextInt();
			if (a == 1) {
				lx = Math.max(lx, x);
			} else if (a == 2) {
				rx = Math.min(rx, x);
			} else if (a == 3) {
				ly = Math.max(ly, y);
			} else {
				ry = Math.min(ry, y);
			}
		}
		
		int ans = 0;
		if (ly<=ry && lx<=rx) {
			ans = (ry-ly) * (rx-lx);
		}
		
		out.println(ans);
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;
	
	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}
	
	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}



Measured memory_bytes: 21588
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
int n,e,t,g[1000],c[1000],d[300],inf=1e8;
vector<int> s[1000];
bool w[300],used[300];
int main(){
	cin>>n>>e>>t;
	t--;
	rep(i,n) cin>>w[i];
	rep(i,e){
		cin>>g[i]>>c[i];
		g[i]--;
		rep(j,c[i]){
			int sij;
			cin>>sij;
			s[i].pb(sij-1);
		}
	}
	rep(i,n) d[i]=(w[i] ? 1 : inf);
	bool update=true;
	while(update){
		update=false;
		rep(i,e){
			vector<int> costs;
			rep(j,c[i]) costs.pb(d[s[i][j]]);
			sort(all(costs),greater<int>());
			if(costs[0]==inf) continue;
			int mx=0;
			rep(j,c[i]) mx=max(mx,costs[j]+j);
			if(mx<d[g[i]]){
				d[g[i]]=mx;
				update=true;
				break;
			}
		}
	}
	if(d[t]==inf) d[t]=-1;
	cout<<d[t]<<endl;
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;





int main() {
    string s;
    cin >> s;
    ll ans = 0, cnt = 0;
    for (int i = 0; i < (int)s.length(); ++i) {
        if (s[i] == 'W') {
            ans += cnt;
        } else {
            ++cnt;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] arr = br.readLine().split(" ");
        int A = Integer.parseInt(arr[0]);
        int P = Integer.parseInt(arr[1]);
        out.println((A * 3 + P) / 2);
        out.close();
    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 999999999
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> Vi;
int a[100][100];
int main(){
  FOR(i,1,10){
	  FOR(j,1,10){
		  printf("%dx%d=%d\n",i,j,i*j);
	  }
  }
  return 0;
}

Measured memory_bytes: 3132
// Problem : B - Product Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 	
int mod=1e9+7;
int po(int x,int y,int m)  { if (y==0) return 1; int t=po(x,y/2,m)%m; t=(t*t)%m; if (y&1) return (t*x)%m;	return t%m; }

signed main() {

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0); 

   int a,b,c,d;
   cin>>a>>b>>c>>d;
			int ans=max({a*d,b*c,a*c,b*d});
			cout<<ans<<endl;
	
   	
   
   	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int MAX = 1000000000;
int main(){
    ll n, w;
    cin >> n >> w;
    ll weight[100010], value[100010];
    for (ll i = 0; i < n;i++){
        cin >> weight[i] >> value[i];
    }
    ll dp[101][100010];
    for(ll i=0;i<w;i++){
        dp[0][i] = 0;
    }
    for (ll i = 0; i < n;i++){
        for (ll j = 0; j <= w;j++){
            if(j < weight[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j], dp[i][j - weight[i]]+value[i]);
            }
        }
    }
    cout << dp[n][w];
}

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

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

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    while (a % 2 == 0) {
      a /= 2;
      ans++;
    }
  }

  cout << ans << endl;
}

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

// 配列が大きいのでグローバル変数にしてます
ll dp[55][55][2600] = {};  // i番目までで、k回選んで合計をsにする組み合わせの数

// ====================================================================

int main() {
  ll n, a;
  cin >> n >> a;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];

  // 俗に言う配るDP
  dp[0][0][0] = 1;  // 初期化
  for (int i = 0; i <= n; i++) {
    for (int k = 0; k <= 50; k++) {
      for (int s = 0; s <= 2500; s++) {
        dp[i + 1][k][s] += dp[i][k][s];
        dp[i + 1][k + 1][s + v[i]] += dp[i][k][s];
      }
    }
  }

  ll ans = 0;
  for (int k = 1; k <= n; k++)
    ans += dp[n][k][a * k];

  cout << ans << endl;
}


Measured memory_bytes: 58496
#include<iostream>
using namespace std;
int main(){
  string A;
  cin>>A;
  if(A[0]==A[1]&&A[2]==A[3]&&A[0]!=A[2]){
    cout<<"Yes"<<endl;
  }
  else if(A[0]==A[2]&&A[1]==A[3]&&A[0]!=A[1]){
    cout<<"Yes"<<endl;
  }
  else if(A[0]==A[3]&&A[1]==A[2]&&A[0]!=A[1]){
    cout<<"Yes"<<endl;
  }

  else cout<<"No"<<endl;

}


Measured memory_bytes: 256