akhauriyash/Code-Regression huggingface dataset:
# https://raw.githubusercontent.com/cheran-senthil/PyRival/master/pyrival/data_structures/SegmentTree.py


class SegmentTree:
    def __init__(self, data, default=0, func=max):
        """initialize the segment tree with data"""
        self._default = default
        self._func = func
        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()

        self.data = [default] * (2 * _size)
        self.data[_size : _size + self._len] = data
        for i in reversed(range(_size)):
            self.data[i] = func(self.data[i + i], self.data[i + i + 1])

    def __delitem__(self, idx):
        self[idx] = self._default

    def __getitem__(self, idx):
        return self.data[idx + self._size]

    def __setitem__(self, idx, value):
        idx += self._size
        self.data[idx] = value
        idx >>= 1
        while idx:
            self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
            idx >>= 1

    def __len__(self):
        return self._len

    def query(self, start, stop):
        """func of data[start, stop)"""
        start += self._size
        stop += self._size

        res_left = res_right = self._default
        while start < stop:
            if start & 1:
                res_left = self._func(res_left, self.data[start])
                start += 1
            if stop & 1:
                stop -= 1
                res_right = self._func(self.data[stop], res_right)
            start >>= 1
            stop >>= 1

        return self._func(res_left, res_right)

    def __repr__(self):
        return "SegmentTree({0})".format(self.data)


N, K = [int(x) for x in input().split()]
LR = [[int(x) for x in input().split()] for i in range(K)]

MOD = 998244353
numWays = SegmentTree([0 for i in range(N + 1)], 0, lambda x, y: x + y)
numWays[1] = 1

for i in range(2, N + 1):
    total = 0
    for l, r in LR:
        if i - l >= 0:
            total += numWays.query(max(0, i - r), i - l + 1)
    numWays[i] = total % MOD


print(numWays[N])


Measured memory_bytes: 85144
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "begin", long, "end");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, m;
    scan(n, m);
    if(n == m)
        writeln("Yes");
    else
        writeln("No");
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

int main() {
    int n; cin >> n;
    vector<int> x(n);
    vector<int> sorted(n);

    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        x[i] = a;
        sorted[i] = a;
    }
    sort(sorted.begin(), sorted.end());

    for (int i = 0; i < n; ++i) {
        int mid = n / 2 - 1;
        mid += x[i] <= sorted[mid];
        cout << sorted[mid] << endl;
    }
}



Measured memory_bytes: 4812
package main

import "fmt"

func main() {
	var N, M, X int
	fmt.Scan(&N, &M, &X)
	A := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&A[i])
	}
	var l, r int
	for i := 0; i < M; i++ {
		if A[i] < X {
			l++
		} else {
			r++
		}
	}
	if l < r {
		fmt.Println(l)
	} else {
		fmt.Println(r)
	}
}


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

using namespace std;
#define endl "\n"

const int MOD = 1000000007;
int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] << endl;	
	
	return 0;
}

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

