akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define     ll              long long
#define     MAX             100000
#define     FI              freopen("input.txt","r",stdin)
#define     FO              freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define     sc(a)           scanf("%d",&a)
#define     sc2(a,b)        scanf("%d %d",&a,&b)


int main()
{
    map<string , int>mp;
    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    int mx = -1;
    string ans;
    for(auto it = mp.begin(); it!=mp.end();it++)
    {
        if(it->second>=mx)
        {
            mx = max(mx,it->second);
        }
    }
    for(auto it = mp.begin(); it!=mp.end();it++)
    {
        if(it->second==mx)
        {
            cout<<it->first<<"\n";
        }
    }
    return 0;
}



Measured memory_bytes: 25216
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s;
    map<ll, bool> m;
    cin >> s;
    m[s] = true;
    int i = 1;
    while (1) {
        i++;
        if (s % 2 == 0) {
            s = s / 2;
        } else {
            s = 3 * s + 1;
        }
        if (m[s]) {
            break;
        }
        m[s] = true;
    }
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            while (sc.hasNext()) {
                int n = Integer.parseInt(sc.nextLine());
                String[] x_strs = sc.nextLine().split(" ");
                ArrayList<Integer> xs = new ArrayList<Integer>();
                ArrayList<Integer> ys = new ArrayList<Integer>();
                for(int i = 0; i < n; i++){
                    xs.add( Integer.parseInt(x_strs[i]) ); 
                    ys.add( Integer.parseInt(x_strs[i]) ); 
                }
                Collections.sort(ys);
                int m1 = ys.get(n / 2 - 1);
                int m2 = ys.get(n / 2 );
                for(int i = 0; i < n; i++){
                    if(xs.get(i) <= m1) System.out.println(m2);
                    else System.out.println(m1);
                }
            }
        }
    }
}

Measured memory_bytes: 74568
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a, b ,c;
    ll k;
    cin >> a >> b >> c >> k;
    int ans = a - b;
    if(k%2 == 0) {
        cout << ans;
    }
    else {
        cout << -ans;
    }
    
    cout << endl;
    return 0;
}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int n ;
vector < unsigned ll > a ;

int main() {
    cin >> n ;
    unsigned ll lcm = 1 ;
    a.resize( n ) ;
    forn( int , i , 0 , n ){
        cin >> a[ i ] ;
    }

    ll sum = 0 ;
    fore( j , a ){
         sum += j - 1 ;
    }

    cout << sum ;

    return 0 ;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
using namespace std;
int D;
double V[16];
double interpolate(int n, int E) {
 double sum = 0.0;
 for (int k=0; k<D+3; ++k) {
  if (k==n || k==E) continue;
  double p = V[k];
  for (int i=0; i<D+3; ++i) {
   if (i != k && i != n && i != E) {
    p *= (n-i)/(double)(k-i);
   }
  }
  sum += p;
 }
 return sum;
}

bool outlier(int E) {
 for (int i=0; i<D+3; ++i) {
  if (i==E) continue;
  double p = interpolate(i, E);
  if (abs(p-V[i]) > 0.1) return false;
 }
 return true;
}

int main() {
 while (cin >> D && D) {
  for (int i=0; i<D+3; ++i) cin >> V[i];
  for (int i=0; i<D+3; ++i) {
   if (outlier(i)) {
    cout << i << endl;
	break;
   }
  }
 }
}


Measured memory_bytes: 1236
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i, a, b) for (ll i = (a); i < (b); i++)
    #define rep2(r, aa, bb) for (ll r = (aa)-1; r >= (bb); r--)
    #define be(x) (x.begin(), x.end())
    #define pb(t) push_back(t)
    #define ll long long
    int main()
    {
        int n;
        cin>>n;
        if(n%2)
        {
        cout << setprecision(8);
            cout<<(double)(n/2+1)/n<<endl;
        }
        else
        {
            cout << setprecision(8)<<(fixed);
           cout<<(double)(n/2)/n<<endl;
        }
    }

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001ll;


int main() {
    int N, M; cin >> N >> M;
    vi X(M);
    rep(i, M) cin >> X[i];

    if (N >= M) {
        cout << 0 << endl;
        return 0;
    }

    sort(all(X));
    vi Y(M - 1);
    rep(i, M - 1) Y[i] = X[i + 1] - X[i];
    sort(all(Y));

    int ans = 0;

    rep(i, M - N) {
        ans += Y[i];
    }

    cout << ans << endl;



}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
 
int main(){
string s ;
cin>> s ;
int k =s.size() ;
int ans=0 ;
rep(i,k){
if(s[i]=='x')
ans++ ;
}
  if(ans>=8) cout<<"NO"<<endl ;
  else cout<< "YES" <<endl ;  
    return 0;
  }

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long a,b,c;
    cin >> a >> b >> c;
    long long minn = min(a,min(b,c));
    long long maxx = max(a,max(b,c));
    long long zhong = a+b+c-minn-maxx;
    if(a%2 == 0||b%2 == 0||c%2 == 0)cout << 0;
    else cout << minn*zhong;
    return 0;
}


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

