akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/12/25  Problem: ABC 088 A / Link: http://arc088.contest.atcoder.jp/tasks/arc088_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	LL X, Y;
	cin >> X>>Y;
	while (X*2<=Y){
		ans++;
		X *= 2;
	}
	ans++;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
def main():
    N, M = (int(i) for i in input().split())
    from collections import defaultdict
    dic = defaultdict(set)
    for i in range(M):
        s, c = (int(i) for i in input().split())
        dic[s].add(c)
    if 0 in dic[1] and N != 1:
        return print(-1)
    for i in range(1, N+1):
        if len(dic[i]) > 1:
            return print(-1)
        elif not(dic[i]):
            dic[i].add(0 if i != 1 or N == 1 else 1)
    # print(dic)
    s = ""
    for i in range(1, N+1):
        s = s + str(dic[i].pop())
    print(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL<<60;
#define rev(s) (string((s).rbegin(), (s).rend()))

int h,w;
vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,1,0,-1};
vector<string> field(1010);
const int inf=1000010;
vector<vector<int>> d(1010,vector<int>(1010,inf));

void bfs() {
    queue<P> q;
    rep(i,h) {
        rep(j,w) {
            if(field[i][j]=='#') {
                q.push(P(i,j));
                d[i][j]=0;
            }
        }
    }
    while (q.size()) {
        P pa = q.front();q.pop();
        rep(i,4) {
            int ny = pa.first+dy[i];
            int nx = pa.second+dx[i];
            if (ny>=0&&ny<h&&nx>=0&&nx<w&&field[ny][nx]!='#'&&d[ny][nx]==inf) {
                d[ny][nx]=d[pa.first][pa.second]+1;
                q.push(P(ny,nx));
            }
        }
    }
}

