akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define F first
#define S second
#define fast_io ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N=1e4+10,LN=30,SQ=550;
const ll INF=1e16;
const int MOD=1000000007 /*998244353*/;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using pll=pair<ll,ll>;
using pii=pair<int,int>;
#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
ll pow(ll x, ll y, ll mod){
    ll ans=1;
    while (y != 0) {
        if (y & 1) ans = ans * x % mod;
        y >>= 1;
        x = x * x % mod;
    }
    return ans;
}
string s;
int main(){
    fast_io;
    cin >> s;
    if(s[s.size()-1]=='s') s+="es";
    else s+='s';
    cout << s;
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,y;
  cin>>x>>y;
  if(y%2!=0)
  {
    cout<<"No";
   return 0;
  }
  else if(x*2>y||x*4<y)
  {cout<<"No";
    return 0;}
  else 
  {cout<<"Yes";
   return 0;}
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(){
  int N, d[100], a, count = 1, r;
  
  scanf("%d", &N);
  for (int i = 0; i < N; i++){
    scanf("%d", &a);
    if(i == 0){
      d[i] = a;
    } else {
      for (int j = i - 1; j >= 0; j--){
        if(a < d[j]){
          d[j + 1] = d[j];
          if(j == 0){
            d[0] = a;
          }
        } else {
          d[j + 1] = a;
          break;
        }
      }
    }
  }
  r = d[0];
  for (int i = 1; i < N; i++){
    if(r != d[i]){
      count++;
      r = d[i];
    }
  }
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<string>
using namespace std;

int main(){
    int a,b;
    int cnt=0;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        string s = to_string(i);
        if(s[0]==s[4] && s[1]==s[3]){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ab = sorted([list(map(int, input().split())) for i in range(M)], key=lambda x: x[0])

t = {i:[] for i in range(1,N+1)}
for a, b in ab:
    if a == 1:
        t[a].append(b)
    elif b == N:
        t[a].append(N)

for i in t[1]:
    if len(t[i]) == 1:
        print('POSSIBLE')
        exit()
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 120920
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

int n;
string s;

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> n >> s;
    if(n%2)
    {
        cout << "No" << endl;
        return 0;
    }
    string t = "";
    forn(i, n/2) t.pb(s[i]);
    if(s == t + t) cout << "Yes";
    else cout << "No";
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  long long ans=0;
  for(int i=0;i<n;i++){
    long long x=distance(a.begin(),lower_bound(a.begin(),a.end(),b[i]));
    long long y=distance(upper_bound(c.begin(),c.end(),b[i]),c.end());
    ans+=x*y;
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n - 1);
  vector<int> buka(n);
  for(int i = 0; i < n - 1; i++){
    cin >> vec.at(i);
    buka.at(vec.at(i) - 1)++;
  }
  for(int i = 0; i < n; i++){
    cout << buka.at(i) << endl;
  }
}

Measured memory_bytes: 4840
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn=100+10,maxm=10000+10;
int n,m;
int v[maxn],w[maxn];
int f[maxm];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>v[i]>>w[i];
	memset(f,0,sizeof(f));
	for(int i=1;i<=n;i++)
		for(int j=m;j>=w[i];j--)
			f[j]=max(f[j],f[j-w[i]]+v[i]);
	cout<<f[m]<<endl;
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>                                                                          
using namespace std;
char swi(string& s){
  if(s.at(0)=='a')
    s.at(0)='A';
  else if(s.at(0)=='b')
    s.at(0)='B';
  else if(s.at(0)=='c')
    s.at(0)='C';
  else if(s.at(0)=='d')
    s.at(0)='D';
  else if(s.at(0)=='e')
    s.at(0)='E';
  else if(s.at(0)=='f')
    s.at(0)='F';
  else if(s.at(0)=='g')
    s.at(0)='G';
  else if(s.at(0)=='h')
    s.at(0)='H';
  else if(s.at(0)=='i')
    s.at(0)='I';
  else if(s.at(0)=='j')
    s.at(0)='J';
  else if(s.at(0)=='k')
    s.at(0)='K';
  else if(s.at(0)=='l')
    s.at(0)='L';
  else if(s.at(0)=='m')
    s.at(0)='M';
  else if(s.at(0)=='n')
    s.at(0)='N';
  else if(s.at(0)=='o')
    s.at(0)='O';
  else if(s.at(0)=='p')
    s.at(0)='P';
  else if(s.at(0)=='q')
    s.at(0)='Q';
  else if(s.at(0)=='r')
    s.at(0)='R';
  else if(s.at(0)=='s')
    s.at(0)='S';
  else if(s.at(0)=='t')
    s.at(0)='T';
  else if(s.at(0)=='u')
    s.at(0)='U';
  else if(s.at(0)=='v')
    s.at(0)='V';
  else if(s.at(0)=='w')
    s.at(0)='W';
  else if(s.at(0)=='x')
    s.at(0)='X';
  else if(s.at(0)=='y')
    s.at(0)='Y';
  else if(s.at(0)=='z')
    s.at(0)='Z';
  return s.at(0);
}
int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  cout << swi(s1) << swi(s2) << swi(s3) << endl;
}               

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

// DPでパティの枚数保存
// 層はf(N+1) = f(N)*2+3
// P
// [1]
// BPPPB
// [0,1,2,3,3]
// BBPPPBPBPPPBB
// [0,0,1,2,3,3,4,4,5,6,7,7,7]
ll layer_cnt(int N) {
  return 4*pow(2LL,N)-3;
}

ll patty_cnt(int N) {
  return 2*pow(2LL,N)-1;
}

ll dfs(ll N, ll X) {
  if (N==0) return 1;
  if (X==1) return 0;
  if (X<=layer_cnt(N)/2) return dfs(N-1,X-1);
  if (X==layer_cnt(N)/2+1) return dfs(N-1,X-1)+1;
  return patty_cnt(N-1) + 1 + dfs(N-1,X-layer_cnt(N)/2-1);
}

int main() {
  ll N,X;cin>>N>>X;

  OUT(dfs(N,X));

  return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
using namespace std;
int main(){
  int n,d=0;
  cin>>n;
  int h[200];
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h,h+n);
  cout<<h[n-1]-h[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
                //to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

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

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

bool ABC(int n) {
	if (0 < n && n < 13) {
		return true;
	}
	else {
		return false;
	}
}

int main(void) {
	rapid_pleaseAC_fast;

	string n;
	cin >> n;
	rep(i, 3) {
		if (n[i] == '7') {
			cout << "Yes" << rt;
			return 0;
		}
	}
	cout << "No" << rt;

	please AC;
}
//参考：---

Measured memory_bytes: 3652
#include <stdio.h>

int main(){
    int S;
    int h, m, s;
    
    scanf("%d",&S);
    
    h = S / 3600;
    
    m = (S%3600)/60;
    
    s = S%60;
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
#define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
#define bug(a)       cerr << #a << " : " << a << endl;
#define sc(a) scanf("%d",&a)
#define sc1(a) scanf("%d",&a)
template<class T>void ExEuclid(T n, T m, T &a, T &b, T &gcd){if(m==0){gcd=n;a=1;b=0;return;}ExEuclid(m,n%m,a,b,gcd);T x=a;a=b;b=x-(n/m)*a;}
template<class T>T gcd(T n, T m){if(m==0){return n;}gcd(m,n%m);}
template<class T>T lcm(T n, T m){return (n*m)/gcd(n,m);}
template<class T>string to_string(T n){string s="";while(n)s+=((n%10)+'0'),n/=10;reverse(s.begin(),s.end());return s;}
template<class T>ll to_int(T s){ll num=0,power=0;for(int i=s.size()-1; i>=0; i--)num+=(pow(10.0,power++)*(s[i]-'0'));return num;}
template<class T>bool is_mod(T n, T m){if(n%m==0)return true;return false;}
template<class T>bool is_upper(T s){for(int i=0; i<s.size(); i++)if(s[i]>90 || s[i]<65)return false;return true;}
template<class T>bool is_lower(T s){for(int i=0; i<s.size(); i++)if(s[i]>122 || s[i]<97)return false;return true;}
template<class T>bool is_palindrome(T s){T s1=s;reverse(s1.begin(),s1.end());if(s==s1)return true;return false;}
template<class T>T mod(T n, T m){return ((n%m)+m)%m;}
template<class T>T Big_mod(T base, T power, T MOD){
    if(power==1)return base;
    if(power & 1)return ((base%MOD)*(Big_mod(base,power-1,MOD))%MOD)%MOD;
    else {T temp=(Big_mod(base,power>>1,MOD));return ((temp%MOD)*(temp%MOD))%MOD;}
}



int main()
{
    faster_io;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,m;
    cin>>n>>m;
    if(n<m)cout<<0<<endl;
    else cout<<10<<endl;
    
    return 0;
}




Measured memory_bytes: 256
n, a = map(int, input().split())
x = list(map(int, input().split()))
X = max(max(x), a)
#dp = [[[0]*(n*X+1) for _ in range(X+1)] for i in range(n+1)]
dp = [[[0]*(n*X+1) for _ in range(n+1)] for i in range(n+1)]

for j in range(n+1):
    for k in range(n+1):
        for s in range(n*X+1):
            if j == 0 and k == 0 and s == 0:
                dp[j][k][s] = 1
            elif j >= 1 and s < x[j-1]:
                dp[j][k][s] = dp[j-1][k][s]
            elif j >= 1 and k >= 1 and s >= x[j-1]:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]]
            else:
                dp[j][k][s] = 0
ans = 0
for k in range(1,n+1):
    ans += dp[n][k][k*a]
print(ans)

Measured memory_bytes: 92636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

bool hast[256];
bool hass[256];

int d[100010][26];
vvi ci(26, vi());

void pr(ll n){
    cout << n << endl;
    exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin >> s;
    string t;
    cin >> t;
    ll n = SZ(s);
    ll m = SZ(t);
    rep(i, n){
        hass[s[i]] = 1;
    }
    rep(i, m){
        hast[t[i]] = 1;
    }
    for(char i = 'a'; i <= 'z'; i++){
        if(!hass[i] && hast[i]){
            pr(-1);
        }
    }
    rep(i, n){
        ci[s[i]-'a'].emplace_back(i);
    }
    //rep(i, 26) dump(ci[i]);
    ll ans = 0;
    rep(i, n){
        if(s[i] == t[0]){
            ans = i;
            break;
        }
    }
    dump(ans);
    rep(i, m-1){
        dump(ci[t[i+1]-'a']);
        auto itr = upper_bound(ALL(ci[t[i+1]-'a']), ans%n);
        ll ne;
        if(itr != ci[t[i+1]-'a'].end()){
            dump(*itr);
            ne = *itr-ans%n;
        }else{
            ne = n-ans%n+ci[t[i+1]-'a'][0];
        }
        ans += ne;
        dump(ne, ans);
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認
 
int main(){
   ll K;
   cin >> K;
   ll sum = 0,M = 7;
   rep(i,10000010){
      sum += M % K;
      if(sum % K == 0){
         cout << i + 1 << endl;
         return 0;
      }
      M = (M * 10) % K;
   }
   cout << -1 << endl;
}

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

using namespace std;

typedef long long ll;
const long long mod = 1000000007;

const int MX = 307;
typedef float ld;

 
float dp[MX + 5][MX + 5][MX + 5];

int main(){
   ll n, k, i, j;

   cin>>n>>k;

   ll a[n];

   for(i = 0;i < n;i++)
    cin>>a[i];
    
    sort(a, a+n);



    bool dp[k+1];
    for(i = 0;i < a[0];i++)
     dp[i] = 0;


    for(i = a[0];i <= k;i++){
        bool res = 0;
        for(j = 0;j < n;j++){
            if(i-a[j] >= 0){
                res = res|(!dp[i-a[j]]);
            }
        }
        dp[i] = res;
    }
    if(dp[k])
    cout<<"First\n";
    else{
        cout<<"Second\n";
    }

} 


Measured memory_bytes: 384
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const int N=2e3+20;
    const int M=22;
    int a[N][N];
    string s;
    int b[N],h[N];
     
     
    int main()
    {
    	int n,m;
    	while(cin>>n>>m)
    	{
    		for(int i=0;i<n;i++)
    		{
    			cin>>s;
    			for(int j=0;s[j];j++)
    				a[i][j]=s[j]=='#'?1:0;
    		}
    		int ans=max(n,m);
    		for (int i = 0; i < n; ++i)
    	    {
    	    	for (int j = 0; j < m; ++j)
    	    	{	
    				if(i&&!(a[i-1][j+1]^a[i][j]^a[i-1][j]^a[i][j+1])) h[j]++;
                		else h[j]=1;
    			}
    			int t=0;
    			for(int j=0;j<m;j++)
    			{
    				while(t&&h[b[t-1]]>=h[j])
    				{
    					int x=b[--t];
    					if(t==0) 
    					    ans=max(ans,(j+1)*h[x]);
    					else
    					    ans=max(ans,(j-b[t-1])*h[x]);
    				//	 cout<<x<<" ";
    				}
    			//	cout<<endl;
    				b[t++]=j;
    			}
    			
    			/*for(int l=0;l<m;l++)
    			{
    			   cout<<h[l]<<" ";
    			}
    			cout<<endl<<ans<<endl;*/
    		}
    		cout<<ans<<endl;
    	}
    	return 0;
    }

Measured memory_bytes: 16000
import math
N, M = map(int, input().split())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if N >= 2 and M >= 2:
    ans = combinations_count(N, 2) + combinations_count(M, 2)
elif N >= 2:
    ans = combinations_count(N, 2)
elif M >=2:
    ans = combinations_count(M, 2)
else:
    ans = 0

print(ans)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
   int N, c=0;
   cin >> N;
   for (int i=1;i<=N;i+=2) {
      int k=0;
      for (int j=1;j<=i;j++) {
	 if (i % j == 0) {
	    k++;
	 }
      }
      if (k == 8) {
	 c++;
      }
   }
   cout << c << endl;
   return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
	  int max=0;
      int[] map = new int[n];
      for(int i = 0;i<n;i++)map[i]=sc.nextInt(); //入力
      int i;
      for(int j = 0;j<n;j++){
	      for(i=j;i<n-1;i++)if(map[i]<map[i+1])break;
          if(max<i-j)max=i-j;
	      j=i;
	      
      }
	  System.out.println(max);
    }
}

Measured memory_bytes: 50544
N = int(input())
A = list(map(int, raw_input().split()))

def gcd(m,n):
    return m if n == 0 else gcd(n, m%n)

L = [0] * (N+1)
R = [0] * (N+1)

# L: list
# boundary: L[0] = 0, L[N-1] = 0
# L[i]: previous (i-1)-th gcd value, i = [0, ..., N-2]
for i in range(N-1):
    L[i+1] = gcd(L[i], A[i])

# R: list
# boundary: R[0] = 0, R[N-1] = 0
# R[i]: last (N-i)-th gcd value, i = [N-1, ..., 1]
for i in range(N-1, 0, -1):
    R[i] = gcd(R[i+1], A[i])

max_gcd = 0
for i in range(N):
    if gcd(L[i], R[i+1]) > max_gcd:
        max_gcd = gcd(L[i], R[i+1])

print '{}'.format(max_gcd)


Measured memory_bytes: 13700
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define int ll
#define Endl endl


signed main(void){
    int N,M,C;
    int B[22],A[22][22];
    cin >> N >> M >> C;
    REP(i,M){cin >> B[i];}
    REP(i,N){REP(j,M){cin >> A[i][j];}}
    int Ans=0;
    REP(i,N){
        int sum=0;
        REP(j,M){
            sum+=A[i][j]*B[j];
        }
        sum+=C;
        if(sum>0)Ans++;
    }
    cout << Ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    a = list(map(int, input().split()))
    l = [[10**9+1] * (N+1) for _ in range(N+1)]
    s = [[0] * (N+1) for _ in range(N+1)]
    for i in range(N-1):
        for j in range(i+1, N+1):
            s[i][j] = s[i][j-1] + a[j-1]
    for i in range(N):
        l[i][i+1] = 0
    for j in range(2, N+1):
        for i in range(N):
            m = i + j
            if m > N:
                continue
            l[i][m] = min(l[i][k] + l[k][m] for k in range(i+1, m)) + s[i][m]
    return l[0][-1]

print(main())


Measured memory_bytes: 45020
n = int(input())
a = []
for i in range(n):
    a.append(list(map(int,input().split())))

ans = 'Yes'
if a[0][0] < abs(a[0][1])+abs(a[0][2]) or (a[0][0]-abs(a[0][1])-abs(a[0][2]))%2 == 1:
    ans = 'No'
for i in range(n-1):
    if (a[i+1][0]-a[i][0]) < (abs(a[i+1][1]-a[i][1])+abs(a[i+1][2]-a[i][2])):
        ans = 'No'
    if (a[i+1][0]-a[i][0]-abs(a[i+1][1]-a[i][1])-abs(a[i+1][2]-a[i][2]))%2!=0:
        ans = 'No'

print(ans)

Measured memory_bytes: 27300
using System;
class AOJ
{
    public static void Main()
    {
        String[] st = System.Console.ReadLine().Split(' ');
        int a=  int.Parse(st[0]);
        int b;
      b=  int.Parse(st[1]);
        int c = a + a + b + b;
        Console.WriteLine("{0} {1}",a*b,c);
    }
}

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
 
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a, b, x;
cin >> x >> a >> b;
if (b <= a){
cout << "delicious\n";
}else if (b - a <= x){
cout << "safe\n";
}else{
cout << "dangerous\n";
}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1e9+7;

int main() {
  int h,w,x,y;
  cin>>h>>w>>x>>y;
  cout<<h*w-h*y-w*x+x*y<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
readline=sys.stdin.readline

A,B,M=map(int,readline().split())
a=list(map(int,readline().split()))
b=list(map(int,readline().split()))

ans=min(a)+min(b)
for i in range(M):
  x,y,c=map(int,readline().split())
  x,y=x-1,y-1
  if a[x]+b[y]-c<ans:
    ans=a[x]+b[y]-c
  
print(ans)


Measured memory_bytes: 18616
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = if n <= m then  List.range n `To m else []
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (0 ++^ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv
let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv
let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'
let itoa n = Char.chr (n + Char.code '0')

let between n x m = n <= x && x < m


(* ===== MAIN ===== *)

let x, y = scan "%d %d" (fun x y -> x, y)

let () =
  Printf.printf "%d\n" (x*y)


Measured memory_bytes: 5436
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer return cout << "NO", 0;
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 1e5 + 200;
const long long MNN = 3e3 + 200;
const long long MOD = 1e9 + 7;
const long long INF = 1e13;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, k, a[102], dp[MXN], fake[MXN];

void add(llong& a, llong b){
    a += b;
    while(a < 0) a += MOD;
    a %= MOD;
}

int main () {
    ios;
    cin >> n >> k;
    dp[0] = 1;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        for(int j = 0; j <= k; j++) fake[j] = 0;
        for(int j = k; j >= 0; j--){
            int x = dp[j];
            int l = j + 1;
            int r = j + min(a[i], k - j);
            if(l <= r){
                add(fake[l], x);
                add(fake[r + 1], -x);
            }
        }
        llong pr = 0;
        for(int j = 0; j <= k; j++){
            add(pr, fake[j]);
            add(dp[j], pr);
        }
    }
    cout << dp[k];
}


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

int main(){
	int a, b;
	cin >> a >> b;

	rep(i, max(a,b)) cout << min(a, b);
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

const LL MOD = 1e9+7;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n,k;
    cin>>n>>k;
    VL a(n);
    REP(i,n)cin>>a[i];
    LL ans = 0;
    REP(i,n){
        LL c_pre = 0;
        LL c_post = 0;
        REP(j,i){
            if(a[i] > a[j])c_pre++;
        }
        FOR(j,i+1,n){
            if(a[i] > a[j])c_post++;
        }
        ans += c_post * k;
        ans %= MOD;
        ans += (c_pre+c_post) * (((k-1) * k / 2)%MOD);
        ans %= MOD;
        //PUTS(ans);
    }
    PUTS(ans);
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<cmath>
#include<cstdio>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
typedef pair<int, int> P;


int main() {
	ll i, j, k, l, m, n, sum, flag, cc,M,X,H,W,N,ans;
	sum = 0;
	ll sumb = 0;
	flag = 0;
	cin >> N;
	vector<int>A(N);
	for (i = 0; i<N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	vector<int>B(N);
	for (i = 0; i<N; i++) {
		cin >> B[i];
		sumb += B[i];
	}
	if (sum < sumb) {
		output("-1");
		return 0;
	}
	ll temp1,temp2;
	ans = 0;
	vector<ll>C;
	REP(i, 0, N) {
		if (A[i] > B[i]) {
			C.push_back(A[i] - B[i]);
		}
	}
	sort(C.begin(), C.end());
	reverse(C.begin(), C.end());
	k = 0;
	j = 0;
	REP(i, 0, N) {
		
		if(A[i]<B[i]){
			ans++;
			temp1 = B[i] - A[i];
			while (temp1 > 0) {
				temp2 = C[k];
				if (temp1 - temp2 > 0) {
					temp1 -= temp2;
					ans++;
					C[k] = 0;
					j = 0;
					k++;
				}
				else {
					j = 1;
					C[k]=temp2 - temp1;
					temp1 = 0;
				}
			}
		}
	}
	if (j == 1) {
		ans++;
	}
	output(ans);
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
const int maxn=3e5+5;
typedef long long ll;
const ll mod=1e9+7;
ll n,cnt[65];
void via(ll x){
	int p=0;
	while(x){
		if(x%2)cnt[p]++;
		x>>=1;p++;
	}
}
int main(){
	cin>>n;
	for(ll i=1;i<=n;i++){
		ll x;cin>>x;
		via(x);
	}
	ll tmp=0,j=1;
	for(ll i=0;i<=62;i++){
			tmp+=((cnt[i]*(n-cnt[i]))%mod*j)%mod;
			tmp%=mod;j*=2;j%=mod;
	}
	cout<<tmp<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> broken(n+1);
    rep(i, m) {
        int a;
        cin >> a;
        broken[a] = 1;
    }
    vector<int> dp(n+2);
    const int mod = 1000000007;
    dp[n] = 1;
    for(int i = n-1; i >= 0; i--) {
        if(broken[i]) {
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i+1] + dp[i+2]) % mod;
    }
    cout << dp[0];
    cout << endl;
    return 0;
}

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

vector<int> p;

int main(){
while(1){	
	
	int m, mi, ma;
	cin >> m >> mi >> ma;
	if(m == 0 and mi == 0 and ma == 0) break;
	for(int i=0; i<m; i++){
		int tmp;
		cin >> tmp;
		p.push_back(tmp);
	}
	
	sort(p.begin(), p.end());
	reverse(p.begin(), p.end());
	
	int gap = 0;
	int ans = 0;
	for(int i=mi; i <= ma; i++){
		if(gap <= p[i-1] - p[i]){
			gap = p[i-1] - p[i];
			ans = i;
		}
	}
	
	cout << ans << endl;
	p.clear();
	
	
	//debug
	//for(int i=0; i<m; i++) cout << p[i] << endl;

}//end	
	
	return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <functional>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(std::min<int>(l_, r_)), r(r_) {}
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): r(std::max<int>(l_, r_) - 1), l(l_ - 1) {}
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

using lint = long long;
constexpr int inf = (1 << 30) - 1;
constexpr lint linf = (1ll << 60) - 1;

int N;
int A[5000], cnt[5000];
std::vector<int> graph[5000];
lint calc[5000][2], dp[5000][5000][2];

void dfs(int v, int p) {
  cnt[v] = 1;
  chmin(dp[v][0][0], A[v]);
  if (A[v] > 0) {
    chmin(dp[v][0][1], A[v]);
  }
  for (int x: graph[v]) {
    if (x == p) {
      continue;
    }
    dfs(x, v);
    for (int i: range(0, cnt[v] + cnt[x])) {
      calc[i][0] = calc[i][1] = linf;
    }
    for (int i: range(0, cnt[v])) {
      for (int j: range(0, cnt[x])) {
        chmin(calc[i + j][0], dp[v][i][0] + dp[x][j][0]);
        chmin(calc[i + j][0], dp[v][i][0] + dp[x][j][1]);
        chmin(calc[i + j][1], dp[v][i][1] + dp[x][j][1]);
        if (dp[x][j][1] < linf) {
          chmin(calc[i + j + 1][0], dp[v][i][0]);
          chmin(calc[i + j + 1][1], dp[v][i][1]);
        }
        if (dp[x][j][0] < 0) {
          chmin(calc[i + j + 1][0], dp[v][i][0]);
          chmin(calc[i + j + 1][1], dp[v][i][1]);
        }
      }
    }
    cnt[v] += cnt[x];
    for (int i: range(0, cnt[v])) {
      dp[v][i][0] = calc[i][0];
      dp[v][i][1] = calc[i][1];
    }
  }
}

int main() {
  std::cin >> N;
  for (int i: range(0, N)) {
    std::cin >> A[i];
  }
  for (int i: range(0, N - 1)) {
    int u, v;
    std::cin >> u >> v;
    --u; --v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  for (int i: range(0, N)) {
    for (int j: range(0, N)) {
      dp[i][j][0] = dp[i][j][1] = linf;
    }
  }
  dfs(0, -1);
  int ans = inf;
  for (int j: range(0, N)) {
    if (dp[0][j][0] < 0) {
      chmin(ans, j);
    }
    if (dp[0][j][1] < linf) {
      chmin(ans, j);
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 391808
// Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector <ll> vec;
typedef pair <ll, ll> pr;
typedef pair <ll, pr> pr2;
typedef map <ll, vector<ll> > mv;

const int MX = 2e6+10;
const int mod = 1e9 + 7;
const ll inf = 1LL << 62;

int dx4[] = { 0, 0, -1, 1 };
int dy4[] = { 1, -1, 0, 0 };

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

// TOOLS
#define LCM(a,b)        (a / __gcd(a,b) ) *b
#define gcd(a,b)        __gcd(a,b)
#define all(x)          (x).begin(), (x).end()
#define mem(a, n)       memset(a, n, sizeof(a))
#define for1(i, n)      for(int i=1; i<=n; i++)
#define for0(i, n)      for(int i=0; i<n; i++)
#define rof0(i, n)      for(int i=n-1; i>=0; i--)
#define rof1(i, n)      for(int i=n; i>=1; i--)
#define forab(i, a, b)  for(int i=a; i<=b; i++)
#define rofab(i, a, b)  for(int i=b; i>=a; i--)
#define pb              push_back
#define pbb             pop_back

// CIN/COUT
#define sin(s)          getline(cin, s)
#define case(a)              cout << "Case "<<(a)<<": "

// SCANF/PRINTF
#define fYES            printf("YES\n")
#define fNO             printf("NO\n")
#define Scf(a)          scanf("%lld", &a)
#define Scf2(a, b)      scanf("%lld %lld", &a, &b)
#define Scf3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define Scf4(a,b,c,d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define Pnf(a)          printf("%lld\n", a)
#define Pnf2(a, b)      printf("%lld %lld\n", a, b)
#define Pnf3(a, b, c)   printf("%lld %lld %lld\n", a, b, c)
#define Bug(n)          printf(">> %lld <<\n", n)

// OTHERS
#define sz(n)          n.size()
#define clr(v)          v.clear()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in              freopen("input.txt", "r", stdin)
#define out             freopen("output.txt", "w", stdout)
#define FastIO          { ios_base::sync_with_stdio(false); cin.tie(0); }
#define F               first
#define S               second
#define mpp             make_pair
//End
vector<int> v;
map<ll,vector<ll> > mp;
priority_queue<ll> PQ;
//priority_queue<pair<ll,ll> >PQ;

int main()
{

    ll  n,k,q, t, cnt = 0, sum = 0,ans=10000000000000000, mx = -inf, mn = inf, a, b, c,d,e,f,g,h,i,j ,x, y, z,temp, temp1;
    string s, s1, s2, s3;
    cin>>s;
    cin>>k;
    i=0;
    while(i<s.size())
    {
        if(s[i]=='1')
            k--;
        else
            break;
        i++;
    }
    if(k<=0)
        cout<<1<<endl;
    else
        cout<<s[i]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

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

void solve(long long n, std::vector<long long> h) {
  vector<long long> H;
  H.PB(h[0]);
  for(int i=1; i< n; i++){
    if(h[i-1]!=h[i])H.PB(h[i]);
  }
  long long N = H.size();
  if(N==1){
    cout<<"Yes"<<endl;
    return;
  }
  else if(N==2){
    if(H[0]-H[1]>1)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return;
  }
  else{
    for(int i=1; i<N-1; i++){

      if(H[i-1]<=H[i] && H[i]<=H[i+1]){continue;}
      else{
        if(H[i-1]<=H[i]-1 && H[i]-1<=H[i+1]){
          H[i]--;
        }
        else{cout<<"No"<<endl; return;}
      }
    }
    
  }

  cout<<"Yes"<<endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> H(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &H[i]);
  }
  solve(N, std::move(H));
  return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define rush() int T;scanf("%d",&T);int kase=1;while(T--)
#define all(x) (x).begin(),(x).End()
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define pb(x) push_back(x)
#define mem(a) memset(a,0,sizeof(a))
using namespace std;
using std::bitset;
typedef long long ll;
const ll maxn=1e6+5;
const ll mod=998244353;
const ll INF=0x3f3f3f3f3f3f3f3f;
const long double PI=acos(-1.0);
const long double eps=1e-5;
inline ll read(){ll ans=0,flag=1;char c;c=getchar();while(c<'0' || c>'9'){if(c=='-')flag=-1;c=getchar();}while(c>='0' && c<='9'){ans=ans*10+(ll)(c-'0');c=getchar();}return ans*flag;}
ll quickpow(ll x,ll y,ll mod){ll ans=1;while(y){if(y&1)ans=ans*x%mod;x=x*x%mod;y>>=1;}return ans;}

map<string,int>mp;

int main()
{
    int n,f;
    cin>>n;
        string t;
        f=1;
        for(int i=0;i<n;i++)
        {
            cin>>t;
            mp[t]++;
            if(mp[t]>1)
                f=0;
        }
        if(f)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
}

Measured memory_bytes: 24832
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 300010

/* Starry Sky Tree */
//0-index

struct StarrySkyTree{
  typedef int Type;
  int segn2;
  vector<Type> data,s_data;
  
  StarrySkyTree(int n){
    for(segn2=1;segn2<n;segn2*=2);
    data.assign(segn2*2,0);
    s_data.assign(segn2*2,0);
  }
  
  //get minimum value of [a,b]
  Type query(int a,int b,int l=0,int r=-1,int k=0){
    if(r==-1) r+=segn2;
    if(r<a || b<l) return INF;
    if(a<=l && r<=b) return data[k] + s_data[k];
    return min(query(a,b,l,(l+r)/2,k*2+1),query(a,b,(l+r)/2+1,r,k*2+2))+s_data[k];
  }
  
  //add x to [a,b]
  Type add(int a,int b,Type x,int l=0,int r=-1,int k=0){
    if(r==-1) r+=segn2;
    if(a<=l && r<=b){
      s_data[k]+=x;
    }else if(a<=r && l<=b){
      data[k] = min(add(a,b,x,l,(l+r)/2,k*2+1),add(a,b,x,(l+r)/2+1,r,k*2+2));
    }
    return data[k] + s_data[k];
  }
  
};



int main(){
  int n,q;
  char s[SIZE];
  int sum[SIZE];
  priority_queue<int> right;
  scanf("%d%d%s",&n,&q,s);

  StarrySkyTree seg(n);
  
  for(int i=0;i<n;i++){
    if(s[i] == '('){
      sum[i] = 1;
    }else{
      sum[i] = -1;
      right.push(-i);
    }

    if(i > 0){
      sum[i] += sum[i-1];
    }

    seg.add(i,i,sum[i]);
  }
  
  for(int i=0;i<q;i++){
    int p, ans;
    scanf("%d",&p);
    p--;
    
    if(s[p] == '('){
      s[p] = ')';
      right.push(-p);
      seg.add(p,n-1,-2);

      while(right.size() && s[-right.top()] == '(') right.pop();

      ans = -right.top();
      s[ans] = '(';
      seg.add(ans,n-1,2);
      
    }else{
      s[p] = '(';
      seg.add(p,n-1,2);

      int l=0, r=p;

      while(l<r){
        int mid = (l+r)/2;
        if(seg.query(mid,n-1) >= 2){
          r = mid;
        }else{
          l = mid+1;
        }
      }

      ans = l;
      s[ans] = ')';
      right.push(-ans);
      seg.add(ans,n-1,-2);
    }

    printf("%d\n",ans+1);
  }
  
  return 0;
}

Measured memory_bytes: 14808
h,w=map(int,input('').split(' '))
masu=0

masu=masu+(w*(h//2))

if h%2==1:
    if w%2==1:
        masu=masu+(w//2)+1
    else:
        masu=masu+(w//2)

if h==1 or w==1:
    masu=1

print(masu)

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const ll MOD = 1000000007LL;

int N, M;
int A[1111], B[1111];

int main(){
	scanf("%d %d", &N, &M);
	for(int i = 0; i < N; i++) scanf("%d", &A[i]);
	for(int i = 0; i < M; i++) scanf("%d", &B[i]);
	
	sort(A, A + N);
	sort(B, B + M);
	ll res = 1LL;
	for(int i = N * M; i >= 1; i--){
		int cnt;
		bool flag = true;
		if(upper_bound(A, A + N, i) - lower_bound(A, A + N, i) > 1){
			printf("0\n");
			return 0;
		}
		if(upper_bound(B, B + M, i) - lower_bound(B, B + M, i) > 1){
			printf("0\n");
			return 0;
		}
		if(binary_search(A, A + N, i) && binary_search(B, B + M, i)) cnt = 1;
		else if(binary_search(A, A + N, i)) cnt = M + (B - lower_bound(B, B + M, i));
		else if(binary_search(B, B + M, i)) cnt = N + (A - lower_bound(A, A + N, i));
		else{
			cnt = (M + (B - lower_bound(B, B + M, i))) * (N + (A - lower_bound(A, A + N, i)));
			flag = false;
		}
		if(!flag && cnt < (M * N - i)){
			printf("0\n");
			return 0;
		}
		if(flag) res *= (ll)cnt;
		else res *= (ll)(cnt - (M * N - i));
		res %= MOD;
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
typedef long long int ll;
int main(){
	int n;
	ll a[100000];
	ll b[100000];
	scanf("%d",&n);
	ll ans = 0;
	for(int i=0;i<n;i++){
		scanf("%lld%lld",a+i,b+i);
	}
	for(int i=n-1;i>=0;i--){
		ll tmp = (a[i] + ans) % b[i];
		if(tmp>0) ans += b[i] - tmp;
	}
	printf("%lld\n",ans);
}


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

using namespace std;
using ll = long long;

int main() {
	ll n, x, m, ans = 0, cnt = 0;
	cin >> n >> x >> m;
	vector<int> f(m);
	bool loop = true;
	while(1) {
		x %= m;
		if (x == 0) break;
		if (x == 1) {
			ans += n - cnt;
			break;
		}
		if (f[x] && loop) {
			ll nx = x, ncnt = 0, sum = 0;
			while(f[nx] != 2) {
				f[nx]++;
				ncnt++;
				sum += nx;
				nx *= nx;
				nx %= m;
			}
			ll r = (n - cnt) / ncnt;
			ans += sum * r;
			cnt += ncnt * r;
			loop = false;
		}
		// 11
		// 12342342342
		// cnt = 4
		else {
			f[x]++;
			ans += x;
			x *= x;
			cnt++;
		}
		if (cnt == n) break;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  
  if (k == 1) cout << 0 << '\n';
  else cout << n - k << '\n';
}

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

constexpr int32_t M = 1000000007;

int32_t Compute(const int n, const std::unordered_map<int, int> &a)
{
    if (n % 2 == 1)
    {
        try
        {
            if (a.at(0) != 1)
            {
                return 0;
            }
            for (int i = 2; i <= n - 1; i += 2)
            {
                if (a.at(i) != 2)
                {
                    return 0;
                }
            }
        }
        catch (const std::exception &e)
        {
            return 0;
        }

        int32_t sum = 1;
        for (int i = 0; i < (n - 1) / 2; ++i)
        {
            sum = sum * 2 % M;
        }
        return sum;
    }
    else
    {
        try
        {
            for (int i = 1; i <= n - 1; i += 2)
            {
                if (a.at(i) != 2)
                {
                    return 0;
                }
            }
        }
        catch (const std::exception &e)
        {
            return 0;
        }

        int32_t sum = 1;
        for (int i = 0; i < n / 2; ++i)
        {
            sum = sum * 2 % M;
        }
        return sum;
    }
}

int main()
{
    int n;
    std::cin >> n;
    std::unordered_map<int, int> a;
    for (int i = 0; i < n; ++i)
    {
        int tmp;
        std::cin >> tmp;
        ++a[tmp];
    }

    std::cout << Compute(n, a) << std::endl;
    return 0;
}


Measured memory_bytes: 6504
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/
int N,M;
priority_queue<int> q;

int main(){
  cin>>N>>M;
  for(int i=0; i<N; i++){
    int x; cin>>x;
    q.push(x);
  }
  while(!q.empty() && M>0){
    int x=q.top();
    q.pop();
    q.push(x/2);
    M--;
  }
  ll ans=0;
  while(!q.empty()){
    ans+=q.top();
    q.pop();
  }
  cout<<ans<<endl;
}

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

int main(){
  int N;
  cin >> N;
  if(N == 0){
    cout << 2 << endl;
  }
  else if(N == 1){
    cout << 1 << endl;
  }
  else{
    vector<long long> ryuka(N + 1);
    ryuka.at(0) = 2;
    ryuka.at(1) = 1;
    for(int i = 2; i < N + 1; i++){
      ryuka.at(i) = ryuka.at(i - 1) + ryuka.at(i - 2);
    }
    cout << ryuka.at(N) << endl;
  }
}



Measured memory_bytes: 256