akhauriyash/Code-Regression huggingface dataset:
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n=nxt();
    vc<pll> v(n);
    rep(a,0,n)
        v[a].fs=nxt(),v[a].sec=nxt();
    ll p=0;
    rep(a,2,n)
    {
        if(v[a].fs==v[a].sec and v[a-1].fs==v[a-1].sec and v[a-2].fs==v[a-2].sec)
            p=1;
    }
    if(p)
        cout<<"Yes\n";
    else
        cout<<"No\n";
	printclock;
	return 0;
}

Measured memory_bytes: 3844
N = int(input())
S = list(map(int, input().split()))

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        if S[i] == S[j]:
            continue
        for k in range(j+1, N):
            if S[k] == S[i] or S[j] == S[k]:
                continue
            if S[i]+S[j] > S[k] and S[j]+S[k] > S[i] and S[k]+S[i] > S[j]:
                ans += 1
                
print(ans)

Measured memory_bytes: 9104
N, M = map(int, input().split())
H = list(map(int, input().split()))

kotae=[True]*N

for j in range(M):
  A, B = list(map(int, input().split()))
  if H[A-1] > H[B-1]:
    kotae[B-1]=False
  if H[A-1] < H[B-1]:
    kotae[A-1]=False
  if H[A-1] == H[B-1]:
    kotae[B-1]=False
    kotae[A-1]=False
ans = 0

for k in kotae:
  if k:
    ans +=1
print(ans)

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

const int MAXN = 200010;
int n, m;
int tag[MAXN << 2], tree[MAXN << 2];
void mkadd(int u, int v) { tag[u] += v, tree[u] += v; }
void pushdown(int u) {
	if (int & t = tag[u]) {
		mkadd(u << 1, t);
		mkadd(u << 1 | 1, t);
		t = 0;
	}
}
void mdf(int u, int l, int r, int L, int R, int v) {
	if (L <= l && r <= R) return mkadd(u, v);
	int mid = l + r >> 1; pushdown(u);
	if (L <= mid) mdf(u << 1, l, mid, L, R, v);
	if (mid < R) mdf(u << 1 | 1, mid + 1, r, L, R, v);
	tree[u] = std::max(tree[u << 1], tree[u << 1 | 1]);
}
std::vector<int> R[MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> m >> n;
	for (int i = 1, t1, t2; i <= m; ++i) {
		std::cin >> t1 >> t2;
		R[t1].push_back(t2);
	}
	for (int i = 0; i <= n + 1; ++i)
		mdf(1, 0, n + 1, i, i, -(n - i + 1));
	int ans = std::max(m - n, 0);
	for (int i = 0; i <= n + 1; ++i) {
		mdf(1, 0, n + 1, i, i, 0xcfcfcfcf);
		for (auto t : R[i]) mdf(1, 0, n + 1, 0, t, 1);
		ans = std::max(ans, tree[1] - i);
	}
	std::cout << ans << std::endl;
	return 0;
}


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

