akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

const int MAX_N = 100000;
const int SENTINEL = 1000000000;

struct Card {
    char suit;
    int value;
};

Card L[MAX_N / 2 + 2], R[MAX_N / 2 + 2];

void merge(Card A[], int n, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;

    for (int i = 0; i < n1; i++) {
        L[i] = A[left + i];
    }

    for (int i = 0; i < n2; i++) {
        R[i] = A[mid + i];
    }

    L[n1].value = SENTINEL;
    R[n2].value = SENTINEL;
    int i = 0, j = 0;

    for (int k = left; k < right; k++) {
        if (L[i].value <= R[j].value) {
            A[k] = L[i];
            i++;
        }
        else {
            A[k] = R[j];
            j++;
        }
    }

}

void mergeSort(Card A[], int n, int left, int right) {
    int mid;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int partition(Card A[], int p, int r) {
    Card x = A[r];
    int i = p - 1;
    Card temp;

    for (int j = p; j < r; j++) {
        if (A[j].value <= x.value) {
            i++;
            temp = A[j];
            A[j] = A[i];
            A[i] = temp;
        }
    }

    temp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = temp;

    return i + 1;
}

void quickSort(Card A[], int p, int r) {
    if (p < r) {
        int q = partition(A, p, r);
        quickSort(A, p, q - 1);
        quickSort(A, q + 1, r);
    }
}

int main () {
    int n;
    Card A[MAX_N], B[MAX_N];

    cin >> n;

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

    quickSort(A, 0, n - 1);
    mergeSort(B, n, 0, n);

    bool stable = true;
    
    for (int i = 0; i < n; i++) {
        if (A[i].suit != B[i].suit) {
            stable = false;
        }
    }

    if (stable) {
        cout << "Stable" << endl;
    }
    else {
        cout << "Not stable" << endl;
    }

    for (int i = 0; i < n; i++) {
        cout << A[i].suit << " " << A[i].value << endl;
    }

}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j

int lbidx(vector<int> x, int y) {
  auto itr = lower_bound(x.begin(), x.end(), y);
  int idx = itr - x.begin();
  return idx;
};

int upidx(vector<int> x, int y) {
  auto itr = upper_bound(x.begin(), x.end(), y);
  int idx = itr - x.begin();
  return idx;
}

int func(int x) {
  if (x % 2 == 0) {
    return x / 2;
  }
  return 3 * x + 1;
};

int main() {
  int s;
  cin >> s;
  set<int> S;
  S.insert(s);
  int counter = 1;
  int ans;
  while (1) {
    counter++;
    s = func(s);
    if (S.find(s) != S.end()) {
      ans = counter;
      break;
    }
    S.insert(s);
  }

  cout << ans << endl;
};


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int cnt[10000] = {};
int main() {
	int n;
	cin >> n;
	REP(i, n) {
		int hoge;
		cin >> hoge;
		cnt[min(hoge / 400, 8)]++;
	}
	int ans = 0;
	for (int i = 0;i < 8;++i) {
		if (cnt[i]) ans++;
	}
	cout << max(1, ans) << " ";
	cout << ans + cnt[8] << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ');
            int step = int.Parse(line[0]);
            int bcount = int.Parse(line[1]);
            double lim = double.Parse(line[2]) + 0.5;

            int c = 0;
            for (int i = 0; (int)(lim / step) > i; i++)
            {
                c += bcount;
            }

            Console.WriteLine(c);
        }
    }
}

Measured memory_bytes: 13140
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int A, B, C, D;
	std::cin >> A >> B >> C >> D;
	if (A+B>C+D) {
		std::cout << "Left\n";
	} else if (A+B==C+D) {
		std::cout << "Balanced\n";
	} else {
		std::cout << "Right\n";
	}
}


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

int main(){
    int N; cin >> N;
    int T[100005],X[100005],Y[100005];
    T[0]=X[0]=Y[0]=0;
    rep(i,N) cin >> T[i] >> X[i] >> Y[i];
    
    bool fla=true;
    for (int i=1; i<=N; i++){
        int dt=T[i]-T[i-1];
        int dx=X[i]-X[i-1];
        int dy=Y[i]-Y[i-1];
        
        if(abs(dx)+abs(dy)<=dt && abs(dx+dy)%2==dt%2) fla=true;
        else fla=false;
    }
    if(fla) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 1408
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		long K=stdIn.nextLong();
		int A[][]=new int[N][2];
		long key=0;
		for(int i=0;i<N;i++){
			A[i][0]=stdIn.nextInt();
			A[i][1]=stdIn.nextInt();
		}
		Arrays.sort(A, (a, b) -> Integer.compare(a[0], b[0]));
		for(int i=0;i<N;i++){
			key+=A[i][1];
			if(key>=K){
				System.out.println(A[i][0]);
				break;
			}
		}
	}
}

Measured memory_bytes: 92680
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
const int inf = 1e8;
vector<int>g[maxn];
int n, k, value[maxn];
int result[maxn];

int li[maxn], ri[maxn];

bool defined[maxn];
bool check;

