akhauriyash/Code-Regression huggingface dataset:
import Data.List
import qualified Data.Sequence as Seq
import Data.Foldable

data Query = QueryReverse | QueryPrepend Char | QueryAppend Char deriving Eq

convertToQueryData :: [String] -> Query
convertToQueryData [_] = QueryReverse
convertToQueryData (_:f:c:_) = if (read f :: Integer) == 1 then QueryPrepend $ head c
  else QueryAppend $ head c

applyQuery :: (Seq.Seq Char, Bool) -> Query -> (Seq.Seq Char, Bool)
applyQuery (xs, isReversed) QueryReverse = (xs, not isReversed) --Seq.reverse xs
applyQuery (xs, False) (QueryPrepend c) = (c Seq.<| xs, False)
applyQuery (xs, True) (QueryPrepend c) = (xs Seq.|> c, True)
applyQuery (xs, False) (QueryAppend c) = (xs Seq.|> c, False)
applyQuery (xs, True) (QueryAppend c) = (c Seq.<| xs, True)

main :: IO ()
main = do
  line <- getLine
  let lineSeq = Seq.fromList line
  nQueriesStr <- getLine
  let nQueries = read nQueriesStr
  stringQueries <- sequence $ take nQueries $ repeat getLine
  let queries = map (convertToQueryData . words) stringQueries
  let (finalList, isReversed) = (foldl' (\ac query -> applyQuery ac query) (lineSeq, False) queries)
  putStrLn (toList (if isReversed then Seq.reverse finalList else finalList))


Measured memory_bytes: 111228
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

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

  int n = sz(s);
  vector<string> ss;
  for (int i = 1; i <= min(n,k); ++i) {
    for (int j = 0; j <= n-i; ++j) {
      ss.pb(s.substr(j,i));
    }
  }
  sort(ss.begin(), ss.end());
  uni(ss);
  cout << ss[k-1] << endl;
  return 0;
}

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

#define AndIamIronMan ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
 
using namespace std;
 
typedef long long int lli; 
 
int main(){
    
    AndIamIronMan;
	lli n,l,i,j,k,x;
	cin>>n>>k;
  	map<lli,lli> mp;
	for(i=0;i<k;i++){
  		cin>>j;
		for(l=0;l<j;l++){
			cin>>x;
			mp[x]++;
		}
	}
	cout<<n-mp.size();	
  	return 0;
}

Measured memory_bytes: 3640
package main

import (
	"fmt"
)

func main() {
	var n, k, c int
	var s string
	fmt.Scan(&n, &k, &c, &s)

	l, r := make([]int, k), make([]int, k)

	for i, j := 0, 0; i < n && j < k; i++ {
		if string(s[i]) == "o" {
			l[j] = i
			i += c
			j++
		}
	}

	for i, j := n-1, k-1; i >= 0 && j >= 0; i-- {
		if string(s[i]) == "o" {
			r[j] = i
			i -= c
			j--
		}
	}

	for i := 0; i < k; i++ {
		if l[i] == r[i] {
			fmt.Println(l[i] + 1)
		}
	}
}


Measured memory_bytes: 6784
def main():
    N, L = map(int, input().split())
    a = [L + n for n in range(N)]
    if L > 0:
        print(sum(a) - a[0])
    elif abs(L) >= N:
        print(sum(a) - a[-1])
    else:
        print(sum(a))


main()


Measured memory_bytes: 3064
p,r=input,range
A=sum([list(map(int,p().split()))for _ in r(3)],[])
N=int(p())
b=[int(p())for _ in r(N)]
print('Yes'if[v for v in[7,56,73,84,146,273,292,448]if sum(1<<i for i in r(9)if A[i]in b)&v==v]else'No')

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

using namespace std;

const int N = 800005;
const int inf = 1000000000;

namespace SegmentTree {
	int s[N];
	int mn[N];
	bool tag[N];

	void pushdown(int x, int l, int r) {
		int mid = l + r >> 1;
		if(tag[x]) {
			tag[x << 1] = true;
			tag[x << 1 | 1] = true;
			s[x << 1] = s[x];
			s[x << 1 | 1] = s[x] + mid - l + 1;
			mn[x << 1] = s[x << 1];
			mn[x << 1 | 1] = s[x << 1 | 1];
			tag[x] = false;
		}
	}

	void update(int l, int r, int x, int a, int b, int S) {
		if(l > b || r < a) {
			return;
		}
		if(l >= a && r <= b) {
			tag[x] = true;
			s[x] = S + l - a;
			mn[x] = S + l - a;
			return;
		}
		pushdown(x, l, r);
		int mid = l + r >> 1;
		update(l, mid, x << 1, a, b, S);
		update(mid + 1, r, x << 1 | 1, a, b, S);
		mn[x] = min(mn[x << 1], mn[x << 1 | 1]);
	}

