akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    vector<int> arr(5, 0);
    for(int& val: arr)
        cin >> val;
    int sub = 0, ans = 0;
    for(int& val: arr) {
        int upper = ((val-1) / 10 + 1) * 10;
        sub = max(sub, upper-val);
        ans += upper;
    }
    cout << ans - sub << endl;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int a[5];
    for (int i = 0; i < 5; i++)
    {
        cin >> a[i];
    }

    int minval = 10;
    int minidx = 0;
    int time = 0;
    for (int i = 0; i < 5; i++)
    {
        int oneplace = a[i] % 10;
        time += a[i] + (10 - oneplace) % 10;
        if (oneplace != 0 && oneplace < minval)
        {
            minidx = i;
            minval = oneplace;
        }
    }

    time -= (10 - minval) % 10;

    cout << time << endl;

    return 0;
}


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

string S, T;

int main() {
    cin >> S >> T;

    int ans = 1.0e9;
    for (int i = 0; i < S.length() - T.length() + 1; i++) {
        int tmp = 0;
        for (int j = 0; j < T.length(); j++) {
            if (S[i+j] != T[j]) {
                tmp++;
            }
        }
        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    string s;
    cin>>s;
    ll n=s.length();
    if(n%2==1)
    {
        cout<<"No\n";
        return;
    }
    for(int i=0;i<s.length();i++)
    {
        if((i%2)==0)
        {
            if(s[i]!='h')
            {
                cout<<"No\n";
                return;
            }
        }
        else
        {
            if(s[i]!='i')
            {
                cout<<"No\n";
                return;
            }
        }
    }
    cout<<"Yes\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

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

	sort(h.begin(), h.end(), greater<int>());

	long long minDiff = 9223372036854775807LL;

	for (int i = 0; i < n - k + 1; i++) {

		minDiff = min(minDiff, h[i] - h[i + k - 1]);
	}
	
	cout << minDiff << endl;
		
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std ;

vector < int > List[28] ;

int N ;
int start ;
bool ans ;

int LineA[28] ;
int LineB[28] ;
char str[35] ;

int toNum ( char ) ;
void init ( ) ;
void BackTracking ( int , int ) ;

int main ( )
{
	while ( scanf ( "%d%*c" , &N ) == 1 && N ) {
		init ( ) ;
		for ( int i = 0 ; i < N ; i++ ) {
			gets ( str ) ;
			start = toNum ( *( str ) ) ;
			LineA[toNum ( *( str ) )]++ ;
			LineB[toNum ( *( str + strlen ( str ) - 1 ) )]++ ;
			List[toNum ( *( str ) )].push_back ( toNum ( *( str + strlen ( str ) - 1 ) ) ) ;
		}
		bool flag = true ;
		for ( int i = 0 ; i < 28 ; i++ ) {
			if ( LineA[i] != LineB[i] ) {
				flag = false ;
				break ;
			}
		}
		if ( flag == false ) {
			printf ( "NG\n" ) ;
		}
		else {
			BackTracking ( 0 , start ) ;
			if ( ans == true ) {
				printf ( "OK\n" ) ;
			}
			else {
				printf ( "NG\n" ) ;
			}
		}
	}
	return 0 ;
}

int toNum ( char c )
{
	if ( c >= 'a' && c <= 'z' ) {
		return c - 'a' ;
	}
	else {
		return -1 ;
	}
}

void init ( )
{
	for ( int i = 0 ; i < 28 ; i++ ) {
		List[i].clear ( ) ;
	}
	memset ( LineA , 0 , 28 * sizeof ( int ) ) ;
	memset ( LineB , 0 , 28 * sizeof ( int ) ) ;
	ans = false ;
}

void BackTracking ( int source , int now )
{
	if ( source == N ) {
		if ( now == start ) {
			ans = true ;
		}
		return ;
	}
	if ( ans == true ) {
		return ;
	}
	vector < int > :: iterator it = List[now].begin ( ) ;
	for (  ; it != List[now].end ( ) ; it++ ) {
		if ( LineB[*( it )] > 0 ) {
			LineB[*( it )]-- ;
			BackTracking ( source + 1 , *( it ) ) ;
			LineB[*( it )]++ ;
		}
	}
}

Measured memory_bytes: 1092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int z = sc.nextInt();
    System.out.println("" + z + " " + x + " " + y);
  }
}