int main(){
    int r, c;
    int n;
    
    int mas[101][101];
    
    cin >> r >> c;
    
    for (int i = 0; i < r + 1; i++) mas[i][c] = 0;
    for (int j = 0; j < c + 1; j++) mas[r][j] = 0;
    
    
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> mas[i][j];
            mas[i][c] += mas[i][j];
            mas[r][j] += mas[i][j];
            mas[r][c] += mas[i][j];
            
        }
    }
            
            
    for (int i = 0; i < r + 1; i++) {
        for (int j = 0; j < c + 1; j++) {
            if(j) cout << " ";
            cout << mas[i][j];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3108
// ------------------------------------
// Date:2018/ 3/ 5
// Problem:ABC 082 GoodSequence c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

int memo[101010];

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

  memset(memo, 0, sizeof(memo));
  int N, tmp, cnt = 0;
  cin >> N;
  vector< int > a;
  REP(i, N) {
    cin >> tmp;
    if (tmp > N) {
      // NG
      ++cnt;
    } else {
      // OK
      ++memo[tmp];
    }
  }
  
  REP(i, N + 1) {
    if (memo[i] < i) {
      cnt += memo[i];
    } else {
      cnt += memo[i] - i;
    }
  }

  cout << cnt << endl;
  return 0;
}



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

#define FOR(i, a, b) for (int i = a; i < (int) b; i++) 
#define F0R(i, a) FOR (i, 0, a)
#define GO(to, a) for (auto to : a)

#define f first
#define s second
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;

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

const int m[] = {+31, +29, +31, +30, +31, +30, +31, +31, +30, +31, +30, +31};

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vi a (n);
	F0R (i, n) cin >> a[i];
	sort (rall(a));
	long long tot = 0;
	FOR (i, k, n) tot += a[i];
	cout << tot << '\n';
	return 0;
}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    set<int> st;
    bool flag = true;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        if(st.count(a))flag = false;
        st.insert(a);
    }

    cout << (flag ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
struct point
{
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n,k;
    cin>>n>>k;
    ve <ll> arr(n+1);
    rep (i,1,n+1)
    {
        cin>>arr[i];
    }
    ve <bool> visit(n+1,false);
    ve <ll> ind(n+1,0);
    ll z=1;
    deque <ll> v1;
    ll starting=0;
    ll ii=1;
    while (true)
    {
        // cout<<"i.. "<<ii<<"\n";
        if (visit[ii])
        {
            starting=ind[ii]-1;
            bb;
        }
        else
        {
            ind[ii]=z;
            z++;
            visit[ii]=true;
            v1.pb(ii);
        }
        ii=arr[ii];
    }
    // for (auto x: v1)
    // {
    //     cout<<x<<" ";
    // }
    // cout<<"\n";
    if (k<=starting)
    {
        cout<<arr[v1[k-1]]<<"\n";
        return 0;
    }
    // cout<<"start.. "<<starting<<"\n";
    k-=starting;
    rep (i,0,starting)
    {
        v1.pop_front();
    }
    ll sz=v1.size();
    k=(k-1)%sz;
    cout<<arr[v1[k]]<<"\n";
}


Measured memory_bytes: 7864
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0; i<n-2; i++)
    {
        if((s[i]=='A') && (s[i+1]=='B') && (s[i+2]=='C'))
            cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3604
#include<stdio.h>
#define N 100
#define MAX 1000000
#define WHITE 0
#define BLACK 1

int main(){

  int a[N][N];
  int d[N],color[N];
  int i,j,n,k,u,v;
  int mincost;

  scanf("%d",&n);
  for( i=0 ; i<n ; i++ ){
    for( j=0 ; j<n ; j++ ){
      a[i][j] = MAX;
    }
  }
  for( i=0 ; i<n ; i++ ){
    d[i] = MAX;
    color[i] = WHITE;
    scanf("%d %d",&u,&k);
    for( j=0 ; j<k ; j++ ){
      scanf("%d",&v);
      scanf("%d",&a[u][v]);
    }
  }
  d[0]=0;

  while(1){
    mincost = MAX;
    for( i=0 ; i<n ; i++ ){
      if( d[i] < mincost && color[i] == WHITE){
	mincost = d[i];
	u = i;
      }
    }
    if( mincost == MAX )break;

    color[u] = BLACK;
    for( v=0 ; v<=n ; v++ ){
      if(a[u][v] == MAX)continue;
      if(d[v] > d[u] + a[u][v]){
	d[v] = d[u] + a[u][v];
      }
    }
  }
  for(i=0 ; i<n ; i++){
    printf("%d %d\n",i,d[i]);
  }
  return 0;
}

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

int main() {
	int temp;
	int number = 0;
	int a = 1;
	while (a == 1) {
		cin >> temp;
		if (temp != 0) {
			number++;
			cout << "Case " << number << ": " << temp << endl;
		}
		else if (temp == 0) {
			break;
		}
	}
	return 0;
}


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

using namespace std;



int main(){

    int N;
    cin >> N;

    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    std::sort(A.begin(), A.end(), std::greater<int>());

    int count = 0, count0 = 0;

    while(count0 < N - 1){
        for(int i = 0; i < N - 1 - count0; i++){
            A[i] %= A[N - 1 - count0];
            if (A[i] == 0) {
                count++;
            }
        }
        sort(A.begin(), A.end(), greater<int>());
        count0 += count;
        count = 0;
    }
    
    cout << A[0] << endl;
    
    

    return 0;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        a: i64, b: i64, c: i64, d: i64
    };

    let res = (a * c).max(a * d).max(b * c).max(b * d);
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    if(N==1){
        cout << 1 << endl;
        return 0;
    }
    vector<pair<ll,ll>> P(N),memo;
    rep(i,N){
        ll x,y;
        cin >> x >> y;
        P[i]=make_pair(x,y);
    }
    map<pair<ll,ll>,ll> mp;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            ll dx = P[i].first-P[j].first;
            ll dy = P[i].second-P[j].second;
            mp[make_pair(dx,dy)]++;
            memo.push_back(make_pair(dx,dy));
            mp[make_pair(-dx,-dy)]++;
            memo.push_back(make_pair(-dx,-dy));
        }
    }
    ll cnt = -INF;
    for(int i=0;i<memo.size();i++){
        cnt = max(cnt,mp[memo[i]]);
    }
    cout << N-cnt << endl;
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}
//Start from Here
int main(){
    ll N, K;
    cin>>N>>K;
    ll mins, maxs;
    ll ans=0;
    for(ll i=K;i<=N+1;i++){
        mins=0;
        mins=i*(i-1)/2;
        mins%=M;
        maxs=0;
        maxs+=(2*N-i+1)*i/2;
        maxs%=M;
        ans+=mod(maxs-mins+1,M);
        ans%=M;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#define df 0


int main(){
  int n,i;
  scanf("%d",&n);
  int a,b,d,s=0;
  scanf("%d",&a);
  scanf("%d",&b);
  d=b-a;
  a=b;
  for(i=2;i<n;i++){
    scanf("%d",&b);
    if((b-a)*d>0)s++;
    d=b-a;
    a=b;
  }

  printf("%d",s);
  return 0;
}


/// confirm df==1 ///

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ll a, b; cin >> a >> b;
    cout << abs(a-2)*abs(b-2) << endl;
    return 0;
}

Measured memory_bytes: 256
# coding:utf-8
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1, 105):
    for j in range(1, 105):
        for k in range(1, 105):
            v = i*i+j*j+k*k+i*j+j*k+k*i
            if v < 10050:  #vはnを表していて、vのところで与式を満たす
                ans[v] += 1
