akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vii;
typedef vector<ll> vll;

#define X first
#define Y second
#define rep(i,n) for(ll i=0; i<(n); i++)
#define repp(i,ed,b) for(ll i=ed; i<=(b); i++)
#define repp2(i,b,ed) for(ll i=b; i>=(ed); i--)
#define fill(ed,val) memset(ed, (val), sizeof(ed))
#define mp make_pair
#define pb push_back
#define sz(x) (ll)x.size()
#define all(c) (c).begin(), (c).end()
#define uni(c) c.resize(distance(c.begin(), unique(all(c))))
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sc(n) scanf("%lld",&n)

ll mod= 1e9 + 7, mod1=1e9+9;
const ll N=200005,MAX=2e6+5;


int main(){
    

    int n;
    string s,t;
    cin>>n>>s>>t;
    int ans=0;
    repp(i,1,n){
        string s2 (s,n-i,i);
        string s3 (t,0,i);
        if(s2==s3)ans=i;
    }
    cout<<(n+n-ans);
    
    return 0;
}


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

typedef pair<long long, long long> ii;

int main(){
	//freopen("i.txt","r",stdin);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int x;
	cin >> x;
	cout << x * x;
}


Measured memory_bytes: 892
/*
 * Author: FreeIdea
 * Created Time:  2011/8/22 12:57:38
 * File Name: A.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
const int maxint = -1u>>1;
template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}
template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}

int cnt[4], ok[4], n;

int get_type(int h, int m) {
    if(11 <= h && h < 15)   return 1;
    if(18 <= h && h < 21)   return 2;
    if((21 <= h && h <= 24) || h < 2)    return 3;
    return 0;
}

bool check(int a, int b, int c) {
    int tmp = (c + 60 - b) % 60;
    return tmp <= 8;
}

int main() {
    while(scanf("%d", &n) == 1 && n) {
        memset(cnt, 0, sizeof(cnt));
        memset(ok, 0, sizeof(ok));
        for(int i = 1; i <= n; i++) {
            int a, b, c;
            scanf("%d%*c%d%d", &a, &b, &c);
            int type = get_type(a, b);
            cnt[type]++;
            if(check(a, b, c)) {
                ok[type]++;
            }
        }
        if(!cnt[1]) {
            printf("lunch no guest\n");
        }
        else {
            printf("lunch %d\n", ok[1] * 100 / cnt[1]);
        }
        
        if(!cnt[2]) {
            printf("dinner no guest\n");
        }
        else {
            printf("dinner %d\n", ok[2] * 100 / cnt[2]);
        }
        
        if(!cnt[3]) {
            printf("midnight no guest\n");
        }
        else {
            printf("midnight %d\n", ok[3] * 100 / cnt[3]);
        }
    }       
    return 0;
}

Measured memory_bytes: 0
// abc154_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N, K;
    cin >> N >> K;
    vector<ll> P(N);
    REP(i, N) cin >> P[i];

    double tmp = 0;
    REP(i, K) tmp += (P[i] + 1) / 2.0;
    double mx = tmp;
    REPN(i, K, N){
        tmp = tmp - ((P[i-K]+1)/2.0) + (P[i]+1)/2.0;
        mx = max(mx, tmp);
    }

    double ans = mx;
    print(ans);

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

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

	ld answ = 0.;

	for(int i = 0; i < n; ++i)
	{
		ld x;
		cin >> x;

		answ += 1. / x;
	}	

	cout << fixed << setprecision(12) << 1. / answ << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
mat=[]
blk=0 
for i in range(n):
    mat.append(list(input()))
for i in range(n):
    for j in range(m):
        if mat[i][j]=='.':
            mat[i][j]=0 
        else:
            mat[i][j]=1 
            blk+=1 
vis=[[0 for j in range(m)]for i in range(n)]
dist=[[-1 for j in range(m)]for i in range(n)]
q=[[0,0]]
dx=[0,0,1,-1]
dy=[-1,1,0,0]
if mat[0][0] or mat[n-1][m-1]:
    print(-1)
    exit()
dist[0][0]=0 
while q: 
    t=q.pop(0)
    x=t[0]
    y=t[1]
    for i in range(4):
        if 0<=x+dx[i]<n and 0<=y+dy[i]<m and vis[x+dx[i]][y+dy[i]]==0 and mat[x+dx[i]][y+dy[i]]==0:
            vis[x+dx[i]][y+dy[i]]=1 
            q.append([x+dx[i],y+dy[i]])
            dist[x+dx[i]][y+dy[i]]=dist[x][y]+1 
if not vis[n-1][m-1]:
    print(-1)
    exit()
print(n*m-dist[n-1][m-1]-blk-1)

Measured memory_bytes: 41328
#include <iostream>
using namespace std;
int n;
int dig,m;
int ans;
int main()
{
	cin>>n;
	dig=1;
	m=10;
	for(int i=1;i<=n;i++)
	{
		if(!(i%m))
		{
			m*=10;
			dig++;
		}	
		if(dig&1)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k,ans;
int main(){
	cin >> n >> k;
	if(k%2==0)ans=pow(n/k,3)+pow((n+k/2)/k,3);
	else ans=pow(n/k,3);
	cout << ans;
	return 0;
}

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

int main() {
  int A, B, Q;
  cin >> A >> B >> Q;
  vector<long long> s(A);
  vector<long long> t(B);
  vector<long long> x(Q);
  for (int i = 0; i < A; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < B; i++) {
    cin >> t[i];
  }
  for (int i = 0; i < Q; i++) {
    cin >> x[i];
  }

  long long backOver = -(2e10 + 7);
  long long frontOver = (2e10 + 7);

  s.push_back(frontOver);
  s.insert(s.begin(), backOver);
  t.push_back(frontOver);
  t.insert(t.begin(), backOver);

  for (int i = 0; i < Q; i++){
    long long xi = x[i];

    auto iterS = lower_bound(s.begin(), s.end(), xi);
    auto iterT = lower_bound(t.begin(), t.end(), xi);

    long long frontClosestS = *(iterS - 1);
    long long backClosestS = *(iterS);
    long long frontClosestT = *(iterT - 1);
    long long backClosestT = *(iterT);

    long long diffFS = abs(frontClosestS - xi);
    long long diffBS = abs(backClosestS - xi);
    long long diffFT = abs(frontClosestT - xi);
    long long diffBT = abs(backClosestT - xi);

    long long costFSFT = max(diffFS, diffFT);
    long long costFSBT = (min(diffFS, diffBT) * 2 + max(diffFS, diffBT));
    long long costBSFT = (min(diffBS, diffFT) * 2 + max(diffBS, diffFT));
    long long costBSBT = max(diffBS, diffBT);

    vector<long long> cost = { costFSFT, costFSBT, costBSFT, costBSBT};

    sort(cost.begin(), cost.end());

    cout << cost[0] << endl;
  }
};


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define N 200020
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
	while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return f?x:-x;
}
int a[N];
ll s1[N], s2[N], ans, res = 1ll << 60;
int main(int argc, char const *argv[]) {
	int n = read(), m = read();
	for (int i = 1; i <= n; i++)
		a[i] = read();
	for (int i = 1; i < n; i++) {
		int x = a[i], y = a[i + 1];
		if (x > y) y += m;
		s1[x + 1] += x + 1;
		s1[y + 1] -= x + 1;
		s2[x + 1] ++;
		s2[y + 1] --;
	}
	for (int i = 1; i <= (m << 1); i++) {
		s1[i] += s1[i - 1];
		s2[i] += s2[i - 1];
	}
	for (int i = 1; i < n; i++)
		if (a[i] <= a[i + 1]) ans += a[i + 1] - a[i];
		else ans += a[i + 1] + m - a[i];
	for (int i = 1; i <= m; i++)
		res = min(res, ans - s2[i] * i - s2[i + m] * (i + m) + s1[i] + s1[i + m]);
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 3712
#include<cstdio>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<iostream>
#include<vector>

using namespace std;

#define bomb exit(1)
#define INF 1061109567
#define LINF 4557430888798830399ll
#define pprint(x) print(x),putchar(' ')
#define fprint(x) print(x),putchar('\n')
#define EE(x); struct edge { int nxt,to;ll w; }e[M << 1]; int head[N],ecnt = 1;\
	void add(int u,int v,ll w = 0) { e[++ecnt].w = w,e[ecnt].to = v,e[ecnt].nxt = head[u];head[u] = ecnt; }\
	void add_edge(int u,int v,ll w = 0) { add(u,v,w),add(v,u,w * x); }
#define ll long long
int mod = 1000000007;
ll Mod(ll x) { return x >= mod ? x - mod : x; }
#define eps 0.0000000001
#define sqr(x) ((x) * (x))
#define iter iterator
#define fi first
#define se second
//#define getchar() (SS == TT && (TT = (SS = BB) + fread(BB,1,1 << 15,stdin),TT == SS) ? EOF : *SS++)
//char BB[1 << 15],*SS = BB,*TT = BB;
ll read()
{
	ll x = 0;int f = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') f = -1;
	for(;isdigit(ch);ch = getchar()) x = x * 10 + (ch ^ 48);
	return x * f;
}
void print(ll x)
{
	if(x < 0) putchar('-'),x = -x;
	if(x > 9) print(x / 10);putchar(x % 10 + '0');
}

const int N = 100010;
ll ans,res;
ll a[N],pre[N],suf[N],tot;
int n,op[N];
int main()
{
	n = read();
	for(int i = 1;i < n;i++)
	{
		tot += (a[i] = read());
		char ch = getchar();while(ch != '+' && ch != '-') ch = getchar();
		op[i] = (ch == '+') ? 1 : -1;
	}tot += (a[n] = read());
	for(int i = n;i;i--) { suf[i] = a[i];if(~op[i]) suf[i] += suf[i + 1]; }
	for(int i = 1;i <= n;i++) pre[i] = pre[i - 1] + a[i];
	res = a[1];ans = -LINF;
	for(int i = 2;i <= n;i++)
	{
		if(op[i - 1] == -1) ans = max(ans,res + pre[n] - pre[i - 1] - 2 * suf[i]);
		res += a[i] * op[i - 1];
	}ans = max(ans,res);fprint(ans);
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#include<unordered_map>
#define ll long long
#define M 1000000007

#define pb push_back
#define fs first
#define se second
using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //  #ifndef ONLINE_JUDGE
    //     freopen("mengawasi_sample_1.in", "r", stdin);
    //     freopen("mengawasi_sample_1.out", "w", stdout);
    // #endif
    ll a,b;
    cin>>a>>b;
    ll f=a+b;
    ll s=a-b;
    ll t=a*b;
    cout<<max(f,max(s,t))<<endl;
}


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



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }




    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        int[] s = sc.intarr;
        int N = s[0];
        int K = s[1];
        int[] A = sc.intarr;
        int ans = 1;
        N -= K;
        K--;
        ans += (N + K - 1) / K;
        wr.wri(ans);
    }
}
    




class Scan
{
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
    public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


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

#define int long long int
#define double long double
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i=a; i<b; ++i)
#define dbg(x) { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const double eps = 0.0000001;
const double PI = acos(-1.0);
const int MOD = 1e9+7;
const int N  = 1005;

int sum[N][N];
char g[N][N];

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int h, w;
    cin >> h >> w;
    for (int i = 1; i <=h ; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> g[i][j];
        }
    }
    sum[1][1]=1;
    for (int i = 1; i <=h ; i++) {
        for (int j = 1; j <= w; j++) {
            if(g[i][j]=='#') {
                sum[i][j] = -inf;
                continue;
            }
            if(sum[i-1][j]!=-inf)
                sum[i][j] += sum[i-1][j];
            if(sum[i][j-1]!=-inf)
                sum[i][j] += sum[i][j-1];
            sum[i][j]%=MOD;
        }
    }
    cout << sum[h][w];
    

    return 0;
}

Measured memory_bytes: 9088
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N, K=map(int, input().split())
HP=sorted(list(map(int, input().split())), reverse=True)
cnt = 0
for i in range(N):
    if K > 0:
        K -= 1
        continue
    cnt += HP[i]

print(cnt)

Measured memory_bytes: 25768
N, Y = map(int, input().split())

from math import floor, ceil

def searcher(N, Y):
	for x in range(N+1):
		y = (Y - 1000 * N - 9000 * x) / 4000
		if (floor(y) == ceil(y)) and int(y) >= 0 and  N-x-int(y) >= 0:
			print(x, int(y), N-x-int(y))
			return 
	else:
		print(-1, -1, -1)
		return 


searcher(N, Y)

Measured memory_bytes: 3064
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math


K = int(input())

N = 50
cnt = 0
ans_count = [0 for i in range(N)]
if K//N > 0:
    cnt = K//N
    for i in range(N):
        ans_count[i] = cnt
rest =K-cnt*N
for i in range(rest):
    ans_count[i] += 1

ans = [0 for i in range(N)]
for i in range(N):
    L = ans_count[i]
    ans[i] = (L+1)*(N+1)-2-K

print(N)
for i in range(N):
    print(ans[i],end=" ")

print()




'''
K回操作がある
そのうちじぶんが操作される回数をLとすると
L*N
それ以外はKーL
よって今の数がN-1とすると
元の数は
N-1＋L*N-K+L
=(L+1)*(N+1)-2-K


K=10
N = 3
L=3,3,4
3-1+3*3-10+3 = 4
4
8

4 4 8
5 5 5
1 6 6
2 3 7
3 4 4
'''




#
# 3
#
# 2 2 2
# 5 1 1
# 8 0 0
#
# N
# N-1+(N*(N-1)) 0 0 0 0
#
# N-1 N-1 N-1
#
#
#
# 3
# 8 0 0
#
#
# 4
# 3+12 0 0 0
# 15 0 0 0
# 11 1 1 1
# 7 2 2 2
# 3 3 3 3
#
#
# 5
# 24 0 0 0 0
# 19 1 1 1 1
# 14 2 2 2 2
# 9 3 3 3 3
# 4 4 4 4 4


Measured memory_bytes: 7096
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int t,n,i,a,b;
   string s;

   cin>>s;
   if(s[0]=='7'||s[1]=='7'||s[2]=='7')
    cout<<"Yes"<<"\n";
   else
    cout<<"No"<<"\n";


 return 0;
 }


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int f(int a, int b){
  int x;
  if(b % 2 == 0){
    x = min(b + 1, (a - b / 2) * 2 + 1);
  }
  else{
    x = min(b + 1, b + 1 - 2 * (b - a));
  }
  if(x < 0){
    return 0;
  }
  else{
    return x;
  }
  
}

int main(){
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  for(int i = 0; i <= k; i++){
    if(s - i <= 2 * k){
      cnt += f(k, s - i);
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    string S;
    int K;
    cin >> S >> K;
    for(int i = 0; i < K; i++) {
        if(S[i] != '1') {
            cout << S[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
}


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

using namespace std;

void dfs(int c, int dp[], bool vis[], vector<vector<int>> &adj) {
    vis[c] = true;
    for (int i : adj[c]) {
        if (!vis[i]) dfs(i, dp, vis, adj);
        dp[c] = max(dp[c], dp[i] + 1);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;

    vector<vector<int>> adj(n + 1);
    int dp[n + 1];
    bool vis[n + 1];

    for (int i = 0; i <= n; i++) {
        dp[i] = 0;
        vis[i] = false;
    }

    while (m--) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
    }

    for (int i = 1; i <= n; i++) {
        if (!vis[i]) dfs(i, dp, vis, adj);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(dp[i], ans);
    }
    cout << ans;

}

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

using namespace std;

int main()
{
  long long int k,n;
  cin>>k>>n;
  long long int a[n];
  for(int i=0; i<n; i++)
  {
    cin>>a[i];
  }
  long long int temp = 0,max = k - a[n-1] + a[0];
  for(int i=1; i<n-1; i++)
  {
    temp = a[i+1] - a[i];
    if(temp  > max)
      max = temp;
  }
  cout<<k-max<<endl;
  return 0;
}

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

const int N = 5005;
const int mod = 998244353;


int A, B, C, D;

int dp[N][N];

int solve(int r, int c) {
    if(r == A && c == B) return 1;
    if(dp[r][c] != -1) return dp[r][c];
    if(r == A) {
        int ans = 1;
        int k = c-B;
        while(k--) ans = 1ll*ans*r%mod;
        return dp[r][c] = ans;
    }
    if(c == B) {
        int ans = 1;
        int k = r-A;
        while(k--) ans = 1ll*ans*c%mod;
        return dp[r][c] = ans;
    }
    int ans = 1ll*solve(r-1, c)*c%mod + 1ll*solve(r,c-1)*r%mod;
    ans %= mod;
    int tt = 1ll*(r-1)*(c-1)%mod;
    ans -= 1ll*solve(r-1,c-1)*tt%mod;
    ans %= mod;
    ans += mod;
    ans %= mod;
    return dp[r][c] = ans;
}


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

    cin >> A >> B >> C >> D;
    memset(dp, -1, sizeof dp);
    cout << solve(C, D);

    return 0;
}



Measured memory_bytes: 101876
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
def lcm(a, b):
    return a * b // gcd(a, b)

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

mod = 10 ** 9 + 7
N = 1000002

#逆元テーブル
inv_t = [0]+[1]
for i in range(2, N):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]

base = a[0]
for ai in a:
    base = lcm(base, ai)
base %= mod
ans = 0
for ai in a:
    ans = (ans + base * inv_t[ai]) % mod
print(ans)


Measured memory_bytes: 96268
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  string s;
  int N = 0,M = 0;
  cin >> s;
  N = s.size();
  M = (N + 1)/2;
  rep(i,N/2){
    if(s[i] != s[N - 1 - i]){
      cout << "No";
      return 0;
    }
  }
  rep(i,N/4){
    if(s[i] != s[M - 2 - i]){
      cout << "No";
      return 0;
    }
  }
  rep(i,N/4){
    if(s[M + i] != s[N - 1 - i]){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

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

using namespace std;

typedef long long ll;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n), x(m), y(m);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    for (int i = 0; i < m; i++) cin >> x[i] >> y[i];
    for (int i = 0; i < n; i++)
    {
        int mind = 1e9, id = 0;
        for (int j = 0; j < m; j++)
        {
            if (abs(a[i] - x[j]) + abs(b[i] - y[j]) < mind)
            {
                mind = abs(a[i] - x[j]) + abs(b[i] - y[j]);
                id = j;
            }
        }
        cout << id + 1 << "\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n);
#define DEBUG printf("%s\n","debug")
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
ll lmax(ll a,ll b){
	if (a<b) return b;
	else return a;
}

int main() {
	int N;
	int K;
	SCD2(N,K);
	static ll S[100002];
	static ll T[100002];
	static ll A[100002];
	
	REP(i,N){
		int x;
		SCD(x);
		ll y = max(0,x);
		if (i==0) {
			S[0] = x;
			T[0] = y;
		}
		else {
			S[i] = S[i-1] + x;
			T[i] = T[i-1] + y;
		}
		
		A[i] = x;
	}
	
	
	ll ans = 0;
	
	FORq(i,K-1,N-1){
		ll now = 0;
		if (i == K-1){
			now = lmax(0,S[K-1]) + T[N-1] - T[K-1];
			
			ans = lmax(now,ans);
			continue;
		}
		
		now = lmax(0,S[i]-S[i-K]);
		int a = i-K+1;
		int b = i;
		
		
		now += T[N-1] - T[b] + T[a-1];
		
		
		ans = lmax(now,ans);
	}
	
	PRINTLLD(ans);
	
	return 0;
} 
 

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>

using namespace std;

#define int long long

signed main() {
    int a, b, c;
    cin >> a >> b >> c;

    int d = c - a - b;
    if(0 < d && 4 * a * b < d * d) {
        cout << "Yes" << endl;
        return 0;
    }

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

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

int main(void) {
  ios::sync_with_stdio(false);
  ll X;
  cin >> X;
  vector<int> item = {100, 101, 102, 103, 104, 105};

  vector<bool> dp(100200, false);
  dp[0] = true;
  for (int i = 0; i <= 100000; i++) {
    for (auto j : item) {
      dp[i + j] = (dp[i + j] | dp[i]);
    }
  }

  if (dp[X])
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
s=[]
sa=input()
sb=input()
sc=input()
s.append(sa)
s.append(sb)
s.append(sc)
now=0
while 1:
    if len(s[now])==0:
        break
    if s[now][0]=="a":
        next=0
    elif s[now][0]=="b":
        next=1
    else:
        next=2
    s[now]=s[now][1:]
    now=next
if now==0:
    print("A")
elif now==1:
    print("B")
else:
    print("C")

Measured memory_bytes: 61568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[100010];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		x--;
		a[i]=x;
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		ll now=a[i];
		if(a[now]==i){
			ans++;
		}
	}
	cout << ans/2;
	return 0;
}

Measured memory_bytes: 1024
W, H = gets.split.map(&:to_i)
pq = []
W.times do |i|
  pq << [:W, gets.to_i, i]
end
H.times do |i|
  pq << [:H, gets.to_i, i]
end
pq.sort_by! { |x| x[1] }
cost = 0
w, h = W, H
pq.each do |s, x, i|
  if s == :W
    cost += x * (h + 1)
    w -= 1
  else
    cost += x * (w + 1)
    h -= 1
  end
end
puts cost


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

using namespace std;

#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    int i,j,k,n,x,ans=0,cnt,a[102];
    cin >> n;
    for(i=1;i<=n;i++)cin >> a[i];
    sort(a+1,a+n+1);
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            if(a[i] == a[j])continue;
            cnt=0;
            x=a[i]+a[j];
            for(k=j+1;k<=n;k++)
            {
                if(a[k] == a[j])continue;
                if(a[k] < x)++cnt;
                else break;
            }
            ans+=cnt;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3660
import bisect
n=input()
N=int(n)


tmp=["3", "5", "7"]
for i in range(1, len(n)):
    next=[]
    for j in tmp:
        for k in ["3", "5", "7"]:
            next.append(j+k)
    tmp=tmp+next

tmp=list(set(tmp))
N_753=[]
for i in tmp:
    if "3" in i and "5" in i and "7" in i:
        N_753.append(int(i))


N_753.sort()

print(bisect.bisect_right(N_753, N))
    




Measured memory_bytes: 20076
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b;
	cin >> a >> b;
	
	if( (a + b) % 2 != 0 ) cout << "IMPOSSIBLE" << endl;
	else cout << abs(a - (a - b) / 2) << endl;
	
	return 0;
}


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

int k;
queue<long long> l;
long long ans, t;

int main()
{
	for (size_t i = 1; i < 10; i++)
	{
		l.push(i);
	}
	cin >> k;
	for (size_t i = 0; i < k; i++)
	{
		ans = l.front();
		l.pop();
		t = ans % 10;
		if (t != 0)
		{
			l.push(10 * ans + t - 1);
		}
		l.push(10 * ans + t);
		if (t != 9)
		{
			l.push(10 * ans + t + 1);
		}
	}
	cout << ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
ll ans = 0LL;
int i_index;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int alpha[1000];
    int maxt = 0;
    for(int i = 1; i < N; i++){
        cnt = 0;
        for(int j = 0; j < 1000; j++){
            alpha[j] = 0;
        }
        for(int j = i; j < N; j++){
            for(int k = 0; k < i; k++){
                if(S[j] == S[k] && alpha[S[k]] == 0){
                    cnt++;
                    alpha[S[j]] = 1;
                }
            }
        }
        maxt = max(maxt, cnt);
    }

    cout<< maxt << endl;
    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

N = int(input())
S = sorted([int(input()) for i in range(N)])
ans = sum(S)

if ans % 10 == 0:
    for i in S:
        if (ans - i) % 10 != 0:
            ans -= i
            break

if ans % 10 == 0:
    ans = 0

print(ans)





Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

LL n, a[100000];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	LL ans = 0;
	inc1(d, n - 1) {
		LL x = 0, y = 0;
		for(LL i = 0; i < n - 1; i += d) {
			if((n - 1) % d == 0 && i >= n - 1 - i) { break; }
			if(i > n - 1 - d) { break; }
			y += a[i] + a[n - 1 - i];
			setmax(x, y);
		}
		setmax(ans, x);
	}
	
	cout << ans << endl;
	
	return 0;
}


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

typedef long long ll;

int main() {
  string S; cin >> S;
  int l = S.length();
  int cnt = 0, i = 0;
  if (S[0] == 'B') {
    i++;
    while (i < l && S[i] != 'W') {
      i++;
    }
    cnt++;
  }
  if (i == l) {
    cout << 0 << endl;
    return 0;
  }
  int j = l-1;
  if (S[j] == 'B') {
    j--;
    while (S[j] != 'W') {
      j--;
    }
    cnt++;
  }
  int s = 0;
  while (++i <= j) {
    if (s == 0 && S[i] == 'B') {
      s = 1;
    } else if (s == 1 && S[i] == 'W') {
      s = 0;
      cnt += 2;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, T;
	cin >> N >> T;

	vector<Int> t(N);
	for (Int i = 0; i < N; i++) {
		cin >> t[i];
	}

	Int ans = 0;
	for (Int i = 0; i < N-1; i++) {
		ans += min(T, t[i + 1] - t[i]);
	}
	ans += T;

	cout << ans << "\n";

}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<char, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

const ll mod = 1000000007;
const ll INF = 100000000000010000;

ll bit[1000010];
//ll kai[1000010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

ll sum(ll i)
{
	i += 1;
	ll t = 0;
	while (i > 0)
	{
		(t += bit[i]) %= mod;
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	i += 1;
	while (i <= 1000005)
	{
		(bit[i] += x) %= mod;
		i += i & -i;
	}
}

void test() {
	cout << "888888888888888888888888" << endl;
}

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

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

/*ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
	//毎回オーダーlog(n)かかる
}

void kaijo() {
	kai[0] = 1;
	for (ll i = 1; i <= 1000005; i++) {
		kai[i] = kai[i - 1] * i % mod;
	}
}*/

