akhauriyash/Code-Regression huggingface dataset:
type 
	arr=array[0..100010] of longint;
var
	s,t:int64;
	i,n:longint;
	a,f1,f2:arr;
procedure qsort(var a:arr; l,r:longint);
var
	i,j,t,mid:longint;
begin
	i:=l; j:=r; mid:=a[(l+r) div 2];
	repeat
		while a[i]<mid do inc(i);
		while a[j]>mid do dec(j);
		if i<=j then
		begin
			t:=a[i]; a[i]:=a[j]; a[j]:=t;
			inc(i); dec(j);
		end;
	until i>j;
	if l<j then qsort(a,l,j);
	if i<r then qsort(a,i,r);
end;
begin
	read(n);
	if n mod 2=0 then
	begin
		f1[1]:=1; f1[n]:=-1;
		f2[1]:=-1; f2[n]:=1;
	end;
	if n mod 2=1 then
	begin
		f1[1]:=1; f1[n]:=1;
		f2[1]:=-1; f2[n]:=-1;
	end;
	for i:=2 to n-1 do
	begin
		if i mod 2=0 then f1[i]:=-2
		else f1[i]:=2;
		if i mod 2=0 then f2[i]:=2
		else f2[i]:=-2;
	end;
	qsort(f1,1,n);
	qsort(f2,1,n);
	s:=0; t:=0;
	for i:=1 to n do read(a[i]);
	qsort(a,1,n);
	for i:=1 to n do
	begin
		s:=s+f1[i]*a[i];
		t:=t+f2[i]*a[i];
	end;
	s:=abs(s); t:=abs(t);
	if s>t then writeln(s)
	else writeln(t);
end.

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

int n,c,crs[14],ans[52];

bool dfs(int s, int t)
{
	if(s==0) return true;

	for(int i=13; i>=1; i--)
	{
		if(crs[i])
		if((s-i)%i == 0)
		{
			ans[t]=i;
			crs[i]--;
			if(dfs(s-i,t+1))
			{
				return true;
			}
			crs[i]++;
		}
	}
	return false;
}