for i in range(n):
    print(ans[i+1])

Measured memory_bytes: 9364
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,i,x,y,pa,pi,ma,mi;
  cin >> n;
  cin >> x >> y;
  pa=x+y;
  pi=x+y;
  ma=y-x;
  mi=y-x;
  for(i=1;i<n;i++){
    cin >> x >> y;
    pa=max(pa,x+y);
    pi=min(pi,x+y);
    ma=max(ma,y-x);
    mi=min(mi,y-x);
  }
  cout << max(pa-pi,ma-mi) << endl;
  return 0;
}

Measured memory_bytes: 3608
let read_ns () = Scanf.scanf "%d %d " (fun x y -> (x, y))

let () =
  let (n, m) = read_ns () in
  let to1 = Array.make (n + 1) false in
  let toN = Array.make (n + 1) false in
  for i = 1 to m do
    let (a, b) = read_ns () in
    if a = 1 then to1.(b) <- true;
    if b = n then toN.(a) <- true;
  done;
  let rec doit i =
    if i = n then "IMPOSSIBLE"
    else if to1.(i) && toN.(i) then "POSSIBLE"
    else doit (i + 1) in
  doit 2 |> print_endline

Measured memory_bytes: 6016
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;

const int maxn=305;

int n,m,k,mp[maxn][maxn];
char s[maxn][maxn];

void make(int x1,int x2,int y1,int y2)
{
	if (x1>x2 || y1>y2) return;
	fo(i,x1,x2)
	{
		bool has=0;
		fo(j,y1,y2) if (mp[i][j]) {has=1; break;}
		if (has)
		{
			fo(j,y1,y2) if (!mp[i][j] && j>y1 && mp[i][j-1]) mp[i][j]=mp[i][j-1];
			fd(j,y2,y1) if (!mp[i][j] && j<y2 && mp[i][j+1]) mp[i][j]=mp[i][j+1];
		} else
		{
			if (i==x1) continue;
			if (mp[i-1][y1])
				fo(j,y1,y2) mp[i][j]=mp[i-1][j];
		}
	}
	fd(i,x2,x1)
	{
		bool has=0;
		fo(j,y1,y2) if (mp[i][j]) {has=1; break;}
		if (has)
		{
			fo(j,y1,y2) if (!mp[i][j] && j>y1 && mp[i][j-1]) mp[i][j]=mp[i][j-1];
			fd(j,y2,y1) if (!mp[i][j] && j<y2 && mp[i][j+1]) mp[i][j]=mp[i][j+1];
		} else
		{
			if (i==x2) continue;
			if (mp[i+1][y1])
				fo(j,y1,y2) mp[i][j]=mp[i+1][j];
		}
	}
}

int main()
{
	scanf("%d %d %d",&n,&m,&k);
	fo(i,1,n) scanf("%s",s[i]+1);
	
	int tot=0;
	fo(i,1,n)
		fo(j,1,m) mp[i][j]=(s[i][j]=='#') ?++tot :0 ;
	
	make(1,n,1,m);
	
	fo(i,1,n)
	{
		fo(j,1,m) printf("%d ",mp[i][j]);
		puts("");
	}
}

Measured memory_bytes: 1152
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    string s;
    cin >> s;

    vector<string> ok;

    FOR(i, 0, 2){
        FOR(j, 0, 2){
            FOR(k, 0, 2){
                FOR(l, 0, 2){
                    stringstream ss;
                    if(i==1){
                        ss << "A";
                    }
                    ss << "KIH";
                    if(j==1){
                        ss << "A";
                    }
                    ss << "B";
                    if(k==1){
                        ss << "A";
                    }
                    ss << "R";
                    if(l==1){
                        ss << "A";
                    }
                    ok.push_back(ss.str());
                }
            }
        }
    }

    for(string ok_str : ok){
        if(s==ok_str){
            p_yes();
            return 0;
        }
    }

    p_no();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main implements Runnable {
    ArrayList<Integer>[] graph;
    boolean[] visited;
    int[] color;
    long one;
    long bipartite;
    long count;
    boolean mujun;
    int dfs(int a,int c){
        if(visited[a]){
            if(color[a]>=0&&color[a]!=c)mujun=true;
            return 0;
        }
        visited[a]=true;
        color[a]=c;
        int total=1;
        for(int b:graph[a]){
            total+=dfs(b,1-c);
        }
        return total;
    }
    public void run(){
        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt();
        int m=scan.nextInt();
        this.graph=new ArrayList[n];
        for(int i=0;i<n;++i)
            this.graph[i]=new ArrayList<Integer>();
        for(int i=0;i<m;++i){
            int u=scan.nextInt()-1;
            int v=scan.nextInt()-1;
            this.graph[u].add(v);
            this.graph[v].add(u);
        }
        visited=new boolean[n];
        color=new int[n];
        Arrays.fill(color,-1);
        one=0;
        bipartite=0;
        count=0;
        for(int i=0;i<n;++i){
            if(visited[i])continue;
            count++;
            mujun=false;
            int kind=dfs(i,0);
            if(kind==1)one++;
            else if(!mujun)bipartite++;
        }
        long total=one*(2*n-one);
        total+=(count-one)*(count-one);
        total+=bipartite*bipartite;
        System.out.println(total);
    }
    // https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4#%E3%82%B9%E3%82%BF%E3%83%83%E3%82%AF%E3%81%AE%E6%8B%A1%E5%BC%B5
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start(); //16MBスタックを確保して実行
    }
}


