akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  // int n;
  // cin>>n;
  // int a[n];
  // rep(i,0,n) cin>>a[i];
  // if(n==2){
  //   cout<<max(a[0],a[1])<<endl;
  //   return;
  // }
  // map<int,int> m;
  // rep(i,0,n){
  //   m[__gcd(a[i],a[(i+1)%n])]+=1;
  // }
  //
  // for(auto i:m){
  //   if(i.s==n-2){
  //     cout<<i.f<<endl;
  //     return ;
  //   }
  // }
  // if(m.begin() -> second >1){
  //   cout<<m.begin()->first<<endl;
  // }
  // else{
  //   auto it=m.begin();it++;
  //   int ans=it->first;
  //   for(;it!=m.end();it++){
  //     ans=__gcd(ans,it->first);
  //   }
  //   cout<<ans<<endl;
  // }
  // // cout<<1<<endl;
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  vector<int>L(N+1);
  vector<int>R(N+1);
  for(int i=0;i<N;i++){
    L[i+1]=__gcd(L[i],a[i]);
  }
  for(int i=N-1;i>=1;i--){
    R[i-1]=__gcd(R[i],a[i]);
  }
  int ans=0;
  for(int i=0;i<N;i++){
   ans=max(ans,__gcd(L[i],R[i]));
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 4528
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int par[100010],dep[100010];
void init(int N){
    for(int i = 0; i < N; i++){
        par[i] = i;
        dep[i] = 0;
    }
}

int find(int x){
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
}

void merge(int a,int b){
    a = find(a);
    b = find(b);
    if (dep[a] > dep[b]){
        par[b] = a;
        dep[a] += b;
    } else {
        par[a] = b;
        dep[b] += a;
    }
}

int main(){
    int N; cin >> N;
    int mon[100010]; fill(mon,mon+100010,MM);
    mon[0] = 0; mon[1] = 1;
    int a[12] = {1,6,36,216,1296,7776,46656,9,81,729,6561,59049};
    for(int i = 0; i < 12; i++){
        for(int num = 0; num <= 100000; num++){
            if (mon[num-a[i]] != MM && num >= a[i]){
                mon[num] = min(mon[num-a[i]] + 1, mon[num]);
            }
        }
    }
    cout << mon[N] << endl;
}


Measured memory_bytes: 640
#include<stdio.h>


int main()
{

    int a,b,c,i,sum=0,max,x,min,count=0,P;

    scanf("%d%d",&a,&b);

    int A[a];

    for(i=0;i<a;i++){

        scanf("%d",&A[i]);

        sum=sum+A[i];
    }

    x=b-sum;

    min=A[0];

    for(i=1;i<a;i++){

        if(min>A[i]) min=A[i];

    }

    if(x>0){

        P=x/min;

        printf("%d\n",P+a);
    }

    else printf("%d\n",a);



    return 0;

}



Measured memory_bytes: 1708
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cassert>
using namespace std;

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

	string s;
	int k;
	cin >> s >> k;
	vector<bool> bad(10);
	for (int i = 0; i < k; i++) {
		int x;
		cin >> x;
		bad[x] = true;
	}
	
	//~ cerr << s << ' ' << k << endl;
	//~ for (auto x : bad) cerr << x << ' '; cerr << endl;
	
	int n = s.length();
	int i;
	for (i = 0; i < n && !bad[s[i]-'0']; i++) ;
	
	if (i == n) {
		cout << s << endl;
		return 0;
	}
	
	int low;
	for (low = 0; bad[low]; low++) ;
	
	//~ cerr << i << ' ' << low << endl;
	
	int carry = 1;
	for (int j = i; j >= 0 && carry; j--) {
		int m = (int)(s[j] - '0') + carry;
		while (m < 10 && bad[m]) m++;
		if (m < 10) {
			s[j] = '0' + m;
			carry = 0;
		}
		else {
			s[j] = '0' + low;
		}
	}
	
	for (int j = i + 1; j < n; j++) s[j] = '0' + low;
	
	if (carry) {
		// now find lowest good number that's not zero
		for (int i = 1; i < 10; i++) {
			if (!bad[i]) {
				cout << (char)('0' + i);
				break;
			}
		}
	}
	cout << s << endl;
}


Measured memory_bytes: 256
from collections import deque

n,m=map(int,input().split())
L=[[] for i in range(n)]

#print(L)

for i in range(m):
    a,b=map(int,input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)

#print(L)
d=[float('inf') for i in range(n)]
m=[0 for i in range(n)]

def bfs():

    que=deque([])
    que.append(0)
    d[0]=0
    
    while que:
        p=que.popleft()
        for np in L[p]:
            if d[np]==float('inf'):
                que.append(np)
                d[np]=d[p]+1
                m[np]=p+1

bfs()
if sum(d)==float('inf'):
    print('No')
else:
    print('Yes')
    for i in range(1,n):
        print(m[i])