int main() {
    int n;  cin >> n;
    string s;   cin >> s;
    int *r = new int[n], *l = new int[n]; //i番目の人がリーダーだった時、動く人数
    l[0] = 0; 
    r[n-1] = 0;

    for (int i = 0; i < n-1; i++) {
        if (s[i] == 'W')
            l[i+1] = l[i]+1;
        else 
            l[i+1] = l[i];
        if (s[n-1-i] == 'E')
            r[n-2-i] = r[n-1-i]+1;
        else 
            r[n-2-i] = r[n-1-i];
    }

    int ans = n;
    for (int i = 0; i < n; i++) {
        ans = min(l[i]+r[i], ans);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;

int main(){

    int S;
    cin >> S;
    int ans = S;

    int res1 = ans / 100;
    if(res1 == 9){
        cout << 1;
        ans -= res1*100;
    }else{
        cout << 9;
        ans -= res1*100; 
    }

    int res2 = ans / 10;
    if(res2 == 9){
        cout << 1;
        ans -= res2*10;
    }else{
        cout << 9;
        ans -= res2*10; 
    }

    int res3 = ans / 1;
    if(res3 == 9){
        cout << 1;
        ans -= res3*1;
    }else{
        cout << 9;
        ans -= res3*1; 
    }
    cout << endl;

}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod=1e9+7;

int64_t N;
int64_t powmod(int64_t x){
  int64_t res=1;
  for(int i=0;i<N;i++){
    (res*=x)%=mod;
  }
  return res;
}
int main() {
  cin>>N;
  int64_t ans=powmod(10)-powmod(9)-powmod(9)+powmod(8);
  ans%=mod;
  ans=(ans+mod)%mod;
  cout<<ans<<endl;
  return 0;
}

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

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

int main(void)
{
    ll n;
    cin >> n;
    vector<ll> arr;
    arr.reserve(100000);
    rep (i, n) {
        ll a;
        cin >> a;
        a = -a;
        if (arr.empty()) {
            arr.push_back(a);
            continue;
        }
        auto pos = upper_bound(arr.begin(), arr.end(), a); // a 以上の要素で最小

        if (pos == arr.end()) {
            arr.push_back(a);
        } else {
            *pos = a;
        }
    }
    cout << arr.size() << endl;
    return 0;
}


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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

// ----------------------------------------------

ll sumOfDigits(ll n) {
  if (n < 10) return n;
  return sumOfDigits(n / 10) + n % 10;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll a;
  cin >> a;

  ll b = a % sumOfDigits(a);

  if (b == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
void secondsort(vector<pair<int, int>> &x) {
	sort(x.begin(), x.end(), [](pair<int, int> &a, pair<int, int> &b) {return a.second < b.second; });
}
int main() {
	cin >> N >> C;
	vector<pair<int, int>> p(N);
	vector<int>c(N);
	set<pair<int, int>> set;
	int maxt = 0;
	for (int i = 0; i < N; i++) {
		cin >> p[i].first >> p[i].second >> c[i];
		maxt = max(maxt, p[i].second);
	}
	for (int i = 0; i < N; i++) {
		set.insert({ p[i].second, c[i] });
	}
	for (int i = 0; i < N; i++) {
		if (set.count({ p[i].first,c[i] }))p[i].first++;
	}
	vector<int>s( maxt + 1,0), t(maxt + 1,0);
	for (int i = 0; i < N; i++) {
		s[p[i].first]++;
	}
	vector<int>sums(maxt + 1,0);
	for (int i = 1; i <= maxt; i++) {
		sums[i] = sums[i - 1] + s[i];
	}
	secondsort(p);
	for (int i = 0; i < N; i++) {
		ll tmp = sums[p[i].second] - i;
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8192
import sys
n=int(input())
list=input()
if len(list)%2==1:
    print("No")
    sys.exit()
else:
    for i in range(0,int(n/2)):
        if list[i]==list[int(i+n/2)]:
            a=1
        else:
            print("No")
            sys.exit()
print("Yes")

Measured memory_bytes: 3060
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int m = sc.NextInt();
        var imos = new int[n + 1];
        for (int i = 0; i < m; i++)
        {
            int l = sc.NextInt() - 1;
            int r = sc.NextInt();
            imos[l]++;
            imos[r]--;
        }

        for (int i = 0; i < n; i++)
        {
            imos[i + 1] += imos[i];
        }

        Console.WriteLine(imos.Count(num => num >= m));
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 42860
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	var cnt int
	for i := 0; i < 3; i++ {
		str1 := s[i : i+1]
		str2 := t[i : i+1]

		if str1 == str2 {
			cnt++
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	
	int A[10];
	
	while( cin >> A[0] ) {
		
		for(int i=1;i<10;i++)
		cin >> A[i];
			
		sort(A,A+10);
		
		for(int i=9;i>6;i--)
		cout << A[i] << "\n";
		
	}
		
	return 0;
}


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

money = 1000
stock = 0
for i in range(N-1):
    # print(money, stock)
    if A[i] < A[i+1]:
        # 明日あがるなら買えるだけ買う
        buy = money // A[i]
        stock += buy
        money -= A[i] * buy
    elif A[i] == A[i+1]:
        # 変わらないなら何もしない
        pass
    else:
        # 明日下がるなら全部売る
        sell = stock
        stock = 0
        money += A[i] * sell

sell = stock
stock = 0
money += A[-1] * sell

print(money)


Measured memory_bytes: 61976
#include<iostream>
#include<vector>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<long long>dam(N);
  for (int i = 0; i < N; i ++) cin >> dam[i];
  long long k = 0;
  for (int i = 0; i < N; i ++) {
    if (i % 2) k -= dam[i];
    else k += dam[i];
  }
  cout << k;
  for (int i = 0; i < N - 1; i++) {
    k = (dam[i] - k / 2) * 2;
    cout << ' ' << k;
  }
  cout << endl;
}



Measured memory_bytes: 2048
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N=s.nextInt();
        int bit=1000000007;
        for(int i=0;i<N;i++){
            int x = s.nextInt();
            bit=Math.min(bit,Integer.lowestOneBit(x));
        }
        
        System.out.println((int)(Math.log(bit)/Math.log(2)));
    }  
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)

ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}

int main(){
	ll n;
	cin>>n;
	vector<ll> a(n);
	vector<ll> b(n);
	
	rep(i,0,n) cin>>a[i];
	rep(i,0,n) cin>>b[i];
	ll idx = n-1;
	rep(i,0,n){
		
		
		if(a[i]==b[i]){
			if(idx<=i) idx = n-1;
			if(a[i]==b[idx]) idx = n-1;
			swap(b[i],b[idx]);
			idx--;
			
		}
	
		/*if(a[i] = b[idx]){
			idx = n-1;
		}*/
/*		cout<<i<<endl;
		rep(i,0,n) cout<<b[i]<<" ";
		cout<<endl;*/
	}
	
	idx = 0;
	rep(i,0,n){
		
		
		if(a[i]==b[i]){
			if(a[i]==b[idx]) idx = 0;
			swap(b[i],b[idx]);
			idx++;
			
		}
	
		/*if(a[i] = b[idx]){
			idx = n-1;
		}*/
		/*cout<<i<<endl;
		rep(i,0,n) cout<<b[i]<<" ";
		cout<<endl;*/
	}
	
	
	ll f = 0;
	rep(i,0,n){
		if(a[i]==b[i]) f=1;
	}
	
	if(f) cout<<"No";
	else{
		cout<<"Yes"<<endl;
		rep(i,0,n) cout<<b[i]<<" ";
		
	}
	
	
}

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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;

const ll maxN = 1'000'000'000'000'000'000;


template <typename T>
vector<T> getValues(int num){
    vector<T> values(num);
    for(int i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

ll culSum(vector<ll> inputs){
  ll ret = 1;
  rep(i,inputs.size()){
    if(inputs.at(i)==0){
      return 0;
    }
  }
  rep(i,inputs.size()){
    if(inputs.at(i) <= maxN/ret){
        ret *= inputs.at(i);
    }else{
      return -1;
    }
  }
  return ret;
}

int main(){
    int N;
    cin >> N;
    auto inputs = getValues<ll>(N);
    printl(culSum(inputs));
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int,int> P;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

mat func(mat &a,int x,int y){
  int d[21][4][4][4]={};
  
  mat res=a;
  res[x][y]++;
  if(res[x][y]<5)return res;
  res[x][y]=0;
  for(int i=0;i<4;i++)d[0][i][x][y]=1;
  
  for(int T=0;T<20;T++){
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
        if(res[i][j]==0){
          for(int k=0;k<4;k++){
            if(i+dx[k]<0||j+dy[k]<0)continue;
            if(i+dx[k]>3||j+dy[k]>3)continue;
            d[T+1][k][i+dx[k]][j+dy[k]]=d[T][k][i][j];
          }
        }else{
          int cnt=0;
          for(int k=0;k<4;k++)cnt+=d[T][k][i][j];
          res[i][j]+=cnt;
          if(res[i][j]>4){
            res[i][j]=0;
            for(int k=0;k<4;k++){
              if(i+dx[k]<0||j+dy[k]<0)continue;
              if(i+dx[k]>3||j+dy[k]>3)continue;
              d[T+1][k][i+dx[k]][j+dy[k]]=true;
            }
          }
        }
      }// j
    }// i
  }// T
  return res;
}
bool check(mat &a){
  for(int i=0;i<4;i++)
    for(int j=0;j<4;j++)
      if(a[i][j])return false;
  return true;
}

int main(){
  mat a(4,vec(4));
  for(int i=0;i<4;i++)
    for(int j=0;j<4;j++)
      cin>>a[i][j];


  queue< mat > Q;
  map< mat , int > d;
  d[a]=0;
  Q.push(a);
  int ans=-1;
  while(!Q.empty()){
    mat p=Q.front();Q.pop();
    int cost=d[p];


    
    if(check(p)){ans=cost;break;}
    if(cost==5)continue;
    
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
        if(p[i][j]==0)continue;
        mat next=func(p,i,j);
        if(d.count(next))continue;
        d[next]=cost+1;
        Q.push(next);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 11608
from sys import stdin
from itertools import repeat
def main():
    n = int(stdin.readline())
    dp = [1] * (n + 1)
    a = map(int, stdin, repeat(10, n))
    d = {}
    for i, x in enumerate(a):
        dp[i+1] = dp[i]
        if x in d and d[x] < i:
            dp[i+1] += dp[d[x]]
            if dp[i+1] >= 1000000007:
                dp[i+1] -= 1000000007
        d[x] = i + 1
    print dp[-1]
main()


Measured memory_bytes: 33208
import java.util.*;

public class Main {
	public static void main(String args[] ){
	    Scanner sc = new Scanner(System.in);
	    int s = sc.nextInt();
	    int h, m;
	    h = s / 3600;
	    m = s % 3600 / 60;
	    s = s % 60;
	    System.out.println(h+":"+m+":"+s);
	}
}



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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    for(int is=0;is<s.size();is++) {
        if(s.at(is)==',') cout << " ";
        else cout << s.at(is);
    }
    cout << endl;
    return 0;
}


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

int main()
{
  std::string S;
  std::cin >> S;
  
  int c = -1, f = -1;
  for(unsigned i=0; i<S.size(); ++i)
  {
    if((c < 0) && (S[i] == 'C')) c = i;
    if(S[i] == 'F') f = i;
  }
  
  if(c < 0 || f < 0)
  {
    std::cout << "No" << std::endl;
  }
  else if(c < f)
  {
    std::cout << "Yes" << std::endl;
  }
  else
  {
    std::cout << "No" << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
s = input()
tmp = 0
test1 = int(s[0]+s[1])
test2 = int(s[2]+s[3])

if test2 > 0 and test2 <= 12:
    #YYMM
    tmp += 1
if test1 > 0 and test1 <= 12:
    tmp += 2
if tmp == 3:
    print("AMBIGUOUS")
elif tmp == 2:
    print("MMYY")
elif tmp == 1:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
from numba import njit,i8,b1


# @njit(b1[:](i8,i8,b1[:]))
@njit
def sieve(N,A,dp):
    for i in range(N):
        now = A[i]
        M = A[-1] // now
        for j in range(2,M+1):
            dp[now*j-1] = False
    return dp


# @njit(i8(i8,i8,b1[:]))
@njit
def cnt(N,A,dp):
    skip = 0
    res = 0
    for i in range(N):
        now = A[i]
        if skip == now:
            continue
        if i != N - 1:
            if now == A[i+1]:
                skip = now
                continue
        if dp[now-1]:
            res += 1
    return res


def main():
    N = int(input())
    A = list(map(int,input().split()))

    A = sorted(A)
    A = np.array(A)

    dp = np.array([True for i in range(A[-1])])
    # print(dp)
    dp = sieve(N,A,dp)
    # print(dp)

    res = cnt(N,A,dp)

    print(res)



main()


Measured memory_bytes: 113564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    
    int cnt=0;
    rep(i,n-1){
        if(s[i]==s[i+1]) cnt++;
    }

    cout<<min(cnt+2*k,n-1)<<endl;
}



Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    Out((N - 1) / 2);

    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std; 
bool sortbysec(const pair<long long int,long long int> &a, 
              const pair<long long int,long long int> &b) 
{ 
    return (a.second < b.second); 
} 
  
int main(){
    long long int N,W,w,v;
    cin>>N>>W;
    vector<pair<long long int,long long int>>vp;
    long long int sum=0;
    vp.push_back(make_pair(0,0));
    for(int i=0;i<N;i++)
    {
        cin>>w>>v;
        sum+=v;
        
        
        vp.push_back(make_pair(w,v));
    }
    long long int dp[N+1][sum+1];
    for(int i=0;i<=N;i++)
        for(int j=0;j<=sum;j++)
        dp[i][j]=1000000000;
        
    sort(vp.begin(),vp.end(),sortbysec);
   
    for(int i=1;i<=N;i++)
    {
        for(int j=1;j<=sum;j++)
        
        {
            if(j-vp[i].second>=0)
            
            dp[i][j]=min(dp[i][j],dp[i-1][j-vp[i].second]+vp[i].first);
            
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
            if(j==vp[i].second)
            dp[i][j]=min(dp[i][j],vp[i].first);
        
        }
    }
    // cout<<dp[1][30]<<"\n";
    long long int ans=0;
    for(long long int i=1;i<=sum;i++)
    {
        if(dp[N][i]<=W)
        ans=max(i,ans);
    }
    cout<<ans;
    
}

Measured memory_bytes: 82356
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
typedef long long ll;

int n,m,k;
string s,t;

int main() {
  cin >> n;
  ll a[200005];
  rep(i,n) cin >> a[i];
  ll sum[200005];
  for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i-1];
  ll ans=1e16;
  for(int i=1;i<n;i++){
    chmin(ans,abs(sum[i]-(sum[n]-sum[i])));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <assert.h>
#include <iostream>

using namespace std;

int min(int a, int b){
    return a < b ? a : b;
}

int max(int a, int b){
    return a > b ? a : b;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while (a && c)
    {
        c-=b;
        if (c <=0) break;
        a-=d;
        if (a <= 0) break;
    }
    
    cout << (c<=0 ? "Yes\n":"No\n");

    return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> A(n);
  rep(i, n) cin >> A[i];
  ll x = 0LL;
  int keta = 0;
  while((k >> keta) > 0) keta++;
  while(keta > 0) {
    keta--;    // 0-base indexing
    int cnt1 = 0;
    rep(i, n) if((A[i] >> keta) & 1) cnt1++;
    if(cnt1 < n / 2 + 1 && x + (1LL << keta) <= k)
      x += (1LL << keta);
  }
  ll ans = 0LL;
  rep(i, n) ans += A[i] ^ x;
  cout << ans << endl;
  return 0;
}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,cys;
ll d[6005][2005],inv[6005];

ll mod(ll x){return x>=cys?x-cys:x;}

ll qpow(ll x,ll p){
	ll ret=1;
	for(;p;p>>=1,x=x*x%cys) if(p&1) ret=ret*x%cys;
	return ret;
}

int main(){
	n=readint()*3; cys=readint();
	inv[0]=1;
	for(int i=1;i<=n;i++) inv[i]=qpow(i,cys-2);
	d[0][0]=1;
	ll ans=0;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n/3;j++){
			d[i][j]=d[i][j]*inv[i]%cys;
			if(i==n) ans=mod(ans+d[i][j]);
			for(int k=i+1;k<=i+3&&k<=n;k++)
				d[k][j+(k-i>=2)]=mod(d[k][j+(k-i>=2)]+d[i][j]);
		}
	}
	for(int i=1;i<=n;i++) ans=ans*i%cys;
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 2e5+10;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int n , k , a[maxn];
int b[maxn];
int prt[maxn];

bool chk(){
    bool oke = 1;
    for(int i = 1 ; i <= n ; i ++){
        if(a[i]!=prt[i])
            oke = 0;
        a[i] = prt[i];
    }
    return(oke);
}

void solve(){
    ms(prt , 0);
    for(int i = 1 ; i <= n ; i ++){
        prt[max(0 , i-a[i])]++;
        prt[min(200005 , i+a[i]+1)]--;
    }
    for(int i = 1 ; i <= n ; i ++)
        prt[i] = prt[i-1]+prt[i];
}

int main(){
    migmig
    cin >> n >> k;
    for(int i = 1 ; i <= n ; i ++)
        cin >> a[i];
    for(int i = 0; i < k ; i ++){
        solve();
        if(chk())break;
    }
    for(int i = 1 ; i <= n ; i ++)cout << a[i] << ' ';
    return(0);
}

Measured memory_bytes: 5212
<?php
fscanf(STDIN, "%d%d", $n, $k);
define("MOD", 10**9+7);
 
nCmBuild($n);
for($i=1; $i <= $k; $i++) { 
	echo nCm($n-$k+1, $i) * nCm($k-1, $i-1) % MOD, "\n";
}

function nCmBuild($n){
  global $pascal;
  $pascal[0][0] = 1;
  for($j = 1; $j <= $n; $j++){
    for($i = 0; $i <= $j; $i++){
      $pascal[$j][$i] = 0;
      $pascal[$j][$i]+=$pascal[$j-1][$i-1] ?? 0;
      $pascal[$j][$i]+=$pascal[$j-1][$i] ?? 0;
      $pascal[$j][$i] %= MOD;
    }
  }
}
function nCm($n, $m){
  global $pascal;
  if($m>$n)return 0;
  if($n<0)return 0;
  return $pascal[$n][$m];
}


Measured memory_bytes: 96760
#include<bits/stdc++.h>
using namespace std;
#define M 100000007
typedef pair<int,int> P;
int main(void){
	int n,m;
	while(1){
		cin>>n>>m;
		if(n==0)break;
		int rin[n+1][n+1];
		for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) rin[i][j]=M;
		for(int i=0;i<m;i++){
			int a,c,d,e;
			cin>>a;
			if(a==1){
				cin>>c>>d>>e;
				if(rin[c][d]>e) rin[c][d]=e;
				if(rin[d][c]>e) rin[d][c]=e;
			} else {
				cin>>c>>d;
				int leng[n+1],f[n+1];
				fill(leng,leng+n+1,M); fill(f,f+n+1,0);
				leng[c]=0;
				for(int l=0;l<n;l++){
					int mi=M,v;
					for(int j=1;j<=n;j++){
						if(f[j]==0&&mi>leng[j]){
							mi=leng[j];
							v=j;
						}
					}
					f[v]=1;
					for(int j=1;j<=n;j++){
						int x=rin[v][j];
						if(x!=M){
							if(leng[j]>(leng[v]+x))leng[j]=leng[v]+x;
						}
					}
				}
				if(leng[d]!=M) cout<<leng[d]<<endl;
				else cout<<-1<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3028
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n, a, b int

	fmt.Scan(&n, &a, &b)

	answer := 0
	ch := make(chan int, 1024)

	for i := 1; i <= n; i++ {
		go sum(i, a, b, ch)
	}

	for i := 1; i <= n; i++ {
		answer += <-ch
	}

	fmt.Println(answer)
}

func sum(i int, a int, b int, ch chan int) {
	iStr := strconv.Itoa(i)
	splitedIStr := strings.Split(iStr, "")

	sum := 0
	for _, j := range splitedIStr {
		jInt, _ := strconv.Atoi(j)
		sum += jInt
	}

	if (a <= sum) && (sum <= b) {
		ch <- i
	} else {
		ch <- 0
	}
}


Measured memory_bytes: 30204
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int n;
  cin >> n;

  int ans = 0;
  int v[22];
  int c[22];

  for (int i = 0; i < n; ++i) cin >> v[i];
  for (int i = 0; i < n; ++i) cin >> c[i];

  for(int i = 0; i < n; ++i)
    if (v[i] > c[i]) ans += v[i] - c[i];

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
using namespace std;

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<int>> vvint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(int i=0;i<n;i++)
#define repf(i,f,n) for(int i=f;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())



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


int main() {


  int a,b,c;
  cin >> a >> b >> c;

  bool ans;

  ans = a==b && b==c;

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;

}

















//


Measured memory_bytes: 256
#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#ifdef DEBUG
    #include "debug.hpp"
#endif

using namespace std;

#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back


#ifdef DEBUG
    #define debug(x...) {dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals);}
    #define light_debug(x) {dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0;}
#else
    #define debug(x...)
    #define light_debug(x) 
#endif


using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;


signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    #ifdef DEBUG
        freopen("debug", "w", stderr);
    #endif
    
    int N;
    cin >> N;
    set<int> W;
    set<int, greater<int>> R;
    R.insert(0), W.insert(N + 1);
    rep1(i, N){
        char c;
        cin >> c;
        if(c == 'W')
            W.insert(i);
        else
            R.insert(i);
    }   

    int ans = 0;

    while(!R.empty() && !W.empty() && *R.begin() > *W.begin())
        R.erase(R.begin()), W.erase(W.begin()), ans++;

    cout << ans << '\n';
    #ifdef DEBUG
        dbg::dout << "\nExecution time: " << clock() << "ms\n";
    #endif

    return 0;
}

Measured memory_bytes: 13020
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;
const ll maxn=1e5+10;
ll n,k,a[maxn],b[maxn],ans;

void dfs(ll pos,ll x,bool top){
	if(top&&pos>=0){
		if(k&(1ll<<pos)){
			dfs(pos-1,x^(1ll<<pos),0);
			dfs(pos-1,x,1);
		}
		else
			dfs(pos-1,x^(1ll<<pos),1);
	}
	else{
		ll res=0;
		for(ll i=1;i<=n;++i)
			if((a[i]&x)==a[i])
				res+=b[i];
		if(ans<res)ans=res;
	}
}

int main(){
	scanf("%lld%lld",&n,&k);
	for(ll i=1;i<=n;++i)
		scanf("%lld%lld",&a[i],&b[i]);
	dfs(30,-1,1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e4+5;
int a[maxn];

int main(){
  for(int x=1;x<=100;x++)
    for(int y=1;y<=100;y++)
      if(y>=x)
      for(int z=1;z<=100;z++)
      if(z>=y){
        int num=x*x+y*y+z*z+x*y+y*z+x*z;
          if(num<=1e4){
      if(x==y&&y==z)
        a[num]+=1;
        else if(x==y||y==z||z==x)
          a[num]+=3;
        else
          a[num]+=6;
          }
      }
   int n;cin>>n;
  for(int i=1;i<=n;i++)
    cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 3556
#include <iostream>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  
  int R[10] = { };
  int high = 0;
  for(int i = 0; i < N; i++) {
   	int r;
    cin >> r;
   	if(r >= 3200) high++;
    else R[r / 400]++;
  }
  
  int cln = 0;
  for(int i = 0; i < 8; i++) {
    cln += (R[i] > 0);
  }
  
  if(cln == 0) cout << 1 << ' ';
  else cout << cln << ' ';
  
  cout << (high + cln) << endl;
  
  return 0;
}
  
    

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();

		if(!(e-a>k)) {
			System.out.print("Yay!");
		} else {
			System.out.print(":(");
		}
	}
}

Measured memory_bytes: 21588
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll x = in();
	ll foo = 0;
	REP1(i, x) {
		foo += i;
		if (foo >= x) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#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 int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	int x[n], y[n];
	for(int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		int t = x[i];
		x[i] = t + y[i];
		y[i] = t - y[i];
	}
	sort(x, x + n);
	sort(y, y + n);
	cout << max(abs(x[n - 1] - x[0]), abs(y[n - 1] - y[0]));

	return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int used[2100][2100]={};

int bfs(){

}

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int w=tx-sx;
    int h=ty-sy;

    rep(i,h)cout<<"U";
    rep(i,w)cout<<"R";

    rep(i,h)cout<<"D";
    rep(i,w)cout<<"L";

    cout<<"L";
    rep(i,h+1)cout<<"U";
    rep(i,w+1)cout<<"R";
    cout<<"DR";

    rep(i,h+1)cout<<"D";
    rep(i,w+1)cout<<"L";

    cout<<"U";

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout<<ans<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    return 0;
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n+5];
    double sum=0.0,mx=0.0;
    for(int i=1;i<=n;i++)cin>>a[i];

    for(int i=1;i<=k;i++){
            double sum1=((double)a[i]+1.0)/2;
        sum+=sum1;;
    }
        int j=1;
        mx=max(mx,sum);
        for(int i=k+1;i<=n;i++)
        {
            double ab=((double)a[j]+1.0)/2;
             double ba=((double)a[i]+1.0)/2;
             sum-=ab;
             sum+=ba;
             mx=max(mx,sum);
             j++;

        }
    printf("%.12lf\n",mx);
    return 0;
}


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

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

	if(n<=111) cout << 111 << endl;
	else if(n<=222) cout << 222 << endl;
	else if(n<=333) cout << 333 << endl;
	else if(n<=444) cout << 444 << endl;
	else if(n<=555) cout << 555 << endl;
	else if(n<=666) cout << 666 << endl;
	else if(n<=777) cout << 777 << endl;
	else if(n<=888) cout << 888 << endl;
	else if(n<=999) cout << 999 << endl;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    k <- getInt
    x <- getInt
    y <- getInt
    print . sum . take n $ (replicate k x) ++ [y,y..]

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

int main() {
	double A, B, C, D, E, F;
	double ansW = 0.0, ansS = 0.0, ansD = 0.0, Water = 0.0, Suger = 0.0, Density = 0.0;
	cin >> A >> B >> C >> D >> E >> F;
	for (int a = 0; a <= 30; a++) {
		if (A * a * 100 > F) break;
		for (int b = 0; b <= 30; b++) {
			Water = (A * a + B * b) * 100;
			if (Water > F) break;
			for (int c = 0; c <= F; c++) {
				if (Water + C * c > F) break;
				for (int d = 0; d <= F; d++) {
					Suger = C * c + D * d;
					if (Water + Suger > F) break;
					Density = Suger / (Water + Suger);
					if (Density * 100 >= ansD && Density <= E / (100 + E)) {
						ansD = Density * 100;
						ansW = Water, ansS = Suger;
					}
				}
			}
		}
	}
	cout << ansW + ansS << " " << ansS;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> H(N+1);
    for ( int i = 1; i <= N; ++i){
        cin >> H.at(i);
    }
    H.at(0) = -10;
    
    bool ans = true;
    
    for ( int i = 0; i < N; ++i){
        if ( H.at(i) < H.at(i+1) ){
            H.at(i+1) = H.at(i+1) - 1;
        } else if ( H.at(i) > H.at(i+1) ) {
            ans = false;
        }
    }
    
    if ( ans ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize ("-Ofast")
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(a) (long long)a.size()
#define all(a) a.begin(), a.end()
#define reset(a, n) a.clear(), a.resize(n)
#ifndef ONLINE_JUDGE
#define cin ___in
#endif
std::ifstream ___in("input.in");
using namespace std;
using ll = long long;
typedef pair<ll, ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > vvec;
typedef vector<pair<ll, ll> > vecpi;
typedef vector<vector<pair<ll, ll> > > vvecpi;
typedef set<ll> seti;
typedef set<pair<ll, ll> > setpi;
typedef multiset<ll> mseti;
typedef multiset<pair<ll, ll> > msetpi;
typedef map<ll, ll> mpi;

static const bool tc = 0;
static const ll mod = LLONG_MAX - 24;

void solve() {
        string s;
        cin >> s;
        if(s == "RRS" || s == "SRR") {
                cout << 2;
                return;
        }
        if(s == "RRR") {
                cout << 3;
                return;
        }
        if(s == "SSS") {
                cout << 0;
                return;
        }
        cout << 1;
}

int main() {
        srand(time(0));
        int T = 1;
        if(tc) cin >> T;
        for(int i = 1; i <= T; ++i) {
                #ifndef ONLINE_JUDGE
                cout << "----- " << i << " -----\n";
                #endif
                solve();
        }
        return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 205
#define MAXH 20
#define MAXM 52
#define INF 1LL << 30
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
const int N = 100005;

int main(){
	fast_io();
	string s;
	int n;
	int cnt[26] = {};
	cu(i,0,26)cnt[i] = MOD;
	int tcnt[26] = {};
	cin >> n;
	while(n--){
		cin >> s;
		memset(tcnt,0,sizeof(tcnt));
		cu(i,0,s.length()){
			++tcnt[s[i] - 'a'];
		}
		cu(i,0,26){
			gmin(cnt[i], tcnt[i]);
		}
	}
	cu(i,0,26){
		while(cnt[i]--){
			cout << (char)(i + 'a');
		}
	}
	cout << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <unistd.h>
using namespace std; 
using namespace std::chrono; 
using namespace __gnu_pbds;
//mp.reserve(1024);
//mp.max_load_factor(0.25);
typedef tree<int, null_type, less<int>, rb_tree_tag,  
                tree_order_statistics_node_update>  
        ordered_set;  
#define ll long long int 

void addEdge(vector<ll> adj[], ll u, ll v) 
{ 
   adj[u].push_back(v); 
   adj[v].push_back(u); 
} 

int main() 
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin); 
   // freopen("output1.txt", "w", stdout); 
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;
 return 0; 
} 


Measured memory_bytes: 256
#include<iostream>
#include<cctype>
using namespace std;
int main(){
    char ch;
    int num;
    int cnt[26]={};
    while(cin >> ch){
        if(isupper(ch)){
            ch = tolower(ch);
        }
        num =ch - 'a';
        cnt[num]++;
    }
    for(int i=0; i<26; i++){
        cout <<(char)(i+'a') <<" : "<< cnt[i]<<endl;
    }
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,X;
int A[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int g=0;
	cin>>N>>X;
	FOR(i,N) {
		cin>>A[i];
		g=__gcd(g,abs(A[i]-X));
	}
	cout<<g<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> color(9);
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        a = min(a, 3200);
        for(int j = 0; j < 9; j++) {
            if(j*400<=a && a<(j+1)*400) color.at(j)++;
        }
    }
    
    int v = 0;
    for(int i = 0; i < 8; i++) v += min(color.at(i),1);
    cout << max(v,1) << " " << v+color.at(8) << endl;
}


Measured memory_bytes: 256