void dfs(int node, int p) {
    int cnt[2] = {0, 0};
    if(value[node] != -1) {
        li[node] = ri[node] = value[node];
        defined[node] = true;
    }


    for(int i:g[node]) {
        if(i!=p) {
            dfs(i, node);

            if(defined[i]) {
                cnt[li[i]%2]++;
            }
        }
    }

    if(cnt[0] > 0 && cnt[1] > 0) {
        check = true;
        return;
    }

    if(value[node] == -1) {
        li[node] = INT_MIN;
        ri[node] = INT_MAX;
    }

    for(int i:g[node]) {
        if(i!=p) {
            if(defined[i]) {
                li[node] = max(li[node], li[i]-1);
                ri[node] = min(ri[node], ri[i]+1);
                defined[node] = true;
            }
        }
    }

    if(li[node] > ri[node]) {
        check = true;
        return;
    }
}

void dfs2(int node, int p) {

    if(value[node] == -1) {
        int x = value[p] - 1;
        if(x >= li[node] && x <= ri[node]) value[node] = x;

        x = value[p] + 1;
        if(x >= li[node] && x <= ri[node]) value[node] = x;


        if(value[node] == -1) {
            check = true;
            return;
        }
    }

    for(int i:g[node]) {
        if(i!=p) {
            dfs2(i, node);
        }
    }
}

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

    int a, b;
    for(int i=0;i<n-1;i++) {
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);

    }

    cin>>k;
    memset(value, -1, sizeof(value));
    memset(result, -1, sizeof(result));
    for(int i=0;i<k;i++) {
        cin>>a>>b;
        value[a] = b + inf;
    }

    dfs(1, -1);

    if(check) {
        cout<<"No\n";
        return 0;
    }

    /*for(int i=1;i<=n;i++) {
        cout<<i<<": "<<li[i]<<" "<<ri[i]<<"\n";
    }*/

    value[1] = li[1];
    dfs2(1, -1);

    if(check) {
        cout<<"No\n";
        return 0;
    }

    cout<<"Yes\n";
    for(int i=1;i<=n;i++) {
        cout<<value[i] - inf<<"\n";
    }

    return 0;
}


Measured memory_bytes: 17408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

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

ordered_set<ll> ors;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

const ll MX=1000001;

ll lp[MX];

void prime()
{
    repf(i,1,MX) lp[i]=i;
    repf(i,2,MX)
    {
        if(lp[i]==i)
        {
            for(ll j=2*i;j<MX;j+=i)
            {
                if(lp[j]==j) lp[j]=i;
            }
        }
    }
}

void solve(ll tt) {
    ll n;
    cin>>n;
    ll a[n];
    repf(i,0,n) cin>>a[i];
    map<ll,ll> mp;
    repf(i,0,n) {
        ll x=a[i];
        while(lp[x]!=1) {
            ll y=lp[x];
            mp[y]++;
            while(x%y==0) x/=y;
        }
    }
    bool f=true;
    for(auto i:mp) if(i.se>1) {
        f=false;
        break;
    }
    if(f) {
        cout<<"pairwise coprime\n";
        return;
    }
    ll g=a[0];
    repf(i,1,n) g=__gcd(g,a[i]);
    if(g==1) {
        cout<<"setwise coprime\n";
        return;
    }
    cout<<"not coprime\n";
} 

int main()
{
    IOS;
    prime();
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}     

Measured memory_bytes: 24156
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

const int INF = 1e9;
int N, K;
vector<int> A;

int memo[100010];
bool vis[100010];

int go(int pos){
  if(pos >= N - 1){
    return 0;
  }
  if(vis[pos]){ return memo[pos]; }
  int best = INF, w  = 0;
  for(int i = 1 ; i <= K ; i++){
    if(pos + i >= N){ break; }
     w = INF;
     w = (abs(A[pos] - A[pos + i])) + go(pos + i);
     best = min(best, w);
  }
  vis[pos] = 1;
  memo[pos] = best;
  return best;
}