Measured memory_bytes: 21332
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

struct Mod {
    static ll BASE;
    ll value = 0;
    static ll residue(ll value) { return (value % BASE + BASE) % BASE; }
    Mod(ll value)
    : value(residue(value)) {}
    Mod operator+(const Mod& rhs) const { return Mod(value + rhs.value); }
    void operator+=(const Mod& rhs) { *this = *this + rhs; }
    Mod operator-(const Mod& rhs) const { return Mod(value - rhs.value); }
    void operator-=(const Mod& rhs) { *this = *this - rhs; }
    Mod operator*(const Mod& rhs) const { return Mod(value * rhs.value); }
    void operator*=(const Mod& rhs) { *this = *this * rhs; }
    static Mod power(Mod base, ll n) {
        assert(n >= 0);
        Mod ans(1);
        Mod pow(base);
        for (int i = 0; i < 63; i++) {
            if ((n >> i) & 1) {
                ans *= pow;
            }
            pow = pow * pow;
        }
        return ans;
    }
};
ll Mod::BASE = 1000000007;

int main() {
    ll N, C;
    cin >> N >> C;
    vector<pair<ll, ll>> ranges(N);
    for (ll i = 0; i < N; i++) {
        cin >> ranges[i].first;
    }
    for (ll i = 0; i < N; i++) {
        cin >> ranges[i].second;
    }
    auto pow_sum_table = make_vec_nd((Mod)0, 401, 402);
    for (ll pow = 0; pow <= 400; pow++) {
        for (ll x_end = 1; x_end <= 401; x_end++) {
            pow_sum_table[pow][x_end] = pow_sum_table[pow][x_end-1];
            pow_sum_table[pow][x_end] += Mod::power(x_end-1, pow);
        }
    }
    auto dp = make_vec_nd((Mod)0, N+1, C+1);
    dp[0][0] = 1;
    for (ll n = 1; n <= N; n++) {
        for (ll c = 0; c <= C; c++) {
            for (ll d = 0; d <= c; d++) {
                Mod factor = pow_sum_table[d][ranges[n-1].second+1];
                factor -= pow_sum_table[d][ranges[n-1].first];
                dp[n][c] += factor * dp[n-1][c-d];
            }
        }
    }
    cout << dp[N][C].value << endl;
}


Measured memory_bytes: 2816
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long long
#define ll long long