int main()
{
	while(cin >> n, n)
	{
		int s=0;
		memset(crs,0,sizeof(crs));
		for(int i=0; i<n; i++)
		{
			cin >> c;
			s+=c; crs[c]++;
		}

		if(dfs(s,0))
		{
			for(int i=n-1; i>=0; i--)
			{
				cout << ans[i] << (i ? " ":"\n");
			}
		}
		else
		{
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 868
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int x;
	cin >> x;
	cout << 800 * x - 200 * (x / 15) << endl;
	//printf((a<=c&&c<=b) ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=4010;
int n,a[N],posa[N],b[N],posb[N],p1[N][N],p2[N][N],f[N][N];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n+n;i++)
	{
		char s[2];int x;
		scanf("%s%d",s,&x);
		if (s[0]=='B') a[i]=x,posa[x]=i;
			else b[i]=x,posb[x]=i;
	}
	for (int i=1;i<=n+n;i++)
		for (int j=0;j<=n;j++)
		{
			p1[i][j]=p1[i-1][j]+(a[i]>j);
			p2[i][j]=p2[i-1][j]+(b[i]>j);
		}
	for (int i=0;i<=n;i++)
		for (int j=0;j<=n;j++)
		if (i||j)
		{
			int x=posa[i],y=posb[j];
			if (!i) { f[i][j]=f[i][j-1]+p1[y][i]+p2[y][j];continue;}
			if (!j) { f[i][j]=f[i-1][j]+p1[x][i]+p2[x][j];continue;}
			f[i][j]=min(f[i-1][j]+p1[x][i]+p2[x][j],f[i][j-1]+p1[y][i]+p2[y][j]);
		}
	printf("%d\n",f[n][n]);
	return 0;
}


Measured memory_bytes: 159488
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int N=2e5+5;
int ans=1e9,n,dpa[N],dpb[N];
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	cin>>s;
	for(int i=0;i<n;i++)
	{
		dpa[i+1]=dpa[i]+(s[i]=='.');
		dpb[i+1]=dpb[i]+(s[i]=='#');
	}
	for(int i=0;i<=n;i++)
	{
		int pnt=dpb[i]+dpa[n]-dpa[i];
		ans=min(ans,pnt);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2196
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define sbits(a) __builtin_popcount(a)
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000001
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1005;
char A[N][N];
ll dp[N][N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int h, w;
    cin >> h >> w;

    for (int i = 1; i <= h; i++)
        cin >> A[i] + 1;

    dp[1][1] = 1;

    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
            if (A[i][j] == '.')
                dp[i][j] += (dp[i - 1][j] + dp[i][j - 1]) % mod;

    cout << dp[h][w] % mod;

    return 0;
}


Measured memory_bytes: 9088
import sys

stdin = sys.stdin

sn = lambda : stdin.readline().rstrip()
an = lambda : map(int, stdin.readline().split())
ni = lambda : int(sn())

s = sn()

odd = s[::2]
even = s[1::2]
ans = "Yes"
for o in odd:
  if o not in ("R", "U", "D"):
    ans = "No"
for e in even:
  if e not in ("L", "U", "D"):
    ans = "No"
print(ans)

Measured memory_bytes: 3064
//https://atcoder.jp/contests/abc121/tasks/abc121_b
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(int argc, char const *argv[]) {
  int N,M,C;
  cin >> N >> M >> C;
  int B[22];
  for (int i=0;i<M;i++){
    cin >>B[i];
  }
  int ans=0;
  for (int i=0; i<N; i++){
    int A[22];
    for(int j=0;j<M;j++){
      cin >>A[j];
    }
    int judge=C;
    for(int j=0;j<M;j++){
      judge+=A[j]*B[j];
    }
    if(judge>0)ans+=1;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {

  int N;
  cin >> N;

  vector<int> h(N);
  int mx = 0;
  for(int i = 0; i < N; i++) {
    cin >> h[i];
    mx = max(mx, h[i]);
  }

  int answer = 0;
  
  int current = 0;

  for (int i = 0; i < N; i++) {
  
    if (h[i] < current) {
      answer += current - h[i]; 
    }
    current = h[i];

  }

  answer+= current;

  cout << answer << endl;

  return 0;

}


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

int main() {
  
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a+b >= c && a <= c) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        a: u64, b: u64
    }
    println!("{}", if a%3==0||b%3==0||(a+b)%3==0 {"Possible"} else {"Impossible"});
}

Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main 
{
	public static void main(String arg[]) throws IOException
	{
	InputStreamReader isr = new InputStreamReader(System.in);
	BufferedReader br = new BufferedReader(isr);
	String buf = br.readLine();
	
	int x = Integer.parseInt(buf);
	
	

	
	System.out.println(x*x*x);
	
	}
}

Measured memory_bytes: 24360
#include<stdio.h>
#define MAX 100
int main(){
  int i, j, k, n, a, b, A[MAX + 1], B[MAX + 1][MAX + 1];
 
  scanf("%d",&n);
  for(i = 1; i <= n; i++)
    scanf("%d%d", &A[i-1], &A[i]);
  
  for(i = 1; i <= n; i++)
    B[i][i] = 0;
  
  for(j = 2; j <= n; j++){
 
    for(i = 1; i <= n - j + 1; i++){
      a = i + j -1;
      B[i][a] = 1000000;
 
      for(k = i; k <= a - 1; k++){
    b = B[i][k] + B[k + 1][a] + A[i - 1]*A[k]*A[a];
    if(B[i][a] >= b)
      B[i][a] = b;
      }
    }
  }
  
  printf("%d\n",B[1][n]);
    
  return 0;
}

Measured memory_bytes: 1820
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int n;
    cin>>n;
    int a,b,c;
    ll ans = 0;
    rep(i,1,n){
        rep(j,1,n){
            rep(k,1,n){
                a = i;
                b = j;
                c = k;
                a = gcd(a,b);
                a = gcd(a,c);
                ans += a;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3
import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62



def solve(H: "List[int]", M: "List[int]", K: int):
    start = H[0] * 60 + M[0]
    end = H[1] * 60 + M[1]
    print(end - start - K)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = [int()] * (2)  # type: "List[int]"
    M = [int()] * (2)  # type: "List[int]"
    for i in range(2):
        H[i] = int(next(tokens))
        M[i] = int(next(tokens))
    K = int(next(tokens))  # type: int
    solve(H, M, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 64988
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
#define All(a) (a).begin(),(a).end()
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;


int main(){
  int N;
  cin >>N;
  vi A(N);
  Rep(i,N){
    cin >>A[i];
    if(A[i]==0){cout <<0;return 0;}
  }
  double logres=0;
  intl res=1;
  Rep(i,N){
    res *= A[i];
    logres += log10(A[i]);
    if(res >= (intl)(1000000000000000001) ){cout <<-1;return 0;}
    if(res <0 ||logres > 18.0){cout <<-1;return 0;}
  }
  
  cout <<res;
}

Measured memory_bytes: 4060
S = list(input())
T = list(input())
s = len(S)
t = len(T)
for i in range(s-t,-1,-1):
    ss = S[i:i+t]
    for j in range(t):
        if ss[j] != "?" and ss[j] != T[j]:
            break
    else:
        for j in range(t):
            if ss[j] == "?":
                S[i+j] = T[j]
        break
else:
    print("UNRESTORABLE")
    exit()
print("".join(S).replace("?","a"))

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

int main(){

    //データ定義
    int w_num;
    int i = 0;

    //主処理
    while(true){
        //データセットを読み込む
        cin >> w_num;

        //0になったら終了
        if(w_num == 0){
            break;
        }

        //出力
        cout << "Case " << i + 1 << ": " << w_num << endl;

        //番号更新
        i++;
    }
    return 0;
}


Measured memory_bytes: 3052
// Last Change:                 11/18/2018 23:30:19.
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

#define STUCKSIZE 205
int top = 0;
int S[STUCKSIZE];
void StuckInitialize() { top = 0; }
bool IsEmpty() { return top == 0; }
bool IsFull() { return top == STUCKSIZE; }
void Push(int x) {
  if (IsFull()) {
    StuckInitialize();
  } else {
    top++;
    S[top] = x;
  }
}
int Pop(void) {
  if (IsEmpty()) {
    return 0;
  }
  top--;
  return S[top + 1];
}

int main() {
  string inputData;
  int a, b;
  while (cin >> inputData) {
    if (inputData == "+") {
      a = Pop();
      b = Pop();
      Push(a + b);
    } else if (inputData == "-") {
      a = Pop();
      b = Pop();
      Push(b - a);  //順番注意
    } else if (inputData == "*") {
      a = Pop();
      b = Pop();
      Push(a * b);
    } else {
      Push(stoi(inputData));
    }
  }
  cout << Pop() << endl;

}


Measured memory_bytes: 3232
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <tuple>
#include <numeric>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <regex>
#include <stack>
#include <limits>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);

	int s;
	cin >> s;
	if (s < 3) { cout << "0\n"; return 0; }
	vector<int> f(s + 1);
	f[0] = 1;
	const int M = 1000000007;
	for (int i = 0; i < s; ++i) {
		for (int j = 3; i + j <= s; ++j) {
			f[i + j] = (f[i + j] + f[i]) % M;
		}
	}
	cout << f[s] << endl;
	return 0;
}


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

ll a,b,n;

int main(){
  cin >> a >> b >> n;
  ll r1=a%b;
  ll k1=a/b;
  cout << (a*min(n,b-1))/b << endl;
  return 0;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader sc = new FastReader();
		int N = sc.nextInt();
		int[] h = new int[N];
		for (int i=0; i<N; i++) {
			h[i] = sc.nextInt(); 
		}
		long[] dp = new long[N]; 
		Arrays.fill(dp, 1<<30);
		dp[0] = 0; 
		for (int i=1; i<N; i++) {
			dp[i] = Math.min(dp[i-1] + Math.abs(h[i]-h[i-1]), dp[i]); 
			if (i-2>=0) {
				dp[i] = Math.min(dp[i-2] + Math.abs(h[i]-h[i-2]), dp[i]); 
			}
		}
		System.out.println(dp[N-1]);
	}

}


Measured memory_bytes: 32856
from numpy import*
n,m=map(int,input().split())

r=[list(map(int,input().split()))[1:]for i in range(m)]
*p,=map(int,input().split())
ans=0
for i in range(2**n):
    lamp=array([i>>j&1for j in range(n)])
    ans+= p==[sum(lamp[array(j)-1])%2 for j in r]
print(ans)

Measured memory_bytes: 12416
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
static const int N = 1000;
int C[N + 1][N + 1];

int lcs(string X, string Y)
{
	int m = X.size();
	int n = Y.size();
	X = ' ' + X;
	Y = ' ' + Y;

	for (int i = 1; i < m; i++) C[i][0] = 0;
	for (int j = 1; j < n; j++) C[0][j] = 0;

	int maxl = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (X[i] == Y[j]) {
				C[i][j] = C[i - 1][j - 1] + 1;
			}
			else {
				C[i][j] = max(C[i - 1][j], C[i][j - 1]);
			}
			maxl = max(maxl, C[i][j]);
		}
	}
	return maxl;
}

int main()
{
	string s1, s2;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;
	}
}



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

int main()
{
	vector<vector<char>>vv;
	vector<char>v;
	int H, W;
	cin >> H >> W;
	char tmp_c;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> tmp_c;
			v.push_back(tmp_c);
		}
		vv.push_back(v);
		v.clear();
	}
	int tmp_cnt = 0;
	//yoko
	for (int i = vv.size()-1; i>=0; i--) {
		tmp_cnt = 0;
		for (int j = vv[i].size()-1; j>=0 ; j--) {
			if (vv[i][j] == '.')tmp_cnt++;
		}
		if (tmp_cnt == vv[i].size()) {
			vv.erase(vv.begin() + i);
		}
	}
	//tate
	for (int i = vv[0].size() - 1; i >= 0; i--) {
		tmp_cnt = 0;
		for (int j = vv.size() - 1; j >= 0; j--) {
			if (vv[j][i] == '.')tmp_cnt++;
		}
		if (tmp_cnt == vv.size()) {
			for (int k = 0; k < vv.size(); k++) {
				vv[k].erase(vv[k].begin() + i);
			}
		}
	}

	for (int i = 0; i<vv.size(); i++) {
		for (int j = 0; j<vv[i].size(); j++) {
			cout << vv[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll INF = ll(1e18) +1;

void solve(long long N, std::vector<long long> P){
    ll m = INF;
    ll ans =0;
    for(int i=0;i<N;i++){
        m = min(m,P[i]);
        if(P[i] == m){
            ans ++;
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 1792
n = int(input())
a = list(map(int,input().split()))

if sum(a) % (n*(n+1)//2) != 0:
    print('NO')
    exit()
else:
    k = sum(a)// (n*(n+1)//2)


for i in range(n-1):
    d = a[i+1] - a[i] - k

    if d > 0 or d % n != 0:
        print('NO')
        exit()

print('YES')

Measured memory_bytes: 62832
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	const int MAXN = 2e5;
	int n, h[MAXN];
	cin >> n;
	map<int, int> cnt;
	for(int i = 1; i <= n; ++i) {
		cin >> h[i - 1];
		++cnt[i - h[i - 1]];
	}
	long long ans = 0;
	for(int i = 1; i <= n; ++i) {
		--cnt[i - h[i - 1]];
		ans += cnt[h[i - 1] + i];
	}
	cout << ans << '\n';
	return 0;
}


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

ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))
#define N 100010

const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL<<62);
const int iinf = (1<<30);
//CLOCKS_PER_SEC

int n, a[N], mn = 1e9;

int main(){
    //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    //ios_base::sync_with_stdio(0); cin.tie(0);
    //ifstream cin ("test.in");
    cin >> n;
    for (int i=1; i<=n; i++) cin >> a[i];
    for (int i=n; i; i--){
        if (a[i] - 1 > mn) rc("No");
        mn = smin(mn, a[i]);
    }
    cout << "Yes";
    return 0;
}


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

int main() {
  int n, temp, min = 0, max = 0, any = 0;
  vector<int> ratings;
  vector<bool> colors = {false, false, false, false, false, false, false, false};
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> temp;
    ratings.push_back(temp);
  }
  
  sort(ratings.begin(), ratings.end());
  for (auto i : ratings) {
    if (i<400) colors[0] = true;
    else if (i<800) colors[1] = true;
    else if (i<1200) colors[2] = true;
    else if (i<1600) colors[3] = true;
    else if (i<2000) colors[4] = true;
    else if (i<2400) colors[5] = true;
    else if (i<2800) colors[6] = true;
    else if (i<3200) colors[7] = true;
    else any++;
  }
  for (auto i : colors) {
    if (i) min++;
  }
  if (min==0 && any>0) {
    min++;
    any--;
  }
  max = min+any;
  cout << min << ' ' << max;
  return 0;
}

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


int main(){
  int N, n, a, s = 0;

  cin >> N;
  n = N;
  
  while(n != 0){
    a = n % 10;
    n /= 10;
    s += a;
  }
  if(N % s == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}


Measured memory_bytes: 256
/**************
*	Shell Sort
*************/

#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>	//??£?¨?
using namespace std;

void insertionSort(vector<int>* A, int g, int* cnt  ){

	for(unsigned int i=g ; i<(A->size()); i++){
		int v = (*A)[i];
		int j = i-g;
		while(j>=0 && (*A)[j]>v){
			(*A)[j+g] = (*A)[j];
			j = j-g;
			(*cnt)++;
		}
		(*A)[j+g] =v;
	}
	return ;
}
//---------------------------------------------------------
void shellSort(vector<int>* A, vector<int>* G, int* cnt){
//	*cnt =0;
//	int m = A->size();
//	vector<int> G(1,m);
	for(unsigned int i=0; i<(G->size()); i++){
		insertionSort(A, (*G)[i], cnt);
	}

	return;
}
//--<<???????????¢??°>>-------------------------------------------------------
int main(){

	//??\???
	int n;
	cin >> n;
	vector<int> A;
	A.resize(n);
	for(unsigned int i=0; i< A.size(); i++){
		cin >> A[i];
	}

	//??????
	vector<int> G;
	int sum = 1;
	while(sum <= n){
	    G.push_back(sum);
		sum = sum * 3 + 1;
	}
	reverse(G.begin(), G.end());

	int cnt = 0;
	shellSort(&A, &G, &cnt);

	//??????
	cout << G.size() << endl;
	for(unsigned int i=0; i<(G.size()); i++){
		cout << G[i];
		if(i!=(G.size()-1)){
			 cout <<" " ;
		}
	}
	cout << endl;
	cout << cnt << endl;
	for(int i=0; i< n; i++){
		cout << A[i]<< endl;
	}

	return 0;
}
//-----------------------------------------------

Measured memory_bytes: 6716
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;
mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;
#[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
#[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where
        <T as FromStr>::Err: Debug,
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse().unwrap())
                .collect()
        }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { println ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }

#[derive(Eq, PartialEq, Clone, Debug)]
struct Rev<T>(pub T);
impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

fn main() {
    let (n, h) = get!(usize, u64);
    let ab = get!(u64, u64; n);

    let a_max = ab.iter().map(|t| t.0).max().unwrap();
    let mut bs: Vec<u64> = ab.iter().map(|t| t.1).filter(|&b| b > a_max).collect();
    bs.sort_by_key(|&x| Rev(x));

    let mut ans = 0;
    let mut sum = 0;

    for &b in &bs {
        sum += b;
        ans += 1;
        if sum >= h {
            break;
        }
    }

    if sum < h {
        ans += (h - sum + a_max -1 ) / a_max;
    }

    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<set>
#include<iterator>
#include<map>
#include<cmath>
#include<unordered_map>
#include<vector>
using namespace std;
#define int long long
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
const int inf = (1e18)+7;
const int neginf = -1*((int)1e17 ) + 7 ; 

int32_t main() {
    fastio
    
        int n;
    cin>>n;
    
    int arr[n];
    
    fo(i,n)
        cin>>arr[i];
    
    int brr[n];
    fo(i,n)
        brr[arr[i]-1] = i+1;
    
    fo(i,n)
        cout<<brr[i]<<" ";
    

    
    
        
    
    
     
    
    
    

        
        
        
    
            
        
       
        
        
        
    
     
    
    
	return 0;
}


Measured memory_bytes: 2432
n = int(input())
c = [[0]*10 for _ in range(10)]

for i in range(1, n+1):
    strI = str(i)
    i = int(strI[0])
    j = int(strI[-1])
    c[i][j] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j]*c[j][i]

print(ans)


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string>board(h);
    rep(i, 0, h){
        cin >> board[i];
    }
    int ans = 0;
    for(int bit1=0; bit1<(1<<h); bit1++){
        for(int bit2=0; bit2<(1<<w); bit2++){
            int cnt = 0;
            rep(i, 0, h){
                rep(j, 0, w){
                    if(bit1&(1<<i))continue;
                    if(bit2&(1<<j))continue;
                    if(board[i][j]=='#')cnt++;
                }
            }
            if(cnt==k)ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    int n;
    string s;
    cin >> n >> s;
    if(n%2 == 1)cout << "No";
    else{
        if(s.substr(0, s.size()/2) == s.substr(s.size()/2, s.size()/2))cout << "Yes";
        else cout << "No";
    }
}  


Measured memory_bytes: 256
import sys
from itertools import combinations

s = list(sys.stdin.readline().rstrip())
l = len(s)

def main():
    res = 0
    cand = range(1, l)
    for inser_cnt in range(l):
        for idces in combinations(cand, inser_cnt):
            t = s.copy()
            idces = list(idces)
            for i in idces[::-1]:
                t.insert(i, '+')
            res += eval(''.join(t))
            
    return res
                     
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    int a;
    cin>>s;
    a=(int)s.find("C");
    if((int)s.find("F",a)!=-1){printf("Yes\n");}
    else {printf("No\n");}
    return 0;
}


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

#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  char c;
  cin >> c;
  cout << (c >= 'A' && c <= 'Z' ? 'A' : 'a') << '\n';
  return 0;
}