	int query(int l, int r, int x, int a, int b) {
		if(l > b || r < a) {
			return inf;
		}	
		if(l >= a && r <= b) {
			return mn[x];	
		}
		pushdown(x, l, r);
		int mid = l + r >> 1;
		return min(query(l, mid, x << 1, a, b), query(mid + 1, r, x << 1 | 1, a, b));
	}
} using namespace SegmentTree;

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

	int h, w;
	cin >> h >> w;

	vector<int> a(h);
	vector<int> b(h);
	for(int i = 0; i < h; ++i) {
		cin >> a[i] >> b[i];
		a[i] -= 1;
		b[i] -= 1;
	}

	int x = 0;
	int y = 0;
	int ans = 0;

	for(int i = 0; i < h; ++i) {
		if(a[i] > 0) {
			int S = query(0, w - 1, 1, a[i] - 1, a[i] - 1);
			update(0, w - 1, 1, a[i], b[i], S + 1);
		} else {
			update(0, w - 1, 1, a[i], b[i], inf);
		}
		int ans = mn[1];
		if(ans >= inf) {
			cout << -1 << '\n';
		} else {
			cout << ans + i + 1<< '\n';
		}
	}

	return 0;
}


Measured memory_bytes: 9396
MAX = 2*10**5+100
fact = [0]*MAX
inv = [0]*MAX
finv = [0]*MAX
 