int main()
{
  ul n;
  int d[100000];
  cin>>n;
  for (size_t i = 0; i < n; i++)
  {
    cin>>d[i];
  }
  sort(d,d+n);
  cout<<d[n / 2] - d[n / 2 - 1]<<endl;

  return 0;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint int
using namespace std;
     
typedef long long lo;
     
template<typename tp> inline void read(tp &x) {
	x = 0; char c = getchar(); int f = 0;
	for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
	for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
	if (f) x = -x;
}
namespace {
    const int mo = 1e9 + 7;
    inline int add(int x, int y) { x += y; return x >= mo ? x - mo : x; }
    inline int sub(int x, int y) { x -= y; return x < 0 ? x + mo : x; }
    inline int mul(int x, int y) { return (lo) x * y % mo; }
    inline int power(int a, int k = mo - 2) {
		int ans = 1;
		for (; k; k >>= 1, a = mul(a, a))
			if (k & 1) ans = mul(ans, a);
		return ans;
    }
	inline void U(int &x, int y) { x = add(x, y); } 
}

const int N = 3e5 + 23;
int n, m;
char str[N];

inline int spj() {
	int ans = 0;
	for (int fi = 0; fi < 2; fi++) {
		vector <vector <int> > dp(n + 1, vector <int> (2, 0));
		dp[1][fi] = 1;
		for (int i = 2; i <= n; i++) {
			U(dp[i][0], dp[i - 1][1]);
			U(dp[i][0], dp[i - 1][0]);
			U(dp[i][1], dp[i - 1][0]);
			// cout << dp[i][0] << " " << dp[i][1] << "\n";
		}
		if (fi == 0) ans = add(ans, add(dp[n][0], dp[n][1]));
		else ans = add(ans, dp[n][0]);
	}
	return ans;
}

inline int doit(int limit) {
	++limit;
	vector <int> dp(n + 1, 0);
	vector <int> sum(n + 1, 0);
	dp[0] = sum[0] = 1;
	for (int i = 1; i <= n; i++) {
		auto getsum = [&](int l, int r) {
			if ((l & 1) != (r & 1)) ++l;
			if (l > r || r < 0) return 0;
			else return sub(sum[r], l >= 2 ? sum[l - 2] : 0);
		};
		// for (int k = i - 2; k >= 0 && k >= i - limit; k -= 2)
		// 	U(dp[i], dp[k]);
		U(dp[i], getsum(max(0, i - limit), i - 2));
		sum[i] = dp[i];
		if (i > 1) U(sum[i], sum[i - 2]);
	}
	int ans = 0;
	for (int pre = 2; pre <= limit; pre += 2) {
		U(ans, mul(pre, dp[n - pre]));
	}
	return ans;
}

int main(void) {
	read(n); read(m);
	scanf("%s", str + 1);
	int first = 0;
	for (int i = 1; i <= m; i++) 
		if (str[i] != str[1]) { first = i; break; }
	if (first == 0) {
		cout << spj() << "\n";
		return 0;
	}
	--first;
	while (m && str[m] == str[1]) --m;
	// cout << "first = " << first << "\n";
	int limit = first & 1 ? first : first + 1;
	int con = limit;
	for (int i = first + 1; i <= m; i++) {
		if (str[i] != str[1]) {
			if (con & 1) limit = min(limit, con);
			con = 0;
		} else {
			++con;
		}			   
	}
	if (con & 1) limit = min(limit, con);
	cerr << "limit = " << limit << "\n";
	cout << doit(limit) << "\n";
}


Measured memory_bytes: 11440
#include<bits/stdc++.h>
using namespace std;
long long p[51]={1};
long long f[51]={1};
long long patty(int n,long long x )
{
    if(x==0) return 0;
    if(x>=f[n]-1) return p[n];
    if(x>=f[n-1]+2) return (p[n-1]+1+patty(n-1,x-f[n-1]-2));
    if(x>=1) return patty(n-1,x-1); 
}

#define sc second;
#define fr first;
int main()
{
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);
   int n; long long x;
   cin>>n>>x;
   for(int i =1;i<51;i++)
   {
     f[i] = 2*f[i-1] + 3;
     p[i] = 2*p[i-1]+1;
   }
   cout<<patty(n,x);
   return 0;
}

Measured memory_bytes: 256
s=input()

x=int(s[:2])
y=int(s[2:])

if (1<=x<=12) and (1<=y<=12):
    print('AMBIGUOUS')

elif (x==0 or x>12) and (1<=y<=12):
    print('YYMM')

elif (1<=x<=12) and (y==0 or y>12):
    print('MMYY')

else:
    print('NA')

Measured memory_bytes: 38384
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#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=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[210000];
int nx[210000][26];
int tmp[26];
char out[210000];
int dp[210000];
int use[210000];
int n;
int dfs(int a){
	if(~dp[a])return dp[a];
	if(a==n+1)return 0;
	int ret=mod;
	int at=0;
	for(int i=0;i<26;i++){
		int tmp=dfs(nx[a][i])+1;
		if(tmp<ret){
			ret=tmp;at=i;
		}
	}
	use[a]=at;
	return dp[a]=ret;
}
int main(){
	scanf("%s",in);
	n=strlen(in);
	for(int i=0;i<26;i++)tmp[i]=nx[n][i]=n+1;
	for(int i=n-1;i>=0;i--){
		tmp[in[i]-'a']=i+1;
		for(int j=0;j<26;j++)nx[i][j]=tmp[j];
	}
	for(int i=0;i<210000;i++)dp[i]=-1;

	dfs(0);
	int sz=0;
	int now=0;
	while(now<n+1){
		out[sz++]=use[now]+'a';
		now=nx[now][use[now]];
	}
	printf("%s\n",out);
}