Measured memory_bytes: 3488
#include <iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    float p1,p2;
    p1 = a/0.08;
    p2 = b/0.1;
    int num;
    int dum = p1*10;
    if(dum%10!=0){
        num = dum/10;
        num +=1;
    }else{
        num  = dum/10;
    }
    bool bl = true;
    int c,d;
    do
    {
        c = num*0.08;
        d = num*0.1;
        // cout<<c<<" "<<d<<endl;
        if(c!=a){
            cout<<-1<<endl;
            return 0;
        }else{
            if(d==b){
                cout<<num<<endl;
                return 0;
            }
        }
        num++;
    }while(true);
    
    
}

Measured memory_bytes: 256
N,M=map(int,input().split())
X=sorted([int(i) for i in input().split()])
ans=X[-1]-X[0]
Y=[0 for i in range(M-1)]
for i in range(M-1):
    Y[i]=X[i+1]-X[i]
Y.sort(reverse=True)
for i in range(min(N-1,M-1)):
    ans-=Y[i]
print(ans)


Measured memory_bytes: 13840
# 2019-11-14 10:01:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *w = [int(x) for x in sys.stdin.read().split()]
    
    min_diff = sum(w)
    for i in range(0, n-1):
        diff = abs(sum(w[:i+1]) - sum(w[i+1:]))
        min_diff = min(min_diff, diff)
    print(min_diff)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