ll N;
double p[3000], dp[3000], ans;

void solve() {
	cin >> N;
	rep(i, N) cin >> p[i];
	dp[0] = 1;
	rep(i, N) {
		for (ll j = N; j >= 1; j--) {
			dp[j] = (1 - p[i]) * dp[j] + dp[j - 1] * p[i];
		}
		dp[0] = dp[0] * (1 - p[i]);
	}
	for (int i = N / 2 + 1; i <= N; i++) {
		ans += dp[i];
	}
	printf("%.10lf\n", ans);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}
////////////////////////////////////////////////////////////////////////////////////////////jagfhaoi;sd;joi;asdfjzasdi;lfjoi;ernjsdoivcnoizvdfnvdfnon/////////////////////////////////////////////////////////
////////////////////jgoiadhsjgoi;vsjvgfonhjasoivhoivhno

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char a[105],b[105],c[105];
int main()
{
	cin>>a>>b>>c; 
	int A=strlen(a);
	int B=strlen(b);
	int C=strlen(c);
	int flag=1;
	int a1=0,a2=0,a3=0;
	while(1)
	{
		if(flag==1)
		{
			if(a1==A) break;
			flag=int(a[a1])-96;
			a1++;
		}
		if(flag==2)
		{
			if(a2==B) break;
			flag=int(b[a2])-96;
			a2++;
		}
		if(flag==3)
		{
			if(a3==C) break;
			flag=int(c[a3])-96;
			a3++;
		}
	}
	cout<<char(flag+64)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int p = 0;
	bool b[3] = {true, false, false};
	char c[3];
	while (1)
	{
		cin >> c[0];
		if (cin.eof()) break;
		cin >> c[1] >> c[2];
		swap(b[c[0]-'A'], b[c[2]-'A']);
		if (b[c[0]-'A'])
			p = c[0]-'A';
		if (b[c[2]-'A'])
			p = c[2]-'A';
	}
	cout << (char)('A'+p) << endl;
}