Measured memory_bytes: 129868
A,B,X=map(int,input().split())
C=A//X
D=B//X
if A%X==0 and B%X==0:
	print(D-C+1)
elif A%X!=0 and B%X==0:
	print(D-C)
elif A%X==0 and B%X!=0:
	print(D-C+1)
else:
	print(D-C)

Measured memory_bytes: 3060
#include <stdio.h>

#define WIDTH 10
#define HEIGHT 10

int field[ WIDTH + 4 ][ HEIGHT + 4 ];
const int dx[ 3 ][ 4 ] = { { -1, 0, 1, 0 }, { -1, 1, -1, 1 }, { -2, 0, 2, 0 } };
const int dy[ 3 ][ 4 ] = { { 0, -1, 0, 1 }, { -1, -1, 1, 1 }, { 0, -2, 0, 2 } };

int main( void ) {
	int i, x, y, size, white, max;

	while ( scanf( "%d,%d,%d", &x, &y, &size ) == 3 ) {
		x += 2;
		y += 2;

		field[ x ][ y ]++;

		while ( size-- )
			for ( i = 4; i--; field[ x + dx[ size ][ i ] ][ y + dy[ size ][ i ] ]++ ) ;
	}

	white = max = 0;
	for ( y = 2; y < HEIGHT + 2; y++ )
		for ( x = 2; x < WIDTH + 2; x++ )
			if ( !field[ x ][ y ] )
				white++;
			else if ( max < field[ x ][ y ] )
				max = field[ x ][ y ];

	printf( "%d\n%d\n", white, max );

	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int t = sc.nextInt();
    int tArray[] = new int[n + 1];
    tArray[n] = t;

    for (int i = 0; i < n; i++) {
      tArray[i] = sc.nextInt();
    }

    int count = 0;
    for (int i = 1; i < n; i++) {
      if(tArray[i] - tArray[i-1] > t) {
        count += t;
      } else {
        count += tArray[i] - tArray[i-1];
      }
    }

    count += t;

    System.out.println(count);
  }
}



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