//code by lynmisakura.wish to be accepted
/****************************/
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;
 
const long long Mod = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;
 
#define itn int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
 
int main(void){
	
	string s,t; cin >> s >> t;
	ll n = s.size();
	ll m = t.size();
	//sの各文字がいつ現れるかを持っておく
	vector<vector<ll>> ch(26,vector<ll>(0));
	rep(i,n) ch[s[i] - 'a'].pb(i);
	rep(i,n) ch[s[i] - 'a'].pb(i + n);
	
	ll ans = 0LL;
	ll p = 0LL;
	rep(i,m){
		if(ch[t[i]-'a'].size() == 0){
			cout << -1 << endl;
			return 0;
		}
		p = *lower_bound(all(ch[t[i]-'a']),p)+1;
		if(p >= n){
			p -= n;
			ans += n;
		}
	}
	cout << ans + p << endl;
	return 0;
}


Measured memory_bytes: 2800
n500 = gets.to_i
n100 = gets.to_i
n50  = gets.to_i
x = gets.to_i
 
x /= 50
counter = 0
(0..n500).each do
  x_ = x
  (0..n100).each do
    counter += 1 if (x_ <= n50)
    x_ -= 2
    break if (x_ < 0)
  end
  x -= 10
  break if (x < 0)
end
puts counter