Measured memory_bytes: 0
S = input()
T = ""
SS = S[::-1]
d = "maerd"
dd = "remaerd"
e = "esare"
ee = "resare"

cnt1 = 0
cnt2 = 5
for i in range(4, len(S)):
    if(SS[cnt1:cnt2] == dd):
        T += dd
        cnt1 = cnt2
        cnt2 +=1
    elif(SS[cnt1:cnt2] == ee):
        T += ee
        cnt1 = cnt2
        cnt2 += 1
    elif(SS[cnt1:cnt2] == d):
        T += d
        cnt1 = cnt2
        cnt2 += 1
    elif(SS[cnt1:cnt2] == e):
        T += e
        cnt1 = cnt2
        cnt2 += 1
    else:
        cnt2 += 1
    
print("YES" if S == T[::-1] else "NO")

Measured memory_bytes: 3444
#include <stdio.h>
#include <ctype.h>
//prototype
int main(void);

int main(void){

  char a_to_z;
  char str[1200];
  int al_str[26] = {0};
  int al_number;
  int i = 0;

  while (scanf("%c", &str) != EOF) {

      al_number = tolower(str[i]);
      al_number -= 'a';
      al_str[al_number]++;

  }

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

    printf("%c : %d\n", (char)(i + 'a'), al_str[i]);

  }

  return 0;
}