int top;
int S[1000];

void push(int x){
    top++;
    S[top] = x;
}

int pop(){
    top--;
    return S[top + 1];
}

int main(){
    int a,b;
    top = 0;
    char s[100];
    while(scanf("%s",s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a-b);
        }else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }else{
            push(atoi(s));
        }
    }

    printf("%d\n",pop());

    return 0;

}


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

int digitSum(const string& n) {
    int ans = 0;
    for (char i : n) {
        ans += (i - '0');
    }
    return ans;
}

int main() {
    string x;
    cin >> x;
    cout << digitSum(x) << endl;
    while (true) {
        cin >> x;
        if (x == "0") break;
        cout << digitSum(x) << endl;
    }
}



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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

void solve()
{
    int d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d){
        cout<<"Yes\n";
    }else cout<<"No\n";
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 1000
using namespace std;
const int dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
int n,m,vis[N+5][N+5];char s[N+5][N+5];struct Data {int x,y,t;}q[N*N+5];
int main()
{
	RI i,j,H=1,T=0;for(scanf("%d%d",&n,&m),i=1;i<=n;++i)
		for(scanf("%s",s[i]+1),j=1;j<=m;++j) s[i][j]=='#'&&(q[++T]=(Data){i,j,0},vis[i][j]=1);
	Data k;RI nx,ny;W(H<=T) for(k=q[H++],i=0;i^4;++i) (nx=k.x+dx[i])&&nx<=n&&
		(ny=k.y+dy[i])&&ny<=m&&!vis[nx][ny]&&(q[++T]=(Data){nx,ny,k.t+1},vis[nx][ny]=1);
	return printf("%d\n",q[T].t),0;
}

Measured memory_bytes: 20408
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;

template <typename T> vector<int> z_algorithm(const T &s){
  int n = s.size();
  vector<int> v(n, 0);
  v[0] = n;
  int j = 0;
  
  FOR(i,1,n){
    while(i+j<n && s[j]==s[i+j]) ++j;
    v[i] = j;
    if(j==0) continue;
    int k = 1;
    while(i+k<n && k+v[k]<j){
      v[i+k] = v[k];
      ++k;
    }
    i += k-1, j -= k;
  }
  return v;
}