Measured memory_bytes: 1788
def s()
  gets().chomp
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end
class Array
  def sum
    total = 0
    self.each do |item|
      total += item
    end
    total
  end
end

def eratosthenes(size)
  prime_list = []
  is_prime = Array.new(size, true)
  is_prime[0] = false
  is_prime[1] = false

  2.upto(size-1){|i|
    if is_prime[i]
      prime_list << i
      (2).upto((size.to_f/i).ceil-1){|j|
        is_prime[j*i] = false
      }
    end
  }
  [prime_list, is_prime]
end

def dijkstra(s, e, cost)
  size = cost.length
  if s==e
    return 0
  end
  dp = {}
  dp[s] = 0
  undefined_node = {}
  size.times{|i|
    if i != s
      undefined_node[i] = cost[s][i]
    end
  }
  while undefined_node.length != 0
    min = undefined_node.min_by{|_, v| v}
    stock = {}
    temp = undefined_node.clone
    temp.each{|k, v|
      if min[1] == v
        undefined_node.delete(k)
        if k == e
          return v
        end
        dp[k] = v
        stock[k] = v
      end
    }

    stock.each{|k, v|
      undefined_node.each{|k2, v2|
        undefined_node[k2] = v + cost[k][k2] < v2 ?  v + cost[k][k2] : v2
      }
    }
  end