int main() {
  cin>>N>>K;
  A = vector<int> (N);
  for(int &i : A) cin>>i;

  cout<<go(0);
  return 0;
}

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

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

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

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    auto S = sread();
    auto T = sread();
    foreach_reverse (i; 0 .. S.length - T.length + 1)
    {
        bool b = true;
        // writeln(S[i .. i + T.length]);
        foreach (j, c; S[i .. i + T.length])
        {
            // writeln(c, T[j]);
            b = b && (c == T[j] || c == '?');
        }
        if (b)
        {
            char[] ans = S.dup;
            ans[i .. i + T.length][] = T;
            foreach (ref c; ans)
                if (c == '?')
                {
                    c = 'a';
                }
            writeln(ans);
            return;
        }
    }
    writeln("UNRESTORABLE");
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	int n[5];
	for(int i=0; i<5; i++)
		cin >> n[i];
	sort(n, n+5, [](int x, int y){
		if((x-1)%10<(y-1)%10)
			return true;
		return false;
	});
	int sum=n[0];
	for(int i=1; i<5; i++){
		n[i]=(n[i]+9)/10*10;
		sum+=n[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main()
{
    ll N;
    cin >> N;
    vector<ll> d;

    for(ll i = 0; i < N;i++)
    {
        ll temp;
        cin >> temp;
        d.push_back(temp);
    }

    ll sum = 0;
    for(ll i = 0;i < N-1;i++)
    {
        for(ll j = i+1;j<N;j++)
        {
            sum += d[i]*d[j];
        }
    }

    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define rep(i,n) for(i=1;i<n;i++)
#define PI 3.14159265358979323846264338327950L
int main(){
    int a,b,i;
    scanf("%d%d",&a,&b);
    rep(i,1010){
        if((a==i*2/25)&&(b==i/10)){
            printf("%d",i);
            break;
        }
    }
    if(i==1010) printf("-1");
    return 0;
}

Measured memory_bytes: 1732
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=8e3+5;
const int M=2e2+5;
const int mod=998244353;
int n,m,f[N<<3],g1[N<<3],g2[N<<3],fac[N],inv[N],dp[N][M];

inline int mul(int x,int y) {return 1ll*x*y%mod;}
template <typename _Tp> inline void IN(_Tp&x) {
    char ch;bool flag=0;x=0;
    while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
    while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    if(flag) x=-x;
}

namespace Poly {
    int filp[N<<3];
    inline int modpow(int x,int y,int res=1) {
        for(;y;y>>=1,x=mul(x,x)) if(y&1) res=mul(res,x);
        return res;
    }
    inline void NTT(int*f,int limit,short inv) {
        for(int i=0;i<limit;++i) if(i<filp[i]) swap(f[i],f[filp[i]]);
        for(int p=2;p<=limit;p<<=1) {
            int len=p>>1,tmp=modpow(3,(mod-1)/p);
            for(int k=0;k<limit;k+=p) {
                int buf=1;
                for(int l=k;l<k+len;++l,buf=mul(buf,tmp)) {
                    int t=mul(f[l+len],buf);
                    f[l+len]=(f[l]-t+mod)%mod,f[l]=(f[l]+t)%mod;
                }
            }
        }
        if(inv==1) return;
        int sl=modpow(limit,mod-2);reverse(f+1,f+limit);
        for(int i=0;i<limit;++i) f[i]=1ll*f[i]*sl%mod;
    }
}using namespace Poly;

int limit=1,cnt=0;
inline int C(int n,int m) {return mul(fac[n],mul(inv[m],inv[n-m]));}
inline void solve(int j) {
    memset(g1,0,sizeof(g1));
    memset(g2,0,sizeof(g2));
	for(int i=1;i<=n;++i) g1[i]=inv[i+2];
	for(int i=0;i<=n;++i) g2[i]=mul(dp[i][j-1],inv[i]);
	for(int i=0;i<=n;++i) dp[i][j]=(dp[i][j]+mul(dp[i][j-1],(1+i+C(i,2))%mod))%mod;
	NTT(g1,limit,1),NTT(g2,limit,1);
	for(int i=0;i<limit;++i) f[i]=mul(g1[i],g2[i]);
	NTT(f,limit,-1);
	for(int i=1;i<=n;++i) dp[i][j]=(dp[i][j]+mul(f[i],fac[i+2]))%mod;
}

int main() {
    IN(n),IN(m),fac[0]=inv[0]=1;
	for(int i=1;i<=n+2;++i) fac[i]=mul(fac[i-1],i);
	for(int i=1;i<=n+2;++i) inv[i]=modpow(fac[i],mod-2);
	while(limit<((n+1)<<1)) limit<<=1,++cnt;
	for(int i=0;i<limit;++i) filp[i]=(filp[i>>1]>>1)|((i&1)<<(cnt-1));
	dp[0][0]=1;
	for(int j=1;j<=m;++j) solve(j);
	int ans=0;
	for(int i=0;i<=n;++i) ans=(ans+mul(C(n,i),dp[i][m]))%mod;
	printf("%d\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 7296
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Wed Jan  2 22:09:57 2019
//
package main

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

const invalidNum = 1 << 60

type route struct {
	to, weight int
}

type node struct {
	routes []route
}

var nodes []node
var nums []int
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func dfs(top int, num int) bool {
	if nums[top] != invalidNum {
		return nums[top] == num
	}

	nums[top] = num
	for _, r := range nodes[top].routes {
		if !dfs(r.to, num+r.weight) {
			return false
		}
	}

	return true
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	nodes = make([]node, N+1)
	for i := 0; i < M; i++ {
		s := nextLine()
		var l, r, d int
		fmt.Sscan(s, &l, &r, &d)
		nodes[l].routes = append(nodes[l].routes, route{to: r, weight: d})
		nodes[r].routes = append(nodes[r].routes, route{to: l, weight: -d})
	}

	nums = make([]int, N+1)
	for i := range nums {
		nums[i] = invalidNum
	}

	for i := range nodes {
		if nums[i] == invalidNum && !dfs(i, 0) {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}


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

int main(){
  while (true){
    int n, x;
    cin >> n >> x;
    if (n==0 && x==0) break;
    int c=0;
    for (int i=1; i<=n-2; ++i){
      for (int j=i+1; j<=n-1; ++j){
	for (int k=j+1; k<=n; ++k){
	  if (i+j+k == x) ++c;
	}
      }
    }
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 3080
#include "bits/stdc++.h"

#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main()
{
   u_int N, C;
   cin >> N >> C;
   int A[100001] = {};
   int S, T, c, k;
   int CS[C][100001];
   int CT[C][100001];
   REP(i, 1, N)
   {
      cin >> S >> T >> c;
      CS[c - 1][S] = 1;
      CT[c - 1][T] = 1;
      if (CS[c - 1][T] == 1)
         A[T]--;
      if (CT[c - 1][S] == 1)
         A[S]--;
      REP(t, S, T)
      A[t] += 1;
   }
   int ans = 0;
   REP(t, 1, 100000)
   ans = max(ans, A[t]);

   cout << ans << endl;
}

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


Measured memory_bytes: 24064
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  
  long long X, i, j;
  cin >> X;
  
  for(i = 0; i < 200; i++){
    for(j = 0; j < 200; j++){
    
      if(pow(i, 5) - pow(j, 5) == X){
        cout << i << " " << j << endl;
        return 0;
      } else if (pow(i, 5) + pow(j, 5) == X) {
        
        cout << i << " " << -j << endl;
        return 0;        
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n;cin>>n;
	ll M=0;
	ll m=1000000009;
	for(int i=0;i<n;++i){
		ll a;cin>>a;
		M=max(M,a);
		m=min(m,a);
	} 
	cout<<M-m<<endl;
}

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

int main(){
  string s;
  cin >> s;
  int paperTime = 0, RockTime = 0;
  int win = 0, lost = 0;
  for(int i = 0; i < s.size(); i++){
    switch (s[i]) {
      case 'g':
        if(RockTime >= paperTime + 1){
          paperTime++;
          win ++;
        }else{
          RockTime++;
        }
        break;
      case 'p':
        if(RockTime >= paperTime + 1){
          paperTime++;
        }else{
          lost ++;
          RockTime++;
        }
        break;
    }
  }
  cout << win - lost << endl;
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
typedef long long int ll;

int main(void){
    ll x;
    scanf("%lld", &x);

    ll q = x/11;
    ll r = x%11;

    ll ans = 0;

    if(r == 0){
        ans = q*2;
    }else if(r <= 6){
        ans = q*2+1;
    }else{
        ans = q*2+2;
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)     for(lint i=n-1;i>=0;--i)
#define REPR1(i,n)    for(lint i=n;i>0;--i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int cnt = 0;
void shell_sort(vector<int>&a, const vector<int>H)
{
	auto insertion_sort = [&a](int h)
	{
		REPI(i, h, a.size())
		{
			int v = a[i];
			for (int j = i - h; ; j -= h)
			{
				if (j < 0 || a[j] <= v)
				{
					a[j + h] = v;
					break;
				}
				a[j + h] = a[j];
				cnt++;
			}
		}
	};
	REPC(i, H)insertion_sort(i);
}
int main()
{
	vector<int>a(in());
	REPC(&i, a)i = in();

	vector<int>H;
	int h = 1;
	for (int h_tmp = 1; h_tmp < a.size(); h_tmp = h_tmp * 3 + 1) h = h_tmp;
	while (h > 0)
	{
		H.push_back(h);
		h /= 3;
	}

	shell_sort(a, H);

	cout << H.size() << endl;
	REP(i, H.size())
	{
		if (i != 0)cout << ' ';
		cout << H[i];
	}
	cout << endl;

	cout << cnt << endl;

	REPC(i, a)
	{
		cout << i << endl;
	}
}


Measured memory_bytes: 6692
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC";
    else cout << "ABC";
    return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>

int main(){
  int a[10];
  int i=0;
  int tmp=0;
  int flg=1;
  for(i=0;i<10;i++){
    scanf("%d",&a[i]);
  }

  i=0;

  while(flg){
    flg=0;
    for(i=0;i<9;i++){
      if(a[i]>a[i+1]){
        tmp=a[i];
        a[i]=a[i+1];
        a[i+1]=tmp;
        flg=1;
      }
    }
  }

  printf("%d\n%d\n%d\n",a[9],a[8],a[7]);
  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;
 class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a =new int[n];
		long sum;
		int i, min, max;
		for(i=0; i<n; i++) {
			a[i]= sc.nextInt();
		}
		
		sum = 0;
		min = a[0];
		max = a[0];
		for(i=0; i<n; i++) {
			if(a[i]<min)	min=a[i];
			else if(a[i]>max)	max=a[i];
			sum += a[i];
		}
		System.out.println(min + " " + max + " " + sum);
	}
}


Measured memory_bytes: 42380
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();

    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut pos = vec![0; n];
    for i in 0..n {
        pos[a[i] - 1] = i;
    }

    let mut ans = 1;
    let mut tmp = 1;
    for i in 1..n {
        if pos[i - 1] < pos[i] {
            tmp += 1;
            ans = max(ans, tmp);
        } else {
            tmp = 1;
        }
    }
    println!("{}", n - ans);
}


Measured memory_bytes: 6344
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Miguel Mini
 */

#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define trav(v, x) for (auto v : x)
#define re(x, y, z) for (int x=y; x<z; ++x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
const int maxn = 2e5 + 10;
long long memo[2][maxn];
long long memo2[2][maxn];
int a[maxn];

class F {
public:
    long long get(int a[], int n) {
        memo[0][0] = a[0];
        memo[1][0] = a[1];
        for (int i = 2; i < n; i += 2) {
            memo[0][i] = memo[0][i-2] + a[i];
            memo[1][i] = max(memo[0][i-2], memo[1][i-2]) + a[i+1];
        }
        return  max(memo[0][n-2], memo[1][n-2]);
    }
    int testNumber = 0;
	void solve(istream& in, ostream& out) {
        //out << "Case #" << ++testNumber << ": ";
        int n;
        in >> n;
        re(i, 0, n) in >> a[i];
        long long ans;
        if (n & 1) {
            memo[0][0] = a[0];
            memo[1][0] = a[1];
            for (int i = 2; i < n; i += 2) {
                memo[0][i] = memo[0][i-2] + a[i];
                memo[1][i] = max(memo[0][i-2], memo[1][i-2]) + a[i+1];
            }
            reverse(a, a+n);
            memo2[0][0] = a[0];
            memo2[1][0] = a[1];
            for (int i = 2; i < n; i += 2) {
                memo2[0][i] = memo2[0][i-2] + a[i];
                memo2[1][i] = max(memo2[0][i-2], memo2[1][i-2]) + a[i+1];
            }
            reverse(a, a+n);
            ans = -1e18;
            for (int i = 0; i < n; ++i) {
                if (i&1) {
                    ll temp11 = i<3?0:memo[0][i-3];
                    ll temp12 = i<3?0:memo[1][i-3];
                    ll temp21 = i+4>n?0:memo2[1][n-i-4];
                    ll temp22 = i+4>n?0:memo2[0][n-i-4];

                    //[0 1 2] 3 4 5 6
                    //1 -> 2
                    //n-1-(i+3)


                    ans = max(ans, temp11 + a[i-1] + max(temp21, temp22));
                    ans = max(ans, max(temp11, temp12) + a[i+1] + temp22);
                } else {
                    ll temp = i<2?0:max(memo[0][i-2], memo[1][i-2]);
                    ll temp2 = i+3>n?0:max(memo2[1][n-i-3], memo2[0][n-i-3]);
                    ans = max(ans, temp + temp2);
                }
                //if (ans == 298) {
                //    cout << i << endl;
                 //   break;
                //}
            }
            //a[n] = 0;
            //ans = max(ans, get(a, n+1));
            //reverse(a, a+n);
            //ans = max(ans, get(a, n+1));
        } else ans = get(a, n);
        out << ans << endl;
	}
};

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

Measured memory_bytes: 10616
import java.util.Scanner;

public class Main {
    static long MOD = 998244353;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt(), S = in.nextInt();
        int[] A = new int[N];
        for (int i=0;i<N;i++) A[i] = in.nextInt();
        long[] dp = new long[S+1];
        dp[0] = 1;
        for (int i=0;i<N;i++) {
            long[] tmp = new long[S+1];
            for (int j=S;j>=0;j--) {
                tmp[j] = (dp[j] * 2) % MOD;
            }
            for (int j=S-A[i];j>=0;j--) {
                tmp[j + A[i]] = (tmp[j + A[i]] + dp[j]) % MOD;
            }
            dp = tmp;
        }

        System.out.println(dp[S]);
    }
}


Measured memory_bytes: 54704
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main() {
	int S,h,m,s;
	scanf("%d", &S);
	h = S / 3600;
	S = S % 3600;
	m = S / 60;
	S = S % 60;
	s = S;
	
	printf("%d:%d:%d\n", h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
int N, d[7], a[320], s, g;
vector<pair<int, int>> dp[320];
int main() {
	cin >> N;
	for (int i = 1; i <= 6; i++)cin >> d[i];
	cin >> s >> g;
	for (int i = 1; i <= N; i++)cin >> a[i];
	for (int i = 0; i < 320; i++) {
		for (int j = 0; j < 10000; j++)dp[i].push_back(make_pair(0, 0));
	}
	dp[s].clear(); queue<int>Q; Q.push(s);
	while (!Q.empty()) {
		int to = Q.front(); Q.pop();
		for (int i = -1 * N; i <= N; i++) {
			int e = abs(i); int OK = 0;
			for (int j = 1; j <= 6; j++) {
				if (e == d[j])OK = 1;
			}
			if (i == 0 || OK == 0)continue;
			if (to + i <= 0 || to + i > N)continue;
			int v = to + i + a[to + i];
			if (dp[v].size() > dp[to].size() + 1) {
				dp[v] = dp[to];
				if (i <= -1)dp[v].push_back(make_pair(-1, -i));
				if (i >= 1)dp[v].push_back(make_pair(1, i));
				Q.push(v);
			}
		}
	}
	for (int i = 0; i < dp[g].size(); i++) {
		while (true) {
			int p; cin >> p;
			if (d[p] == dp[g][i].second) {
				cout << dp[g][i].first << endl;
				break;
			}
			else {
				cout << "0" << endl;
			}
		}
	}
	return 0;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	string S;
	
	cin >> S;
	
	if(S == "Sunny")
		cout << "Cloudy";
	else if(S == "Cloudy")
		cout << "Rainy";
	else
		cout << "Sunny";
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
   int  n , l;cin>>n>>l;
   vector<int>v(n+1);
   ll sum = 0;
   bool ok = false;
   vector<int>vp,vn;
   for(int i=1;i<=n;i++){

    v[i] =  l+i-1;
    sum+=v[i];
    if(v[i] == 0){
        ok = true;
    }
    if(v[i] < 0){
        vn.push_back(abs(v[i]));
    }
    if(v[i] > 0){
        vp.push_back(v[i]);
    }
   }
   if(ok){
    cout<<sum<<endl;
    return 0 ;
   }
   sort(vp.begin(),vp.end());
   sort(vn.begin(),vn.end());
   if(vp.size() == 0){
    cout<<sum+vn[0];
    return 0;
   }
   if(vn.size() == 0){
    cout<<sum-vp[0];
    return 0 ;
   }
   if(vn[0] >= vp[0]){
    cout<<sum-vp[0];
    return 0 ;
   }
   if(vn[0] < vp[0]){
    cout<<sum+vn[0];
    return 0;
   }

    return 0 ;
}


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

int main(void) {
  int M1, M2, D1, D2, ans=0;

  cin >> M1 >> D1;
  cin >> M2 >> D2;

  if(M2==M1+1) ans=1;

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstdlib>
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)

typedef long long ll;

using namespace std;

int main(){
    int K;
    int c[100001];
    string s;
    cin>>s;
    cin>>K;
    int p=s.size()-1;
    rp(i,0,s.size()){
        int tmp=int('z')-int(s[i])+1;
        if (s[i]=='a') tmp=0;
        if(tmp<=K) {c[i]=int('a');K-=int(tmp);}
        else {c[i]=int(s[i]);}
    }
    K=K%26;
    c[p]+=K;

    rp(i,0,s.size()) cout<<char(c[i]);
    cout<<endl;
    return 0;
}



Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>

int main(){
  char S[200002],T[200002];
  int N,c=0;;
  scanf("%s\n%s",S,T);
  N=strlen(S);
  for(int i=0;i<N;i++){
    if(S[i]!=T[i]) c++;
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 2072
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
#include <stack>
//#include <math.h>
//#include <vector>
#include <string>
//typedef long long LL;
using namespace std;
 
int main(){
    string s;
    stack<char> cube;
    int ans=0;
    cin >> s;
    for(int i=0; i<s.size(); i++){
        if(!cube.empty() && cube.top()!=s[i]){
            cube.pop();
            ans+=2;
        }else{
            cube.push(s[i]);
        }
    }
    cout << ans << endl;
}

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

ll dp[3030][3030];

int main(){
    string s, t;
    cin >> s >> t;
    s = "+" + s;
    t = "@" + t;
    for(ll i = 1; i < s.size(); i++){
        for(ll j = 1; j < t.size(); j++){
            if(s[i] == t[j])dp[i][j] = dp[i - 1][j - 1] + 1;
            else dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
        }
    }
    string ans = "";
    for(ll i = s.size() - 1, j = t.size() - 1; i || j;){
        if(s[i] == t[j]){
            ans += s[i];
            i--;
            j--;
        }
        else if(i == 0)j--;
        else if(j == 0)i--;
        else if(dp[i - 1][j] > dp[i][j - 1])i--;
        else j--;
        
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 71936
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int main(){
	// sengen
	string s;
	// nyuryoku
	cin >> s;
	int n = s.size();
	int val[2019] = {};
	// keisan
	LL mul = 1;
	LL rem = 0;
	val[rem]++;
	LL ans = 0;
	for(int i=0;i<n;i++){
		LL add = s[n-1-i] - '0';
		rem = (rem + add*mul)%2019;
		mul = (mul*10)%2019;
		val[rem]++;
	}
	for(int i=0;i<2019;i++){
		ans += val[i]*(val[i]-1)/2;
	}
	// syutsuryoku
	cout << ans << endl;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 2e5+10 , M = 5e5+10 ,  MOD = 1e9+7;
const ll OO = 0x3f3f3f3f;
const double EPS = 1e-3;
#define M_PI 3.14159265358979323846
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define pb push_back
#define F first
#define S second
#define all(v) ((v).begin()) , ((v).end())
#define sz(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 

int k;
    
int main(){
    
 
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
 

    vector < int > v(5);
    for(auto &x : v)
        cin >> x;
    
    cin >> k;
    puts(v[4]-v[0] > k ? ":(" : "Yay!");
    


    return 0;
}

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

int main()
{

int  n;
string s;
cin>>n>>s;
int tmp=1;
char c;
for(int i=0;i<n;i++)
{
for(int k=i+1;k<n;k++)
{
   c=s[i];
   for(int k=i;k<n;k++)
   {
       if(s[k]==c)i++;
       else
       {
           tmp++;
           break;
       }
   }
}
}
cout<<tmp;

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define M 200005
#define ll long long
int a[M],cnt[M]; 
int main(){
	int n;ll ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),cnt[a[i]]++;
	for(int i=1;i<=n;i++)
		if(cnt[i]>=2)ans+=(ll)cnt[i]*(cnt[i]-1)/2;
	for(int i=1;i<=n;i++){
		if(cnt[a[i]]<2)printf("%lld\n",ans);
		else printf("%lld\n",ans-cnt[a[i]]+1);
	} 
	return 0;
}
//5942866 

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int main(){
    vector<bool> pr(100001,true);
    for(ll i = 2; i <= 100000; i++){
        if(pr[i]){
            for(ll j = i*i; j <= 100000; j += i){
                pr[j] = false;
            }
        }
    }
    vector<int> ans(100001,0);
    for(int i = 2; i <= 100000; i++){
        if(i % 2 == 1 && pr[i] && pr[(i+1)/2]) ans[i] = ans[i-1] + 1;
        else ans[i] = ans[i-1];
    }
    int q; cin >> q;
    for(int i = 0; i < q; i++){
        int l,r; cin >> l >> r;
        cout << ans[r] - ans[l-1] << endl;
    }
    return 0;
}


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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}
const int m = 1e9 + 7;
long long n, k, ans;
int main(){
    n = read(), k = read();
    for (long long i = k; i <= n + 1; i++){
        unsigned long long s = (i - 1) * i >> 1;
        unsigned long long b = (n + n - i + 1) * i >> 1;
        //cout << i << ' ' << s << ' ' << b << endl;
        ans += (b - s + 1) % m;
        ans = ans % m;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
const long long inf=1e9+7;
const long long mod=1e9+7;
const int64_t CYCLES_PER_SEC=2800000000;
//
inline uint32_t Xor128(){
	static uint32_t x=123456789;
	static uint32_t y=362436069;
	static uint32_t z=521288629;
	static uint32_t w=88675123;
	uint32_t t=x^(x<<11);
	x=y;y=z;z=w;
	return w=(w^(w>>19))^(t^(t>>8));
}
struct Timer{
	int64_t start;
	Timer(){reset();}
	void reset(){start=getcycle();}
	void plus(double a){start-=(a*CYCLES_PER_SEC);}
	inline double get(){return (double)(getcycle()-start)/CYCLES_PER_SEC;}
	inline int64_t getcycle(){
		uint32_t low,high;
		__asm__ volatile ("rdtsc":"=a"(low),"=d"(high));
		return ((int64_t)low)|((int64_t)high<<32);
	}
};
int main(){
	double l;
	cin>>l;
	cout<<fixed<<setprecision(12)<<l*l*l/27<<endl;
	return 0;
}

Measured memory_bytes: 256
// file creato da gio il 2020-03-31 21:23:51.243900

#include <bits/stdc++.h>
#define FAST 

#ifdef FAST
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

#define S second
#define F first
#define PB push_back
using namespace std;

int main(){
	//freopen("output","w",stdout);
	//freopen("input","r",stdin);
#ifdef FAST
	ios::sync_with_stdio(0);
  	cin.tie(0);
#endif

	string s;
	cin >> s;
	if(s[5-1]==s[6-1]&&s[3-1]==s[4-1]){
		cout << "Yes\n";
	}else{
		cout <<"No\n";
	}

	
}

Measured memory_bytes: 256
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass #sortされていない

n = int(input())
ans = 0
for i in range(1,n+1):
    if i%2 == 1 and len(divisor(i)) == 8:
        ans += 1
print(ans)


Measured memory_bytes: 3188
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>

using namespace std;

int main(){

    string S;
    cin >> S;

    int N = S.size();

    vector<int> ans(N, 0);

    char old_c = 'R';
    int R_count = 0;
    int L_count = 0;
    for(int i = 0; i < N; i++){
        if (old_c == 'R' && S[i] == 'R'){
            // cout << "R-R:" << i << endl;
            R_count++;
        }else if (old_c == 'R' && S[i] == 'L'){
            // cout << "R-L:" << i << endl;
            ans[i-1] += (R_count + 1) / 2;
            ans[i] += R_count / 2;
            R_count = 0;
            L_count = 1;
            if (i == N-1){ // 最後の処理
                ans[i] += 1;
            }
            old_c = 'L';
        }else if (old_c == 'L' && S[i] == 'L'){
            // cout << "L-L:" << i << endl;
            L_count++;
            if (i == N-1){ // 最後の処理
                ans[i-L_count] += L_count / 2;
                ans[i-L_count+1] += (L_count + 1) / 2;
            }
        }else if (old_c == 'L' && S[i] == 'R'){
            // cout << "L-R:" << i << endl;
            ans[i-L_count-1] += L_count / 2;
            ans[i-L_count] += (L_count + 1) / 2;
            R_count = 1;
            L_count = 0;
            old_c = 'R';
        }
    }

    for (int i = 0; i < N; i++){
        cout << ans[i] << " ";
    }

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s="";
  char c;
  while(cin>>c){
    if(c=='B'){
      if(s.size()!=0){
        s=s.substr(0,s.size()-1);
      }
    }
    else{
      s+=c;
    }
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(lambda x: int(x), input().split(" ")))

ans = 0

kari = 0
i = 0
for m in range(0,n-1):
	if h[m] >= h[m+1]:
		kari += 1
	else:
		kari = 0
	if ans < kari:
		ans = kari



print(ans)

Measured memory_bytes: 15020
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<< setprecision(20);

    int N;cin >> N;
    vector<int> vec;
    for(int i = 0;i < N-1;i++){
        int b;cin >> b;
        vec.push_back(b);
    }
    ll ans = vec.front();
    for(int i = 0;i < N-2;i++){
        ans += min(vec.at(i), vec.at(i+1));
    }
    ans += vec.back();
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
    int A,B,C;
    char a[11],b[11],c[11];
    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);
    if(a[strlen(a)-1]==b[0] && b[strlen(b)-1]==c[0]){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}

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

int main() {
  string s;
  int k;
  cin >> k >> s;
  if (s.size() > k) {
    for (int i = 0; i < k; i++) cout << s.at(i);
    cout << "..." << endl;
  }
  else cout << s << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define T second.first
#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,pair<int,int>> piii;

const int N= 1e4+5, L = 14, OO = 0x3f3f3f3f;
const ll M=1000000007  ;
const double ESP = 1e-8;



int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ll x;
    cin>>x;
    ll ans = 0;
    ans += (x/500)*1000;

    x%=500;
    ans += (x/5)*5;
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) (i%(ll)(1e9 + 7))


ull dp[55][55][3000] = {};

int main(){
	int n,a,x[55];
	cin >> n >> a;

	rep(i,0,n)cin >> x[i];
	dp[0][0][0] = 1;

	rep(i,0,n){
	    rep(j,0,n){
	        rep(k,0,3000){
	            dp[i+1][j+1][x[i]+k] += dp[i][j][k];
	            
	            dp[i+1][j][k] += dp[i][j][k];
	        }
	    }
	}

	ull ans = 0;
	rep(i,1,n+1)ans += dp[n][i][i*a];

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

Measured memory_bytes: 66560
<?php
 
$n = explode(" ", (trim(fgets(STDIN))));

if(($n[0] < 1 || $n[0] > 9) || ($n[1] < 1 || $n[1] > 9)) {
    echo -1;
} else {
    echo $n[0] * $n[1];
}


Measured memory_bytes: 4856
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)

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

  vector<int> c(n),s(n),f(n);
  r(i,n-1){
    cin>>c.at(i)>>s.at(i)>>f.at(i);
  }


  r(i,n){
    int t=0;
    for(int j=i;j<n-1;j++){
      if (t<s.at(j))t=s.at(j);
      else if ( t % f.at(j)==0);
      else t = t +f.at(j) - t %f.at(j);
      t +=c.at(j);
    }
      cout<<t<<endl;
  }
return 0;}


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

int main(int argc, char const *argv[])
{
    int n; cin >> n;
    vector<long long> a(n,0);
    for(int i=0;i<n;++i) cin >> a[i];
    sort(a.begin(),a.end());

    long long z; int m=n/2;
    if(n&1) {
        // -2, -2, -2, -2, 1, 1, 2, 2, 2
        // -2, -2, -2, -1, -1, 2, 2, 2, 2
        z = - accumulate(a.begin(), a.begin()+m,0L) 
        + accumulate(a.begin()+m, a.end(),0L);
        z *= 2;
        z += max(-a[m] - a[m+1],a[m-1] - 3*a[m]);
    } else {
        z = - accumulate(a.begin(), a.begin()+m,0L) 
        + accumulate(a.begin()+m, a.end(),0L);
        z *= 2;
        z -= -a[m-1] + a[m];
    }
    cout << z << endl;

    return 0;
}


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

int main() {
	int a, b, c, n, q;
	long long sum = 0;
	cin >> n;
	vector<int> cnt(100001);
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		cnt[a]++;
		sum += a;
	}
	cin >> q;
	long long* adSum;
	adSum = new long long[q];
	for (int i = 0; i < q; i++)
	{
		cin >> b >> c;
		adSum[i] = ((long long)c - b) * cnt[b];
		cnt[c] += cnt[b];
		cnt[b] = 0;
	}

	for (int i = 0; i < q; i++)
	{
		sum += adSum[i];
		cout << sum << endl;
	}
	return 0;
}

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

int main(){
    
    int w,h,n;
    cin >> w >> h >> n;
    vector<int> x(n),y(n),a(n);
    for(int i=0; i<n; i++){
        cin >> x.at(i) >> y.at(i) >> a.at(i);
    }

    int a1=0,a2=w,a3=0,a4=h;
    for(int i=0; i<n; i++){
        if(a.at(i)==1) a1=max(a1,x.at(i));
        else if(a.at(i)==2) a2=min(a2,x.at(i));
        else if(a.at(i)==3) a3=max(a3,y.at(i));
        else if(a.at(i)==4) a4=min(a4,y.at(i));
    }
    if(a2-a1>=0 && a4-a3>=0) cout << (a2-a1)*(a4-a3) << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3632
a=int(input())
b=int(input())
c=int(input())
x=int(input())
cnt=0
for i in range(a, -1, -1):
  for j in range(b, -1, -1):
    l=(x-500*i-100*j)//50
    if 0<=l<=c:
      cnt+=1
print(cnt)

Measured memory_bytes: 3064
import sys

file_input = sys.stdin
d = int(file_input.readline())

import bisect

def calc_distance(destination):
    p = bisect.bisect(shop, destination)
    d1 = shop[p] - destination
    d2 = destination - shop[p - 1]
    return min(d1, d2)

while d:
    n = int(file_input.readline())
    m = int(file_input.readline())
    shop = [int(file_input.readline()) for i in range(n - 1)]
    shop.append(0)
    shop.append(d)
    shop.sort()
    k = (int(file_input.readline()) for i in range(m))
    ans = sum(map(calc_distance, k))
    print(ans)
    d = int(file_input.readline())



Measured memory_bytes: 10224