Measured memory_bytes: 2032
#include <iostream>
int main() {
	int n = 0, m = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			std::cout << i << "x" << j << "=" << i*j << std::endl;
		}
	}
}

Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int D;
LL G;
int p[11];
LL c[11];
LL q[11];
int main(){
	cin>>D>>G;
	REP(i,D){
		cin>>p[i]>>c[i];
	}
	LL ans=1e9;
	REP(i,1<<D){
		LL score=0;
		LL now=0;
		vector<int>v;
		REP(j,D){
			if((i>>j)&1){
				//cout<<"j"<<j<<"a"<<endl;
				now+=p[j];
				score+=p[j]*(j+1)*100+c[j];
			}else{
				REP(k,p[j]){
					v.push_back((j+1)*100);
				}
			}
		}
		sort(v.begin(),v.end());
		reverse(v.begin(),v.end());
		REP(j,v.size()){
			if(score<G){
				score+=v[j];
				now++;
			}
		}
		//cout<<now<<endl;
		ans=min(ans,now);
	}
	cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input!{
        N: String,
    }
    let mut Sn = 0;
    for c in N.chars() {
        Sn += c.to_digit(10).unwrap() as usize;
    }
    println!(
        "{}",
        if N.parse::<usize>().unwrap() % Sn == 0 {
            "Yes"
        } else {
            "No"
        }
    );
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int A, B;
string S;
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> A >> B;
	cin >> S;

	int match = 1;
	for(int i=0; i<A; i++){
		if(S[i] == '-'){
			match = 0;
			break;
		}
	}
	if(match == 0 || S[A] != '-'){
		printf("No\n");
		return 0;
	}
	for(int i=0; i<B; i++){
		if(S[A+1+i] == '-'){
			match = 0;
			break;
		}
	}
	if(match == 0){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}

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

void GG(){
	puts("0"),exit(0);
}

const int N=1505,mod=998244353;
int a[2][N][N],c[N],pw[N*N],vi[N],n,m0,m1,sum;
vector<int> e[N];
char s[N];

void dfs(int u){
	sum^=c[u],vi[u]=1;
	for(auto v:e[u]) if(!vi[v]) dfs(v);
}

int solve(int m,int a[N][N]){
	int res=0;
	rep(i,1,m) rep(j,i+1,m) res+=!a[i][j];
	if(m%2==0) return res;
	rep(i,1,m) e[i].clear(),vi[i]=c[i]=0;
	rep(i,1,m) rep(j,i+1,m)
		if(a[i][j]==1) c[i]^=1,c[j]^=1;
		else if(!a[i][j]) e[i].push_back(j),e[j].push_back(i);
	rep(i,1,m) if(!vi[i]){
		sum=0,res++,dfs(i);
		if(sum) GG();
	}
	return res-m;
}

int main(){
	scanf("%d",&n);
	m0=(n+2)/2,m1=(n+1)/2;
	rep(i,1,n-1){
		scanf("%s",s+1);
		rep(j,1,n-1){
			if(s[j]=='?') continue;
			int k=(i+j)&1,a=i,b=j,t=i+j-n;
			if(a<b) swap(a,b);
			if(t>0) a-=t,b-=t;
			int aim=(s[j]=='x'?1:-1);
			int u=(a-b)/2+1,v=(a+b)/2+1;
			if(::a[k][u][v]){
				if(::a[k][u][v]!=aim) GG();
				continue;
			}
			::a[k][u][v]=aim;
		}
	}
	pw[0]=1;
	rep(i,1,n*n) pw[i]=pw[i-1]*2%mod;
	cout<<pw[solve(m0,a[0])+solve(m1,a[1])]<<endl;
	return 0;
}

Measured memory_bytes: 23936
#include <stdio.h>
#include <cassert>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
#include <iomanip>
 
#ifdef LOCAL_CODE
	#define DEBUG(x) cerr << "[" << #x << '=' << x << "]" << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int i = (N)-1; i >= 0; i--)
#define REP(i, N) for(int i = 0; i < (int)(N); i++)
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.first >> p.second; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.first << ' ' << p.second; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

int n,m;
void solve(istream& cin, ostream& cout) {
	int A,B,H,M;
	cin>>A>>B>>H>>M;
	long double PI = 3.14159265358979323846264338327950288L;
	M += 60*H;
	long double minutovaUhl = 2*PI/60*M;
	long double hodinovaUhl = 2*PI/(60*12)*M;
	long double x1 = sin(minutovaUhl)*B, y1 = cos(minutovaUhl)*B;
	long double x2 = sin(hodinovaUhl)*A, y2 = cos(hodinovaUhl)*A;
	cout <<setprecision(20) << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))<<endl;
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