end

def get_bits(len)
  res =  []
  (2**len).times{|i|
    res << i.to_s(2).rjust(len, '0')
  }
  res
end

n, m, q = li()
ruiseki = Array.new(501, 0)
501.times{|i|
  ruiseki[i] = Array.new(501, 0)

}


lrs = []
m.times{
  temp = li()
  lrs << temp
  ruiseki[temp[0]][temp[1]] += 1
}

501.times{|i|
  500.times{|j|
    ruiseki[500-j-1][i] += ruiseki[500-j][i]
  }
}
501.times{|i|
  500.times{|j|
    ruiseki[i][j+1] += ruiseki[i][j]
  }
}
qs = []
q.times{
  qs << li()
}
qs.each{|l, r|
  puts ruiseki[l][r]
}



Measured memory_bytes: 30204
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;
int main()
{
	ll N;
	cin>>N;
	for(ll i=1000;;i=i+1000){
		if(i>=N){
			cout<<i-N<<endl;
			return 0;
		}
	}

}

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


void minimization()
{
  int n, k;
  cin >> n >> k;

  cout << ceil((float)(n - 1) / (float)(k - 1)) << "\n";
}


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

  sort(b.begin(), b.end());

  int mid = b[n / 2];
  long long int ans = 0;
  for (int i = 0; i < n; ++i) ans += abs(mid - b[i]);
  cout << ans << "\n";

}