Measured memory_bytes: 23040
function Main(input) {
  input = input.trim()
  input = input.split(" ");
  input= input[0]+input[1]+input[2]+"";
  input-=0;
if(input%4==0){
  console.log("YES")
}else{
console.log("NO")
}
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
macro_rules! input {
    ($t:ty) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty ;) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ; $n:expr) => {
        (0..$n).map(|_|
            input!($t)
        ).collect::<Vec<_>>()
    };
}

fn main(){
    let (a,op,b) = input!(isize,String,isize);
    println!("{}", if op=="+"{a+b}else{a-b});
}

Measured memory_bytes: 4352
n = int(input())
build = [[[0 for i in range(10)]for j in range(3)]for k in range(4)]
for i in range(n):
    b, f, r, v = list(map(int, input().split()))
    build[b-1][f-1][r-1] += v
for b in range(4):
    for f in range(3):
        for r in range(10):
            print("", build[b][f][r], end="")
        print()
    if b != 3: 
        print("####################")


Measured memory_bytes: 5636
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, k = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    P = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    P.sort()
    cnt=0

    for i in range(k):
        cnt += P[i]

    print(cnt)


resolve()

Measured memory_bytes: 62272
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 100100100100100;


int main() {
  ll A,B;
  cin >> A >> B;
  cout << max(A+B,max(A-B,A*B)) << endl;
}

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