int main(){
  int N;
  string s;
  while(cin >> N >> s){
    int ans = 0;

    REP(i,N){
      auto t = s.substr(i);
      dump(t);
      auto z = z_algorithm(t);
      dump(z);

      REP(j,N-i){
        if(z[j] <= j) chmax(ans, z[j]);
      }
    }
    

    

    cout << ans << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
vector<ll> a;  
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    a.resize(n);
    rep(i, 0, n) cin >> a[i];
    ll sum = 0, ans = 0;
    int right = 0;
    rep(left, 0, n)
    {
        while (right < n && (sum ^ a[right]) == (sum + a[right])) {
            sum += a[right];
            right++;
        }
        ans += right - left;
        if (right == left) right++;
        else {
            sum -= a[left];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
// 4:27~
#include <bits/stdc++.h>
using namespace std;

bool solve(vector<int>& a)
{
	int even=0,odd=0;
	for(auto x:a) (x&1?odd:even)++;
	assert(odd>=1);
	if(even&1)
		return true;
	if(odd>=2)
		return false;
	for(auto& x:a) if(x&1){
		if(x==1) return false;
		x--;
		break;
	}
	int g=a[0];
	for(auto x:a) g=__gcd(g,x);
	for(auto& x:a) x/=g;
	return !solve(a);
}

int main()
{
	for(int n;cin>>n&&n;){
		vector<int> a(n);
		for(auto& x:a) cin>>x;
		cout<<(solve(a)?"First":"Second")<<endl;
	}
}


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

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

int main() {
  ll a, b;
  cin >> a >> b;
  ll d = gcd(a, b);
  ll r = 1;
  ll t = d;
  for (ll i = 2; i <= t && i * i <= d; i++) {
    if (t % i == 0) {
      r++;
      while (t % i == 0) t /= i;
    }
  }
  r += t > 1;
  cout << r << endl;
}


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

// clang-format off
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

vector<vector<int>> r;
int n, k, ans;

int sum(int y, int x, int Y, int X) {
  return (r[Y][X] - r[Y][x] - r[y][X] + r[y][x]);
}

int query(int y, int x) {
  int X = x + k, Y = y + k;
  return sum(0, 0, y, x) + sum(y, x, Y, X) + sum(Y, X, 2 * k, 2 * k) + sum(0, X, y, 2 * k) + sum(Y, 0, 2 * k, x);
}

int main() {
  cin >> n >> k;
  r.assign(2 * k + 1, vector<int>(2 * k + 1, 0));
  for (int i = 0; i < n; ++i) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    if (c == 'W') x += k;
    x %= 2 * k;
    y %= 2 * k;
    r[y + 1][x + 1]++;
  }

  rep(i, 2 * k) rep(j, 2 * k) r[i + 1][j + 1] += r[i + 1][j] + r[i][j + 1] - r[i][j];
  rep(i, k) rep(j, k) chmax(ans, max(query(i, j), n - query(i, j)));

  cout << ans << endl;
}


Measured memory_bytes: 16000
a = []
for i in range(4):
    a.append(int(input()))

c = 0
if a[0] <= a[1]:
    c = a[0]
else:
    c = a[1]

if a[2] <= a[3]:
    c += a[2]
else:
    c += a[3]

print(c)

Measured memory_bytes: 3316
#include <stdio.h> 
int main(void) {
  int sum, N, M, P, ply[100], i;
  int gold;
  while(scanf("%d%d%d",&N,&M,&P) , M+N+P) {
    sum = 0;
    for(i = 0; i < N; i++ ) {
      scanf("%d",&ply[i]);
      sum += ply[i];
    }
    if(ply[M-1]) {
      gold = sum * (100 - P) / ply[M-1];
    } else {
      gold = 0;
    }
    printf("%d\n",gold);
  }
  return 0;
}

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


int main(){
  int n;
  string s;
  cin >> n >> s;
  string ans = "Yes";
  
  if (n % 2 == 1) ans = "No";
  
  if (n % 2 == 0){  
  rep(i,n/2){
  if(s.at(i) != s.at(i+n/2)){
    ans = "No";
    break;
  }
  }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N, M;
  cin >> N >> M;
  vector<ll> as(N);
  vector<ll> bs(N);
  set<pair<ll, ll>> has;
  for (auto i = 0; i < M; i++) {
    ll a, b;
    cin >> a >> b;
    has.insert(make_pair(a, b));
    has.insert(make_pair(b, a));
  }

  string res = "IMPOSSIBLE";
  for (auto key : has) {
    if (has.find(make_pair(1, key.first)) != has.end()
        && has.find(make_pair(key.first, N)) != has.end()) {
      res = "POSSIBLE";
      break;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 28416
num = input()
count = 0
renzoku = 0

if num[0] == "R":
    count += 1
    renzoku += 1

if num[1] == "R":
    count += 1
    renzoku += 1
else:
    renzoku = 0

if num[2] == "R":
    count += 1
    renzoku += 1

if count == 1:
    print(count)
else:
    print(renzoku)

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

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

  vector<int> c(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    c[a] += 1;
    c[b] += 1;
  }

  bool ok = true;
  for (int i = 0; i < n; ++i) {
    if (c[i] % 2 != 0) {
      ok = false;
    }
  }

  if (ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int l[100005] = {};
vector<int> pc(1000000,-1); 
vector<int> f(1000000,-1); 
int lc[2001][2001];
int co[2001][2001][2];

int main() {
  int h,w;
  string s;
  cin >> h >> w;
  for(int i= 0;i<h;i++){
    cin >> s;
    for(int j =0;j<w;j++){
      lc[i][j] = s[j];
    }
  }
  
  int c = 0;
  int mx = 0;
  for(int i= 0;i<h;i++){
    for(int j =0;j<w;j++){
      if(lc[i][j] == '.'){
        if(i> 0 && lc[i-1][j] != '#'){
          co[i][j][0] = co[i-1][j][0];
        }else{
          c = 0;
          for(int k =i;k < h;k++){
            c++;
            if(lc[k+1][j] != '.'){break;}
          }
          co[i][j][0] = c;
        }
        
        if(j> 0 && lc[i][j-1] != '#'){
          co[i][j][1] = co[i][j-1][1];
        }else{
          c = 0;
          for(int k =j;k < w;k++){
            c++;
            if(lc[i][k+1] != '.'){break;}
          }
          co[i][j][1] = c;
        }
      }
      mx = max(co[i][j][0] + co[i][j][1]-1,mx);
      //cout << i << " " << j << " " << co[i][j][0] + co[i][j][1] -1<< endl;
    }
  }
  cout << mx; 
}


Measured memory_bytes: 57964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll h[200005],a[200005],dp[200005];
int n;
void go(ll i, ll v)
{
	while(i<200005)
	{
		dp[i]=max(dp[i],v);
		i+=i&-i;
	}
}
ll query(int i)
{
	ll ans=0;
	while(i)
	{
		ans=max(ans,dp[i]);
		i-=i&-i;
	}
	return ans;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>h[i];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)
		go(h[i],query(h[i])+a[i]);
	cout<<query(n);
	return 0;
}

Measured memory_bytes: 8316
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
  int n, d, x ;
  cin >> n >> d >> x ;
  int sum = 0 ;
  REP(i,n){
    int a ;
    cin >> a ;
    sum += (d-1)/a+1 ;
  }
  
  cout << sum+x <<endl ;

  return 0 ;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	string s;
	cin >> s;
	string t;
	cin >> t;
  	int cnt=0;
	REP(i,s.length()){
		if(t[i]==s[0]){cnt=0;
			REP(j,s.length())
				if(t[(i+j)%s.length()]==s[j]){
					cnt++;
				}else break;
			if(cnt==s.length()){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,ans = 1;
  cin >> n;
  ll a[n],t[n];
  ll h[n];
  for(int i=0;i<n;i++){
    cin >> t[i];
    if(i==0||t[i]!=t[i-1]){
      h[i] = t[i];
    }else{
      h[i] = -1;
    }
  }
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=n-1;i>=0;i--){
    if(i==n-1||a[i]!=a[i+1]){
      if(h[i]!=-1&&a[i]!=h[i]){
        ans = 0;
        break;
      }
      h[i] = a[i];
    }else if(h[i]!=-1){
      if(h[i]>a[i]){
        ans = 0;
        break;
      }
    }else{
      ans *= min(a[i],t[i]);
      ans %= MOD;
    }
  }
  cout << ans << endl;
}


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

int main(){
  int N,D,d;
  cin >> D >> N;
  
  if(D==0)d=1;
  else if(D==1)d=100;
  else    d=10000;
  
  if(N == 100)cout << 101*d;
  else cout <<N*d;
}
  


Measured memory_bytes: 256
class Combination:
    """
    SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う
    使い方:
    comb = Combination(SIZE, MOD)
    comb(10, 3) => 120
    """

    def __init__(self, N, MOD=10 ** 9 + 7):
        self.MOD = MOD
        self.fact, self.inv = self._make_factorial_list(N)

    def __call__(self, n, k):
        if k < 0 or k > n:
            return 0
        res = self.fact[n] * self.inv[k] % self.MOD
        res = res * self.inv[n - k] % self.MOD
        return res

    def _make_factorial_list(self, N):
        fact = [1] * (N + 1)
        inv = [1] * (N + 1)
        MOD = self.MOD
        for i in range(1, N + 1):
            fact[i] = (fact[i - 1] * i) % MOD
        inv[N] = pow(fact[N], MOD - 2, MOD)
        for i in range(N, 0, -1):
            inv[i - 1] = (inv[i] * i) % MOD
        return fact, inv


if __name__ == "__main__":
    r1, c1, r2, c2 = map(int, input().split())
    mod = 10 ** 9 + 7
    comb = Combination(2 * 10 ** 6 + 10, mod)

    def f(r, c):
        return comb(r+c+2, r+1)

    CD = (f(r2, c2) - f(r2, c1-1) + mod) % mod
    C = (f(r1-1, c2) - f(r1-1, c1-1) + mod) % mod
    ans = (CD - C + mod) % mod
    print(ans)


Measured memory_bytes: 161268
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

#define INF 1e9
using namespace std;

int d[1001];
int dp[1001];
int tdp[1001][5001];

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	int *p = new int[n];
	vector<int> *vec = new vector<int>[n];
	map<int, vector<int> > mp;
	p[0] = 0;
	for(int i = 1; i < n; i++){
			cin >> p[i];
			p[i]--;
			vec[p[i]].push_back(i);
	}
	int *x = new int[n];
	int maxi = -1;
	for(int i = 0; i < n; i++){
			cin >> x[i];
			int current = i;
			while(current != 0){
					d[i]++;
					current = p[current];
			}
			if(mp.find(d[i]) == mp.end()){
					vector<int> tvec;
					tvec.push_back(i);
					mp[d[i]] = tvec;
			}else{
					mp[d[i]].push_back(i);
			}
			maxi = max(maxi, d[i]);
	}
	for(int i = maxi; i >= 0; i--){
			if(mp[i].size() == 0)continue;
			for(auto itr = mp[i].begin(); itr != mp[i].end(); ++itr){
					if(vec[*itr].size() == 0){
							continue;
					}
					for(int j = 0; j <= vec[*itr].size(); j++){
							for(int k = 0; k <= x[*itr]; k++){
									if(k == 0){
											if(j == 0)tdp[j][k] = 0;
											else{
													if(tdp[j - 1][k] != INF && (dp[vec[*itr][j - 1]] == 0 || x[vec[*itr][j - 1]] == 0))tdp[j][k] = tdp[j - 1][k] + x[vec[*itr][j - 1]];
													else tdp[j][k] = INF;
											}
									}else tdp[j][k] = INF;
							}
					}
					for(int j = 0; j < vec[*itr].size(); j++){
							for(int k = 1; k <= x[*itr]; k++){
									if(k >= x[vec[*itr][j]])tdp[j + 1][k] = min(tdp[j + 1][k], tdp[j][k - x[vec[*itr][j]]] + dp[vec[*itr][j]]);
									if(k >= dp[vec[*itr][j]])tdp[j + 1][k] = min(tdp[j + 1][k], tdp[j][k - dp[vec[*itr][j]]] + x[vec[*itr][j]]);
							}
					}
					int mini = INF;
					for(int j = 0; j <= x[*itr]; j++){
							mini = min(mini, tdp[vec[*itr].size()][j]);
					}
					if(mini == INF){
							cout << "IMPOSSIBLE" << endl;
							return 0;
					}
					dp[*itr] = mini;
			}
	}
	cout << "POSSIBLE" << endl;
	return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> dp(n, 1e9), num(n);
    for (int &i : num)
    {
        cin >> i;
    }
    dp.at(0) = 0;
    dp.at(1) = abs(num.at(1) - num.at(0));
    for (int i = 2; i < n; ++i)
    {
        for (int j = 1; j <= k && i - j >= 0; ++j)
        {
            dp.at(i) = min(abs(num.at(i) - num.at(i - j)) + dp.at(i - j), dp.at(i));
        }
    }
    cout << dp.back();
    return 0;
}

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

vector<vector<int>> get(vector<int>& A, int X) {
    vector<vector<int>> ret(1, vector<int>());
    for (int& a : A) {
        if (a >= X) {
            ret.back().push_back(a);
        } else if (ret.back().size() > 0) {
            ret.push_back(vector<int>());
        }
    }
    return ret;
}

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

    int ans = 1e9;
    for (int X : A) {
        vector<vector<int>> vs = get(A, X);
        vector<int> cand;
        for (vector<int>& v : vs) {
            sort(v.begin(), v.end());
            int n = v.size();
            for (int i = 0; i < n - K + 1; i++) {
                cand.push_back(v[i]);
            }
        }

        if (cand.size() >= Q) {
            sort(cand.begin(), cand.end());
            ans = min(ans, cand[Q - 1] - X);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <utility>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LOWBIT(x) x & (-x)
#define Pair pair<int,int>
#define LL long long
using namespace std;

struct node
{
	int x,y;
	int num;
}a[100048];

struct node2
{
	int x,y;
	int l;
}edge[300048];

bool cmp1(node x,node y)
{
	return x.x<y.x;
}

bool cmp2(node x,node y)
{
	return x.y<y.y;
}

bool cmp(node2 x,node2 y)
{
	return x.l<y.l;
}

int n,top;
int pre[100048];
inline int find_anc(int x)
{
	if (pre[x]!=x) pre[x]=find_anc(pre[x]);
	return pre[x];
}
inline void merge(int x,int y)
{
	x=find_anc(x);y=find_anc(y);
	pre[x]=y;
}

int main ()
{
	int i;
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>a[i].x>>a[i].y;
		a[i].num=i;
	}
	sort(a+1,a+n+1,cmp1);
	top=0;
	for (i=1;i<=n-1;i++)
	{
		edge[++top].x=a[i].num;
		edge[top].y=a[i+1].num;
		edge[top].l=a[i+1].x-a[i].x;
	}
	sort(a+1,a+n+1,cmp2);
	for (i=1;i<=n-1;i++)
	{
		edge[++top].x=a[i].num;
		edge[top].y=a[i+1].num;
		edge[top].l=a[i+1].y-a[i].y;
	}
	for (i=1;i<=n;i++) pre[i]=i;
	sort(edge+1,edge+top+1,cmp);
	int cnt=0;i=0;
	LL ans=0;
	while (cnt<n-1)
	{
		i++;
		if (find_anc(edge[i].x)!=find_anc(edge[i].y))
		{
			ans+=edge[i].l;
			merge(edge[i].x,edge[i].y);
			cnt++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5376
n=int(input())
i=0
b=[]
pos=0
maxi=0
while(i<n):
  k=int(input())
  b.append(k)
  if(k>maxi):
    pos=i
    maxi=k
  i+=1
b.sort()
ns=b[n-2]
i=0
while(i<n):
  if(i==pos):
  	print(ns)
  else:
    print(b[n-1])
  i+=1

Measured memory_bytes: 12532
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
#define SQ(x) (x)*(x)
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define debug(x) cerr<<#x<<" is "<<x<<endl
using namespace std;

#define int ll

const int maxn = 1e5+5;
const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"No\n"; exit(0);}

ll pow(ll a, ll n){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mod;
        a = a*a %mod;
        n>>=1;
    }
    return re;
}

ll inv (ll b){
    if (b==1) return b;
    return (mod-mod/b) * inv(mod%b) % mod;
}

ll fac[4005];

ll C(int a, int b){
    return fac[a] * inv(fac[a-b]) %mod * inv(fac[b]) %mod;
}

ll fit(int a, int b){
    return C(a+b-1,b-1);
}

main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    fac[0]=1;
    FOR(i,1,4002){
        fac[i]=fac[i-1]*i%mod;
    }
    int n, k; cin>>n>>k;
    int A = n-k, B = k;

    FOR(m, 1, k+1){
        if (A < m-1) cout<<0<<'\n';
        else cout<<fit(B-m,m) * fit(A-m+1,m+1)%mod<<'\n';
    }

    
}

Measured memory_bytes: 256
using System;

public class Program{
    public static void Main(){
        
        var antennaFlag = true;
        int[] antennas = new int[6];
        for(var i = 0; i < 6; i++){
            antennas[i] = int.Parse(Console.ReadLine());
        }
        for(var i = 0; i < antennas.Length - 2; i++){
            for(var j = i + 1; j < antennas.Length - 1; j++){
                if(antennas[j] - antennas[i] > antennas[5]){
                    antennaFlag = false;
                        break;
                }
            }
        }
        if(antennaFlag){
            Console.WriteLine("Yay!");
        }else{
            Console.WriteLine(":(");
        }
    }
}

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

const int N = 1e5+3;
char s[N], t[N];
int sp[N], tp[N];
int main()
{
    int q, a, b, c,d;
    scanf("%s%s%d",s+1,t+1,&q);
    for(int i=1; s[i]; ++i)
        sp[i] = sp[i-1]+((s[i]=='A')?1:2);
    for(int i=1; t[i]; ++i)
        tp[i] = tp[i-1]+((t[i]=='A')?1:2);
    while(q--)
    {
        scanf("%d%d%d%d",&a,&b,&c,&d);
        if((sp[b]-sp[a-1])%3 == (tp[d]-tp[c-1])%3)
            puts("YES");
        else
            puts("NO");
    }
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, int> PL;
constexpr ll INF = (1LL << 60);

int main() {
  int n;
  cin >> n;
  map<int,int> mp1, mp2;
  rep(i,n) {
    int d;
    cin >> d;
    mp1[d]++;
  }
  int m;
  cin >> m;
  rep(i,m) {
    int t;
    cin >> t;
    mp2[t]++;
  }
  bool ok = true;
  for (auto e : mp2) {
    if (mp1[e.first] < e.second) ok = false;
  }
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
} 

Measured memory_bytes: 18944
{-
     9 * a + 5 * b =  10 * N - Y
         a +     b <= N

-}

main = do
    input <- fmap words getLine
    let (n, y) = (read $ head input, (read $ input!!1))
    let pairs = [(a, b) | a <- [0..n], b <- [0..n], a + b <= n]
    let satisfiesEquation = filter (\(a ,b) -> 9000 * a + 5000 * b == 10000 * n - y) pairs
    if length satisfiesEquation /= 0 then
        do
            let (t, f) = head satisfiesEquation
            let (thousand, fiveThousand) = (round t, round f)
            putStr $ show $ (round $ n - t - f)
            putStr " "
            putStr $ show  fiveThousand
            putStr " "
            putStrLn $ show thousand
    else
        putStrLn "-1 -1 -1"


Measured memory_bytes: 1020
import heapq
x, y, z , k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)
q = [[-(a[0] + b[0] + c[0]), 0, 0, 0]]
qh = [[-(a[0] + b[0] + c[0]), 0, 0, 0]]
heapq.heapify(q)
ans = []
heapq.heapify(ans)
for i in range(k):
    t, aq, bq, cq = heapq.heappop(q)
    heapq.heappush(ans, t)
    if aq + 1 < len(a):
        if [-(a[aq + 1] + b[bq] + c[cq]), aq + 1, bq, cq] not in qh:
            heapq.heappush(q, [-(a[aq + 1] + b[bq] + c[cq]), aq + 1, bq, cq])
            heapq.heappush(qh, [-(a[aq + 1] + b[bq] + c[cq]), aq + 1, bq, cq])
    if bq + 1 < len(a):
        if [-(a[aq] + b[bq + 1] + c[cq]), aq, bq + 1, cq] not in qh:
            heapq.heappush(q, [-(a[aq] + b[bq + 1] + c[cq]), aq, bq + 1, cq])
            heapq.heappush(qh, [-(a[aq] + b[bq + 1] + c[cq]), aq, bq + 1, cq])
    if cq + 1 < len(a):
        if [-(a[aq] + b[bq] + c[cq + 1]), aq, bq, cq + 1] not in qh:
            heapq.heappush(q, [-(a[aq] + b[bq] + c[cq + 1]), aq, bq, cq + 1])
            heapq.heappush(qh, [-(a[aq] + b[bq] + c[cq + 1]), aq, bq, cq + 1])
for i in range(len(ans)):
    print(-heapq.heappop(ans))


Measured memory_bytes: 5228
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
ll n , k ;
vector<vector<ll>> dp;
vector<ll> a;

/*
ll f(ll x, ll y){
    if(dp.at(x).at(y)!=INF){
        return dp.at(x).at(y);
    }
    ll ret = 0;
    for(int i=0;i<=a.at(y);i++){
        if(x-i<0) break;
        ret = (ret + f(x-i,y+1))%mod;
    }
    dp.at(x).at(y) = ret;
    return ret;
}
*/

int main(){
    cin >> n >> k;
    a.resize(n);
    rep(i,n) cin>>a.at(i);
    dp.resize(k+1,vector<ll>(n,INF));

    vector<ll> rui(k+1);

    for(int i=0;i<=k;i++){
        dp.at(i).at(n-1) = (i<=a.at(n-1));
        if(i==0){
            rui.at(0) = dp.at(i).at(n-1);
        }else{
            rui.at(i) = rui.at(i-1)+dp.at(i).at(n-1);
        }
    }

    for(int i=n-2;i>=0;i--){
        for(int j=0;j<=k;j++){
            if(j-a.at(i)<=0){
                dp.at(j).at(i) = rui.at(j);
            }else{
                dp.at(j).at(i) = (rui.at(j) - rui.at(j-a.at(i)-1))%mod;
                if(dp.at(j).at(i)<0) dp.at(j).at(i) += mod;
            }
        }
        for(int j=0;j<=k;j++){
            if(j==0){
                rui.at(0) = dp.at(j).at(i);
            }else{
                rui.at(j) = (rui.at(j-1)+dp.at(j).at(i))%mod;
            }
        }
    }

    cout << dp.at(k).at(0) << endl;

    /*
    for(int i=0;i<k+1;i++){
        for(int j=0;j<n;j++){
            cout << dp.at(i).at(j) << " ";
        }
        cout << endl;
    }
    */

}

Measured memory_bytes: 83072
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> anys;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(anys{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N;
	cin >> N;
	ll ans = 0;
	for(int i=1; i<=N; i++){
		if(i%3!=0 && i%5!=0) ans+=i;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

    int n ;
    cin >> n;
    vector<ll> h(n+1);
    rep(i, n) {
        cin >> h[i];
    }
    h[n] = INF;

    int ans = 0;
    int tmp = 0;
    for (int i = 0; i < n; ++i) {
        if (h[i + 1] <= h[i]) {
            tmp += 1;
        } else {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
using static Atcoder.IO;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        static long N;
        static List<(long h, long s)> lis = new List<(long h, long s)>();

        public static void Answer()
        {
            var x = IO.RSInt;
            long ans = 0;
            foreach (var item in x)
            {
                if (item == 1) ans += 300000;
                else if (item == 2) ans += 200000;
                else if (item == 3) ans += 100000;
            }
            if (x.Where(a => a == 1).Count() == 2) ans += 400000;
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

int n,A[50];

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

int main(){
    int q,M,i;
    cin >> n;
    for(i = 0; i < n;i++){
        cin >> A[i];
    }
    cin >> q;
    for(i = 0; i < q;i++){
        cin >> M;
        if(solve(0,M) == 1) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C(I) cout<<(I)<<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1000][1000];
vector<ll> va,vb,vc;


int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>cd[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(cd[i][j]=='#')cout<<"#";
            else{
                c=0;
                for(int qa=-1;qa<=1;qa++){
                    for(int qi=-1;qi<=1;qi++){
                        c+=cd[i+qa][j+qi]=='#';
                    }
                }
                cout<<c;
            }
        }
        cout<<endl;
    }
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n],b[n];
  for(int i=0;i<n;i++)
    cin >> a[i] >> b[i];
  int maxindex=0;
  for(int i=0;i<n;i++){
    if(a[i]>a[maxindex])
      maxindex = i;
  }
  cout << a[maxindex] + b[maxindex] << "\n";
  return 0;
}


Measured memory_bytes: 1024
//Solution by Tima
#include <bits/stdc++.h>
 
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
 
using namespace std;    
const int N = 220, mod = int(1e9)  + 7; 

char a[N][N];
int n;

int d[N][N], used[N];

void dfs(int v,int c){
	used[v] = c;
	for(int to = 1; to <= n; to++) if(d[v][to] == 1){
		if(used[to]){
			if(used[to] == used[v]){
				cout << -1;
				exit(0);
			}
		}
		else{
			dfs(to, 3 - c);
		}
	}
}

int main () {
	cin >> n;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			char ch;
			cin >> ch;
			if(ch == '1') d[i][j] = 1;
			else{
				if(i == j) d[i][j] = 0;
				else d[i][j] = N;
			}
		}
	}
	for(int i = 1; i <= n; i++){
		if(!used[i]){
			dfs(i,1);
		}
	}
    for(int k = 1; k <= n; k++){
    	for(int i = 1; i <= n; i++){
    		for(int j = 1; j <= n; j++){
    			d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    		}
    	}
    }
   	int ans = 0;
   	for(int i = 1; i <= n; i++){
   		for(int j = 1; j <= n; j++){
   			ans = max(ans, d[i][j]);
   		}
   	}
   	cout << ans + 1;


    
return 0;
}

Measured memory_bytes: 384
// myfirstatcoder.cpp : アプリケーションのエントリ ポイントを定義します。

#include "bits/stdc++.h"
#define rep(i,cc,n) for(int i=cc;i<(n);++i)
#define drep(i,cc,n) for(int i=cc;i>(n);--i)
#define llrep(i,cc,n) for(long long i=cc;i<(n);++i)
using namespace std;
using ll = long long;

int main()
{
	int x;
	cin >> x;
	llrep(i, -200, 200)
		llrep(j, -200, 200)
		if (i*i*i*i*i - j * j*j*j*j == x) {
			cout << i << " " << j << endl;
			return 0;
		}
	//cout << a << b << endl;
}

/*
ライブラリ
・string
・vector<int>
::::vector<vector<int>> A(N,vector<int>(M));
::::A[i][j] = i;
・map<string,int>

関数
・rep(i,n) … ループ(i=0;i<N;++i)
・rep_b(i,n) … ループ(i=1;i<=N;++i)
・gcd(int, int) … 最大公約数 int
・find_string(str, str) … 文字列検索 bool
*/

Measured memory_bytes: 3620
S = list(input())

n = S.count("N")
s = S.count("S")
e = S.count("E")
w = S.count("W")

if n!=0 and s!=0 and e==0 and w==0:
    print("Yes")
elif n==0 and s==0 and e!=0 and w!=0:
    print("Yes")
elif n!=0 and s!=0 and e!=0 and w!=0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 8904
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int a,b,c,x,y;
	scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);

	long long min = 5000*100000*2;
	for(int i=0;i<=100000;i++){
		long long tmp = i*2*c + max(0,x-i)*a + max(0,y-i)*b;
		if(min > tmp) min = tmp;
	}

	printf("%lld\n", min);

	return 0;
}


Measured memory_bytes: 256
/**
 *	author: jasonpogi
 *	created: 15.07.2020 09:14:22
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int l, r, d, cnt = 0;
	cin >> l >> r >> d;
	for (int i = l; i <= r; i++) {
		if (i % d == 0) cnt++;
	}
	cout << cnt << '\n';
	return 0;
}


Measured memory_bytes: 3612
N,T=map(int,input().split())
ct=[]
d=[]
for i in range(N):
    ct.append(list(map(int,input().split())))
for i in range(N):
    if ct[i][1]<=T:
        d.append(ct[i])
if len(d)==0:
    print('TLE')
else:
    e=d[0]
    for i in range(len(d)):
        if e[0]>=d[i][0]:
            e=d[i]
    print(e[0])

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

int main(){
  int64_t N, M;
  cin >> N >> M;
  vector<vector<int64_t>> vec(N,vector<int64_t>(3));
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  vector<string> v = {"0", "1"};
  queue<string> Q;
  for(int i=0; i<v.size(); i++){
    Q.push(v.at(i));
  }

  for(int i=0; i<2; i++){
    int cnt = Q.size();
    int k = 0;
    bool end = true;
    while(k < cnt){
      string S = Q.front();
      Q.pop();
      for(int j=0; j<v.size(); j++){
        string T = S;
        T += v.at(j);
        Q.push(T);
      }
      k++;
    }
  }
  
  int64_t ans = 0;
  for(int i=0; i<8; i++){
    string S = Q.front();
    Q.pop();
    vector<int64_t> sum(N);
    int64_t pre_ans = 0;
    for(int j=0; j<N; j++){
      for(int k=0; k<3; k++){
        if(S.at(k) == '0'){
          sum.at(j) += vec.at(j).at(k);
        }
        else{
          sum.at(j) += vec.at(j).at(k) * -1;
        }
      }
    }
    sort(sum.rbegin(),sum.rend());
    for(int j=0; j<M; j++){
      pre_ans += sum.at(j);
    }
    ans = max(ans,pre_ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
route = [[] for i in range(n + 1)]
for j in range(m):
    a, b = map(int, input().split())
    route[a].append(b)
    route[b].append(a)
for h in set(route[1]):
    for b in set(route[h]):
        if b == n:
            print("POSSIBLE")
            exit()
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 43824