void modulo_summation()
{
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ans += a - 1;
  }

  cout << ans << "\n";
}


//skip
void all_green()
{
  int d, g;
  cin >> d >> g;
  vector<int> p(d);
  vector<int> c(d);
  for (int i = 0; i < d; ++i) cin >> p[i] >> c[i];


}


void base_2_number()
{
  int n;
  cin >> n;

  string s = "";
  if (n == 0) s = '0' + s;
  while (n != 0)
  {
    if (n % 2 != 0)
    {
      --n; //-２進数の整合性
      s = '1' + s;
    }
    else
    {
      s = '0' + s;
    }
    n /= -2;
  }

  cout << s << "\n";
}


void to_infinity()
{
  string s;
  long long int k;
  cin >> s >> k;

  char digit = '1';
  for (int i = 0; i < k; ++i)
  {
    if (s[i] != '1')
    {
      digit = s[i];
      break;
    }
  }
  cout << digit << "\n";
}


void candles()
{
  int n, k;
  cin >> n >> k;
  vector<long long int> x(n);
  for (int i = 0; i < n; ++i) cin >> x[i];

  long long int ans = 100000000000000000;
  for (int i = 0; i < n - k + 1; ++i)
  {
    long long int tmp = abs(x[i + k - 1] - x[i])+ min(abs(x[i]), abs(x[i + k - 1]));
    ans = min(ans, tmp);
  }

  cout << ans << "\n";
}


int main()
{
  //minimization();
  //linear_approximation();
  //modulo_summation();
  //all_green();
  //base_2_number();
  //to_infinity();
  candles();
}


Measured memory_bytes: 1024
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    let k: i64 = input();
    const MOD: i64 = 1000000007;

    let mut comb = vec![vec![0; 2005]; 2005];
    for i in 0..2005 {
        for j in 0..i + 1 {
            if j == 0 || j == i {
                comb[i][j] = 1;
            } else {
                comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % MOD;
            }
        }
    }

    for i in 1..k + 1 {
        println!(
            "{}",
            comb[k as usize - 1][i as usize - 1] * comb[n as usize - k as usize + 1][i as usize]
                % MOD
        );
    }
}


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