Measured memory_bytes: 98220
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 100005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<int,int> pii;
map<string,int>M;
vector<int> V[MAX];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string S;
        cin>>S;
        M[S]++;
    }
    cout<<"AC x "<<M["AC"]<<endl;
    cout<<"WA x "<<M["WA"]<<endl;
    cout<<"TLE x "<<M["TLE"]<<endl;
    cout<<"RE x "<<M["RE"]<<endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    int arr[N];
    for(int i=0; i<N; i++) cin >> arr[i];
    
    int break_cnt = 0;
    for(int i=0; i<N; i++) {
        if(i+1-break_cnt != arr[i]) break_cnt++;
    }
    
    if(break_cnt == N) cout << -1 << endl;
    
    else cout << break_cnt << endl;
    
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector> 
using namespace std;

int main() {
	int n, h; cin >> n >> h;
	vector <int> Y;
	int max_x = 0;
	for (int i = 0; i < n; i ++) {
		int x, y; cin >> x >> y;
		max_x = max(max_x, x);
		Y.push_back(y);
	}
	
	sort(Y.begin(), Y.end());
	int ans = 0, sum = 0;
	for (int i = Y.size()-1; Y[i] > max_x && i >= 0; i --) {
		sum += Y[i]; ans ++;
		if (sum >= h) break;
	}
	if (sum < h) {
		ans += (h-sum)/max_x;
		if ((h-sum) % max_x) ans ++;
	}
	cout << ans << endl;
	
	return 0; 
}

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

int main(){
  int H,W;
  cin >> H >> W;
  
  int i,j = 0;
  
  vector<vector<char>> table(H,vector<char>(W));
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      cin >> table.at(i).at(j);
    }
  }
  
  vector<bool> flagH(H,false);
  vector<bool> flagW(W,false);
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      if(table.at(i).at(j)=='#'){
        flagH.at(i)=true;
        flagW.at(j)=true;
      }
    }
  }
  
    for(i=0;i<H;i++){
      if(flagH.at(i)){
        for(j=0;j<W;j++){
          if(flagW.at(j))
            cout << table.at(i).at(j);
        }
      }
      cout << endl;
    } 
   
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  int count = 0;
  
  rep(i,N){
    cin >> vec[i];
    if(vec[i]%2 == 1) count++;
  }
  
  if(count%2 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

int main(){
	int sh, sm, ss, eh, em, es;
	for(int p =0; p < 3; p++){
		int ah=0, am=0, as=0;

		cin >> sh >> sm >> ss;
		cin >> eh >> em >> es;

		as += es - ss;
		if(as < 0){
			am--;
			as+= 60;
		}
		am += em - sm;
		if(am < 0){
			ah--;
			am+= 60;
		}
		ah += eh - sh;

		cout << ah << ' ' << am << ' ' << as << endl;
	}
}

Measured memory_bytes: 1160
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author /\
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D756 solver = new D756();
        solver.solve(1, in, out);
        out.close();
    }

    static class D756 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            Map<Integer, Integer> factors = new HashMap<>();
            for (int k = 1; k <= n; k++) {
                int i = k;
                while (i % 2 == 0) {
                    factors.put(2, factors.getOrDefault(2, 0) + 1);
                    i /= 2;
                }
                for (int j = 3; j <= Math.sqrt(i); j += 2) {
                    while (i % j == 0) {
                        factors.put(j, factors.getOrDefault(j, 0) + 1);
                        i /= j;
                    }
                }
                if (i > 2) {
                    factors.put(i, factors.getOrDefault(i, 0) + 1);
                }
            }
            int[] divNum = new int[]{2, 4, 24, 14, 74};
            long[] num = new long[5];
            for (int v : factors.values()) {
                for (int i = 0; i < 5; i++) {
                    if (v >= divNum[i]) {
                        num[i]++;
                    }
                }
            }
            long res = 0;
            res += num[4];
            res += num[3] * (num[1] - 1);
            res += num[2] * (num[0] - 1);
            res += num[1] * (num[1] - 1) / 2 * (num[0] - 2);
            out.println(res);
        }

    }

    static class Scanner {
        private StringTokenizer st;
        private BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}



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

using namespace std;

const uint64_t B = 103, H = 1e+17+3;

inline uint64_t ctoi(char c) { return c - 'a' + 1; }

uint64_t to_hash(const string &s)
{
  uint64_t _hash = 0;
  for (uint64_t i = 0; i < s.size(); ++i) {
    _hash = (_hash * B) % H;
    _hash = (_hash + ctoi(s[i])) % H;
  }
  return _hash;
}

inline uint64_t build_mask(uint64_t L) {
  uint64_t mask = 1;
  for (uint64_t i = 0; i < L - 1; ++i) {
    mask = (mask * B) % H;
  }
  return mask;
}

inline uint64_t change_hash(uint64_t _hash, uint64_t mask, char c1, char c2)
{
  uint64_t x = (ctoi(c1) * mask) % H;
  _hash = ((_hash + H) - x) % H;
  _hash = (_hash * B) % H;
  _hash = (_hash + ctoi(c2)) % H;
  return _hash;
}