int main()
{
	long long a, b;

	cin >> a >> b;
	if ((a - b) % 2 != 0) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		long long k;
		if (a < b) {
			k = a + (b - a) / 2;
		}
		else {
			k = b + (a - b) / 2;
		}
		cout << k << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define PI 3.14159265359
int main(void){
    int a,b,h,m;
    double k;
    scanf("%d%d%d%d",&a,&b,&h,&m);
    k = 30.0*h+m/12.0*6.0-m*6.0;
    printf("%.10lf",sqrt(a*a+b*b-2*a*b*cos(k*PI/180)));
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  if(a[0] != 0) {
    cout << -1 << endl;
    return 0;
  }
  rep(i, n-1) {
    if(i < a[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  ll ans = 0;
  for(int i = 1; i < n; ++i) {
    if(a[i]!=a[i-1]+1) {
      if(a[i] > a[i-1]+1) {
        cout << -1 << endl;
        return 0;
      }
      ans += a[i-1];
    }
  }
  ans += a[n-1];
  cout << ans << endl;
}

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

int main(void) {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  A--;
  B--;
  C--;
  D--;
  string S;
  cin >> S;
  S += "--";

  vector<bool> pathAC(N + 2, false);
  pathAC[A] = true;
  for (int i = A; i < C; ++i) {
    if (!pathAC[i]) continue;
    if (S[i + 1] == '.') pathAC[i + 1] = true;
    if (S[i + 2] == '.') pathAC[i + 2] = true;
  }

  vector<bool> pathBD(N + 2, false);
  pathBD[B] = true;
  for (int i = B; i < D; ++i) {
    if (!pathBD[i]) continue;
    if (S[i + 1] == '.') pathBD[i + 1] = true;
    if (S[i + 2] == '.') pathBD[i + 2] = true;
  }

  if (!pathAC[C] || !pathBD[D]) {
    cout << "No" << endl;
    return 0;
  }

  if (C > D) {
    bool swap = false;
    for (int i = B; i <= D; ++i) {
      if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
        swap = true;
        break;
      }
    }
    if (!swap) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc =new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int cou=0;
		for(int x = 0;x<=k;x++) {
			for(int y = 0; y <= k;y++) {
				if(s-x-y >=0 && s-x-y <=k) {
					cou++;
				}
			}
		}
		System.out.println(cou);
	}

}


Measured memory_bytes: 21588
#include <iostream>

using namespace std;

int main()
{
	int check[101] = { 0, };
	int n=0,N, D[101] = { 0, };
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		if (!check[tmp])
		{
			check[tmp] = 1;
			D[n++] = tmp;
		}
	}
	cout << n << endl;
	return 0;
	
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>

using namespace std;

int main()
{
	long long r, d;
	long long a;
	long long x;
	int i;

	scanf("%lld %lld %lld", &r, &d, &a);

	x = a;

	for (i = 0; i < 10; i++)
	{
		x = r*x - d;

		printf("%lld\n", x);
	}

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>          // printf(), scanf()
#include <math.h>           // fabs()

int
main(int argc, char **argv)
{
	int n;
	scanf("%d", &n);
	while (n--)
	{
		int h, m;
		scanf("%d:%d", &h, &m);
		double a1 = h * 360 / 12 + m * 30.0 / 60.0;
		double a2 = m * 360 / 60;
		double th = fabs(a1 - a2);

		if (th > 180)
			th = 360 - th;

		if (th < 30)
			printf("alert\n");

		else if (th < 90) // 30 <= th < 90 ?
			printf("warning\n");

		else // 90 <= th <= 180 ?
			printf("safe\n");
	}

	return 0;
}

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

int main () {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int attack;
  if (C%B == 0) attack = C/B-1;
  else attack = C/B;
  if (A <= D*attack) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll N,M;
  cin>>N>>M;
  map<ll,ll> S;
  for(ll i=0;i<N;i++) {
ll A;
    cin>>A;
    S[A]++;
  }
  
  for(ll i=0;i<M;i++) {
ll B,C;
    cin>>B>>C;
    S[C]+=B;
  }
  
  vector<pair<ll,ll>> vec(0);
  for(auto x:S) {
    vec.push_back(x);
  }

  sort(all(vec));
  reverse(all(vec));
  ll ans=0;
  ll count=0;
  ll i=0;
  while(count<N) {
    if(vec[i].second+count>N) {
ans+=vec[i].first*(N-count);
      break;
    }
ans+=vec[i].first*vec[i].second;
    count+=vec[i].second;
    i++;
  }

  cout<<ans<<endl;
}
  
  

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

ll MOD = 1e9+7;

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

    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> Ones(61, 0);

    auto modpow = [](ll a, ll n, ll mod) {
        ll res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    };

    rep(i, N) {
        rep(b, 61) {
            if (bitset<61>(A[i])[b] == 1) {
                Ones[b]++;
            }
        }
    }

    ll ans = 0;
    rep(i, 61) {
        ll p = (ll)modpow(2, i, MOD);
        ans += (Ones[i] * (N - Ones[i])) % MOD * p;
        ans %= MOD;
    }
    cout << (ll)ans << endl;
}

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

ll f(ll n, ll k, ll x) { return (n - x) / k + 1;}

int main() {
    ll n, k;
    cin >> n >> k;
    if (n * 3 < k) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    ans += (n / k) * (n / k) * (n / k);
    if (k % 2 == 0) {
        ll x = k / 2;
        ans += f(n, k, x) * f(n, k, x) * f(n, k, x);
    }
    cout << ans << endl;
}


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;
using P = pair<int,int>;

void Main()
{
  int N;
  cin >> N;
  vector<int> X(N), Y(N);
  rep(i,N) {cin >> X[i]; Y[i] = X[i];}
  sort(X.begin(), X.end());
  int right = X[N/2];
  int left = X[N/2-1];
  rep(i,N) {
    if (Y[i] <= left) cout << right << endl;
    else if (Y[i] >= right) cout << left << endl;
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define endl "\n" 
using namespace std;
#define debug(x) cout<<"The value of "<<#x<<" is "<<x<<endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    cin.sync_with_stdio(0); cin.tie(0); 
    char s;
    cin>>s;
    if(s>='A'&&s<='Z')
    cout<<"A"<<endl;
    else 
    cout<<"a"<<endl;
    
}


Measured memory_bytes: 3600
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

int main() {
    ll H, W;
    cin >> H >> W;
    
    if( H%3==0 || W%3==0 ){
        cout1(0);
        return 0;
    } else if(H==1 || W==1){
        cout1(1);
        return 0;
    }
    
    ll minv = H*W;
    ll ru = H/2, rl = H-ru;
    for(ll l=1,r=W-1; l < W ; l++,r--){
        minv = min( minv, abs(max(l*H,r*rl)-min(l*H,r*ru)));
    }
    
    swap(H,W);
    ru = H/2, rl = H-ru;
    for(ll l=1,r=W-1; l < W ; l++,r--){
        minv = min( minv, abs(max(l*H,r*rl)-min(l*H,r*ru)));
    }
    
    minv = min(minv,min(H,W));
    
    cout<<minv<<endl;
    
}

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

using namespace std;

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

  int n, x, t;
  cin >> n >> x >> t;
  cout << t * ((n + x - 1) / x);

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  if (n < 10) cout << n << endl;
  else if (n < 100) cout << 9 << endl;
  else if (n < 1000) cout << n - 90 << endl;
  else if (n < 10000) cout << 909 << endl;
  else if (n < 100000) cout << n - 9090 << endl;
  else cout << 90909 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void){
    int A,B;
    cin >> A >> B;
    int tmp = (A - B) < 0 ? (A - B) * (-1) : A - B;
    if (tmp > 1){
        tmp = A > B ? A + A - 1 : B + B - 1;
    }else{
        tmp = A + B;
    }
    cout << tmp << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);
    int diff1 = x > a ? x - a : a - x;
    int diff2 = x > b ? x - b : b - x;
    diff1 > diff2 ? puts("B") : puts("A");
    return 0;
}


Measured memory_bytes: 1636
#include <iostream>

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    using namespace std;
    int N;
    cin >> N;
    int plus_max = -2e9, minus_max = -2e9, plus_min = 2e9, minus_min = 2e9;
    for(int i = 0; i < N; i++){
        int A, B;
        cin >> A >> B;
        chmax( plus_max, A + B );
        chmax( minus_max, A - B );
        chmin( plus_min, A + B );
        chmin( minus_min, A - B );
    }
    cout << max( plus_max - plus_min, minus_max - minus_min ) << '\n';
}

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  string s = stin();
  string t = stin();
  bool flag = false;
  for(int i = s.size()-t.size(); i >= 0; --i) {
    bool flag2 = true;
    for(int j = 0; j < t.size(); ++j) {
      if(s[i+j] == '?') continue;
      if(s[i+j] == t[j]) continue;
      else {
        flag2 = false;
        break;
      }
    }
    if(flag2) {
      for(int j = 0; j < t.size(); ++j) {
        s[i+j] = t[j];
      }
      flag = true;
      break;
    }
  }
  if(!flag) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] == '?') cout << 'a';
    else cout << s[i];
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int,int> P;
int n,m;
char a[55][55];
int f[111][111];
int black;
int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};
signed main(){
	cin>>n>>m;
	rep(i,n)rep(j,m){
		cin>>a[i][j];
		black+=(a[i][j]=='#');
		f[i][j]=1145141919;
	}
	queue<P>q;
	q.push({0,0});
	f[0][0]=0;
	while(!q.empty()){
		P p=q.front();
		q.pop();
		rep(i,4){
			int x=p.first+dx[i];
			int y=p.second+dy[i];
			if(x<0||x>=n||y<0||y>=m||a[x][y]=='#')continue;
			if(f[x][y]>f[p.first][p.second]+1){
				f[x][y]=f[p.first][p.second]+1;
				q.push({x,y});
			}
		}
	}
	if(f[n-1][m-1]==1145141919)puts("-1");
	else cout<<n*m-f[n-1][m-1]-black-1<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	private static Scanner sc=new Scanner(System.in);
	
	public static void main(String[] args){
		int n=readInt();
		int t=readInt();
		int[] a=new int[n];
		HashMap<Integer,Integer> map=new HashMap<Integer,Integer>();
		for(int i=0;i<n;i++){
			a[i]=readInt();
			map.put(a[i],i);
		}
		int min=a[0];
		int diff=0;
		for(int i=1;i<n;i++){
			if(diff<a[i]-min)
				diff=a[i]-min;
			if(min>a[i])
				min=a[i];
		}
		int ans=0;
		for(int i=0;i<n;i++){
			Integer x=map.get(a[i]+diff);
			if(x!=null&&i<x)
				ans++;
		}
		System.out.println(ans);
	}
	
	private static int readInt(){
		return Integer.parseInt(sc.next());
	}
}