int main(void){

    long N,A,B,C,D,E;
    cin>>N>>A>>B>>C>>D>>E;
    long mini = min({A,B,C,D,E});
    cout<<((N-1)/mini)+5<<endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
al = list(map(int,input().split()))

from collections import defaultdict
dic = defaultdict(int)
if n % 2 == 0:
   for a in al:
      dic[a] += 1
   for i in range(n//2):
      if dic[i*2+1] == 2:
         pass
      else:
         break
   else:
      print(2**(n//2)%(10**9+7))
      import sys
      sys.exit()
   print(0)
   import sys
   sys.exit()
else:
   for a in al:
      dic[a] += 1
   for i in range(n//2):
      if i == 0:
         if dic[i] == 1:
            pass
         else:
            break
      else:
         if dic[i*2] == 2:
            pass
         else:
            break
   else:
      print(2**(n//2)%(10**9+7))
      import sys
      sys.exit()
   print(0)
   import sys
   sys.exit()

   

Measured memory_bytes: 14692
import java.io.*;
import java.util.*;
class Main
{
	public static void main(String args[]) throws IOException
	{
		try{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		char a[]=br.readLine().toCharArray();
		char b[]=br.readLine().toCharArray();
		int ans=Integer.MAX_VALUE;int cou=0;int ind=0;
		for(int i=0;i<a.length-b.length+1;i++)
		{
			//System.out.print(a[i]+",");
			for(int j=i;j<i+b.length;j++)
			{
				if(b[ind++]!=a[j])
				{
					cou+=1;
				}
			}
			//System.out.println(cou);
			ans=Math.min(cou,ans);
			ind=0;cou=0;
		}
		System.out.println(ans);
	}
	catch(Exception e){}
}}

Measured memory_bytes: 32796
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

n=gets.to_i
ans=[]
n.times  do
  cmd=get
  case cmd[0]
  when "insert" then
      ans.unshift(cmd[1].to_i)
  when "delete" then
      ans.delete_at(ans.index(cmd[1].to_i)) if ans!=[] and not ans.index(cmd[1].to_i).nil?
  when "deleteFirst" then
      ans.shift unless ans==[]
  when "deleteLast" then
      ans.pop unless ans==[]
  end
end
puts ans.join(" ") if ans!=[]


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; string s; cin>>n>>s;
	vector<int>w(n,0),e(n,0);
	if(s.at(0)=='W')++w.at(0);
	for(int i=1;i<n;++i){
		if(s.at(i)=='W')++w.at(i);
		w.at(i)+=w.at(i-1);
	}
	if(s.back()=='E')++e.back();
	for(int i=n-2;i>=0;--i){
		if(s.at(i)=='E')++e.at(i);
		e.at(i)+=e.at(i+1);
	}
	int ans=1e9;
	for(int i=0;i<n;++i){
		ans=min(ans,w.at(i)+e.at(i)-1);
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 2964
/* created   : 2019-08-09 10:28:07
 * accepted  : 2019-08-09 11:35:16
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

const int mod = 1e9 + 7;

struct mint {
  ll x;
  mint(ll _x = 0)  {
    x = _x % mod;
    if (x < 0) {
      x += mod;
    }
  }

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

  mint& operator-=(const mint a) {
    if ((x -= a.x) < 0) {
      x += mod;
    }
    return *this;
  }

  mint& operator*=(const mint a) {
    x = ((x * a.x) % mod);
    return *this;
  }

  mint operator++(int) {
    mint ret(*this);
    *this += 1;
    return ret;
  }

  mint operator--(int) {
    mint ret(*this);
    *this -= 1;
    return ret;
  }

  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }

  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }

  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }

  mint pow(ll t) const {
    mint ret = 1;
    mint p = *this;
    while (t) {
      if (t & 1) {
        ret *= p;
      }
      p *= p;
      t >>= 1;
    }
    return ret;
  }

  mint inv() const {
    int a = x;
    int b = mod;
    int u = 1;
    int v = 0;
    while (b != 0) {
      int t = a / b;
      a -= t * b;
      u -= t * v;
      swap(a, b);
      swap(u, v);
    }
    assert(b == 1);
    if (u < 0) {
      u += mod;
    }
    return u;
  }

  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }

  mint operator/(const mint a) const {
    mint ret(*this);
    return ret /= a;
  }

  friend ostream& operator<< (ostream& os, mint& a) {
    return os << a.x;
  }
};

const int N = 1e5 + 7;
mint dp[N][17];

void solve() {
  string s;
  cin >> s;
  int n = (int) s.size();
  vector<int> p(n);
  p[0] = 1;
  for (int i = 1; i < n; i++) {
    p[i] = (p[i - 1] * 10) % 13;
  }
  reverse(s.begin(), s.end());
  for (int i = 0; i <= 9; i++) {
    if (s[0] == '?' || s[0] - '0' == i) {
      dp[0][i] = 1;
    }
  }
  trace(make_pair(dp[0], 13));
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 13; j++) {
      for (int k = 0; k <= 9; k++) {
        if (s[i] == '?' || s[i] - '0' == k) {
          int cur = (j + k * p[i]) % 13;
          dp[i][cur] += dp[i - 1][j];
        }
      }
    }
  }
  cout << dp[n - 1][5] << '\n';
}

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


Measured memory_bytes: 14160
n = int(input())
lists = []
for i in range(n):
    a = input()
    k = []
    for i in range(10):
        k.append(a[i])
    k.sort()
    lists.append(k)
lists.sort()
lists.append([])
count = -1
ans = 0
for i in range(n):
    if lists[i] != lists[i+1]:
        c = i-count
        count = i
        ans += c*(c-1)//2
print(ans)


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

using namespace std;

int N, M;
int d[15][15];

bool read() {
  cin >> M;
  if (M == 0) return false;
  for (int i = 0; i <= 10; i++) {
    for (int j = 0; j <= 10; j++) {
      d[i][j] = 1<<20;
    }
    d[i][i] = 0;
  }
  N = 0;
  int s, e, m;
  for (int i = 0; i < M; i++) {
    cin >> s >> e >> m;
    d[s][e] = m;
    d[e][s] = m;
    N = max(N, s);
    N = max(N, e);
  }
  return true;
}

void floyd(int n) {
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
}

void solve() {
  floyd(N+1);
  int dmin = 1<<20, idx = 0;
  for (int i = 0; i <= N; i++) {
    int dis = 0;
    for (int j = 0; j <= N; j++) {
      dis += d[i][j];
    }
    if (dis < dmin) dmin = dis, idx = i;
  }
  cout << idx << ' ' << dmin << endl;
}


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while (read()) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3080
h,w = map(int,input().split())
F = [list(input()) for _ in range(h)]

for i in range(h):
  for j in range(w):
    cnt = 0
    if F[i][j] == '#':
      if 0 <= (i-1) < h: 
        if F[i-1][j] == '#': cnt += 1
      if 0 <= (i+1) < h: 
        if F[i+1][j] == '#': cnt += 1
      if 0 <= (j-1) < w:
        if F[i][j-1] == '#': cnt += 1
      if 0 <= (j+1) < w:
        if F[i][j+1] == '#': cnt += 1
      if cnt == 0:
        print('No')
        exit()
print('Yes')

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;

const ll llinf = 1e18;

class segment_tree
{
  vector<ll> ST, lazy;
public:
  segment_tree(int n)
  {
    ST.assign(4 * n + 5, -llinf);
    lazy.assign(4 * n + 5, 0);
  }
#define lc id << 1
#define rc id << 1 | 1
  void dolazy(int id, int l, int r)
  {
    ST[id] += lazy[id];
    if (l != r){
      lazy[lc] += lazy[id];
      lazy[rc] += lazy[id];
    }
    lazy[id] = 0;
  }

  void update(int id, int l, int r, int L, int R, ll v)
  {
    dolazy(id, l, r);
    if (l > R || L > r || L > R) return;
    if (L <= l && r <= R){
      ST[id] += v;
      if (l != r){
        lazy[lc] += v;
        lazy[rc] += v;
      }
      return;
    }
    int mid = (l + r) / 2;
    update(lc, l, mid, L, R, v); update(rc, mid + 1, r, L, R, v);
    ST[id] = max(ST[lc], ST[rc]);
  }

  ll getmax(int id, int l, int r, int L, int R)
  {
    dolazy(id, l, r);
    if (l > R || L > r) return -llinf;
    if (L <= l && r <= R) return ST[id];
    int mid = (l + r) / 2;
    return max(getmax(lc, l, mid, L, R), getmax(rc, mid + 1, r, L, R));
  }
};

const int maxn = 5e3 + 5, maxm = 205;

int a[maxn], b[maxn][maxm];
int N, M;
vector<int> st[maxm];

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  if (fopen("A.INP", "r")){
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  }
  cin >> N >> M;
  for (int i = 1; i < N; ++i){
    cin >> a[i];
  }
  for (int i = 1; i <= N; ++i){
    for (int j = 1; j <= M; ++j){
      cin >> b[i][j];
    }
  }
  segment_tree tree(N);
  tree.update(1, 1, N, 1, 1, llinf);
  ll res = 0;
  for (int i = 1; i <= M; ++i){
    st[i].pb(1);
    res += b[1][i];
  }
  tree.update(1, 1, N, 1, 1, res);
  for (int i = 2; i <= N; ++i){
    tree.update(1, 1, N, i, i, llinf);
    tree.update(1, 1, N, 1, i - 1, -a[i - 1]);
    for (int j = 1; j <= M; ++j){
      tree.update(1, 1, N, i, i, b[i][j]);
      while (st[j].size() && b[st[j].back()][j] < b[i][j]){
        int r = st[j].back(), val = b[st[j].back()][j];
        st[j].pop_back();
        int l = (st[j].size() ? st[j].back() : 0);
        tree.update(1, 1, N, l + 1, r, b[i][j] - val);
      }
      st[j].pb(i);
    }
    res = max(res, tree.getmax(1, 1, N, 1, i));
  }
  cout << res << '\n';
}


Measured memory_bytes: 4608
import java.util.*;
public class Main {
    public static void main(String[] args) {	
	Main main = new Main();
    	main.solveA();
    }
    
    private void solveA() {
	Scanner sc = new Scanner(System.in);
    String s = sc.next();
	int ans = 0;

	for (int i=0;i < 4;i++){
	    if (s.charAt(i) == '+'){
		ans++;
	    }
	    else{
		ans--;
	    }
	}
    	System.out.println(ans);
    }
}

Measured memory_bytes: 21588
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = line[0], K = line[1];

            var dict = new Dictionary<long, long>();
            dict[K] = 0;

            for (var i = 1; i <= N; i++)
            {
                if (dict.ContainsKey(i % K))
                    dict[i % K]++;
                else
                    dict[i % K] = 1;
            }

            var ret = 0L;

            for (var a = 0; a < K; a++)
            {
                var b = (K - a) % K;
                var c = (K - a) % K;
                if ((b + c) % K != 0) continue;
                if (!dict.ContainsKey(a) || !dict.ContainsKey(b)) continue;

                ret += dict[a] * dict[b] * dict[c];
            }

            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 19296
#include<cstdio>
#define maxn 100005
int n;
struct node { int v; node *nxt; } edge[maxn*2],*head[maxn],*ncnt;
void addedge(int u,int v)
{
	ncnt++;
	ncnt->v=v,ncnt->nxt=head[u];
	head[u]=ncnt;
}
int dfs(int u,int fa)
{
	int res=0;
	for(node *p=head[u];p;p=p->nxt)
	{
		int v=p->v;
		if(v!=fa) res^=dfs(v,u)+1;
	}
	return res;
}
int main()
{
	scanf("%d",&n);
	ncnt=&edge[0];
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(u,v); addedge(v,u);
	}
	printf("%s\n",dfs(1,0)?"Alice":"Bob");
}

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

int main() {
    int n,best;
    vector<int> a(100000);
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    best = 1;
    for (int i=2;i<n;i++){
        if (abs((double)(a.at(best))-(double)(a.at(0))/2)
            > abs((double)(a.at(i))-(double)(a.at(0))/2)){
                best = i;
        }
    }
    cout << a.at(0) << " " << a.at(best) << endl; 
}

Measured memory_bytes: 640
import java.nio.Buffer;
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
        int h = Integer.parseInt(line[0]);
        int w = Integer.parseInt(line[1]);
        int[][] mx = new int[h][w];
        String[] rec;
        int count = 0;
        StringBuffer ans = new StringBuffer();
        for(int i=0;i<h;i++){
            rec = sc.nextLine().split(" ");
            for(int j=0;j<w;j++){ 
                mx[i][j] = Integer.parseInt(rec[j]);
            }
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(mx[i][j] % 2 == 1){
                    if(j+1 < w){
                        mx[i][j]--; 
                        mx[i][j+1]++;
                        ans.append((i+1) + " " + (j+1) + " " + (i+1) + " " + (j+2) + ",");
                        count++;
                    }else if(i+1 < h){
                        mx[i][j]--; 
                        mx[i+1][j]++;
                        ans.append((i+1) + " " + (j+1) + " " + (i+2) + " " + (j+1) + ",");
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
        if(count > 0){
            String[] ansList = ans.toString().substring(0,ans.toString().length() - 1).split(",");
            for(int i=0;i<ansList.length;i++){
                System.out.println(ansList[i]);
            }
        }
	}
}

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

int main(void){

    string S; cin>>S;
    int N = S.size();

    if(S[0]!='A'){
        cout<<"WA"<<endl;
        return 0;
    }
    int count=0,ank;
    for (int i = 2; i < N-1; ++i) {
        if(S[i]=='C'){
            count++;
            ank=i;
        }
    }
    if(count!=1){
        cout<<"WA"<<endl;
        return 0;

    }

    for (int i = 1; i < N; ++i) {
        if(i==ank) continue;
        if(isupper(S[i])){
            cout<<"WA"<<endl;
            return 0;
        }
    }
    cout<<"AC"<<endl;

    return 0;
}

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

int judge(int &n){
	if(n==2){n=1; return n;}
	if(n==4||n==6||n==9||n==11){n=2; return n;}
	else{n=3; return n;}
}

int main(){
	int x,y; cin>>x>>y;
	judge(x);
	judge(y);
	if(x==y) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

vector<int> v;

void rekkyo(int n, int r) {
	if (n == 0){
		v.push_back(r);
		return;
	}

	rekkyo(n - 1, r*10+7);
	rekkyo(n - 1, r*10+5);
	rekkyo(n - 1, r*10+3);
}

signed main(){

	int N;

	cin >> N;

	for (int i = 1; i <= 9; i++)
		rekkyo(i, 0);

	int ans = 0;
	for (int i = 0; i < v.size(); i++){
		if (v[i] <= N){
			int digit[10] = {0};
			// 753が一回以上出てるか
			while (v[i]>0){
				digit[v[i] % 10] ++;
				v[i] /= 10;
			}
			if (digit[3] > 0 && digit[5] > 0 && digit[7] > 0){
				ans++;
			}
		}
	}
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 640
/*||>>>> Praveen Ojha <<<<>>>> 30 June 2019 <<<<>>>> 01:03:48 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	int n;
	cin>>n;
	vi a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	vi vv;
	int ans=0;
	for(int i=1;i<n-1;i++){
		int cur=a[i];
		for(int j=i-1;j<=i+1;j++)
			vv.push_back(a[j]);
		sort(all(vv));
		if(cur==vv[1])
			ans++;
		vv.clear();
	}
	cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 256
// Problem : A - Hitachi String
// Contest : Social Infrastructure Information Systems Division, Hitachi Programming Contest 2020
// URL : https://atcoder.jp/contests/hitachi2020/tasks/hitachi2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)


// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    string s;
	cin >> s;
	int f=0,f1=0;
	for(int i=0;s[i];++i)
	{
		if(s[i]=='h' || s[i]=='i');
		else
		f1=1;
		if(s[i]=='h' && f==0)
		f=1;
		else if(s[i]=='h')
		f1=1;
		if(s[i]=='i' && f==1)
		f=0;
		else if(s[i]=='i')
		f1=1;
	}
	if(f1 || f)
	cout << "No" << endl;
	else
	cout << "Yes " << endl;
}
int main()
{
    solve();
	return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

const int MAXN = 1e5 + 5;

ll cnt[MAXN], isboundary[MAXN];
vector<pair<ll,ll>>v[4];

int main()
{
	FAST_IO;

 	ll r, c, n;
 	cin >> r >> c >> n;
 	for(int i=0;i<n;i++)
 	{
 		ll x1, y1, x2, y2;
 		cin >> x1 >> y1 >> x2 >> y2;
 		if(x1 == 0 || x1 == r || y1 == 0 || y1 == c) isboundary[i] += 1;
 		if(x2 == 0 || x2 == r || y2 == 0 || y2 == c) isboundary[i] += 1;
 		if(isboundary[i] == 2)
 		{
 			if(x1 == 0) v[0].pb({y1, i});
 			else if(y1 == c && x1 > 0) v[1].pb({x1, i});
 			else if(x1 == r && y1 < c) v[2].pb({-y1, i});
 			else if(y1 == 0 && x1 < r) v[3].pb({-x1, i});

 			if(x2 == 0) v[0].pb({y2, i});
 			else if(y2 == c && x2 > 0) v[1].pb({x2, i});
 			else if(x2 == r && y2 < c) v[2].pb({-y2, i});
 			else if(y2 == 0 && x2 < r) v[3].pb({-x2, i});

 		}
 	}
 	for(int j=0;j<4;j++) sort(v[j].begin(), v[j].end());
 	stack<ll>s;
 	for(int j=0;j<4;j++)
 	{	
	 	for(auto it : v[j])
	 	{
	 		if(cnt[it.second] == 1)
	 		{
	 			if(s.top() != it.second)
	 			{
	 				cout << "NO" << endl;
	 				return 0;
	 			}
	 			else s.pop();
	 		}
	 		else
	 		{
	 			s.push(it.second);
	 			cnt[it.second] += 1;
	 		}
	 	}
	}	
 	cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 8460
s = list(input())
chara = set(s)
N = len(s)
ans = 100

for i in chara:
    tmp = 0
    high = 0
    for j in s:
        if i != j:
            tmp += 1
        elif tmp > high:
            high = tmp
            tmp = 0
        else:
            tmp = 0
    else:
        if tmp > high:
            high = tmp

    if high < ans:
        ans = high

print(ans)

Measured memory_bytes: 3064
package main
 
import(
  "fmt"
  "bufio"
  "os"
  "strings"
  "strconv"
  "log"
)
 

func main(){
  a,b,c := 0,0,0
  fmt.Scan(&a)
  fmt.Scan(&b)
  fmt.Scan(&c)
  count := 0
  for i := a; i <= b ; i++{
    if c%i == 0{count+=1}
  }
  fmt.Println(count)
}


var sc = bufio.NewScanner(os.Stdin)

func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}



//入力関係ライブラリ(Atcoder:yamanobori_oldさんのもの)
func make_liner(maxByte int) *bufio.Scanner {
  liner := bufio.NewScanner(os.Stdin)
  liner.Buffer(make([]uint8, 0, 8192), maxByte)
  return liner
}
func word_spliter() *bufio.Scanner {
  words := make_liner(8192) 
  words.Split(bufio.ScanWords)
  return words
}

func eGetLine(r *bufio.Scanner) string {
  if r.Scan() {
    return r.Text()
  }
  err := r.Err()
  if err != nil {
    log.Fatal(err)
  }
  // EOF
  return ""
}

func eGetInt(r *bufio.Scanner) int {
  line := eGetLine(r)
  return eAtoi(line)
}

func eAtoi(s string) int {
  n, err := strconv.Atoi(s)
  if err != nil {
    log.Fatal(err)
  }
  return n
}


Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
struct threeElements{
int _1st,_2nd,_3rd;
};
int n,m;
int color[14],a[1000];
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
    int a[1000];
    cin>>n;
    ll mn=0,mx=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        int q=a[i]/400;
        color[q]++;
    }
    for(int i=0;i<8;i++)
    {
        if(color[i]) mn++;
    }
    for(int i=8;i<13;i++)
        if(color[i]) mx+=color[i];
    if(mn==0)
    {
        cout<<1<<" "<<mx;
        return 0;
    }
    cout<<mn<<" ";
        cout<<mn+mx;
}


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

int main(){
	string s,ss;
	int k;
	cin>>k>>s;
	int l=s.size();
	
	ss=s.substr(0,k);
	
	if(l<=k){
		cout<<s;
		return 0;
	}
	else{
		cout<<ss<<"...";
	}
	
	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n,m;
    cin >> n >> m;
    
    vector<int> p(m),y(m);
    
    rep(i,m) cin >> p[i] >> y[i];
    
    vector<vector<int>> cor(n+1);
    rep(i,m){
        cor[p[i]].push_back(y[i]);
    }
    
    for(int i = 1; i <= n; i++) sort(cor[i].begin(), cor[i].end());
    rep(i,m){
        int num = lower_bound(cor[p[i]].begin(), cor[p[i]].end(), y[i]) - cor[p[i]].begin() + 1;
        cout << setfill('0') << setw(6) << p[i] << setfill('0') << setw(6) << num << endl;
    }
    
}




Measured memory_bytes: 7808