akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

template <class T>
using gp_queue=priority_queue<T, vector<T>, less<T>>;

using Weight=int;
using DArray=vector<Weight>;
using DMatrix=vector<DArray>;

static const Weight INF=1<<29;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

pair<Weight, Edges> minimum_spanning_tree(const Graph &g, size_t s=0) {
    /* Prim */
    size_t V=g.size();
    Edges T;
    Weight total=0;

    vector<bool> visited(V);
    gp_queue<Edge> q; q.push(Edge(-1, s, 0));
    while (!q.empty()) {
        Edge e=q.top(); q.pop();
        if (visited[e.dst]) continue;

        T.push_back(e);
        total += e.weight;
        visited[e.dst] = true;
        for (const Edge &f: g[e.dst])
            if (!visited[f.dst])
                q.push(f);
    }

    return make_pair(total, T);
}

int main() {
    size_t n;
    scanf("%zu", &n);

    Graph g(n);
    for (size_t i=0; i<n; ++i)
        for (size_t j=0; j<n; ++j) {
            Weight a;
            scanf("%d", &a);

            if (a > -1)
                connect(g, i, j, a);
        }

    printf("%d\n", minimum_spanning_tree(g).first);
    return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 3;
	if (a == b && b == c) {
		cout << "1" << endl;
		return 0;
	}
	if (a == b) {
		ans--;
	}
	if (b == c){
		ans--;
		}
	if (a == c) {
		ans--;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,p;
  cin >> n >> p;
  int even = 0;
  int odd = 0;
  int a;
  long long int answer;
  for(int i = 0;i < n;i++){
    cin >> a;
    if(a % 2 == 0)even++;
    else odd++;
  }
  if(odd == 0){
    if(p == 0){
      answer = pow(2,n);
      cout << answer << endl;
    }
    else cout << 0 << endl;
  }else{
    answer = pow(2,n-1);
    cout << answer << endl;
  }
}
    


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

int main(){
	int n,m; cin>>n>>m;
	n++;
	vector<int> v(n);
	rep(i,m){
		int a,b; cin>>a>>b;
		v[a]++; v[b]++;
	}
	for(int i=1; i<n; i++) cout<<v[i]<<endl;
}

Measured memory_bytes: 3576
N = int(input())
data = []
max1 = 0
max2 = 0
for i in range(N):
    x = int(input())
    if x > max1:
        max1 = x
        max_i = i
    elif x > max2:
        max2 = x
for i in range(N):
    if max_i == i:
        print(max2)
    else:
        print(max1)

Measured memory_bytes: 4668
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(){
    int n;
    cin >> n;
    
    vector<vector<int>> to(n), cost(n);

    for(int i = 0; i < n-1; i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
        cost[a].push_back(c);
        cost[b].push_back(c);
    }

    vector<int> ans(n, -1);
    queue<int> q;
    ans[0] = 0;
    q.push(0);

    while(!q.empty()){
        int x = q.front();
        q.pop();

        for(int i = 0; i < to[x].size(); i++){
            int u = to[x][i];
            int w = cost[x][i];

            if(ans[u] != -1) continue;
            ans[u] = (ans[x] + w) % 2;
            q.push(u);
        }

    }

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


Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, k, a[N];
inline bool check(int len)
{
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		cnt += ceil(1.0 * a[i] / len) - 1;
		if (cnt > k) return 0;
	}
	return 1;
}
int main(){
	scanf ("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf ("%d", &a[i]);
	
	int l = 1, r = 1e9, mid, ans;
	while (l <= r) {
		mid = (l + r) >> 1;
		if (check(mid)) { ans = mid; r = mid - 1; }
		else l = mid + 1;
	}
	printf ("%d\n", ans);
  return 0;
}

Measured memory_bytes: 4464
N, A, B = map(int, input().split())

d = B - A

if (d % 2 == 0):
    ans = d // 2
else:
    left = B - 1
    right = N - A
    mini_1 = min(left, right)
    
    kado = min(A - 1, N - B)
    mini_2 = kado + 1 + (d - 1) // 2
    
    ans = min(mini_1, mini_2)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//
uint64_t dp[101010][13]; // mod13

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i){
        cin >> A[i];
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        // same を抜ける
        while (i + 1 < N && A[i] == A[i + 1]){
            ++i;
        }

        // up
        if (i + 1 < N && A[i] < A[i + 1]) {
            while (i + 1 < N && A[i] <= A[i + 1]){
                ++i;
            }
        }

        // down
        else if (i + 1 < N && A[i] > A[i + 1]) {
            while (i + 1 < N && A[i] >= A[i + 1]){
                ++i;
            }
        }
        ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  char c;
  cin >> c;
  bool ok = c=='a'||c=='e'||c=='i'||c=='o'||c=='u';
  if(ok) {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
a = list(map(int,input().split()))

ac = Counter(a)

cur_a = 0
res = 0
# print(ac)
for a,c in ac.items():
	# print(a,c)
	if c < 2:
		continue
	else:
		res = max(res,cur_a*a)
		cur_a = max(cur_a,a)
		if c >= 4:
			res = max(res,a*a)
	# print(cur_a,res)
print(res)

Measured memory_bytes: 18600
def main():
    N, K = map(int, input().split())
    S = input()

    if S[K-1] == 'A':
        new_S = S[0:K-1] + 'a' + S[K:N]
    elif S[K-1] == 'B':
        new_S = S[0:K-1] + 'b' + S[K:N]
    elif S[K-1] == 'C':
        new_S = S[0:K-1] + 'c' + S[K:N]

    print(new_S)


if __name__ == '__main__':
    main()



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

int main(){
    int n; cin >> n;
    ll sum = 0;
    vector<ll> lis(n);
    for(int i = 0; i < n; i++){
        cin >> lis[i];
        sum += lis[i];
    }
    ll mid = 0;
    for(int i = 1; i < n; i+=2){
        mid += (2*lis[i]);
    }
    vector<ll> ans(n);
    ans[0] = sum - mid;
    for(int i = 1; i < n; i++){
        ans[i] = 2 * (lis[i-1] - (ans[i-1]/2));
    }
    for(int i = 0; i < n; i++){
        cout << ans[i] << " ";
    }
}

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

int main(){
  int n;
  cin >> n;
  
  vi h(n+2);
  REP(i,1,n+1) cin >> h.at(i);
  h.at(0) = 0;
  h.at(n+1) = 0;
  
  int ans = 0;
  rep(i,1'000'0){
    int flag = 0;
    rep(j,n+2){
      if (flag == 0 && h.at(j) > 0){
        flag = 1;
        h.at(j)--;
      }
      else if (flag == 1 && h.at(j) == 0){
        flag = 0;
        ans++;
      }
      else if (flag == 1){
        h.at(j)--;
      }
    }
    /*rep(j,n+2){
      printf("%2d ", h.at(j));
    }
    printf("ans = %d", ans);
    cout << endl;*/
    int cnt = 0;
    rep(j,n+2){
      if (h.at(j) == 0){
        cnt++;
      }
    }
    if (cnt == n+2){
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int mod = 1e9 + 7;
const int MN = 5010;

int exp(int x, int n) {
    int ret = 1;
    while(n) {
        if(n & 1) ret = 1LL * ret * x % mod;
        x = 1LL * x * x % mod;
        n >>= 1;
    }
    return ret;
}
int inv(int x) {
    return exp(x, mod - 2);
}
int fact[MN], invf[MN];
int comb(int n, int k) {
    return 1LL * fact[n] * invf[k] % mod * invf[n - k] % mod;
}

int N, M, R;
string S;
int f[MN][MN], g[MN][MN];

int main() {
    fact[0] = 1;
    for(int i = 1; i < MN; i++) {
        fact[i] = 1LL * fact[i - 1] * i % mod;
    }
    for(int i = 0; i < MN; i++) {
        invf[i] = inv(fact[i]);
    }

    cin >> N >> S;

    M = S.size();
    R = N - M;

    f[0][0] = 1;
    for(int i = 2; i <= R; i++) {
        for(int j = 1; j <= M + R; j++) {
            f[i][j] += 2LL * f[i - 2][j - 1] % mod;
            f[i][j] %= mod;
            f[i][j] += 4LL * f[i - 2][j] % mod;
            f[i][j] %= mod;
            f[i][j] += 2LL * f[i - 2][j + 1] % mod;
            f[i][j] %= mod;
        }
    }

    g[0][0] = 1;
    for(int i = 1; i <= R; i++) {
        for(int j = 0; j <= R; j++) {
            g[i][j] += 2LL * g[i - 1][j + 1] % mod;
            g[i][j] %= mod;
            g[i][j] += g[i - 1][max(0, j - 1)];
            g[i][j] %= mod;
        }
    }

    int ans = 0;
    for(int i = 0; i <= R; i++) {
        for(int j = 0; j <= M; j++) {
            ans += 1LL * g[i][0] * f[R - i][j] % mod * comb(M, j) % mod;
            ans %= mod;
        }
    }
    printf("%d", ans);
}


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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;
bool fir[200000];
bool sec[200000];
int32_t main() {
    nitin;
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    --a;--b;--c;--d;
    string s;
    cin>>s;
    if(a>b)
    {
        swap(a,b);
        swap(c,d);
    }
    fir[a]=true;
    sec[b]=true;
    for(int i=1;i<=c;i++)
    {
        if(s[i]=='.')
        {
            fir[i]|=fir[i-1];
            fir[i]|=fir[i-2];
        }
    }for(int i=1;i<=d;i++)
    {
        if(s[i]=='.')
        {
            sec[i]|=sec[i-1];
            sec[i]|=sec[i-2];
        }
    }
    if(c<d)
    {
        if(fir[c] && sec[d])
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    else{
        for(int i=1;i<n-1;i++)
        {
            if(s[i]=='.' && sec[i] && fir[i-1] && fir[i+1])
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        cout<<"No"<<endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
typedef pair<ll,ll> P;
const ll INF=10000000000000000;
const ll mod=1000000007;
#define F first
#define S second
#define all(a) (a.begin(),a.end())
int main(void){
    int h,w,d;cin>>h>>w>>d;
    vector<vector<P>>v(d,vector<P>((h*w+d-1)/d));
    int x;
    rep(i,h)rep(j,w){
        cin>>x;
        v[x%d][(x+d-1)/d-1]=make_pair(i,j);
    }
    vector<vector<ll>>ans(d);
    rep(i,d){
        int j=0;
        ans[i].push_back(0);
        while(j<(h*w+d-1)/d){
            ans[i].push_back(ans[i][j]+abs(v[i][j].F-v[i][j+1].F)+abs(v[i][j].S-v[i][j+1].S));
            j++;
        }
    }
    int q;cin>>q;int m,n;
    rep(i,q){
        cin>>m>>n;
        cout<<ans[n%d][(n+d-1)/d-1]-ans[m%d][(m+d-1)/d-1]<<endl;
    }
}

Measured memory_bytes: 10240
#include "bits/stdc++.h"
#include <chrono>
#include <random>
#include <cstdio>
#define ll long long int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mod 998244353LL
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500001;
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
ll inf = 100000000000000000;

void solve() 
{
    int a, b, c, d, e, f;
    cin>>a>>b>>c>>d>>e>>f;
    
    vi x, y;

    rep(i, 3000)
    {
        rep(j, 3000)
        {
            int tmp = i*a + j*b;
            if(tmp*100 <= f)
            {
                x.pb(tmp);
            }
        }
    }

    // for(auto i:x) cout<<i<<" ";
    //     cout<<endl;

    rep(i, 3000)
    {
        rep(j, 3000)
        {
            int tmp = i*c + j*d;
            if(tmp <= f)
            {
                y.pb(tmp);
            }
        }
    }

    double mx = -1;
    int ans1, ans2;

    for(int i:x)
    {
        for(int j:y)
        {
            double p = (double)j/i;
            // cout<<p<<endl;
            if(p > e) continue;
            if(100*i + j > f) continue;
            double density = 100*(double)j/(i+(double)j);
            // cout<<i<<" "<<j<<" "<<density<<endl;
            if(density >= mx)
            {
                mx = density;
                ans1 = i, ans2 = j;
            }

        }
    }

    // cout<<mx<<endl;
    cout<<ans1*100 + ans2<<" "<<ans2<<endl;

    // cout<<(100)*(990)/(double)2790<<endl;

}

int main()
{   

    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


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

using namespace std;

int main(){

    int n,cont=0;
    int v[1000000];

    cin >> n;

    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    for(int j=0;j<n;j++){
        for(int k=j+1;k<n;k++){
            for(int l=k+1;l<n;l++){
                if(v[j]!=v[k] && v[k]!=v[l] && v[j]!=v[l]){
                    if(v[j]<v[k]+v[l] && v[j]>abs(v[k]-v[l])){
                        if(v[k]< v[j]+v[l] && v[k]>abs(v[j]-v[l])){
                            if(v[l]<v[k]+v[j] && v[l]>abs(v[k]-v[j])){
                                cont++;
                            }
                        }
                        
                    }   
                    
                }
            }
        }
    }

    cout << cont << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD = 1000000007LL;

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

    ld w, h, x, y;
    cin >> w >> h >> x >> y;

    cout << w * h / 2 << " ";

    if (x == w / 2 && y == h / 2) {
        cout << 1 << "\n";
    } else {
        cout << 0 << "\n";
    }

    return 0;
}

Measured memory_bytes: 888
use itertools::Itertools;
fn main() {
    proconio::input! {
        n: usize,
        m: usize,
        q: usize,
        abcds: [(usize, usize, usize, usize); q],
    }
    let ans = (1..=m)
        .combinations_with_replacement(n)
        .map(|v| {
            abcds
                .iter()
                .filter(|(a, b, c, _d)| v[*b - 1] - v[*a - 1] == *c)
                .fold(0, |sum, (_, _, _, d)| sum + d)
        })
        .max()
        .unwrap();
    println!("{}", ans);
}


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

const int moder = 1e9 + 7;
const int N = 100010;

int x[N], y[N], prex[N], prey[N];
int n, m;


int main(){
	scanf("%d%d", &n, &m);
	int sum1 = 0;
	for (int i = 1; i <= n; ++ i){
		scanf("%d", &x[i]);
		prex[i] = (prex[i - 1] + x[i]) % moder;
		sum1 = (sum1 + 1ll * x[i] * i - prex[i]) % moder;
	}
	int sum2 = 0;
	for (int i = 1; i <= m; ++ i){
		scanf("%d", &y[i]);
		prey[i] = (prey[i - 1] + y[i]) % moder;
		sum2 = (sum2 + 1ll * y[i] * i - prey[i]) % moder;
	}
	return printf("%lld\n", (1ll * sum1 * sum2 % moder + moder) % moder), 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define pb push_back
#define fi first`
#define se second
const int N = 1e5 + 500;
void solve()
{
    ll n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    std::vector<ll> v(n);
    for(int i=0;i<n;i++)
    {
    	v[i]=(s[i]-'0')%p;
    }
    if(p==2 or p==5)
    {
    	ll ans=0;
    	for(int i=0;i<n;i++)
    	if(v[i]==0)
    		ans+=(i+1);

    	cout<<ans;
    	return;
    }


    ll base=1;
    for(int i=n-1;i>=0;i--)
    {
    	v[i]*=base;
    	v[i]%=p;
    	base=base*10%p;
    }
    // for(auto i:v)
    // 	cout<<i<<" ";
    map<ll,ll> cnt;
    ll ans=0,tot=0;

    for(auto i:v)
    {
    	tot+=i;
    	tot%=p;
    	if(tot==0)
    		ans++;
    	ans+=cnt[tot];
    	cnt[tot]++;

    }
    cout<<ans;




}

int main()
{


    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
        // cout << endl;
    }

}




Measured memory_bytes: 2564
a, b, c =map(int, input().split())
i,j,k = a,b,c
X=0

if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
    print(0)
    exit()

if a ==b and b ==c:
  print('-1')
  exit()
else:
  while i%2 ==0 and j%2==0 and k%2==0:
    i = (b+c)/2
    j = (c+a)/2
    k = (a+b)/2
    a,b,c = i,j,k
    X +=1
print(X)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	public static void move(int sx, int sy, int tx, int ty, StringBuilder sb, boolean first){
		final int x_sign = Integer.signum(tx - sx);
		final int y_sign = Integer.signum(ty - sy);
		
		int cur_x = sx, cur_y = sy;
		if(!first){
			cur_x += (-x_sign);
			sb.append(x_sign > 0 ? "L" : "R");

			ty += (y_sign);
		}
		
		for(;cur_y != ty; cur_y += y_sign){
			sb.append(y_sign > 0 ? "U" : "D");
		}
		
		
		for(; cur_x != tx; cur_x += x_sign){
			sb.append(x_sign > 0 ? "R" : "L");
		}
		
		if(!first){
			sb.append(y_sign > 0 ? "D" : "U");
		}
	}
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int sx = sc.nextInt();
		final int sy = sc.nextInt();
		final int tx = sc.nextInt();
		final int ty = sc.nextInt();
		
		StringBuilder sb = new StringBuilder();
		
		move(sx, sy, tx, ty, sb, true);
		move(tx, ty, sx, sy, sb, true);
		move(sx, sy, tx, ty, sb, false);
		move(tx, ty, sx, sy, sb, false);
		
		System.out.println(sb);
		
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 8528
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int a,b,c,k,i,m,km;
  cin >> a >> b >> c >> k;
  m=max(a,max(b,c));
  km=m;
  for (i=0;i<k;i++) km*=2;
  cout << a+b+c+km-m << endl;
  return 0;
}

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

int main() {
	int n; cin >> n;
	int sum = 0;
	vector<int>s(n); for (auto&& x : s) { cin >> x; sum += x; }
	sort(s.begin(), s.end());
	for (int i = 0; i < s.size(); i++) {
		if (sum % 10 != 0) {
			cout << sum << endl;
			return 0;
		}
		sum -= s[i] % 10 != 0 ? s[i] : 0;
	}
	if (sum % 10 == 0)sum = 0;
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  val sc = new Scanner(System.in)
  def main(args: Array[String]): Unit = {
    val sA = sc.next
    val sB = sc.next
    val sC = sc.next

    val res = loop(sA,sB,sC, "a")

    println(res)
  }

  def loop(strA: String, strB: String, strC: String, player: String): String = {
//    println(s"(strA, strB, strC, player) = ${(strA, strB, strC, player)}")
    (strA, strB, strC, player) match{
      case ("", _, _, "a") => "A"
      case (_, "", _, "b") => "B"
      case (_, _, "", "c") => "C"

      case (stA, stB, stC, _) =>
        player match{
          case "a" => loop(stA.substring(1), stB, stC, stA.head.toString)
          case "b" => loop(stA, stB.substring(1), stC, stB.head.toString)
          case "c" => loop(stA, stB, stC.substring(1), stC.head.toString)
        }
    }
  }
}


Measured memory_bytes: 25552
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
    if (x < y) {
        swap(x, y);
    }
    if (y == 0) {
        return x;
    } else {
        return gcd(y, x % y);
    }
}

bool isEternal(ll a, ll b, ll c, ll d) {
    if (a < b) {
        return false;
    } else {
        if (d % b == 0) {
            return !(c < a % b && a % b < b); 
        } else if (b > d) {
            return false;
        } else {
            ll n = gcd(b, d - b);
            ll m = a % b;
            return !(n * ((c - m) / n) + m + n < b);
        }
    }
}

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

    for (int i = 0; i < t; i++) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if (isEternal(a, b, c, d)) {
            cout << "Yes" << "\n";
        } else {
            cout << "No" << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 256
// ~/SolverToBe/Developers/Corvus
// ~/sudo apt-get verdict Accpeted

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>
#include <assert.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = 200005, M = 1000005;
const ll MOD = 1e9 + 7;
const double eps = 1e-9;

int n,h[N],a[N];
ll seg[4*N], dp[N];

void add(int p,int s,int e,int i,ll v) {
    if(s==e) {
        seg[p] = max(seg[p], v);
        return;
    }
    if(i<=(s+e)/2) add(2*p,s,(s+e)/2,i,v);
    else add(2*p+1,(s+e)/2+1,e,i,v);
    seg[p] = max(seg[2*p],seg[2*p+1]);
}

ll get(int p,int s,int e,int l,int r) {
    if(s>=l && e<=r)
        return seg[p];
    if(s>r || e<l)
        return -1e9;
    return max(get(2*p,s,(s+e)/2,l,r), get(2*p+1,(s+e)/2+1,e,l,r));
}

int main() {
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",h+i);
    for(int i=0; i<n; i++)
        scanf("%d",a+i);
    ll ans = 0;
    for(int i=0; i<n; i++) {
        dp[i] = get(1,1,n,1,h[i]) + a[i];
        add(1,1,n,h[i],dp[i]);
        ans = max(ans, dp[i]);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <deque>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){

    int a, b;
    cin>>a>>b;
    
    int cnt=0;
    
    for(int i=a; i<=b; i++){
        string s=to_string(i);
        string ss=s;
        reverse(ss.begin(), ss.end());
        
        if(s==ss){
            cnt++;
        }
    }
    
    cout<<cnt<<endl;
}


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

const int INF = 1e9+7;
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,M;
	cin >> N >> M;
	vector<pair<int,int>> key;
	for(int i=0;i<M;i++){
		int a,b;
		cin >> a >> b;
		int s = 0;
		for(int j=0;j<b;j++){
			int c;
			cin >> c;
			c--;
			s |= (1<<c);
		}
		key.emplace_back(s,a);
	}
	vector<int> dp(1<<N,INF);
	dp[0] = 0;
	for(int s=0;s<(1<<N);s++){
		for(int i=0;i<M;i++){
			int t = s | key[i].first;
			int cost = dp[s]+ key[i].second;
			dp[t] = min(dp[t],cost);
		}
	}
	int ans = dp.back();
	if(ans == INF)cout << -1 << endl;
	else cout << ans << endl;
}

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


int main()
{
    long long N;
    cin >> N;
    vector<pair<long long,long long>> ball(N);
    for( long long i = 0; i < N; ++i ) cin >> ball[i].first >> ball[i].second;


    long long cost = 51;
    for( long long i = 0; i < N; ++i ){
        for( long long j = 0; j < N; ++j ){
            if( i == j ) continue;
            long long p = ball[j].first - ball[i].first;
            long long q = ball[j].second - ball[i].second;
            long long same_d = 0;
            for( long long k = 0; k < N; ++k ){
                for( long long l = 0; l < N; ++l ){
                    if( k != l 
                    and p == ball[l].first - ball[k].first
                    and q == ball[l].second - ball[k].second ) ++same_d;
                }
            }
            cost = min(cost, N-same_d);
        }
    }
    if(N == 1) cout << 1 << endl;
    else cout << cost << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	string s;
	cin >> s;
	bool ch[4];
	fill(ch, ch+4, false);
	for(int i = 0; i < (int)s.size(); i++){
		if(s[i] == 'N')ch[0] = true;
		else if(s[i] == 'W')ch[1] = true;
		else if(s[i] == 'S')ch[2] = true;
		else ch[3] = true;
	}
	if(ch[0] == ch[2] && ch[1] == ch[3])cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<climits>
using namespace std;
#define N 100000
char s[N];
int main()
{
	scanf("%s",s+1);
	int lens=strlen(s+1);
	for(int i=1;i<=lens;i++)
	{
		if(s[i]==s[i+1]) 
		{
		printf("%d %d",i,i+1);
		return 0;
		}
		else if(s[i]==s[i+2])
		{
			printf("%d %d",i,i+2);
			return 0;
		}
	}
	printf("-1 -1");
}

Measured memory_bytes: 256
# 全部の赤を左側に持っていきたい
N = int(input())
C = input()

Red_cnt = 0
for i in range(N):
    if C[i] == "R":
        Red_cnt += 1

ans = 0
for i in range(Red_cnt):
    if C[i] == "W":
        ans += 1
print(ans)


Measured memory_bytes: 67376
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	map<int, int> occs1, occs2;
	int x;
	for (int i = 0; i < n; ++i) {
		cin >> x;
		if (i & 1) {
			++occs2[x];
		} else {
			++occs1[x];
		}
	}

	int a = 0, b = 0;
	int oa = 0, ob = 0;
	for (auto it = occs1.begin(); it != occs1.end(); ++it) {
		if (it->second > oa) {
			ob = oa;
			b = a;
			oa = it->second;
			a = it->first;
		}
		else if (it->second > ob) {
			ob = it->second;
			b = it->first;
		}
	}	

	int c = 0, d = 0;
	int oc = 0, od = 0;
	for (auto it = occs2.begin(); it != occs2.end(); ++it) {
		if (it->second > oc) {
			od = oc;
			d = c;
			oc = it->second;
			c = it->first;
		}
		else if (it->second > od) {
			od = it->second;
			d = it->first;
		}
	}

	if (a != c) {
		cout << n / 2 - oa + n / 2 - oc << "\n";
	} else {
		cout << min(n / 2 - oa + n / 2 - od, n / 2 - ob + n / 2 - oc) << "\n";
	}

	return 0;

}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vector<double> t(n), v(n);
    int totalt = 0;
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
        totalt += t[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    vector<double> speed;
    speed.reserve(2 * totalt);
    speed.push_back(0);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < t[i]; ++j) {
            speed.push_back(v[i]);
            speed.push_back(v[i]);
        }
        if (i != n - 1)
            chmin(speed.back(), v[i + 1]);
    }
    speed.back() = 0;
    for (int i = 1; i < 2 * totalt + 1; ++i) {
        chmin(speed[i], speed[i - 1] + 0.5);
    }
    for (int i = 2 * totalt; i >= 0; --i) {
        chmin(speed[i], speed[i + 1] + 0.5);
    }
    double ret = 0;
    for (int i = 1; i < 2 * totalt + 1; ++i) {
        ret += (speed[i] + speed[i - 1]) / 2.0 / 2.0;
    }
    cout << fixed << setprecision(10) << ret << "\n";
    return 0;
}

Measured memory_bytes: 896
import heapq
N, M, S, T = map(int, input().split())
S,T = S-1, T-1 # 0-indexed
A = [[] for _ in range(N)]
B = [[] for _ in range(N)]
inf = 10**18

for i in range(M):
  u,v,a,b = map(int, input().split())
  u,v = u-1, v-1
  A[u].append((v,a))
  A[v].append((u,a))
  B[u].append((v,b))
  B[v].append((u,b))
  
def dij(D, parent):
  fixed = [ False for _ in range(N)]
  ret = [ 10**18 for _ in range(N)]
  h = []
  heapq.heappush(h, (0,parent))
  while h:
    d, now = heapq.heappop(h)
    if fixed[now]:
      continue
    fixed[now] = True
    ret[now] = d
    for nxt, cost in D[now]:
      if fixed[nxt]:
        continue
      heapq.heappush(h, (d+cost, nxt))
  return ret
  
DA = dij(A, S)
DB = dij(B, T)

ANS = [ 0 for _ in range(N+1) ]
ANS[N] = inf
for i in range(N-1,-1,-1):
  ANS[i] = min(ANS[i+1], DA[i] + DB[i])
  
for i in range(N):
  print(10**15 - ANS[i])

#print(DA)
#print(DB)
"""
aのネットワークと、bのネットワーク別々に作って、SからTの最短距離を出す
n-1年目から1年目に遡っていく形で最短を出していく。
A[S][T] と A[S][N-1] + B[N-1][T]を比較すれば良い
"""

Measured memory_bytes: 127092
import java.util.Scanner;
//0630
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),d=sc.nextInt(),e=sc.nextInt(),s=0;
        System.out.println(a<=0?a*-c+d+e*b:(b-a)*e);
    }
}


Measured memory_bytes: 26240
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
using namespace std;
typedef long long ll;

int main() {
	ll i, j;
	ll a;
	string s;
	cin >> a;
	cin >> s;
	if (a < 3200)
		s = "red";
	cout << s << endl;

	return 0;
}

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

int main(){
    int M1, M2, D1, D2;
    cin >> M1 >> D1;
    cin >> M2 >> D2;

    if((M1<M2) || (M1==12 && M2==1)) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	S := next()
	i := 0
	for _, s := range S {
		k := (int)(s - '0')
		i = (i + k) % 9
	}
	if i%9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 2196
#include<iostream>
#include<cassert>
using namespace std;
#define MAX 100000
typedef long long ll;

int n, k;
ll T[MAX];

// 最大積載量 P の k 台のトラックで何個の荷物を積めるか？
int check(ll p){
  int i = 0;
  for ( int j = 0; j < k; j++ ){
    ll s = 0;
    while( s + T[i] <= p ) {
      s += T[i];
      i++;
      if ( i == n ) return n;
    }
  }
  return i;
}

int solve(){
  ll left = 0;
  ll right = 100000*10000; // 荷物の個数×1個当たりの最大重量
  ll mid;
  while( right - left > 1 ){
    mid = (left + right)/2;
    int x = check(mid); // mid == P を決めて何個積めるかチェック
    if ( x >= n ) right = mid;
    else left = mid;
  }

  return right;
}

main(){
  cin >>n >> k;
  for ( int i = 0; i < n; i++ ) cin >> T[i];
  ll ans = solve();
  cout << ans << endl;
}





Measured memory_bytes: 3848
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<59)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

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

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV], ax[MV];
ll arr[MV];

void solve(int T)
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	cin>>ar[i];
	for(int i=0;i<m;i++)
	{
		int s,d;
		cin>>s>>d;
		int p1 = ax[s];
		int p2 = ax[d];
		int h1 = ar[s];
		int h2 = ar[d];
		ax[s] = max(p1, h2);
		ax[d] = max(p2, h1);
	}
	int ct = 0;
	for(int i=1;i<=n;i++)
	ct += (ax[i] < ar[i]);
	cout<<ct<<"\n";
	return;	
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 4440
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  long a,b;
  cin >> a >> b;
  long ans = 0;
  rep(i,b-a+1) ans += i;
  cout << ans - b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<4;i++){
		if(s[i]=='+')
			ans++;
		if(s[i]=='-')
			ans--;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
  string s;
  cin >> s;
  int cnt=0;
  FOR(i,s.size()){
    if(s[i]=='o'){
      
    }else{
      cnt++;
    }
  }
  if(cnt>7){
    cout << "NO" << endl;
  } else{
    cout << "YES" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int  main(void){
	int n;
	int a[100];
cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int j=n-1;j>=0;j--){
		if(j!=0)
	cout<<a[j]<<' ';
		else cout<<a[j]<<endl;
	} 
	return 0;
}


Measured memory_bytes: 3064
n, k =gets.chomp.split(' ').map(&:to_i)
s = gets.chomp
i = k-1
t = s[i].downcase

if k == 1
  print("#{t}#{s[k..-1]}\n")
else
  print("#{s[0..i-1]}#{t}#{s[k..-1]}\n")
end


Measured memory_bytes: 1788
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
	int  n;
	char str1[100];
	char str2[100];
	
	cin>>n;
	cin>>str1>>str2;

	char *top = str1;
	char *mid = str2;
	
	for(int i=0; i<n ; i++) {
		cout<<*top++;
		cout<<*mid++;
	}
	cout<<endl;
	
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000;
const ll LINF=4000000000000000010;
int main(){
	int n;
	double t,a;cin>>n>>t>>a;
	double h[1010];
	double ans=INF;
	int res=0;
	for(int i=0;i<n;i++){
		cin>>h[i];
		if(ans>abs(a-(t-h[i]*0.006))){
			ans=abs(a-(t-h[i]*0.006));
			res=i+1;
		}
	}
	cout<<res<<endl;
}	


Measured memory_bytes: 256
#pragma GCC optimize("O3") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
#define __USE_MINGW_ANSI_STDIO 0
#include<bits/stdc++.h>                               
using namespace std;

#define PI acos(-1)
#define pb push_back
#define fi first
#define se second
#define TASK ""
#define sz(a) (int)(a).size()
#define all(c) (c).begin(), (c).end()
#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair <int, int> pii;
typedef vector <vi> vvi;
typedef vector <pii> vpii;
typedef vector <string> vs;

const int MAXN = 2e5 + 9;
const int MOD = (int)(1e9 + 7);
const int LOG2MAXN = 17;
const int INF = 1e9;

int di[] = {0, 1, 0, -1};
int dj[] = {1, 0, -1, 0};
char ddir[] = {'R', 'U', 'L', 'D'};

ll add[MAXN], answer[MAXN], psum[MAXN], mul[MAXN];
ll padd[MAXN], pmul[MAXN];

void input() {    
	ll n, m;
	ll res = 0;
	cin >> n >> m;
	vll aa(n, 0);
	for(int i = 0; i < n; i++) {
		cin >> aa[i];
		if(i > 0) {
			if(aa[i] > aa[i - 1]) {
				res += aa[i] - aa[i - 1];
				mul[aa[i - 1] + 2]++;
				mul[aa[i] + 1]--;
				add[aa[i] + 1] += aa[i - 1] + 1;
				add[aa[i - 1] + 2] -= aa[i - 1] + 1;
			}
			else {
				res += (aa[i] + (m - aa[i  - 1]));
				mul[aa[i - 1] + 2]++;
				mul[aa[i] + m + 1]--;
				add[aa[i] + m + 1] += aa[i - 1] + 1;
				add[aa[i - 1] + 2] -= aa[i - 1] + 1;
			}
		}
	}
	for(int i = 1; i <= 2 * m; i++) {
		padd[i] = padd[i - 1] + add[i];
		pmul[i] = pmul[i - 1] + mul[i];
	}
	/*for(int i = 1; i <= 2 * m; i++) cerr << "\t" << padd[i] << ' ';
	cerr << endl;
	for(int i = 1; i <= 2 * m; i++) cerr << "\t" << pmul[i] << ' ';
	cerr << endl;*/
	for(int i = 1; i <= 2 * m; i++) {
		ll curmul = pmul[i];
		ll curadd = padd[i];
		ll cur = curadd + curmul * i;
		//cerr << "\t" << cur << ' ';
		int tt = i;
		if(tt > m) tt -= m;
		answer[tt] += cur;
	}
	//cerr << endl;
	ll ans = 0;
	for(int i = 1; i <= m; i++) {
		//cerr << res - answer[i] << ' ';
		ans = max(ans, answer[i]);
	}
	cout << res - ans;
}

void solve() {
	
}

int main() {     
#ifdef LOCAL
	freopen("xxx.in", "r", stdin);
	freopen("xxx.out", "w", stdout);
#else
	//freopen(TASK".in", "r", stdin);
	//freopen(TASK".out", "w", stdout);
#endif	
	input();
	solve();
	return 0;
}


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


int main() {
	int n, m;
	cin >> n >> m;
	vector<string> a(n), b(m);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) cin >> b[i];
	int lim = n - m + 1;
	for (int top = 0; top < lim; top++) {
		for (int left = 0; left < lim; left++) {
			bool inc = true;
			for (int h = 0; h < m; h++) {
				if (a[top + h].substr(left, m) != b[h]) {
					inc = false;
					break;
				}
			}
			if (inc) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))

unit = n*(n+1)//2
k, m = divmod(sum(a), unit)
if m:
    ans = "NO"
else:
    count = [None] * n # iを選んだ回数
    for i in range(n):
        diff = a[i] - a[i-1]
        x, m = divmod(k- diff, n)
        if x<0 or m:
            ans = "NO"
            break
        count[i-1] = x
    else:
        if sum(count)==k and sum(c*(n-i) for i,c in enumerate(count)):
            ans = "YES"
        else:
            ans = "NO"
print(ans)

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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   int N, ans = 0;
   cin >> N;
   vector<int> h(N);
   rep(i, N) cin >> h.at(i);

   bool done = false;
   while (done == false) {
     bool done_tmp = false;
     rep(i, N) {
       if (h.at(i) > 0) {
         done = false;
         h.at(i)--;
         ans++;
         for (int j = i + 1; j < N; j++) {
           if (h.at(j) == 0) break;
           else h.at(j)--;
         }
         done_tmp = true;
       }
       if (done_tmp) break;
       else done = true;
     }
   }
   cout << ans << endl;
 }


Measured memory_bytes: 256
from itertools import product

# 10 ** 9
l753 = []
for i in range(3, 10):
    l = ['753'] * i
    for s in product(*l):
        if '7' in s and '3' in s and '5' in s:
            l753.append(int("".join(s)))
l753 = sorted(l753)
N = int(input())
count = 0
for i in l753:
    if i > N:
        break
    count += 1
print(count)



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

using i64 = std::int_fast64_t;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()

signed main() {
  i64 N, M;
  scanf("%lld %lld", &N, &M);
  vector<i64> A(N);
  REP(i, N) scanf("%lld", &A[i]);
  sort(ALL(A));
  vector<i64> S(N + 1);
  REP(i, N) S[i + 1] = S[i] + A[i];
  i64 h_ng = 0;
  i64 h_ok = A[N - 1] * 2 + 1;
  i64 h = h_ok;
  i64 ans = 0;
  while (h_ok > h_ng + 1) {
    h = (h_ok + h_ng) / 2;
    i64 s = 0;
    i64 q = 0;
    i64 r = 0;
    i64 ge = 0;
    i64 gt = 0;
    RREP(i, N) {
      while (ge < N && !(A[i] + A[ge] >= h)) ge++;
      while (gt < N && !(A[i] + A[gt] > h)) gt++;
      q += N - gt;
      r += gt - ge;
      s += S[N] - S[gt] + A[i] * (N - gt);
    }
    if (q <= M) {
      h_ok = h;
      ans = s + (M - q) * h;
    } else {
      h_ng = h;
    }
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){
    
    cin >> N;

    //エラトステネスの篩
    ll pSize = 55555;
    vector<bool > IsPrime(pSize + 1, true);
    
    //初期化
    IsPrime[0] = false;
    IsPrime[1] = false;

    //2は素数
    //合成数gはSprt(n)以下の約数を持つのでループはSprt(n)までで良い
    for(ll i = 2; i <= sqrt(pSize); i++){
        if(IsPrime[i] == true){
            //自分自身は素数，それ以上の倍数は素数ではない
            for(ll j = 2; i * j <= pSize; j++){
                IsPrime[i * j] = false;
            }
        }
    }

    vector<ll > ans;
    ll cnt = 0;
    for(ll i = 2; i <= pSize; i++){
        if(IsPrime[i] == true){
            if(i % 5 == 1){
                if(cnt < N - 1){
                    cout << i << " ";
                    cnt++;
                }else{
                    cout << i << endl;
                    break;
                }
                ans.push_back(i);
            }
        }
    }



    //確認
    /*
    for(ll i = 0; i < pSize; i++){
        if(IsPrime[i] == true){
            cout << i << endl;
        }
    } 
    */
} 

Measured memory_bytes: 256