int main() {
    cin>>h>>w;
    rep(i,h) {
        cin>>field[i];
    }
    bfs();
    int ans=-1;
    rep(i,h) {
        rep(j,w) {
            if (d[i][j]!=100010) {
                ans=max(ans,d[i][j]);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 13456
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr)
import Control.Monad (forM_)
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

main = do
  [n,k] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  -- 1 <= n <= 300, 1 <= k <= 10^5
  xs <- U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  -- 1 <= a1 < a2 < ... < an <= k
  let vec = U.create $ do
        vec <- UM.new (k + 1)
        UM.write vec 0 False
        forM_ [1..k] $ \i -> do
          result <- not . U.and <$> U.mapM (\x -> UM.read vec (i - x)) (U.takeWhile (<= i) xs)
          UM.write vec i result
        return vec
  -- vec ! i: 石が i 個ある状態で、双方が最善を尽くした時に現在の手番の人が勝つなら True
  putStrLn (if U.last vec then "First" else "Second")


Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <sstream>
#include <string>
#include <time.h>
#include <math.h>

using namespace std;

int main() {
  long long int N;
  long long int M;
  cin >> N >> M;
  long long int a = 0;
  if(M>2*N) {
    M -= 2*N;
    a += N;
    a += M/4;
  }else{
    a += M/2;
  }
  cout << a << endl;
}

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

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n+5];
    for(int i=1;i<=n;i++)cin>>arr[i];
    vector<int>adj[n+5];
    while(k--)
    {
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int counter=0;
    for(int i=1;i<=n;i++)
    {
        int flag=0;
        for(int j=0;j<adj[i].size();j++)
        {
           // cout<<i<<" "<<adj[i][j]<<endl;
            if(arr[i]>arr[adj[i][j]])
            {
            flag++;
            }
        }
        if(flag==adj[i].size())counter++;
    }
    cout<<counter<<endl;
}


Measured memory_bytes: 9144
import sys
from collections import defaultdict

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7

N, P = MI()
S = input()

if P == 2:
    ans = 0
    for i, c in enumerate(S):
        if int(c) % 2 == 0:
            ans += i + 1
    print(ans)
elif P == 5:
    ans = 0
    for i, c in enumerate(S):
        if c in ['5', '0']:
            ans += i + 1
    print(ans)
else:
    d = defaultdict(int)
    tenmod = 1
    lastmod = 0
    for i, c in enumerate(reversed(S)):
        if i > 0:
            tenmod = tenmod * 10 % P
        lastmod = (int(c) * tenmod % P + lastmod) % P
        d[lastmod] += 1
    ans = 0
    for m, cnt in d.items():
        if m == 0:
            ans += cnt
        ans += cnt * (cnt - 1) // 2
    print(ans)


Measured memory_bytes: 43212
#include<set>
#include<cmath>
#include<queue>
#include<utility>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<numeric>
#include<functional>
#include<string>
#include<iostream>

using namespace std;
const int one = 1;
const int big = (one<<20);
typedef long long int llint;

bool solve(void){
	llint i,j,n,m,h,k,moto=0,ans=99999999,a,b;
	vector<llint> ami[1001];
	vector<pair<llint,llint>> bow;
	vector<llint> ten;
	llint up_to_ten[1001];//???????????????????????????????????£????????£????????????????????????
	scanf("%lld %lld %lld %lld",&n,&m,&h,&k);
	ten.push_back(0);
	for(i=1;i<=n;i++){
		scanf("%lld",&a);
		ten.push_back(a);
	}
	if(n==0){ return false; }
	for(i=0;i<=n;i++){
		ami[0].push_back(i);
	}
	for(i=0;i<m;i++){
		scanf("%lld %lld",&a,&b);
		bow.push_back(make_pair(b,a));//?????????????¨????????????¨???
	}
	sort(bow.begin(),bow.end());
	j=0;
	for(i=1;i<=h;i++){
		ami[i]=ami[i-1];
		while(j<m){
			b=bow[j].first;//??????
			a=bow[j].second;//?¨?
			if(i<b){break;}
			swap(ami[i][a],ami[i][a+1]);
			j++;
		}
	}
	for(i=1;i<=n;i++){
		up_to_ten[ami[h][i]]=ten[i];
		if(ami[h][i]<=k){
			moto+=ten[i];
		}
	}
	//printf("de moto=%d\n",moto);
	ans=moto;
	for(i=0;i<m;i++){
		a=ami[bow[i].first][bow[i].second];
		b=ami[bow[i].first][bow[i].second+1];
		if(b<a){swap(a,b);}//????????´??????????????????????????????????????£???????????¨?????¨?????¢???????????????
		if(a<=k&&k<b){
			ans=min(ans,moto-up_to_ten[a]+up_to_ten[b]);//a??????????????¨b???????????????????????\????????????
		}
	}
	//printf("de %d\n",moto);
	printf("%lld\n",ans);
	return true;
}
int main(void){while(solve()){}return 0;}

Measured memory_bytes: 12332
#include <stdio.h>

int main(void){
    int sec;
    int min;
    int hour;
    scanf("%d",&sec);
    min = sec / 60;
    sec = sec % 60;
    hour = min / 60;
    min = min % 60;
    printf("%d:%d:%d\n",hour,min,sec);
    return 0;
}


Measured memory_bytes: 2112
#include <stdio.h>

int main(void)
{
	int w, n;
	int v[30];
	int a, b;
	int i, tmp;

	scanf("%d", &w);
	scanf("%d", &n);

	for (i = 0; i < w; i++){
		v[i] = i + 1;
	}

	for (i = 0; i < n; i++){
		scanf("%d,%d", &a, &b);
		tmp = v[a - 1];
		v[a - 1] = v[b - 1];
		v[b - 1] = tmp;
	}

	for (i = 0; i < w; i++){
		printf("%d\n", v[i]);
	}

	return 0;
}

Measured memory_bytes: 596
# coding: utf-8
#71

r,c = map(int,input().split())

A = [list(map(int,input().split())) for i in range(r)]
G=0
for i in range(r):
    a=0
    print(*A[i],end=' ')
    print(sum(A[i]))
    G += sum(A[i])
for j in range(c):
    b=0
    for k in range(r):
        b += A[k][j]
    print(b,end=' ')
print(G)

    


Measured memory_bytes: 6228
def main():
    s = str(input())
    b_count = s.count('B')
    w_count = len(s) - b_count

    if b_count == len(s) or w_count == len(s):
        count = 0
    else:
        count = 0
        index = 0
        alp = s[index]

        while True:
            if b_count == 0 or w_count == 0:
                break
            else:
                if s[index] == 'B':
                    b_count -= 1
                else:
                    w_count -= 1

                if s[index] == alp:
                    index += 1
                else:
                    count += 1
                    alp = s[index]
                    index += 1

        if not (b_count == 0 and w_count == 0):
            count += 1

    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 100005

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int cnt[30]={0};
int main(){
	string str;
	cin>>str;
	int n=str.size();
	for(int i=0;i<n;i++){
		int x=str[i]-'a';
		cnt[x]++;
	}
	ll ans=0;
	for(int i=0;i<26;i++){
		ans+=(ll)cnt[i]*(ll)(n-cnt[i]);
	}
	ans=ans/(ll)2+(ll)1;
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	int N;
	cin >> N;
	int color[N];
	rep(i, 0, N) {
		cin >> color[i];
	}
	int rsl[H][W];
	memset(rsl, 0, sizeof(rsl));
	int x = 0, y = 0;
	bool flag = true;
	rep(i, 0, N) {
		rep(j, 0, color[i]) {
			rsl[y][x] = i + 1;
			if(flag) {
				x++;
				if(x >= W) {
					y++;
					x = W - 1;
					flag = false;
				}
			} else {
				x--;
				if(x < 0) {
					y++;
					x = 0;
					flag = true;
				}
			}
		}
	}

	rep(i, 0, H) {
		rep(j, 0, W - 1) {
			cout << rsl[i][j] << " ";
		}
		cout << rsl[i][W - 1];
		cout << endl;
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int a[100100];
int main(){
    int n;
    cin >> n;
    long long cnt = 0;
    for(int i = 1; i <= n;i++){
        cin >> a[i];
    }

    for(int i = 1; i <= n;++i){
        if(i == 1 && a[i]==i){
            swap(a[i],a[i + 1]);
            cnt++;
        }
        else if(i == n && a[i]==i){
            swap(a[n], a[n - 1]);
            cnt++;
        }
        else {
            if(a[i] == i){
                swap(a[i], a[i + 1]);
                cnt++;
            }
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 640
import kotlin.math.max
import kotlin.math.min

fun main(args: Array<String>) {
    val (k, x) = readIntList()
    val l = max(x - (k - 1), -1000000)
    val r = min(x + (k - 1), 1000000)
    (l..r).forEach { print("$it ") }
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 36668
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
    int x1, y1, x2, y2, r;
    cin >> x1 >> y1 >> x2 >> y2 >> r;
    if (x2 - r >= 0 && x2 + r <= x1 && y2 - r >= 0 && y2 + r <= y1) cout << "Yes";
    else cout << "No";
    cout << endl;
}

Measured memory_bytes: 3092
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from heapq import heappop, heappush

n, m = li()
works = []
heap = []
ans = 0

for i in range(n):
    ai, bi = li()
    heappush(works, (ai, bi))

for i in range(1, m+1):
    while works:
        ai, bi = heappop(works)
        if ai > i:
            heappush(works, (ai, bi))
            break
        else:
            heappush(heap, -bi)

    if heap:
        ans += -heappop(heap)

print(ans)




Measured memory_bytes: 119388
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


void solve()
{
    int n;cin>>n;
    int d[n];REP(i,n)cin>>d[i];
    int sum=0;
    REP(i,n)rep(j,i+1,n)
    {
        sum+=d[i]*d[j];
    }
    cout<<sum<<endl;
}

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

Measured memory_bytes: 256
#和を求める解法
a,b,c = map(int,input().split(" "))
sum = a+b+c
max = max(a,b,c)
if (sum - max)%2 == 0:
    print(int((max*3 - sum)/2))
else:
    print(int(((max+1)*3 - sum)/2))

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

using namespace std;

const int N = 2e5 + 10;
long long ans;
int a[N], n, k;

int main() {
//	freopen("c.in", "r", stdin);
//	freopen("c.out", "w", stdout);
	cin >> n >> k;
	for(int i = 1; i <= n; ++ i)
		++ a[i % k];
	ans += 1ll * a[0] * a[0] * a[0];
	if(!(k & 1))
		ans += 1ll * a[k >> 1] * a[k >> 1] * a[k >> 1];
	cout << ans << endl;
	return 0;
}


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


int main()
{
    int n;
    string s;
    map<string,int>mp;
    cin>>n;
    while(n--)
    {
        cin>>s;
        mp[s]++;
    }
    // Declaring the type of Predicate that accepts 2 pairs and return a bool
	typedef function<bool(pair<string, int>, pair<string, int>)> comp;

    comp compare=[](pair<string,int>a,pair<string,int>b)
                    {
                        return a.second>b.second || a.first<b.first ;
                    };
    multiset<pair<string,int>,comp>s1(mp.begin(),mp.end(),compare);

    pair<string,int> res = *s1.begin();

    for(pair<string,int>it:s1)
    {
        if(it.second==res.second)
            cout<<it.first<<endl;
    }

}


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

void solve() {
    map<int, long long> m;
    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        m[v[i]]++;
    }
    long long res = 0;
    for (auto it = m.begin(); it != m.end(); it++) {
        long long cnt = it->second;
        res += (cnt * (cnt - 1)) / 2;
    }
    for (int i = 0; i < n; i++) {
        long long cnt = m[v[i]];
        res -= (cnt * (cnt - 1)) / 2;
        cnt --;
        res += (cnt * (cnt - 1)) / 2;
        cout << res << endl;
        res -= (cnt * (cnt - 1)) / 2;
        cnt++;
        res += (cnt * (cnt - 1)) / 2;
    }
}

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


Measured memory_bytes: 10368
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
namespace Not_Sure
{
	inline void check_min(int a,int &b){if(a<b)b=a;}
	inline void check_max(int a,int &b){if(a>b)b=a;}
	const int N=17,M=N*N*2,INF=2147483647;
	inline bool inset(int S,int p){return S&(1<<(p-1));}
	int begin[N],next[M],to[M],w[M];
	int f[1<<N][N];
	int n,m,e,S;
	void add(int x,int y,int z,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		w[e]=z;
		if(k)add(y,x,z,0);
	}
	void initialize()
	{
		scanf("%d%d",&n,&m);S=1<<n;
		for(int i=1,u,v,k;i<=m;i++)
			scanf("%d%d%d",&u,&v,&k),add(u,v,k);
		for(int i=0;i<S;i++)
			for(int j=1;j<=n;j++)
				f[i][j]=INF;
	}
	int val[N],res[1<<N];
	void get_val(int k)
	{
		memset(val,0,sizeof(val));
		for(int p=1;p<=n;p++)
			if(!inset(k,p))
				for(int i=begin[p];i;i=next[i])
					if(inset(k,to[i]))val[p]+=w[i];
	}
	int lowbit(int x){return x&(-x);}
	int bit(int x)
	{
		int ret=0;
		while(x)x>>=1,ret++;
		return ret;
	}
	int calc(int nk,int T)
	{
		if(nk==T)
		{
			int ret=0,tmp=nk;
			for(;nk;nk-=lowbit(nk))
				ret+=val[bit(lowbit(nk))];
			return res[tmp]=ret;
		}
		else 
		{
			int h=lowbit(T^nk);
			return res[nk]=res[nk|h]-val[bit(h)];
		}
	}
	void solve()
	{
		initialize();
		int T=(S-1)^1,g,cost,sum;
		f[1][1]=0;
		for(int k=T;k;k=(k-1)&T)
			f[k|1][1]=0;

		for(int k=0;k<S;k++)
			for(int i=1;i<=n;i++)
			{
				if(f[k][i]==INF)continue;
//				printf("f[%d][%d] = %d\n",k,i,f[k][i]);
				int dk=(S-1)^k;
				get_val(k);
				for(int u=begin[i],j;u;u=next[u])
				{
					j=to[u];
					if(inset(k,j))continue;
					sum=0;
					for(int o=begin[j];o;o=next[o])
						if(inset(k,to[o]))sum+=w[o];
					sum-=w[u];

					T=dk^(g=1<<(j-1));
					check_min(f[k][i]+sum,f[k|g][j]);

					for(int nk=T;nk;nk=(nk-1)&T)
					{
						cost=calc(nk,T)+sum;
						check_min(f[k][i]+cost,f[k|nk|g][j]);
					}
				}
			}
		printf("%d\n",f[S-1][n]);
	}
}
int main()
{
//	freopen("in","r",stdin);
	Not_Sure::solve();
//	printf("time = %d\n",(int)clock());
	return 0;
}


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

def main():
    H, W, d = map(int, input().split())
    color = ("R", "Y", "G", "B")
    d2 = d * 2
    for i in range(H):
        for j in range(W):
            print(color[2 * (((i+j) % d2) < d) + (((i-j) % d2) < d)], end="")
        print()

if __name__ == "__main__":
    main()

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

const int MOD=1e9+7;
const int INF=0x7ffffff;
const int magic=348;

int n;
int c1,c2,c3;
int a[100048];

int main ()
{
	int i,x;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&x);
		a[i]=x;
		if (x%2!=0)
		{
			c1++;
			continue;
		}
		if (x%4!=0)
		{
			c2++;
			continue;
		}
		c3++;
	}
	if (n==2)
	{
		LL res=a[1];
		res*=(LL)a[2];
		if (res%4==0) printf("Yes\n"); else printf("No\n");
		return 0;
	}
	if (n==3)
	{
		if (c3>=1)
		{
			printf("Yes\n");
			return 0;
		}
		if (c1!=0)
		{
			printf("No\n");
		}
		else
		{
			printf("Yes\n");
		}
		return 0;
	}
	if (n%2==0)
	{
		if (c3>=c1) printf("Yes\n"); else printf("No\n");
	}
	else
	{
		if (c3>=c1-1) printf("Yes\n"); else printf("No\n");
	}
	return 0;
} 

Measured memory_bytes: 640
a,b,c,d = list(map(int,list(input())))

def myprint(c1,c2,c3):
    return print(str(a)+c1+str(b)+c2+str(c)+c3+str(d)+'=7')

if a+b+c+d==7:
    myprint('+','+','+')
elif a+b+c-d==7:
    myprint('+','+','-')
elif a+b-c+d==7:
    myprint('+','-','+')
elif a+b-c-d==7:
    myprint('+','-','-')
elif a-b+c+d==7:
    myprint('-','+','+')
elif a-b+c-d==7:
    myprint('-','+','-')
elif a-b-c+d==7:
    myprint('-','-','+')
elif a-b-c-d==7:
    myprint('-','-','-')

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

# define    ll            long long 
# define    vi             std::vector<int>
# define    int            long long 
# define    setbits(x)     __builtin_popcountll(x)
# define    zrobits(x)     __builtin_ctzll(x)
# define    fast           ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
# define    pb             push_back
# define    fn             for(int i=0;i<n;i++)
# define    rep(i,a,b)      for(ll i=a;i<b;i++)
# define    all(x)         x.begin(), x.end()
# define    allr(a)        a.rbegin(), a.rend()
# define    PI             3.14159265358979323846
# define    mod            1000000007
# define    endl           "\n"
# define    pii            pair<ll,ll>
# define    deb1(x)        cout<<#x<<" "<<x<<endl;
# define    deb2(x,y)      cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
# define    deb3(x,y,z)    cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
 
void getio();

void solve()
{
	// code here : 
	string s;
	cin>> s;
	int n=s.size();
	vi a;
	int cnt=0;
	rep(i,0,n)
	{
		if(s[i]=='R')
			cnt++;
		else {a.pb(cnt); cnt=0;}
	}
	a.pb(cnt);
	cout << *max_element(all(a)) << endl;
}



int32_t main()
{
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	// getio();
    // int t; cin>>t; while(t--) 
    solve();
}

void getio()
{
    fast
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-13;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int p[310010];
int u[310000];
int sz[310000];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	if(b+c>a+1||(long long)b*c<a){
		printf("-1\n");return 0;
	}
	if(b+c==2&&a>1){
		printf("-1\n");return 0;
	}
	sz[b-1]=c;
	for(int i=0;i<b-1;i++)sz[i]=1;
	int rem=a;
	for(int i=0;i<b;i++)rem-=sz[i];
	int at=0;
	while(rem){
		sz[at%(b-1)]++;rem--;at++;
	}
	at=0;
	for(int i=0;i<b;i++){
		int st=at;
		for(int j=0;j<sz[i];j++){
			p[at++]=st+sz[i]-j;
		}
	}
	for(int i=0;i<a;i++)printf("%d ",p[i]);printf("\n");
}

Measured memory_bytes: 3968
#include <iostream>
#include <vector>

int main(void){
    using namespace std;
    int n, x;
    std::cin >> n >> x;

    int d = 0;
    int count = n+ 1;
    for (int i = 0; i < n;i++){
        int l;
        std::cin >> l;

        d += l;
        if(d>x) {
            count = i + 1;
            break;
        }
    }

    std::cout << count << std::endl;
    return 0;
}

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

void solve(long long A, long double B){
    ll ans = A*B;
    cout << ans << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long double B;
    scanf("%Lf",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 200001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n;
string s;

signed main(){
    cin >> s;
    for(char c: s){
        cout << "x";
    }
    cout << endl;
    return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,A,B;
int S[111111];

signed main(){
    cin>>N>>A>>B;
    rep(i,N)cin>>S[i];

    if(A==B){
        int X=0;
        rep(i,N)X^=S[i]%(A+1);
        if(X)cout<<"Hanako"<<endl;
        else cout<<"Jiro"<<endl;
        return 0;
    }

    if(A>B){
        int X=0;
        rep(i,N)X^=S[i]%(B+1);
        if(X){
            cout<<"Hanako"<<endl;
            return 0;
        }

        rep(i,N){
            if(S[i]>B){
                cout<<"Hanako"<<endl;
                return 0;
            }
        }
        cout<<"Jiro"<<endl;
        return 0;
    }

    int X=0;
    rep(i,N)X^=S[i]%(A+1);
    if(X==0){
        cout<<"Jiro"<<endl;
        return 0;
    }

    vint lis;
    rep(i,N)if(S[i]>A)lis.pb(i);
    if(lis.size()==0){
        cout<<"Hanako"<<endl;
        return 0;
    }
    if(lis.size()>1){
        cout<<"Jiro"<<endl;
        return 0;
    }
    int k=lis[0];
    int Y=0;
    rep(i,N)if(i!=k)Y^=S[i]%(A+1);

    if(Y>A){
        cout<<"Jiro"<<endl;
        return 0;
    }
    
    
    int tmp;
    if(S[k]%(A+1)>Y)tmp=S[k]%(A+1)-Y;
    else tmp=S[k]%(A+1)+(A+1-Y);

    if(S[k]-tmp>A){
        cout<<"Jiro"<<endl;
    }
    else{
        cout<<"Hanako"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3960
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner scn = new Scanner(System.in);
       
        
            int total = scn.nextInt();
            int nof = scn.nextInt();
            
            int[] prize = new int[total];
            for (int i = 0; i < total; i++) {
                prize[i]= scn.nextInt();
            }
            Arrays.sort(prize);
            int sum=0;
            for (int i = 0; i < nof; i++) {
                sum = sum + prize[i];
            }
            System.out.print(sum);



    }
}

Measured memory_bytes: 38832
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

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

    vi oks(m, 0);
    rep(i, n) {
        int k; cin >> k;
        rep(i, k) {
            int a; cin >> a;
            oks[a - 1]++;
        }
    }
    int ans = 0;
    rep(i, m) {
        if (oks[i] == n) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    ans = (0, 0, 0)
    for h in range(1, 3501):
        for n in range(1, 3501):
            # 式をwについて解いた
            num = N * n * h
            denom = 4 * h * n - N * (h + n)
            if denom > 0 and num % denom == 0:
                w = num // denom
                ans = (h, n, w)
                break

    print(*ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 74480
import functools
import re

MOD = 10 ** 9 + 7
ACGT = 'ACGT'
GOOD = 'TTT'
BAD = re.compile(r'AGC|GAC|ACG|A.GC|AG.C')


@functools.lru_cache(maxsize=None)
def dfs(n, i, last3):
    if i == n:
        return 1
    else:
        return sum(
            dfs(n, i + 1, last3[1:] + c)
            for c in ACGT
            if not re.search(BAD, last3 + c)) % MOD


N = int(input())
print(dfs(N, 0, GOOD))


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
vector<int> e[maxn];
int main(){
	int n, m; cin >> n >> m;
	for(int i = 0; i < n; i++){
		int x; scanf("%d", &x);
		e[x % m].push_back(x);
	}
	int ans = e[0].size() / 2;
	for(int i = 1; i < m; i++){
		int j = m - i;
		if(i == j){
			ans += e[i].size() / 2;
		} else if(i < j){
			int pi = e[i].size(), pj = e[j].size();
			int k = min(pi, pj);
			{
				map<int,int> v;
				for(auto u : e[i]) v[u]++;
				int upto = ((pi - k) / 2) * 2;
				for(auto p : v){
					int can = (p.second / 2) * 2;
					int now = min(can, upto); 
					ans += now / 2;
					upto -= now;
				}
			}
			{
				map<int,int> v;
				for(auto u : e[j]) v[u]++;
				int upto = ((pj - k) / 2) * 2;
				for(auto p : v){
					int can = (p.second / 2) * 2;
					int now = min(can, upto);
					ans += now / 2;
					upto -= now;
				}
			}
			ans += k;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    char c;
    cin >> c;
    string s = "aiueo";
    REP(i,5){
        if (c == s[i]){
            cout << "vowel" << endl;
            return 0;
        }
    }
    cout << "consonant" << endl;

    return 0;
}

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

const int INF=1<<30;

int main(){
    int D;
    long long G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    for(int i=0; i<D; i++){
        cin >> p[i] >> c[i];
    }
    int res=INF;
    for(int bits=0; bits<(1<<D); bits++){
        bool ok=false;
        long long total=0;
        int num=0;
        for(int i=0; i<D; i++){
            if((bits>>i) & 1){
                num+=p[i];
                total+=p[i]*100*(i+1)+c[i];
            }
        }
        if(total >= G) ok=true;
        else{
            for(int i=D-1; i>=0; i--){
                if(~(bits>>i) & 1){
                    for(int j=0; j<p[i]; j++){
                        num++;
                        total+=100*(i+1);
                        if(total >= G){
                            ok=true;
                            break;
                        }
                    }
                    break;
                }
            }
        }
        if(ok) res=min(res, num);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <complex>
using namespace std;

using D = double;
using P = complex<D>;
using L = pair<P,P>;
using Poly = vector<P>;

#define X real()
#define Y imag()

const D EPS = 1e-8;

D dot(const P a, const P b){ return a.X*b.X + a.Y*b.Y; }
D cross(const P a, const P b){ return a.X*b.Y - a.Y*b.X; }

int ccw(P a, P b, P c){
  b -= a, c -= a;
  if(cross(b,c) > EPS) return 1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < 0) return 2;
  if(norm(b) < norm(c) - EPS) return -2;
  return 0;
}

bool is_cross(L a, L b){
  P af = a.first, as = a.second, bf = b.first, bs = b.second;
  return (ccw(af,as,bf)*ccw(af,as,bs) <= 0 and ccw(bf,bs,af)*ccw(bf,bs,as) <= 0);
}

int in_poly(P a, const Poly &p){
  int n = p.size(), c = 0;
  for(int i = 0; i < n; ++i){
    P s  = p[i] - a, t = p[(i+1)%n] - a;
    if(not ccw(s,t,P(0,0))) return 1;
    if(s.Y > t.Y + EPS) swap(s,t);
    if((s.Y*t.Y < 0 or (s.Y*t.Y < EPS and t.Y > EPS)) and cross(s,t) < EPS) ++c;
  }
  if(c%2) return 2;
  return 0;
}

struct UnionFind{
private:
  vector<int> data;
public:
  int N;
  UnionFind(int n) : data(n,-1), N(n) {}
  bool unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return false;
    --N;
    if(data[y] < data[x]) swap(x,y);
    data[x] += data[y];
    data[y] = x;
    return x != y;
  }
  int find(int x){
    if(data[x] < 0) return x;
    return (data[x] = find(data[x]));
  }
};

bool connected(const Poly &A, const Poly &B){
  int n = A.size(), m = B.size();
  for(auto p : A){
    if(in_poly(p,B)) return true;
  }
  for(auto p : B){
    if(in_poly(p,A)) return true;
  }
  for(size_t i = 0; i < A.size(); ++i){
    L a(A[i],A[(i+1)%n]);
    for(size_t j = 0; j < B.size(); ++j){
      L b(B[j],B[(j+1)%m]);
      if(is_cross(a,b)) return true;
    }
  }
  return false;
}


int main(){
  int N;
  while(cin >> N, N){
    for(int i = 0; i < N; ++i){
    vector<Poly> V;
      int M;
      cin >> M;
      UnionFind uf(M);
      for(int j = 0; j < M; ++j){
        Poly pol;
        for(int k = 0; k < 4; ++k){
          D x, y;
          cin >> x >> y;
          pol.emplace_back(x,y);
        }
        V.push_back(pol);
      }
      for(int j = 0; j < M; ++j){
        for(int k = 0; k < j; ++k){
          if(connected(V[j],V[k]))
            uf.unite(k,j);
        }
      }
      cout << uf.N << endl;
    }
  }
}



Measured memory_bytes: 3228
import java.io.BufferedInputStream;
import java.util.*;

public class Main {


    public static void main(String[] args) {

        Scanner s = new Scanner(new BufferedInputStream(System.in));
        String str = s.nextLine();
        int[] n = new int[26];
        for (int i = 0;i < str.length(); i++) {
            n[str.charAt(i) - 'a']++;
        }
        for (int i: n) {
            if ((i & 1 )== 1) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 21844
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))

if N >= M:
  print(0)
else:
  L = sorted([X[i + 1] - X[i] for i in range(M - 1)], reverse=True)
  print(X[-1] - X[0] - sum([L[i] for i in range(N - 1)]))

Measured memory_bytes: 20536
#include<stdio.h>
int main(){

  int i,j,n;
  int count=0,swap,data[100];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&data[i]);
  }
  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(data[j]<data[j-1]){
	swap=data[j];
	data[j]=data[j-1];
	data[j-1]=swap;
	count++;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i==n-1){
      printf("%d\n",data[i]);
    }
    else{
      printf("%d ",data[i]);
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2080
n, k=map(int, input().split())
p=list(map(int, input().split()))
idx=0
sum=0
for i in range(k):
    sum+=p[i]
max=sum
for i in range(k,n):
    sum+=p[i]
    sum-=p[i-k]
    if sum>=max:
        max=sum
        idx=i-k+1

e=0
for i in range(idx,idx+k):
    e+=((p[i]+1)/2)
print(e)

Measured memory_bytes: 25060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        long[] num = new long[3];
        for (int i = 0; i < 3; i++)
        {
            num[i] = cin.nextLong();
        }
        int cnt = 0;
        Dictionary<long, int> dic = new Dictionary<long, int>();
        while (true)
        {
            for (int i = 0; i < 3; i++)
            {
                if(num[i] % 2 != 0)
                {
                    Console.WriteLine(cnt);
                    return;
                }
            }
            long[] nextnum = new long[3];
            long sum = 0;
            for (int i = 0; i < 3; i++)
            {
                sum += num[i] / 2;
            }
            for (int i = 0; i < 3; i++)
            {
                nextnum[i] = sum - num[i] / 2;
            }
            cnt++;
            num = nextnum;
            Array.Sort(num);
            long hash = getHash(num);
            if (dic.ContainsKey(hash))
            {
                Console.WriteLine(-1);
                return;
            }
            dic[hash] = 1;
        }


    }
    
    long getHash(long[] a)
    {
        long hash = 0;
        hash += a[0] * 19786316311312L;
        hash += a[1] * 123184165781941L;
        hash += a[2] * 535871674169487L;
        return hash;
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main(){
  	vector <int > a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  	int x;
  cin >> x;
  cout << a[x-1] << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=1e6+10,M2=1e6+10,M3=1e3+10,inf=1e9+10,mod=1e9+7;
main()
{
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
}

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

using namespace std;
#define ll long long int
int main() {

    ll x, y;
    cin >> x >> y;
    if ((x*y) % 2 == 0) {
        cout << "Even"<< endl;
    }
    else {
        cout << "Odd" << endl;
    }

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1000000000;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  	 int n;
  	 cin >> n;
  	 vector<int> v;
  	 for(int i = 0; i < n; i++){
	   int x;
	   cin >> x;
	   v.push_back(x);	 
	}
	 if (n == 1){ cout << "Yes" << endl;}
	 else{
	  for(int i = n - 1; i > 0; --i) if (v[i] < v[i - 1]) v[i - 1]--;
	  bool ok = true;
	  for(int i = 0; i + 1 < n; i++){
		   if (v[i] > v[i + 1]){
			    ok = false;
			    break; 
			  } 
		 }
	  if (ok) cout << "Yes" << endl;
	  else cout << "No" << endl;	 
	}
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 1400
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
ans=1
if 0 in lis:
    print(0)
    sys.exit()
for i in range(n):
    ans*=lis[i]
    if ans>10**18:
        print(-1)
        sys.exit()
print(ans)

Measured memory_bytes: 22560
#include <stdio.h>
int main(void) {
        int a,b,c,x,y;
        if(scanf("%d",&a)==1);
        if(scanf("%d",&b)==1);
        if(scanf("%d",&c)==1);
        if(scanf("%d",&x)==1);
        if(scanf("%d",&y)==1);
        long int min=a*x+b*y;
        int max=x;
        if(x<y)max=y;
        long int z;
        for(int i=2;i<=max*2;i+=2){
                int z_a=a*(x-i/2);
                if(z_a<0)z_a=0;
                int z_b=b*(y-i/2);
                if(z_b<0)z_b=0;
                z=c*i+z_a+z_b;
                if(min>z){
                        min=z;
                }
        }
        printf("%ld\n",min);
        return 0;
}


Measured memory_bytes: 128
N = int(input())
C = input()

"""
RRRWWWになれば幸せ

8
WRWW RWRR
Csum = [0, 1, 1, 2, 3x, 3, 4, 4, 4]

"""

Csum = [0] * (N+1)
for i in range(N):
  Csum[i+1] = Csum[i] + (1 if C[i] == 'W' else 0)
  
# 赤白の個数
CW = Csum[N]
CR = N - CW

ans = 200001
# iを含む右を全部Wに、含まない左をRにする
for i in range(N+1):
  leftR = i - Csum[i]
  leftW = Csum[i]
  rightR = CR - leftR
  rightW = CW - leftW
  #print(i,leftR,leftW,rightR,rightW)
  cnt = 0
  # irekae
  cnt += min(leftW, rightR)
  leftW -= cnt
  leftR += cnt
  rightR -= cnt
  rightW += cnt
  cnt += leftW + rightR
  #print(cnt)
  ans = min(ans,cnt)
  
print(ans)

Measured memory_bytes: 69824
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	long long int n;
	long long int a, b;
	cin >> n;
	cin >> a >> b;
	long long int ans = 0;
	ans = modpow(2, n, MOD);
	long long int ansa = 1;
	long long int ansb = 1;
	for (long long int i = 1; i <= a; i++) {
		ansa = ansa * (n + 1 - i);
		ansa = ansa % MOD;
		ansa = ansa * modinv(i, MOD) % MOD;
	}
	for (long long int i = 1; i <= b; i++) {
		ansb = ansb * (n + 1 - i);
		ansb = ansb % MOD;
		ansb = ansb * modinv(i, MOD) % MOD;
	}
	long long int c = ansa + ansb;
	c = c % MOD;
	ans = ans - 1-c;
	if (ans <= 0) {
		if (ans == 0) {
			cout << 0;
			return 0;
		}
		cout << MOD + ans;
	}
	else {
		if (ans == MOD) {
			cout << 0;
			return 0;
		}
		cout << ans;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a[11][5];
  int h,i,j,k,c,po,score,sw,sw2;
  while(1){
    score=0;
    sw=0;
    sw2=0;
    po=0;
    c=0;

    scanf("%d",&h);
    if(h==0)break;
    for(i=0;i<h;i++){
      for(j=0;j<5;j++){
	scanf("%d",&a[i][j]);
      }
    }
    //  printf("check0\n");
    while(1){
      sw=score;
      //del
      for(i=0;i<h;i++){
	for(j=0;j<3;j++){
	  c=1;
	  po=a[i][j];
	  for(k=1;j+k<5;k++){
	    if(a[i][j+k]==po){
	      c++;
	    }
	    else break;
	  }
	  if(c>=3){
	    for(k=0;k<c;k++){
	      score+=a[i][j+k];
	      a[i][j+k]=0;
	    }
	  }
	}
      }
      if(sw==score)break;
      //del end
      //  printf("check1\n");
      //fall
      while(1){
	sw2=0;
	if(h!=0){
	  for(i=h-2;i>=0;i--){
	    for(j=0;j<5;j++){
	      if(a[i][j]!=0&&a[i+1][j]==0){
		a[i+1][j]=a[i][j];
		a[i][j]=0;
		sw2=1;
	      }
	    }
	  }
	}
	if(sw2==0)break;
      }
      //fall end
      //  printf("check2\n");
    }
    printf("%d\n",score);
  }
  return 0;
}

Measured memory_bytes: 1028