def C_init():
    fact[0] = 1
    fact[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    
    for i in range(2, MAX):
        fact[i] = fact[i-1]*i%MOD
        inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
        finv[i] = finv[i-1]*inv[i]%MOD
 
def C(n, r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD

H, W, A, B = map(int, input().split())
MOD = 10**9+7
C_init()
ans = 0

for i in range(H-A):
    ans += C(i+B-1, i)*C(H-1-i+W-B-1, W-B-1)
    ans %= MOD

print(ans)

Measured memory_bytes: 44272
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a;i<b;i++)
#define vi vector<int>
#define vii vector<ll>
#define all(x) x.begin(),x.end()
#define mod 1000000007
#define pb push_back
#define ii pair<int,int>
#define iii pair<ll,ll>
#define MAX 10000000000000
#define pi 3.1415926535
typedef long long ll;
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    vii h(n), dp(n,INT_MAX);
    f(i,0,n) cin>>h[i];
    dp[0] = 0;
    for(int i=1;i<n;i++) {
        for(int j=i-1; j>=max(0,i-k); j--)
            dp[i] = min(dp[i], dp[j]+abs(h[i]-h[j]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }

const int MAXN = 1023;

int n, m, k;
int s[MAXN], mrk[MAXN];

ll cnt[MAXN];

vector<ll> p;

int main (){
	for(ll a=2;a<MAXN;a++){
		if(mrk[a])continue;
		p.pb(a);
		for(ll b=a;a*b<MAXN;b++)
			mrk[a*b] = 1;
	}
	scanf("%d", &n);
	for(int a=2;a<=n;a++){
		int val = a;
		for(int ip = 0;ip < p.size();ip++){
			ll pri = p[ip];
			if(pri > val) break;
			while(val%pri == 0 && val != 0){
				val/=pri;
				cnt[ip]++;
			}
			
		}
	}
	ll res = 1;
	for(int a=0;a<p.size();a++){
		res = mod(res *( cnt[a] + 1) );
	}
	printf("%lld\n", res);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int n,m,a,b;
int main(){
        cin>>n>>m;
        vector <int> h(n);
        for(int i=0;i<n;i++){
                cin>>h[i];
        }

        vector <int> g(n,1);

        while(m--){
                cin>>a>>b;
                a--;
                b--;
                if(h[a]>h[b])
                        g[b]=0;
          		if(h[a]==h[b])
                  		g[a]=g[b]=0;
                if(h[b]>h[a])
                        g[a]=0;
        }

        int sum=0;
        for(int i=0;i<n;i++)
                sum+=g[i];
        cout<<sum;
}

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

#define ff first
#define ss second
#define pb push_back
#define int long long

bool comp(int a,int b){
return a>b ;	
}


bool foo(int arr[],int n,int k){
	
	if(n==0 || k==0)
	return 0;
	
	for(int i=0;i<n;i++){
		if(k>=arr[i]){	
			bool state=foo(arr,n,k-arr[i]);
			if(!state)
				return 1;
		}
	}
	return 0;
}

signed main(){

//int mod=1000000007;

#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#else
// online submission
#endif

int n ;
cin >> n  ;

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


int dp[n]={0};

for(int i=n-1;i>=0;i--){
	for(int j=i;j<n;j++){
		
		if(i==j){
			dp[j]=arr[j] ;
		}
		else{
			dp[j]=max(arr[i]-dp[j],arr[j]-dp[j-1]);
		}
	}
}



cout<<dp[n-1] ;
	return 0;
    
}




Measured memory_bytes: 3620
N=int(input())
 
for h in range(1,3501):
  for n in range(1,3501):
    #divが負数ならwは負数になる
    if (4*h*n)-(N*n)-(N*h)>0:
      w=N*h*n/((4*h*n)-(N*n)-(N*h))
      if w.is_integer():
        print(h,n,int(w))
        exit()

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		String str = input.readLine();
		
		int n1 = str.indexOf(" ");
		int n2 = str.indexOf(" " , n1 + 1);
		int n3 = str.indexOf(" ", n2 + 1);
		
		double x1 = Double.parseDouble(str.substring(0 , n1));
		double y1 = Double.parseDouble(str.substring(n1 + 1 , n2));
		double x2 = Double.parseDouble(str.substring(n2 + 1 , n3));
		double y2 = Double.parseDouble(str.substring(n3 + 1));
		
		double x = Math.pow(x1 - x2 , 2);
		double y = Math.pow(y1 - y2 , 2);
		
		double det = Math.sqrt(x + y);
		
		System.out.println(det);
		
	}

}

Measured memory_bytes: 17064
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    LLONG N, K; cin >> N >> K;
    // N = K のとき，明らかに N = 0 が最小
    if (N == K)
    {
        cout << 0 << endl;
    }
    // N > K のとき，N を K ずつ減らして差が N % K になる
    // 以降は N % K と K - N % K を行き来する
    else if (N > K)
    {
        cout << min(N % K, K - N % K) << endl;
    }
    // N < K のとき，N と K - N を行き来する
    else
    {
        cout << min(N, K - N) << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int n, G[101][101];
int main() {
  scanf("%d", &n);
  for(int i = 1, u, k; i <= n; ++i) {
    scanf("%d %d", &u, &k);
    for(int j = 1, v; j <= k; ++j) {
      scanf("%d", &v);
      G[u][v] = 1;
    }
  }
  for(int i = 1; i <= n; ++i) {
    for(int j = 1; j <= n; ++j) {
      printf("%d", G[i][j]);
      if(j < n) printf(" ");
    }
    printf("\n");
  }
}


Measured memory_bytes: 2756
# -*- coding: utf-8 -*-

s=list(input())
n=len(s)

cnt=0
for i in range(2,n-1):
    if s[i]=='C':
        cnt+=1

if s[0]=='A' and cnt==1:
    s.pop(0)
    s.remove('C')
    for c in s:
        if c.islower()==False:
            print("WA")
            break
    else:
        print("AC")
else:
    print("WA")


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

string s[50];

int cnt = 0;
int h,w;
bool vis[50][50];

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

void dfs(int x,int y){
  vis[x][y] = 1;
  cnt++;
  for(int i = 0; i < 4; i++){
  	  if(x+dx[i]>=h || y+dy[i]>=w || x+dx[i]<0 || y+dy[i]<0) continue;
  	  if(!vis[x+dx[i]][y+dy[i]] && s[x+dx[i]][y+dy[i]]=='#') dfs(x+dx[i],y+dy[i]);
  }
}

int main(){
	cin>>h>>w;

	for(int i = 0; i < h; i++) cin>>s[i];

	for(int i = 0; i < h; i++) {
	   for(int j = 0; j < w;j++){
	   	  if(!vis[i][j] && s[i][j]=='#'){
	   	  	dfs(i,j);
	   	  	if(cnt<2){
	   	  		cout<<"No";
	   	  		return 0;
	   	  	}
	   	  	//cout<<cnt<<endl;
	   	  	cnt = 0;
	   	  }
	   }
	}

	cout<<"Yes";

}

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

#define imie(...) " [" <<#__VA_ARGS__<<':'<<(__VA_ARGS__)<<"] "

const int MAX = 1e5;
int arr[100][2];
long long dp[(int)1e5+6][100];
int n,W;

//recursion + memoization
long long go(int w,int i){
	if(i == n) return 0;
	if(dp[w][i]) return dp[w][i];
	long long choose = 0;
	if(arr[i][0] <= w){
		choose = 1ll*arr[i][1] + 1ll*go(w-arr[i][0],i+1);
	}
	long long notChoose = go(w,i+1);
	// cout<< imie(w) imie(i) imie(choose) imie(notChoose) <<'\n';
	return dp[w][i] = max(notChoose,choose);
} 


int main () {
	#ifndef ONLINE_JUDGE
	    freopen("in.txt","r",stdin);
	    freopen("out.txt","w",stdout);
    #endif
	cin>>n>>W;

	for(int i=0;i<n;i++){
		cin>>arr[i][0]>>arr[i][1];
	}
	cout<<go(W,0);


	
	

}

Measured memory_bytes: 81268
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>

int main(void) {
    std::string str;
    int a;
    int b;
    int q;
    std::string start = "";
    std::string sub = "";
    std::string end = "";
    std::string s = "";
    std::cin >> str >> q;

    for (int i = 0; i < q; i++) {
        std::string order;
        std::cin >> order;
        std::cin >> a >> b;
        start = str.substr(0, a);
        sub = str.substr(a, b - a + 1);
        end = str.substr(b + 1, str.size() - b);

        if (order == "replace") {
            s = "";
            std::cin >> s;
            str = start + s + end;
        } else if (order == "reverse") {
            std::reverse(sub.begin(), sub.end());
            str = start + sub + end;
        } else if (order == "print") {
            std::cout << sub << std::endl; 
        } else {
        }
    }

    return EXIT_SUCCESS;
}

Measured memory_bytes: 3192
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 100010 
using namespace std;
ll f[N][2]; ll a[N]; int n;
void solve()
{
	memset(f,-48,sizeof(f)); f[0][0]=f[0][1]=0;
	for(int i=1;i<=n;i++)
	{
		if(i==1)	f[i][0]=a[i];
		else
		{
			f[i][0]=max(f[i-1][0],f[i-1][1])+a[i];// printf("QAQ %d %lld\n",i,a[i]);
			f[i][1]=max(f[i-1][0]-2*a[i-1],f[i-1][1]+2*a[i-1])-a[i];
		}
	}
	printf("%lld\n",max(f[n][0],f[n][1]));
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	solve(); 
	return 0;
}

Measured memory_bytes: 2560
function Main(input) {
    input = input.trim().split("\n");
    var tmp = input[0].split(" ");
    var N = parseInt(tmp[0], 10);
    var AB = [];
    for (var i = 1; i < N + 1; i++){
        tmp = input[i].split(" ");
        AB[i-1] = {A:parseInt(tmp[0],10),B:parseInt(tmp[1],10)}
    }
    AB.sort(function (a, b) {
        if (a.B < b.B) return -1;
        if (a.B > b.B) return 1;
        return 0;
    });
    var time = 0;
    var judge = "Yes";
    for (var i = 0; i < N; i++){
        time += AB[i].A;
        if (time > AB[i].B) {
            judge = "No";
            break;
        }
    }
    console.log(judge);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 62484
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;

int main(void) {
    ll a, b, k;
    cin >> a >> b >> k;
    if (a - k >= 0) {
        cout << a - k << " " << b << endl;
    } else {
        cout << 0 << " " << max(0LL, b - k + a) << endl;
    }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
mod = int(1e9+7)
n,k = map(int,input().split())
L=list(map(int,input().split()))

ans = 1
if k==n:
    for i in L:
        ans*=i
        ans%=mod
    print(ans%mod)
    sys.exit()
pos = []
neg = []
for i in L:
    if i>=0:
        pos.append(i)
    else:
        neg.append(i)
pos.sort(reverse=True)
neg.sort()
if len(pos) == 0 and k%2!=0:
    for i in range(1,k+1):
        ans*=neg[-i]
        ans%=mod
    print(ans%mod)
    sys.exit()
if k%2!=0:
    ans*=pos.pop(0)
    k-=1
l=[]
for i in range(1,len(pos),2):
    l.append(pos[i]*pos[i-1])

for i in range(1,len(neg),2):
    l.append(neg[i]*neg[i-1])

l.sort(reverse = True)
for i in range(k//2):
    ans*=l[i]
    ans%=mod

print(ans%mod)


Measured memory_bytes: 112948
S=list(input())
N=len(S)
#print(S, N)
s1=S[(N-1)//2]
s3=S[(N+3)//2-1:]

if S==S[::-1] and s1==s1[::-1] and s3==s3[::-1]:
  print("Yes")
else:
  print("No")




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

int main(){

    cin.tie(nullptr);
    ios_base::sync_with_stdio(0);

    int n, k; cin >> n >> k;
    vector<int> v(n);
    for(int &u : v) cin>>u;

    int lw=1, hh=*max_element(v.begin(),v.end()), ans=-1;
    while(lw <= hh){
        int m = (lw + (hh-lw)/2);
        int need = 0;
        for(int u : v) if(u>m)
            need += (u-1)/m;
//        cout << m << " " << need << "\n";
        if(need <= k)
            ans=m, hh=m-1;
        else lw=m+1;
    }cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3952
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: i64,
        b: i64,
        x: [i64; n]
    };

    let mut ans = 0;
    for (i, x_i) in x.iter().enumerate().skip(1) {
        let d = x_i - x[i - 1];
        ans += std::cmp::min(d * a, b);
    }
    println!("{}", ans);
}


Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
	int n;
	cin >> n;
	if(n==9){
		cout << "Yes" << endl;
		return 0;
	}
	if(n%10==9){
		cout << "Yes" << endl;
		return 0;
	}
	if(n>=90){
		cout << "Yes" << endl;
		return 0;
	}
	
	cout << "No" << endl;
	
	return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> dp1(n), dp2(n);
  dp1[0] = a[0];
  for(int i = 1; i < n; ++i) dp1[i] = __gcd(a[i], dp1[i-1]);
  reverse(ALL(a));
  dp2[0] = a[0];
  for(int i = 1; i < n; ++i) dp2[i] = __gcd(a[i], dp2[i-1]);
  reverse(ALL(dp2));
  ll ans = 0;
  ans = max(dp1[n-2], dp2[1]);
  for(int i = 1; i < n-1; ++i) chmax(ans, __gcd(dp1[i-1], dp2[i+1]));
  cout << ans << endl;
}


Measured memory_bytes: 5620
#include<iostream>

using namespace std;

int main(){
    int N;
    int a[50];
    cin>>N;
    int AbsMaxInd;
    int AbsMax=-1;
    for(int i=0;i<N;i++){
        cin>>a[i];
        if(abs(a[i]) > AbsMax){
            AbsMax=abs(a[i]);
            AbsMaxInd=i;
        }
    }
    AbsMaxInd++;
    if(AbsMax==0){
        cout<<0<<endl;
    }else if(a[AbsMaxInd-1]>0){//絶対値の一番大きい数が正の時
        cout<<(2*(N-1))<<endl;
        for(int i=1;i<=N;i++){
            if(i != AbsMaxInd){
                cout<< AbsMaxInd << ' ' << i <<endl;
            }
        }
        for(int i=1;i<N;i++){
            cout<< i << ' ' << (i+1) <<endl;
        }
    }else{//絶対値の一番大きい数が負の時
        cout<<(2*(N-1))<<endl;
        for(int i=1;i<=N;i++){
            if(i != AbsMaxInd){
                cout<< AbsMaxInd << ' ' << i <<endl;
            }
        }
        for(int i=N;i>1;i--){
            cout<< i << ' ' << (i-1) <<endl;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const ll MOD = 1000000007;

//#define __DBG__




void solve(void){
  
  int A, B;
  cin >> A >> B;
  
  int XA = A * 13;
  int XB = B * 10;
  
  int tmp, tmp2;
    
  if (XA<XB){
    tmp = XA;
    tmp2=XB;
  }
  else{
    tmp = XB;
    tmp2=XA;
  }
  
  int flag=-1;
  
  for (int i=tmp; i<=tmp2; i++){
    int TA=i*0.08;
    int TB=i*0.10;
    if(TA==A && TB==B)
    {
      flag=i;
      break;
    }
  }
 
  cout << flag << endl;
  
  return;
}

int main(int argc, const char * argv[]) {



    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <sstream>

int main(void)
{
    int64_t N;
    std::string S;

    std::cin >> N >> S;

    int64_t ans = 0;
    uint64_t pos = S.find("ABC");
    while(pos != std::string::npos) {
        ans++;
        pos = S.find("ABC", pos + 3);
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
template <class Key, class Compare = less<Key>>
using Tree = __gnu_pbds::tree<Key, __gnu_pbds::null_type, Compare, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;



const ll mod = 1e9 + 7;

int n;
bool a[22][22];
ll dp[22][(1<<21)+1];

ll dfs(int i, int m) {
  ll& res = dp[i][m];
  if (res != -1) {
    return res;
  }
  if (i == n) {
    return res = 1;
  }
  res = 0;
  for (int j = 0; j < n; ++j) {
    if (a[i][j] && !(m & (1 << j))) {
      res += dfs(i+1, m | (1 << j));
      res %= mod;
    }
  }
  return res;
}

void Main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> a[i][j];
    }
  }
  memset(dp, -1, sizeof(dp));
  ll ans = dfs(0, 0);
  cout << ans << '\n';
}

int main() {
  ios::sync_with_stdio(false);
//  cin.tie(nullptr);
  #ifdef _DEBUG
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  #endif
  Main();
  return 0;
}


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

using namespace std;


int main(){

long long a,b,c;cin >> a >> b >> c;

long long ans,ans2;
ans = (c-a-b)*(c-a-b);
ans2 = 4*a*b;

if (ans2<ans&&c-a-b>0)
{
   cout << "Yes";
}
else{
    cout << "No";
}

return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int h, m, s;

  scanf("%d", &h);
  s = m = h;
  h /= 3600;
  m = (m - (h * 3600) ) / 60;
  s = s - (h * 3600 + m * 60);
  
  printf("%d:%d:%d\n", h, m, s);

  return 0;
}
  

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <math.h>
#include <cmath>
#include <ctime>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
typedef pair<int, int> P;

const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool chmax(int& xx, int yy) {
	if (xx < yy) {
		xx = yy;
		return true;
	}
	return false;
}
bool chmin(int& xx, int yy) {
	if (xx > yy) {
		xx = yy;
		return true;
	}
	return false;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	string s, t;
	cin >> s >> t;
	for (int i = s.size() - t.size(); i >= 0; i--) {
		bool b = 1;
		for (int j = 0; j < t.size(); j++) {
			if (s[j + i] != '?' && s[j + i] != t[j]) {
				b = 0;
			}
		}
		if (b) {
			rep(j, s.size()) {
				if (s[j] != '?') {
					cout << s[j];
				}
				else if (j >= i && j < t.size() + i) {
					cout << t[j - i];
				}
				else {
					cout << 'a';
				}
			}
			cout << endl;
			return 0;
		}
	}
	cout << "UNRESTORABLE" << endl;	
}

Measured memory_bytes: 3632
let () =
    let split s =
        let rec loop i cur flag acc =
            if i = String.length s then ( if flag then cur :: acc else acc) else (
                match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) "" false (cur :: acc)
                | false, ' ' -> loop (i + 1) "" false acc
                | true,  v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
                | false, v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
            )
        in
        List.map int_of_string (List.rev (loop 0 "" false []))
    in
    let main () =
        let n = int_of_string (read_line ()) in
        let a = Array.of_list (split (read_line ())) in
        let f = Array.make n 0 in
        let (_, x) = Array.fold_left (fun (sign, sum) v -> -sign, sum + sign * v) (1, 0) a in
        f.(0) <- x;
        for i = 1 to n - 1 do
            f.(i) <- 2 * a.(i - 1) - f.(i - 1)
        done;
        Array.iter (Printf.printf "%d ") f;
        print_newline ()
    in
    main ()

Measured memory_bytes: 18816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    int ans = 0;
    for(int i = 1; i <= x; i++)
        for(int j = 1; j <= x; j++)
            for(int k = 1; k <= x; k++)
                    ans += __gcd(__gcd(i, j), k);

    cout << ans;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int n,k;
long long ans,t;
int main(){
	scanf("%d%d",&n,&k);
	ans=n/k;ans=ans*ans*ans;
	if (k%2==0){
		t=(n>=k/2)?1+(n-k/2)/k:0;
		ans+=t*t*t;
	}
	printf("%lld\n",ans);
	return 0;
} 

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e2 + 5);

int n;
vector<int> b;

vector<int> ans;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    int tmp;
    scanf("%d", &tmp);
    b.push_back(tmp);
  }

  while (!b.empty()) {
    bool flg = false;

    for (int j = b.size() - 1; j >= 0; --j) {

      if (b[j] == j + 1) {
        flg = true;
        ans.push_back(b[j]);
        b.erase(b.begin() + j);
        break;
      }
    }

    if (!flg) {
      printf("%d\n", -1);
      return 0;
    }
  }

  reverse(ans.begin(), ans.end());

  for (auto e: ans) {
    printf("%d\n", e);
  }

  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())

AB=[]

for i in range(N):
    a,b=map(int,input().split())
    
    AB.append([a,b])

AB.sort()
buy_num=0
i=0
ans=0

for i in range(N):

    ai=AB[i][0]
    bi=AB[i][1]
    
    if M-buy_num>bi:
        buy_num+=bi
        ans+=ai*bi
            
    else:
        #bu_num+=M-ans
        ans+=ai*(M-buy_num)
        break
        
print(ans)
    
    

Measured memory_bytes: 20072
#include <bits/stdc++.h>
using std::max;
using std::min;
int x,n,Q,a,t,r[100005];
int main(){
	scanf("%d",&x);
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&r[i]);
	int lx=0,rx=x,ly=0,ry=x;
	scanf("%d",&Q);
	scanf("%d%d",&t,&a);
	int now=-1;
	for (int i=1;i<=n;i++){
		while (t<=r[i] && Q){
			t=t-r[i-1];
			if (a<=lx) printf("%d\n",min(x,max(ly+t*now,0)));
			else if (a>=rx) printf("%d\n",min(x,max(ry+t*now,0)));
			else printf("%d\n",min(x,max(ly+(a-lx)+t*now,0)));
			Q--;
			if (Q==0) break;
			scanf("%d%d",&t,&a);
		}
		int ti=r[i]-r[i-1]; 
		if (now==-1){
			if (ly-ti<0) lx+=ti-ly;
			if (lx>x){
				lx=x,rx=0;
				ry=0;
			}
			ly=std::max(0,ly-ti);
			ry=std::max(0,ry-ti);
		}else{
			if (ry+ti>x) rx-=(ry+ti-x);
			if (rx<0){
				lx=x,rx=0;
				ly=x;
			}
			ly=std::min(x,ly+ti);
			ry=std::min(x,ry+ti);
		}
		now=now*(-1);
	}
	while (Q){
			t=t-r[n];
			if (a<=lx) printf("%d\n",min(x,max(ly+t*now,0)));
			else if (a>=rx) printf("%d\n",min(x,max(ry+t*now,0)));
			else printf("%d\n",min(x,max(ly+(a-lx)+t*now,0)));
			Q--;
			if (Q==0) break;
			scanf("%d%d",&t,&a);
		}
}

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

int main(){
    int N;
    cin >> N;
    long long ans = 0;
    for(int i=1;i<=N;i++){
        if(i%3 == 0 || i%5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N;
  cin >> N;
  map<string, int> m;
  rep(i, N){
    string s;
    cin >> s;
    m[s]++;
  }
  int max_v = 0;
  for(auto c = m.begin(); c != m.end(); c++){
    max_v = max(max_v, c->second);
  }

  vector<string> st;
  int cnt = 0;
  //auto c = m.begin();
  for(auto c = m.begin(); c != m.end(); c++){
    if (c->second == max_v){
      st.push_back(c->first);
      cnt++;
    }else{
      continue;
    }
  }
  sort(st.begin(), st.end());
  rep(i, cnt){
    cout << st[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 27248
#include<bits/stdc++.h>
#define int long long
#define fr(i,a,b) for(int i(a),end##i(b);i<=end##i;i++)
#define fd(i,a,b) for(int i(a),end##i(b);i>=end##i;i--)
using namespace std;
const int mod=998244353;
const int maxn=4e7+5;
int ksm(int x,int k){
	int ans=1;
	while(k){
		if(k&1)ans=ans*x%mod;
		x=x*x%mod;
		k>>=1;
	}
	return ans;
}
int jc[maxn],inv[maxn];
void init(int n){
	jc[0]=1;
	fr(i,1,n)jc[i]=jc[i-1]*i%mod;
	inv[n]=ksm(jc[n],mod-2);
	fd(i,n-1,0)inv[i]=inv[i+1]*(i+1)%mod;
}
int C(int n,int m){
	if(n<0||m<0||n<m)return 0;
	return jc[n]*inv[m]%mod*inv[n-m]%mod;
}
int D(int n,int m){
	if(n<0||n+m<0||((n+m)&1))return 0;
	return C(n,n+m>>1);	
}
int x,y,t,ans;
signed main(){
#ifdef pig
	freopen("f.in","r",stdin);
	freopen("f.out","w",stdout);
#endif
	cin>>t>>y>>x;
	if(!x&&!y&&t){
		cout<<1;
		return 0;
	}
	init(3e7);y=x-y;
	if(2*x-t-y==0)ans=D(t-1,2*x-t-1)-D(t-1,2*x-t+1);
	fr(k,1,2*x-y){	
		int h=2*x-k-y;
		(ans+=C(h+t-k-1,h)*(D(k-1,2*x-k-1)-D(k-1,2*x-k+1)))%=mod;	
	}
	cout<<(ans+mod)%mod;
	return 0;
}

Measured memory_bytes: 473344
b = list(map(int, input().split()))
K = int(input())
for i in range(3 ** K):
    a = b[::]
    for j in range(K):
        a[i % 3] *= 2
        i //= 3
    if a[0] < a[1] and a[1] < a[2]:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 64864
#include <stdio.h>

int main(void) {
	int i,n,mon = 100000;
	scanf("%d",&n);
	for(i = 0; n > i; i++){
		mon *= 1.05;
		mon += 999;
		mon = (int)(mon/1000)*1000;
	}
	printf("%d\n",mon);
	return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())


using P = pair<ll,ll>;
#define w first
#define v second

vector<P> all_enumerate(vector<P> vp, ll W, bool need_sort){
    int N = vp.size();
    vector<P> dp;
    for (int mask = 0; mask < (1<<N); mask++) {
        ll sumV = 0, sumW = 0;
        for (int i = 0; i < N; i++) {
            if (mask & (1<<i)) {
                sumV += vp[i].v;
                sumW += vp[i].w;
            }
        }
        if (sumW <= W) {
            dp.push_back({sumW, sumV});
        }
    }
    if (!need_sort) return dp;
    // V降順
    sort(dp.begin(), dp.end(), [](P a, P b){
        return a.v != b.v ? a.v > b.v : a.w < b.w;
    });
    vector<P> res;
    int w_border = W+1;
    for(P s : dp){
        if( w_border > s.w){
            w_border = s.w;
            res.push_back(s);
        }
    }
    // V昇順 & W昇順
    reverse(res.begin(), res.end());
    return res;
}

int main(void){
    cin.tie(0); ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n+1),w(n+1);
    rep1(i,n){
        cin >> v[i] >> w[i];
    }
    int H2 = log2(n)/2 + 3;
    vector<vector<P>> dp((1<<H2)+1);
    for (int i = 1; i < (1<<H2); i++) {
        if (i > n) break;
        vector<P> vp;
        int x = i;
        while(x) {
            vp.push_back({w[x], v[x]});
            x /= 2;
        }
        dp[i] = all_enumerate(vp, 100000LL, true);
    }
    int Q;
    cin >> Q;
    rep(q,Q){
        int x, L;
        cin >> x >> L;
        vector<P> vp;
        while((1<<H2) <= x) {
            vp.push_back({w[x], v[x]});
            x /= 2;
        }
        vector<P> dp1 = dp[x];
        vector<P> dp2 = all_enumerate(vp, L, false);
        ll max_v = 0;
        for (P p : dp2) {
            int pos = lb(dp1, P({L - p.w + 1, 0LL})) - 1;
            if (pos < 0) {
                if (p.w <= L) {
                    max_v = max(max_v, p.v);
                }
            } else {
                if (p.w + dp1[pos].w <= L) {
                    max_v = max(max_v, p.v + dp1[pos].v);
                }
            }
        }
        cout << max_v << endl;
    }
    return 0;
}




Measured memory_bytes: 48476
#include<queue>
#include<iostream>
using namespace std;
main(){
  int n,m;
  queue<int> poteto;
  while(1){
    cin>>n>>m;
    if(n==0&&m==0) break;
    for(int i=1;i<=n;i++){
      poteto.push(i);
    }
    while(poteto.size()>1){
      for(int j=0;j<m-1;j++){
	poteto.push(poteto.front());
	poteto.pop();
      }
      poteto.pop();
    }
    cout<<poteto.front()<<endl;
    poteto.pop();
  }
}

Measured memory_bytes: 1224
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 



int main(){
    string S;
    cin >> S;
    int L=S.length();
    string T;
    for(int i=0;i<L;++i){
        T+='x';
    }
    cout << T;
    }

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N;
    cin >> N;
    vec H(N);
    REP(i,0,N) cin >> H[i];

    bool f = false, g = true;;
    REP(i,0,N-1) {
        if(H[i] < H[i+1]) f = false;
        else if(H[i] == H[i+1]) continue;
        else if(H[i] - H[i+1] == 1) {
            if(!f) f = true;
            else {
                g = false;
                break;
            }
        }
        else {
            g = false;
            break;
        }
    }
    if(g) PR("Yes");
    else PR("No");

    return 0;
}

/*



*/

Measured memory_bytes: 1024
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let uvw: Vec<(usize, usize, i32)> = (1..n).map(|_| (input(), input(), input())).collect();

    let mut e = vec![vec![]; n];
    for (u, v, w) in uvw {
        let (u, v) = (u - 1, v - 1);
        e[u].push((v, w % 2));
        e[v].push((u, w % 2));
    }

    let mut v = vec![-1; n];
    dfs(0, 0, &mut v, &e);
    for v in v {
        println!("{}", v);
    }
}

fn dfs(cur: usize, w: i32, v: &mut Vec<i32>, e: &Vec<Vec<(usize, i32)>>) {
    v[cur] = if w % 2 == 0 { 0 } else { 1 };
    for &(next, w1) in &e[cur] {
        if v[next] < 0 {
            dfs(next, w + w1, v, e);
        }
    }
}


Measured memory_bytes: 18684
#include <stdio.h>

int main(int argc, char *argv[])
{
    int min, max;
    long sum = 0;
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        int value;
        scanf("%d", &value);
        min = (!i || value < min) ? value : min;
        max = (!i || value > max) ? value : max;
        sum += value;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}



Measured memory_bytes: 2148
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int d;
  cin>>d;

  string ans="Christmas";
  while(d-25<0)
  {
    ans+=" Eve";
    d++;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int n;
    cin >> n;
    set<int> s;
    int count = 0;
    s.insert(MOD);
    REP(i, n) {
        int a;
        cin >> a;
        if(a < *s.begin()) count++;
        s.insert(a);
    }
    cout << count << endl;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <string>

using namespace std;
using ll = long long;

ll N;
string S;

const ll MOD = 1e9 + 7;

void input() {
    cin >> N >> S;
}

ll solve() {
    vector<ll> ccount(256, 0);
    for (auto c : S)
        ccount[c]++;
    
    ll ans = 1;
    for (auto count : ccount) {
        ans = (ans * (count + 1)) % MOD;
    }
    return (ans + MOD - 1) % MOD;
}

int main() {
    input();
    cout << solve() << endl;
    
    return 0;
}



Measured memory_bytes: 1144
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class E {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            if (in.nextInt() >= 30) out.println("Yes");
            else out.println("No");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main(){
  int r; cin >> r;
  cout << 3 * pow(r,2);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define int long long
using namespace std;
const int mod = 1e9+7;

signed main() {
  int N; cin >> N;
  string s[2]; cin >> s[0] >> s[1];
  int ans;
  if(s[0][0] == s[1][0]) ans = 3;
  else ans = 6;
  for(int i = 1; i < N; ++i) {
    if(s[0][i-1] == s[0][i]) continue;
    if(s[0][i] == s[1][i]) {
      if(s[0][i-1] == s[1][i-1]) ans *= 2;
      ans %= mod;
      continue;
    }
    if(s[0][i-1] == s[1][i-1]) ans *= 2;
    else ans *= 3;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split(' '))
p = [int(x) for x in input().split(' ')]

sum = 0
for i in range(K):
    sum += p[i]
Max = sum
for i in range(K, N):
    sum += p[i] - p[i - K]
    Max = max(sum, Max)

print((Max + K) / 2)

Measured memory_bytes: 24676