Measured memory_bytes: 52396
#include<cstdio>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		static bool t[1000][1440];
		int bless[1000]={},enter[1000]={},last[1000]={};

		int pre=-1;
		rep(k,n+1){
			int date,id;
			if(k<n){
				int mon,day,hh,mm;
				scanf("%d%*c%d %d%*c%d %*c %d",&mon,&day,&hh,&mm,&id);
				date=31*mon+day;

				if(enter[id]==0){
					enter[id]=60*hh+mm;
				}
				else{
					fill(t[id]+enter[id],t[id]+60*hh+mm,true);
					enter[id]=0;
				}
			}
			else{
				date=7777777;
			}

			if(pre!=date){
				rep(i,1000) if(last[i]==pre) rep(j,1440) if(t[i][j] && t[0][j]) bless[i]++;
				rep(i,1000) if(last[i]==pre) fill(t[i],t[i]+1440,false);
			}
			last[id]=pre=date;
		}

		printf("%d\n",*max_element(bless+1,bless+1000));
	}

	return 0;
}

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

int N;
char phone[9][6] = {".,!? ","abc","def","ghi","jkl", "mno", "pqrs", "tuv","wxyz"};

int main(){
  cin >> N;
  
  for(int i=0; i<N; ++i){
    char input[1025];
    cin >> input;
    char old = '0';
    int count = 0;
    for(int j=0; input[j] != '\0'; ++j){
      if(input[j] == '0'){
        if(old != '0'){
          if('2' <= old && old <= '6' || old == '8'){
            putchar(phone[old-'1'][(count-1)%3]);
          }
          else if(old == '1'){
            putchar(phone[old-'1'][(count-1)%5]);
          }
          else{
            putchar(phone[old-'1'][(count-1)%4]);
          }
        }
        old = input[j];
        count = 0;
      }else{
        old = input[j];
        count++;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1144
n,k=map(int,input().split())
num=list(map(int,input().split()))
a=[0]*n
for x in num:
    a[x-1]+=1
a=sorted(a)
for i in range(n):
    if a[i]!=0:
        del a[:i]
        break
ans=0
i=0
while len(a)-i>k:
    ans+=a[i]
    i+=1
print(ans)


Measured memory_bytes: 24996
import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        final int MOD = 1000000007;

        int n = sc.nextInt();
        HashMap<String, Long> map = new HashMap<>();
        for(int i=0;i<n;i++) {
            char[] c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            String s = new String(c);
            if(map.containsKey(s)) map.put(s, map.get(s) + 1);
            else map.put(s, 1L);
        }

        long ans = 0;
        for(long x : map.values()) {
            ans += (x*(x-1))/2;
        }
        pw.println(ans);
        pw.close();
    }
}


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

int main()
{
	string s;
	cin >> s;

	int ret = 0;
	int temp = 0;
	int n = s.size();
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			temp++;
		}
		else {
			if (ret < temp) {
				ret = temp;
			}
			temp = 0;
		}
	}

	if (ret < temp) {
		ret = temp;
	}


	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc147_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string r = string.Concat(s.Reverse());

            int change = 0;
            for (int i = 0; i < s.Length / 2; i++)
            {

                if (s[i] == r[i])
                {

                }
                else
                {
                    change++;
                }
            }
            Console.WriteLine(change);
            Console.Read();
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9 + 7;
const int INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    int n;cin>>n;
    for(int i=0;i<n;i++){
        if(i*100<=n and i*105>=n){
            cout<<"1"<<endl;
            return 0;
        }
    }
    cout<<"0"<<endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)