bool find(uint64_t N, const string &S, uint64_t L)
{
  uint64_t mask = build_mask(L);
  
  uint64_t hash = to_hash(S.substr(0, L));
  
  map<uint64_t, set<uint64_t, greater<uint64_t>>> m;
  m[hash].insert(0);
  
  for (uint64_t i = 1; i <= S.size() - L; ++i) {
    hash = change_hash(hash, mask, S[i - 1], S[i + L - 1]);
    
    if (m[hash].size() > 0) {
      if (i >= L) {
        auto itr = m[hash].lower_bound(i - L);
        if (itr != m[hash].end()) {
          return true;
        }
      }
    }
    
    m[hash].insert(i);
  }
  
  return false;
}

int main()
{
  uint64_t N;
  cin >> N;
  
  string S;
  cin >> S;
  
  uint64_t hi = N, lo = 0;
  
  while (hi - lo > 1) {
    uint64_t L = (hi + lo) >> 1;
    if (find(N, S, L)) {
      lo = L;
    } else {
      hi = L;
    }
  }
  
  if (find(N, S, hi)) {
    cout << hi << endl;
  } else {
    cout << lo << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1016
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(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; }


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }
    int avg1 = sum / n; int avg2 = avg1 + 1;
    int cost1 = 0, cost2 = 0;
    rep(i, n){
        cost1 += (a[i] - avg1) * (a[i] - avg1);
        cost2 += (a[i] - avg2) * (a[i] - avg2);        
    }
    cout << min(cost1, cost2) << ln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define _GLIBCXX_DEBUG
const int INF=1e15;

signed main(){
    int N;cin>>N;
    int all=0;
    int MAX=0;
    REP(i,N){
        int a;cin>>a;
        all+=a;
        MAX=max(MAX,a);
    }
    if(MAX<all-MAX)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
N = int(input())
S = str(input())
K = int(input())

hogo = list(S)
rewrite = list(S)

cnt = 0
for s in range(0, N):
    if rewrite[s] != (hogo[K - 1]):
        rewrite[cnt] = "*"
    cnt += 1

print(''.join(rewrite))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
vector<ll> V;
map<ll,ll> M;
int main() {
    ll a=1000,b=1001;
    ll x;cin>>x;
    for(ll i=-1000;i<=1000;i++) M[i*i*i*i*i]=i;
    for(ll a=-1000;a<=1000;a++) {
        if(M[a*a*a*a*a-x]) {
            cout<<a<<' '<<M[a*a*a*a*a-x]<<endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

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

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

    long ans = -1e18;
    for (int i = 0; i < N; ++i)
    {

        long cycle_cnt = 0;
        long cycle_sum = 0;
        int pos = i;
        for (int j = 0; j < N; ++j)
        {
            ++cycle_cnt;
            cycle_sum += C[pos];
            pos = P[pos];
            if (pos == i)
            {
                break;
            }
        }

        long acc_score = 0;
        pos = i;

        for (int j = 0; j < cycle_cnt; ++j)
        {
            if (j >= K)
            {
                break;
            }
            acc_score += C[pos];
            long score = acc_score + max(0l, cycle_sum) * ((K - j - 1) / cycle_cnt);
            chmax(ans, score);
            pos = P[pos];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3668
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    N = int(input())
    S = input()
    cnt0 = S.count("1")

    if cnt0 == 0:
        print("\n".join(map(str, [1]*N)))
        return

    X = int(S, 2)

    def f2():
        cache = [0] * (cnt0 + 1)
        i = 1
        bi = []
        while i <= cnt0:
            bi.append(i)
            i <<= 1
        from collections import deque
        dq = deque([(0, 0, 0)])
        ls = len(bi) -1
        while dq:
            i, x, cnt = dq.popleft()

            cnt += 1
            for j in range(i, ls):
                y = x | bi[j]

                if y > cnt0: break

                cache[y] = cache[y % cnt] + 1

                j += 1
                dq.append((j, y, cnt))
            else:
                y = x | bi[ls]
                if y > cnt0: continue
                cache[y] = cache[y % cnt] + 1
        return cache


    memo = f2()

    dc = []
    for v in [1, -1]:
        x = cnt0 + v
        y = X % x if x else 0
        dc.append((x, v, y, [1, N-1]))

    ans = [0] * N
    for i in reversed(range(N)):
        cnt, v, n, m1 = dc[0 if S[i] == "0" else 1]

        if cnt == 0:
            ans[i] = 0
            continue

        m2 = (m1[0]<<(m1[1]-i)) % cnt
        n = (n + v*m2) % cnt
        m1[0], m1[1] =  m2, i

        ans[i] = 1 + memo[n]

    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 96404
#include <bits/stdc++.h>
using namespace std;
int compare(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;++i){
    cin>>a[i];
  }
  qsort(a,n,4,compare);
  cout<<(a[0]-a[n-1]);
  return 0;

}


Measured memory_bytes: 256
N=int(input())
List = []
for i in range (N):
  List.append(input())
res1 = List.count("AC")
res2= List.count("WA")
res3= List.count("TLE")
res4= List.count("RE")

print("AC x",res1)
print("WA x",res2) 
print("TLE x",res3)
print("RE x",res4)

Measured memory_bytes: 16276
code = r"""
# distutils: language=c++
# distutils: include_dirs=/opt/ac-library
# cython: cdivision=True
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "<atcoder/lazysegtree>" namespace "atcoder" nogil:
    cdef cppclass lazy_segtree[S, OP, E, F, mapping, composition, id]:
        lazy_segtree(vector[S] v)
        void set(int p, S x)
        S get(int p)
        S prod(int l, int r)
        S all_prod()
        void apply(int p, F f)
        void apply(int l, int r, F f)
        int max_right[G](int l)
        int min_left[G](int r)
cdef long mod = 998244353
cdef struct s_t:
    long v, s
ctypedef long f_t
cdef extern from *:
    ctypedef int op_t "myop"
    ctypedef int e_t "mye"
    ctypedef int m_t "mymapping"
    ctypedef int c_t "mycomposition"
    ctypedef int i_t "myid"
    ctypedef int g_t "myg"
    cdef s_t myop(s_t a, s_t b) nogil
    cdef s_t mye() nogil
    cdef s_t mymapping(f_t f, s_t x) nogil
    cdef f_t mycomposition(f_t f, f_t g) nogil
    cdef f_t myid() nogil
    cdef bool myg(s_t k) nogil
cdef s_t myop(s_t a, s_t b) nogil:
    cdef s_t c
    c.v = (a.v * b.s + b.v) % mod
    c.s = (a.s * b.s) % mod
    return c
cdef s_t mye() nogil:
    cdef s_t e
    e.v = 0
    e.s = 1
    return e
cdef f_t myid() nogil:
    return -1
cdef s_t mymapping(f_t f, s_t x) nogil:
    if f == myid(): return x
    cdef s_t y
    y.v = (x.s - 1) * 443664157 * f % mod
    y.s = x.s
    return y
cdef f_t mycomposition(f_t f, f_t g) nogil:
    if f == myid(): return g
    return f
from libc.stdio cimport getchar, printf
cdef inline int read() nogil:
    cdef int b, c = 0
    while 1:
        b = getchar() - 48
        if b < 0: return c
        c = c * 10 + b
cdef main():
    cdef int n = read(), i, l, r, d
    cdef s_t a
    a.v = 1
    a.s = 10
    cdef lazy_segtree[s_t, op_t, e_t, f_t, m_t, c_t, i_t] *seg = new lazy_segtree[s_t, op_t, e_t, f_t, m_t, c_t, i_t](vector[s_t](n, a))
    for i in range(read()):
        l, r, d = read(), read(), read()
        seg.apply(l - 1, r, d)
        printf('%ld\n', seg.all_prod().v)
main()
"""
import os, sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('solve.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b solve.pyx')
import solve

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

int main () {
  int A, B, C, X, count;
  cin >> A >> B >> C >> X;
  
  for (int i = 0; i < A+1; i++) {
    for (int j = 0; j < B+1; j++) {
      for (int k = 0; k < C+1; k++) {
        if (500*i+100*j+50*k == X) {
          count ++;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & -x)

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("a.in", "r", stdin);

    int n;
    cin >> n;
    vector<int> dp(n + 1, 0);
    vector<int> v(n + 1, 0);

    for(int i = 1; i <= n; i ++) {
        cin >> v[i];

        if(i > 1)
            dp[i] = dp[i - 1] + abs(v[i] - v[i - 1]);
        if(i > 2)
            dp[i] = min(dp[i], dp[i - 2] + abs(v[i] - v[i - 2]));
    }

    cout << dp[n];

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
priority_queue<int,vector<int>,greater<int> > q1;
priority_queue<int> q2;
LL sum,sum1,sum2;

int main()
{
	int n,m; cin>>m;
	while (m--) {
		int opt; scanf("%d",&opt);
		if (opt==1) {
			int x,y; scanf("%d%d",&x,&y);
			n++; sum+=y;
			q1.push(x); sum1+=x;
			while (!q1.empty() && !q2.empty() && q1.top()<q2.top()) {
				sum1-=q1.top(); sum1+=q2.top();
				sum2-=q2.top(); sum2+=q1.top();
				int t=q1.top(); q1.pop();
				q1.push(q2.top());
				q2.pop(); q2.push(t);
			} 
			if (q1.size()-q2.size()>=2) 
				sum1-=q1.top(),sum2+=q1.top(),q2.push(q1.top()),q1.pop();
		} else {
			int mid;
			if (n%2) mid=q1.top(); else mid=q2.top();
			LL ans=((LL)mid*(n/2)-sum2)+(sum1-(LL)mid*(n-n/2))+sum;
			printf("%d %lld\n",mid,ans);
		}
	}
	return 0;
}

Measured memory_bytes: 3452
import math

while 1:
    q = int(input())
    if q == -1:
        break
    
    x = q/2
    while 1:
        if abs(x*x*x - q) < (0.00001*q):
            break
        x -= (x*x*x - q) / (3*x*x)
  
    print( '{:.6f}'.format(x))


Measured memory_bytes: 5668
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main () {
    string a;
    cin>>a;
    for(int i=0;i<3;i++){
        if(a[i]=='1'){
            a[i]='9';
        }else{
            a[i]='1';
        }
    }
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);

  for (i64 i = 0; i < N; ++i) {
    if (A[i] > i) {
      std::cout << -1 << std::endl;
      return 0;
    }
  }

  i64 answer = 0;
  i64 prev_A_i = 0;
  for (i64 i = N - 1; i >= 0; --i) {
    if (A[i] < prev_A_i - 1) {
      std::cout << -1 << std::endl;
      return 0;
    } else if (A[i] >= prev_A_i) {
      answer += A[i];
    }
    prev_A_i = A[i];
  }

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define INF 1e+18
#define pb push_back
using namespace std;

int ans[1 << 16];

int eval(string &s,int &pos){
	if(s[pos] == '-'){
		return !eval(s,++pos);
	}else if(s[pos] == '('){
		int e1 = eval(s,++pos);
		char op = s[pos];
		int e2 = eval(s,++pos);
		pos++;
		return ((op == '^') ? (e1 ^ e2) : (e1 & e2));
	}else{
		return s[pos++] - '0';
	}
}

int calctf(string s){
	int ret = 0;
	for(int i = 0;i < 16;i++){
		string t = s;
		for(int j = 0;j < t.length();j++){
			for(int k = 0;k < 4;k++){
				if(t[j] == 'a' + k) t[j] = (char)(((i >> k) & 1) + '0');
			}
		}
		int pos = 0;
		//cout << t << endl;
		ret += (eval(t,pos) << i);
	}
	return ret;
}

vector<string> vec[17];
string moji[] = {"0","1","a","b","c","d"};

signed main(){
	string s;
	for(int i = 0;i < (1 << 16);i++) ans[i] = INF;
	for(int i = 0;i < 6;i++) vec[1].pb(moji[i]);
	for(int i = 2;i <= 16;i++){
		for(string t : vec[i - 1]) vec[i].pb('-' + t);
		for(int j = 1;j <= i - 3 - j;j++){
			for(string s1 : vec[j]){
				for(string s2 : vec[i - j - 3]){
					vec[i].pb('(' + s1 + '*' + s2 + ')');
					vec[i].pb('(' + s1 + '^' + s2 + ')');
				}
			}
		}
	}
	for(int i = 1;i <= 16;i++){
		for(string t : vec[i]){
			int num = calctf(t);
			ans[num] = min(ans[num],i);
		}
	}
	while(cin >> s,s != ".") cout << ans[calctf(s)] << endl;
}


Measured memory_bytes: 132048
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int N, K, Q, aux;
map <int, int> M;
int A[2005], res = 2000000005, A2[2005];
vector <int> V[2005];
void Read()
{
    cin >> N >>K >> Q;
    for(int i = 1; i <= N; i++)
    {
        cin >> A[i];
        M[A[i]] = 1;
    }
    int cnt = 0;
    for(auto it = M.begin(); it != M.end(); it = next(it))
    {
        it -> second = ++cnt;
    }
    for(int i = 1; i <= N; i++)
    {
        A2[M[A[i]]] = A[i];
        A[i] = M[A[i]];
    }


}
bool check(int up)
{
    int ans = 0;
    for(int i = 1; i <= aux; i++)
    {
        int sz = V[i].size() - K + 1, number = 0;
        for(int j = 0; j < V[i].size(); j++)
            if(V[i][j] <= up)
                ++number;
        ans += min(max(0, sz), number);
    }
    return ans >= Q;
}
void Solve(int nb)
{
    aux = 1;
    for(int i = 1; i <= N; i++)
        V[i].clear();
    for(int i = 1; i <= N; i++)
    {
        if(A[i] >= nb)
            V[aux].push_back(A[i]);
        else
            ++aux;
    }
    int left = nb, right = N, mid, sol = -1;
    while(left <= right)
    {
        mid = (left + right) / 2;
        if(check(mid))
        {
            sol = mid;
            right = mid - 1;
        }
        else
            left = mid + 1;
    }
    if(sol != -1)
    {
        res = min(res, A2[sol] - A2[nb]);
    }
}
int main()
{
    Read();
    for(int i = 1; i <= N; i++)
        Solve(i);
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll H, W;
ll INF = 1e9;
vector<vector<char>> field;
vector<vector<ll>> dist;
vector<ll> dx = {1, 0};
vector<ll> dy = {0, 1};
deque<pair<ll, ll>> q;

void dfs(ll h, ll w) {
    for (ll i = 0; i < 2; i++) {
        ll nh = h+dx[i]; ll nw = w+dy[i];
        if (nh < 0 || nw < 0 || nh >= H || nw >= W) continue;
        if (dist[nh][nw] > dist[h][w] && field[nh][nw] == '#') {
            dist[nh][nw] = dist[h][w];
            q.push_back(make_pair(nh, nw));
            dfs(nh, nw);
        }
    }
}

int main() {
    cin >> H >> W;
    ll INF = 1e9;
    field.assign(H, vector<char> (W));
    dist.assign(H, vector<ll> (W, INF));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> field[i][j];
        }
    }

    q.push_back(make_pair(0, 0));
    if (field[0][0] == '.') dist[0][0] = 0;
    else if (field[0][0] == '#') {
        dist[0][0] = 1;
        dfs(0, 0);
    }

    while(q.size()) {
        ll h = q.front().first; ll w = q.front().second;
        q.pop_front();
        for (int i = 0; i < 2; i++) {
            ll nh = h+dx[i]; ll nw = w+dy[i];
            if (nh < 0 || nw < 0 || nh >= H || nw >= W) continue;
            if (dist[nh][nw] > dist[h][w] && field[nh][nw] == '#') {
                dist[nh][nw] = dist[h][w]+1;
                q.push_back(make_pair(nh, nw));
                dfs(nh, nw);
            }
            if (dist[nh][nw] > dist[h][w] && field[nh][nw] != '#') {
                dist[nh][nw] = dist[h][w];
                q.push_front(make_pair(nh, nw));
            }
        }
    }
    cout << dist[H-1][W-1] << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
int ceil(int a,int b){
    return (a+b-1)/b;
}
int main(void){
    string s;
    cin>>s;
    vector<int> v(3,0);
    rep(i,3){
        v[s[i]-'a']++;
    }
    int cnt=0;
    rep(i,3){
        if(v[i]==1) cnt++;
    }
    if(cnt==3) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	if (s[0] == s[1] && s[0] == s[2] && s[1] == s[2]) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
  	Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    long sum = 0l;
    long high = sc.nextLong();
    for(int i = 1; i < n; i++){
      long next = sc.nextLong();
      if(high > next){
      	sum += (high - next);
      } else {
        high = next;
      }
    }
    
    System.out.println(sum);
  }
}


Measured memory_bytes: 48356
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define LONGMAX 1e18
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define endl "\n"
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define INF 1e9
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll powe(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
void ceilsearch(ll ar[],ll low,ll high,ll x,ll &y){ll mid=(low+high)/2;if(low>high)return;if(ar[mid]>x){y=mid;ceilsearch(ar,low,mid-1,x,y);}else{ceilsearch(ar,mid+1,high,x,y);}}
int main()
{
	fastio();
	ll N,M;
	cin>>N>>M;
	cout<<(N+M-1)/M<<endl;
}

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


int main()
{
	int n,k,a=1;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		a=min(a*2,a+k);
	}
	cout<<a<<endl;
	return 0;
}

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

signed main() {
	vector<string> dice(7);

	dice[1] = "##3524#";
	dice[2] = "#4#16#3";
	dice[3] = "#26##15";
	dice[4] = "#51##62";
	dice[5] = "#3#61#4";
	dice[6] = "##4253#";

	vector<int> s(7);
	map<int, int> a;
	for (int i = 1; i < 7; ++i) {
		cin >> s[i];
		a[s[i]] = i;
	}

	int N;
	cin >> N;
	
	for (int i = 0; i < N; ++i) {
	    int n, m;
	    cin >> n >> m;
	    cout << s[int(dice[a[n]][a[m]] - '0')] << endl;
	}
}



Measured memory_bytes: 3176
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	vector<int> A=vector<int>(3);
	cin>>A[0]>>A[1]>>A[2];
	sort(A.begin(),A.end(),greater<int>());
	cout<<A[0]*10+A[1]+A[2]<<endl;
}


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

using namespace std;

#define MAX 1000000000000000000

int main()
{
    int n;
    cin >> n;
    long long temp;
    long long a = 1;
    for(int i=0; i<n; i++){
        cin >> temp;
        if(temp == 0){
            a = 0;
            break;
        }
        else if(a <= MAX/temp)
            a *= temp;
        else{
            a = -1;
            for(int j = i; j<n; j++){
                cin >> temp;
                if(temp == 0)
                    a = 0;
            }
            break;
        }
    }
    cout << a;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

/* 二項係数 C(n,k) mod p を計算 */
const int MAX = 100010;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  vector<int> A(N);
  ll sum = 0;

  REP(i, N){
    cin >> A[i];
  }

  COMinit();
  vector<ll> h(N+1);
  h[0] = 0;

  FOR(i, 1, N+1){
    h[i] = h[i-1] + inv[i] % MOD;
    h[i] %= MOD;
  }
 
  ll ans = 0;

  FOR(i, 1, N+1){
    ans += A[i-1] * (h[i] + h[N+1-i] % MOD - 1 % MOD) % MOD;
    ans %= MOD;
  }

  ans *= fac[N] %MOD;
  ans %= MOD;

  cout << ans << endl;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define maxn 15
#define ll long long
#define db double
#define vi vector<int>
#define pb push_back
#define mod 998244353
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
// head
char fl[maxn][maxn];
int main() {
	int h, w;
	cin >> h >> w;
	int cnt = 0;
	for (int i = 0; i < h; i++) {
		cin >> fl[i];
		for (int j = 0; j < w; j++)
			if (fl[i][j] == '#') cnt++;
	}
	int x = 0, y = 0;
	while (1) {
		cnt--;
		if (fl[x + 1][y] == '#') x++;
		else if (fl[x][y + 1] == '#') y++;
		else break;
	}
	if (cnt) cout << "Impossible" << endl;
	else cout << "Possible" << endl;;
	return 0;
}


Measured memory_bytes: 256
function main(input) {
  let N = parseInt(input, 10);
  let ans;
  
  if (N === 10 || N === 100 || N === 1000 || N === 10000 || N === 100000) {
  	console.log(10);
    return;
  }
  
  while(true) {
    if (!ans) { 
      ans = Math.floor(N % 10);
    } else {
      ans += Math.floor(N % 10);
    };
    
    N = N / 10;
    
    if (N <= 0) { break; }
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29632
#include<bits/stdc++.h>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<queue>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define pb push_back
using namespace std;
typedef pair<int, int>pii;

int main(){
	int a,b,c;
	cin >> a >> b >>c;
	if(a+b>=c) cout <<"Yes"<<endl;
	else cout <<"No"<<endl;
	return 0;
}
	

Measured memory_bytes: 256
//written by NewbieChd
#include <cstdio>
#include <cctype>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    register int f = 0;
    register char c;
    while (!isdigit(c = getChar())) {}
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return f;
}

const int N = 3007;
long long dp[N];

int main() {
    int r = read(), g = read(), b = read(), n = read(), i, j;
    dp[0] = 1;
    for (i = 1; i <= n; ++i)
        if (i >= r)
            dp[i] += dp[i - r];
    for (i = 1; i <= n; ++i)
        if (i >= g)
            dp[i] += dp[i - g];
    for (i = 1; i <= n; ++i)
        if (i >= b)
            dp[i] += dp[i - b];
    printf("%d\n", dp[n]);
    return 0;
}


Measured memory_bytes: 128
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . ___
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         佛祖保佑       永无BUG
*/
//use readint!
#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<stdio.h>
#include<fstream>
#include<assert.h>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<string.h>
#define mp make_pair
#define ll long long
using namespace std;
const int INF=1e9;
inline int pt(int a[],int l,int r){
	int p,i,j;
	p=a[l];
	i=l;
	j=r+1;
	for(;;){
		while(a[++i]<p) if(i>=r) break;
		while(a[--j]>p) if(j<=l) break;
		if(i>=j) break;
		else swap(a[i],a[j]);
	}
	if(j==l) return j;
	swap(a[l],a[j]);
	return j;
}
inline void q_sort(int a[],int l,int r){
	int q;
	if(r>l){
		q=pt(a,l,r);
		q_sort(a,l,q-1);
		q_sort(a,q+1,r);
	}
}
inline int readint(){
    int x=0;
    int f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
	if(ch=='-'){
		f=-1;
		ch=getchar();
	}
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}

int main(){
	set<string> ss;
	string s,T;
	ss.clear();
	cin>>s;
	T=s;
	sort(T.begin(),T.end());
	T.erase(unique(T.begin(),T.end()),T.end());
	int i,j,k;
//	cout<<T<<endl;
	cin>>k;
	for(i=0;i<s.size();i++){
		if(s[i]==T[0]){
			for(j=i;j<min((int)s.size(),i+5);j++){
				ss.insert(s.substr(i,j-i+1));
			}
		}
	}
	int t=0;
	for(set<string>::iterator it=ss.begin();it!=ss.end();it++){
		t++;
		if(t==k){
			cout<<*it;
			return 0;
		}
	}
	ss.clear();
	for(i=0;i<s.size();i++){
		if(s[i]==T[1]){
			for(j=i;j<min((int)s.size(),i+5);j++){
				ss.insert(s.substr(i,j-i+1));
			}
		}
	}
	for(set<string>::iterator it=ss.begin();it!=ss.end();it++){
		t++;
		if(t==k){
			cout<<*it;
			return 0;
		}
	}
	ss.clear();
	for(i=0;i<s.size();i++){
		if(s[i]==T[2]){
			for(j=i;j<min((int)s.size(),i+5);j++){
				ss.insert(s.substr(i,j-i+1));
			}
		}
	}
	for(set<string>::iterator it=ss.begin();it!=ss.end();it++){
		t++;
		if(t==k){
			cout<<*it;
			return 0;
		}
	}
	ss.clear();
	for(i=0;i<s.size();i++){
		if(s[i]==T[3]){
			for(j=i;j<min((int)s.size(),i+5);j++){
				ss.insert(s.substr(i,j-i+1));
			}
		}
	}
	for(set<string>::iterator it=ss.begin();it!=ss.end();it++){
		t++;
		if(t==k){
			cout<<*it;
			return 0;
		}
	}
	ss.clear();
	for(i=0;i<s.size();i++){
		if(s[i]==T[4]){
			for(j=i;j<min((int)s.size(),i+5);j++){
				ss.insert(s.substr(i,j-i+1));
			}
		}
	}
	for(set<string>::iterator it=ss.begin();it!=ss.end();it++){
		t++;
		if(t==k){
			cout<<*it;
			return 0;
		}
	}
	ss.clear();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main(){
    int k,n;
    cin >> k >>n;
    vector<int> A(n);

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

    int m = k - A[n-1] + A[0];

    for(int i=0;i<n-1;i++){
        m = max(m, A[i+1] - A[i]);

    }

    cout << k - m;

}

Measured memory_bytes: 1024
str = input()
ans = "Yes"
for i in range(len(str)):
  if (i + 1) % 2 == 0 and str[i] not in ('L', 'U', 'D'):
    ans = "No"
  if (i + 1) % 2 == 1 and str[i] not in ('R', 'U', 'D'):
    ans = "No"
 
print(ans)

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

enum Sauce{ NOT_DETERMINED = 0, Tomato = 1, Cream = 2, Basil = 3 };
enum Seq{ SAME, DIFF };

const int divisor = 10000;

class Pasta{
public:
	Pasta(int _N);
	~Pasta();

	Sauce* sauceary;
	int schedule(int i, Sauce yesterday, Seq seq);

private:
	int N;
	int*** memo;
};

Pasta::Pasta(int _N){
	N = _N;
	sauceary = new Sauce[N + 1];
	memo = new int**[N + 1];

	for (int i = 0; i <= N; i++) sauceary[i] = NOT_DETERMINED;

	for (int i = 0; i <= N; i++){
		memo[i] = new int*[4];
		for (int j = 0; j < 4; j++){
			memo[i][j] = new int[2];
			memo[i][j][SAME] = -1;
			memo[i][j][DIFF] = -1;
		}
	}
}

Pasta::~Pasta(){
	delete[] sauceary;
	delete[] memo;
}

int Pasta::schedule(int i, Sauce yesterday, Seq seq){
	if (i == N + 1) return 1;
	if (memo[i][yesterday][seq] >= 0) return memo[i][yesterday][seq];

	if (seq == SAME && yesterday == sauceary[i]){
		memo[i][yesterday][SAME] = 0;
		return 0;
	}

	if (sauceary[i] == NOT_DETERMINED){
		int tmpmemo = 0;

		for (int si = 1; si <= 3; si++){
			if ((Sauce)si == yesterday && seq == SAME) continue;
			else if ((Sauce)si == yesterday && seq == DIFF) tmpmemo += schedule(i + 1, (Sauce)si, SAME) % divisor;
			else tmpmemo += schedule(i + 1, (Sauce)si, DIFF) % divisor;
		}

		memo[i][yesterday][seq] = tmpmemo % divisor;
		return tmpmemo;
	}
	else {
		if (yesterday == sauceary[i]) memo[i][yesterday][seq] = schedule(i + 1, sauceary[i], SAME) % divisor;
		else memo[i][yesterday][seq] = schedule(i + 1, sauceary[i], DIFF) % divisor;
			
		return memo[i][yesterday][seq];
	}
}

int main(){
	int N, K;
	cin >> N >> K;

	Pasta* pasta = new Pasta(N);

	for (int i = 0; i < K; i++){
		int A, B;
		cin >> A >> B;
		pasta->sauceary[A] = (Sauce)B;
	}

	cout << pasta->schedule(1, NOT_DETERMINED, DIFF) % divisor << endl;

	delete pasta;
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    string S;
    cin >> N >> S >> K;

    char c =  S[K-1];
    for(int i = 0; i < N;i++){
        if(S[i] != c){
            S[i]='*';
        }
    }
    cout << S << endl;

    

    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class ATenki {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string s, t; cin >> s >> t;
      int ans = 0;
      rep(i, 3) {
        if (s[i] == t[i]) {
          ans++;
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  ATenki solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <string>
#include <map>
#include <queue>
#include <list>

using namespace std;

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

    vector<int> a_copy = a;

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

    for(int i = 0; i < n; i++){
        if(a_copy[i] == a[0]){
            cout << a[1] << endl;
        } else {
            cout << a[0] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4468
#include <iostream>
using namespace std;
int main(){
    int A,B,N;//A以上B以下　Nまで
    int g=0;//総和
    int k=0;//10で割られていくもの
    int j=0;//各桁の和
    cin >> N >> A >> B;

    for(int i=1;i<=N;i++){
        int j = 0;
        for(int k=i;k>0;){
            j += (k%10);
            k/=10;
            }
        if(j>=A && j<=B){
            g=g+i;
        }
    }
    cout << g << endl;
}


Measured memory_bytes: 256