Measured memory_bytes: 3608
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
bool used[35];
int val[200005];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    string a;
    cin>>a;
    int i;
    int sum=26;
    int ans=1;
    for (i=a.length()-1;i>=0;i--)
    {
        val[i]=ans;
        if (used[a[i]-'a']) continue;
        sum--;
        used[a[i]-'a']=true;
        if (sum==0)
        {
            //putchar(a[i]);
            int j;
            for (j=0;j<26;j++)
            {
                used[j]=false;
            }
            sum=26;
            ans++;
        }
        val[i]=ans;
    }
    //printf("%d\n",ans);
    int last=0;
    for (i=0;i<a.length();i++)
    {
        if (val[i+1]==ans) continue;
        memset(used,false,sizeof(used));
        int j;
        for (j=last;j<i;j++)
        {
            used[a[j]-'a']=true;
        }
        if (ans==1) used[a[j]-'a']=true;
        for (j=0;j<26;j++)
        {
            if (!used[j]) break;
        }
        putchar('a'+j);
        ans--;
        for (;;)
        {
            if (a[i]=='a'+j) break;
            i++;
            if (i==a.length()) break;
        }
        last=i+1;
    }
    if (ans==1) putchar('a');
    return 0;
} 


Measured memory_bytes: 1412
N, T = map(int, input().split())
a = list(map(int, input().split()))
if N == 1:
    print(1)
    exit()