s="L"+s+"R"
res=[0 for i in range(n+2)]
for i in range(1,n+1):
    if s[i]=="R" and s[i+1]=="L":
        rcnt=0
        j=i
        while(s[j]=="R"):
            rcnt+=1
            j-=1
        lcnt=0
        j=i+1
        while(s[j]=="L"):
            lcnt+=1
            j+=1
        res[i]=(rcnt+1)//2+lcnt//2
        res[i+1]=rcnt//2+(lcnt+1)//2
for i in range(1,n+1):
    print(res[i],end=" ")

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

int main() {
	int N;
	cin >> N;
	unsigned long int result=0;

	for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			result += i;
		}
	}

	cout << result;

	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

long long INF=numeric_limits<long long>::max();

char grid[10][10];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int h,w,total(0);
    cin >> h >> w;
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            cin >> grid[i][j];
            if(grid[i][j]=='#')total++;
        }
    }
    if(total==h+w-1&&grid[0][0]=='#')cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := make([]int, N+2)
	A[0] = 0
	for i := 1; i <= N; i++ {
		A[i] = sc.nextInt()
	}
	A[N+1] = 0
	S := make([]int, N+1)
	S[0] = abs(A[0] - A[1])
	for i := 1; i <= N; i++ {
		S[i] = S[i-1] + abs(A[i]-A[i+1])
	}
	for i := 1; i <= N; i++ {
		var total int
		if 2 <= i && i <= N-1 {
			total = S[N] - S[i] + S[i-2] + abs(A[i-1]-A[i+1])
		} else if i == 1 {
			total = S[N] - S[i] + abs(A[i-1]-A[i+1])
		} else {
			total = S[N-2] + abs(A[i-1]-A[i+1])
		}
		fmt.Fprintln(wtr, total)
	}

	wtr.Flush()
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
const double eps=1e-7;
typedef long long ll;
const ll maxx=2e5+10;
const ll mod=1e9+7;
const ll inf=0x3f3f3f3f;
char s[maxx];
unordered_map<string,int > mp;
int main(){
    int n; cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%s",s+1);
        int m=strlen(s+1);
        string x="";
        for(int j=1;j<=m;j++) x+=s[j];
        mp[x]++;
    }
    int ans=0;
    for(auto t:mp){
        ans=max(ans,t.second);
    }
    vector<string> res;
    for(auto t:mp){
        if(t.second==ans) res.push_back(t.first);
    }
    sort(res.begin(),res.end());
    for(auto t:res)
    {
        for(int i=0;i<t.size();i++)
            printf("%c",t[i]);

        puts("");
    }
}


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