int main(){
  
  //入力・準備
  string S;
  cin >> S;
  int N;
  N=S.size();
  int chn[N]={0};
  bool fg=false;
  int side=0;
  int mid=0;
  
  for(int i=0;i<N;i++){
    
    if((S[i]=='L') ^ fg){
      continue;
    }
    if(S[i]=='R'){
      fg=true;
      if(i){
      chn[mid]=(mid-side)/2+(i+1-mid)/2;
      chn[mid-1]=i-side-chn[mid];
      }
      side=i;
    }else{
      fg=false;
      mid=i;
    }
    
  }
  chn[mid]=(mid-side)/2+(N+1-mid)/2;
  chn[mid-1]=N-side-chn[mid];
  
  for(int i=0;i<N;i++){
    cout << chn[i] << " ";
  }
  
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

ll cal(string s){
  ll ans=0;
  ll tmp=s[0]-'0';
  for(int i=1;i<s.size();i++){
    if(s[i]=='+'){
      i++;
      ans+=tmp;
      tmp=s[i]-'0';
    }
    else{
      tmp*=10;
      tmp+=s[i]-'0';
    }
  }
  ans+=tmp;
  return ans;
}

string f(string s,int x){
  string ans;
  ans=s[0];
  for(int i=1;i<s.size();i++){
    if(x%2==1){
      ans+="+";
    }
    x/=2;
    ans+=s[i];
  }
  return ans;
}

int main(void){
  string s;
  cin>>s;
  ll res=0;
  for(int i=0;i<pow(2,s.size()-1);i++){
    res+=cal(f(s,i));
  }
  cout<<res<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int maxn=1e5+7;
int cnt[maxn];
int a[maxn];
vc<pi> all;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int cc=1;
	for(int i=1;i<n;i++)
	{
		if(a[i]!=a[i-1])
		{
			all.emplace_back(a[i-1],cc);
		//	dbg(a[i-1],cc);
			cc=1;
		}
		else cc++;
	}
	all.emplace_back(a[n-1],cc);
	int l=0,r=all.size()-1;
	int ans=0;
	while(l<r)
	{
		while(l<r&&all[l].second==1) ans++,l++;
		while(l<r&&all[r].second==1) r--,ans++;
		if(l<r)
		{
			all[l].second--;
			all[r].second--;
		}
	//	dbg(l,r,ans);
	}
	if(l==r)
	{
		if(all[l].second&1) ans++;
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 1784
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
int mod = (int) 1e9 + 7;

int main(){
    
    int n;
    cin >> n;
    
    n %= 10;
    
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
        cout << "hon" << "\n";
    } else if(n == 0 || n == 1 || n == 6 || n == 8){
        cout << "pon" << "\n";
    } else {
        cout << "bon" << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 3096
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		String s = sc.next();
		
		int a = 15-s.length();
		
		int w = 0;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i) == 'o') {
				w++;
			}
		}
		
		w+=a;
		if(w>=8) {
			out.println("YES");
		}else {
			out.println("NO");
		}
		
		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 21716
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dp[2010][2];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = abs(a[n-1] - w);
    if(n >= 2) chmax(ans, abs(a[n-1] - a[n-2]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    // freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x;
    scanf("%d %d",&n,&x);
    vi m(n);
    int iw=0,ans=0,t=n;
    while (t--)
    {
        scanf("%d",&m[iw]);
        iw++;
    }
    for (int i = 0;i<n; i++)
    {
        x-=m[i];
        ans++;
    }
    int mn=INT32_MAX;
    rep(i, 0, n){
        (m[i]>mn)?:mn=m[i];
    }
    ans+=x/mn;
    // while (x>0)
    // {
    //     x-=mn;
    //     ans++;
    // }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  ll a[n];
  REP(i, n) { cin >> a[i]; }
  deque<ll> deq;
  REP(i, n) {
    if (i % 2 == 0) {
      deq.push_back(a[i]);
    } else {
      deq.push_front(a[i]);
    }
  }
  REP(i, n) {
    if (i > 0) cout << " ";

    ll ans;

    if (n % 2 == 0) {
      ans = deq.front();
      deq.pop_front();
    } else {
      ans = deq.back();
      deq.pop_back();
    }
    cout << ans;
  }
  return 0;
}

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

using namespace std;

long long dp[100020][110];
long long v[101];
long long w[101];
long long INF=1000000000000;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, W;
    cin >> n >> W;

    for(int i = 1; i <= n; i++)
    {
        cin >> w[i] >> v[i];
        dp[v[i]][i] = w[i];
    }
    for(int i=1;i<=100000;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i][j]=INF;
        }
    }
    for(int i=1;i<=100000;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i >= v[j]){ dp[i][j] = min(dp[i][j-1], w[j] + dp[i - v[j]][j-1]);}
            else dp[i][j] = min(dp[i][j], dp[i][j-1]);
        }
    }

    long long res=0;
    for(long long i=100000;i>0;i--)
    {
        if(dp[i][n]<=W)res=max(res,i);
    }
    cout<<res;
    return 0;
}


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

int main(){
  int t,i=0;
  cin>>t;
  int k=t;
  string s[t];
  while(t--){
    cin>>s[i];
    i++;
  }
  int c1=0,c2=0,c3=0,c4=0;
  for(int i=0;i<k;i++){
    if(s[i]=="AC") c1++;
    else if(s[i]=="WA") c2++;
    else if(s[i]=="TLE") c3++;
    else c4++;
  }
  string st[4]={"AC","WA","TLE","RE"};
  int a[4]={c1,c2,c3,c4};
  for(int i=0;i<4;i++){
    cout<<st[i]<<" x "<<a[i]<<endl;
  }
  return 0;
}
    

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

int main()
{
    char a[4];
    for (int i = 0; i < 4; i++) {
        scanf("%c", &a[i]);
    }
    if (a[0] == a[1]) {
        printf("Bad\n");
    } else if (a[1] == a[2]) {
        printf("Bad\n");
    } else if (a[2] == a[3]) {
        printf("Bad\n");
    } else {
        printf("Good\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define ll  long long int
long long int power(long long int a,long long int b )
{
    long long int res=1;
    a=a%mod;
    while(b>0)
    {
        if(b&1)
        res=(res*a)%mod;
        b=b>>1;
        a=(a*a)%mod;
    }
    return res;
}
int main()
{
   int x;
   cin>>x;
   int ans=x/500;ans*=1000;
   x%=500;
   ans+=(x/5)*5;
   cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  int N, i, count = 0;
  cin >> N;
  
 for ( i = 0; i < N; i++) { 
   cin >> S ;
		if (S == "Y") {
			count = 1;
        }
  }
  if(count == 1) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 3640