ans = []
ans.append(a[1] - a[0])
mina = min(a[1], a[0])
maxri = ans[0]
for i in range(2, N):
    ans.append(a[i] - mina)
    maxri = max(ans[i - 1], maxri)
    mina = min(a[i], mina)

print(ans.count(maxri))

Measured memory_bytes: 63876
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, x; cin >> n >> x;
	VE l(n); rep(i, n)cin >> l[i];
	VE a(n + 1); a[0] = 0;
	rep(i, n) {
		a[i + 1] = a[i] + l[i];
	}
	int ans = 0;
	rep(i, n+1) {
		if (a[i] <= x)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// #define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
void yesOrNo(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

void solve(ll N, ll M, std::vector<ll> A) {
  sort(all(A));

  ll sum = 0;
  rep(i, N) { sum += A.at(i); }
  double bound = (double)sum / (double)(4 * M);

  ll result = ((double)A.at(N - M) >= bound);

  yesOrNo(result);
}

int main() {
  ll N;
  scanf("%lld", &N);
  ll M;
  scanf("%lld", &M);
  std::vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, M, std::move(A));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <float.h>
typedef long long unsigned int ll;
using namespace std;

int main() {
    ll m,n,d;
    cin>>n>>m>>d;
    double ans;
    if(d!=0) ans=(double) 2*(n-d)*(m-1)/pow(n,2);
    else ans=(double) (m-1)/n;
    printf("%f", ans);
    //cout<<ans<<endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int a, b;
    cin >> a >> b;

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

    return 0;
}

Measured memory_bytes: 892