const int DIM = 2e5 + 5;

int col[2][DIM], aux[2];

vector<int> edg[2][DIM];
map<pair<int, int>, int> mmp;

void dfs( int x, int k, int p ) {
    col[p][x] = k;
    
    for( int y : edg[p][x] )
        if( col[p][y] == 0 )
            dfs( y, k, p );
    
    return;
}

int main( void ) {
  
    int n;
    cin >> n >> aux[0] >> aux[1];
    
    for( int p = 0; p <= 1; p ++ ) {
        for( int i = 1; i <= aux[p]; i ++ ) {
            int x, y;
            cin >> x >> y;
        
            edg[p][x].push_back( y );
            edg[p][y].push_back( x );
        }
    }
    
    aux[0] = aux[1] = 0;
    for( int p = 0; p <= 1; p ++ ) {
        for( int i = 1; i <= n; i ++ ) {
            if( col[p][i] == 0 )
                dfs( i, ++ aux[p], p );
            if( p == 1 )
                mmp[make_pair( col[0][i], col[1][i] )] ++;
        }
    }
    
    for( int i = 1; i <= n; i ++ )
        cout << mmp[make_pair( col[0][i], col[1][i] )] << " ";
    cout << endl;

    return 0;
}

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

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

	int ans = 1;
	N -= K;
	while( N > 0 ) {
		ans++;
		N -= K - 1;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define ll long long 
#define hell 1000000007
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll int i = a;i<b;i++)
#define pi 3.1415926536
#define Mod 998244353
#define endl '\n'
//char a[2000][2000];
using namespace std;
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);            
    //std::setprecision(20);    
    int tests=1;
      //freopen("input.txt", "r", stdin);   
    //cin>>tests;
  while(tests--)
    { 
        int n;
        cin>>n;
        vector<pair<ll,ll> > v(n);
        for(int i =0;i<n;i++){
            cin>>v[i].S>>v[i].F;
        }
        sort(all(v));
        for(int i = 0;i<n;i++){
            swap(v[i].F,v[i].S);
        }
        ll ans = 0;
        //for(int i = 0;i<n;i++)
          //cout<<v[i].F<<" "<<v[i].S<<endl;
        for(int i = 0;i<n;i++){
            if(ans+v[i].F <= v[i].S){
                ans = ans + v[i].F;
                continue;
            }
            else{
                cout<<"No";
                exit(0);
            }
        }
       // cout<<ans;
        cout<<"Yes";
    }
}


Measured memory_bytes: 3456