akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

struct UnionFind {
	vector<int> par, s;
	UnionFind(int N) : par(N), s(N, 1) { rep(i, 0, N)par[i] = i; }
	int root(int x) { return par[x] == x ? x : par[x] = root(par[x]); }
	void unite(int x, int y) { x = root(x), y = root(y); if (x == y)return; if (s[x] < s[y])swap(x, y); s[x] += s[y]; par[y] = x; }
	bool same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return s[root(x)]; }
	map<int, int> cnt() { map<int, int> cnt; rep2(v, par)cnt[root(v)]++; return cnt; }
};
int main(void) {
	int n, q;
	cin >> n >> q;
	UnionFind tree(n);
	rep(i, 0, q) {
		int t, u, v;
		cin >> t >> u >> v;
		if (t == 0)tree.unite(u, v);
		else printf("%d\n", tree.same(u, v));
	}
	return 0;
}


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

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

    if (s.size() <= k) {
        cout << s << endl;
    }
    else {
        cout << s.substr(0, k) + "..." << endl;
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
int m,d;
cin >> m >> d;
int ans = 0;
for(int i=1;i<=m;i++){
    for(int j=10;j<=d;j++){
        int keta = 1,che=j;
        while(che>0){
            keta*=che%10;
            che/=10;
        }
        if(keta==i&&j%10>=2&&j/10>=2){ans++;}

    }
}
cout << ans << endl;
}
 


Measured memory_bytes: 256
def pow10(d)
  if d.zero?
    1
  elsif d == 1
    10
  elsif d.odd?
    (10 * pow10(d - 1)) % 2019
  else
    (pow10(d / 2) ** 2) % 2019
  end
end

S = gets.chomp
ans = 0
dp = Array.new(2020, 0)
dp_mod = Array.new(S.size + 1, 0)
dp[0] = 1

(1 .. S.size).each do |d|
  s = S[-d].to_i
  dp_mod[d] = (s * pow10(d) + dp_mod[d - 1]) % 2019
  ans += dp[dp_mod[d]]
  dp[dp_mod[d]] += 1
end
puts ans


Measured memory_bytes: 16068
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll N;
bool a[105];
int main(){
  cin>>N;
  for(ll i=0;i<N;i++){
  ll x,y;cin>>x>>y;
    a[i]=(x==y);
  }string ans="No";
  for(ll i=0;i<N-2;i++)
    if(a[i] &&a[i+1] &&a[i+2])ans="Yes";
  cout<<ans<<endl;
  
  return 0;
}
  

Measured memory_bytes: 3628
<?php
$answer = 0;

fscanf(STDIN, "%d", $N);
$array = array('M' => 0, 'A' => 0, 'R' => 0, 'C' => 0, 'H' => 0);
$keys = array_keys($array);
for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%s", $S);
    $arrS = str_split($S);
    if (in_array($arrS[0], array_keys($array))) {
        $array[$arrS[0]]++;
    }
}
$sum = array_sum($array);
for ($i = 0; $i < 5; $i++) {
    for ($j = 0; $j < 5; $j++) {
        if ($i == $j) continue;
        $rest = $sum - $array[$keys[$i]] - $array[$keys[$j]];
        $answer += $array[$keys[$i]] * $array[$keys[$j]] * $rest;
    }
}
echo $answer / 6 . PHP_EOL;

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

int main(){
    int H, W;
    while(true){
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; ++i){
            for (int j = 0; j < W; ++j){
                if ((i % 2 == 1 && j % 2 == 1) || (i % 2 == 0 &&  j % 2 == 0)) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>

using namespace std;

int main(){

	string str[2];
	string under;
	pair<int,int> center;
	center.first=500;
	center.second=500;
	char field2[1000][1000];

	while(cin>>str[0]&&str[0]!="-"){
		bool pl[200];
		memset(pl,0,sizeof(pl));


		cin>>str[1]>>under;
		for(int i = 0; i<under.size(); i++){
			pl[under[i]]=true;
		}
		vector<int> v;
		for(int i = 0; i < str[1].size()-1; i++){
			v.push_back(1);
		}
		// under
		for(int i = 0; i < str[0].size(); i++){
			v.push_back(0);
		}
		sort(v.begin(),v.end());
	//	do{
			// Rs[µÄ­é
			memset(field2,0,sizeof(field2));
			for(int i = 0; i < str[0].size(); i++){
				field2[center.first-1-i][center.second]=str[0][i];
			}
			for(int i = 0; i < str[1].size(); i++){
				field2[center.first][center.second-1-i+1]=str[1][i];
			}

			// ±±ÅV~[V
			for(int i = 0; i < v.size(); i++){
				if(pl[field2[500][500]]){
					// ºÖ¨­é
					for(int i = 999; i >= 1; i--){
						field2[i][500]=field2[i-1][500];
					}
				}
				else{
					// EÖ¨­é
					for(int i = 999; i >= 1; i--){
						field2[500][i]=field2[500][i-1];
					}
				}
			}
			// EÖ¨­é
			for(int i = 999; i >= 1; i--){
				field2[500][i]=field2[500][i-1];
			}

			string ret1,ret2;
			for(int i = 501; i < 1000; i++){
				if((field2[500][i]>='a'&&field2[500][i]<='z')||(field2[500][i]>='A'&&field2[500][i]<='Z')){
					ret1+=field2[500][i];
				}
				else
					break;
			}
			for(int i = 501; i < 1000; i++){
				if((field2[i][500]>='a'&&field2[i][500]<='z')||(field2[i][500]>='A'&&field2[i][500]<='Z')){
					ret2+=field2[i][500];
				}
				else
					break;
			}
			reverse(ret2.begin(),ret2.end());
			if(ret2==under){
				reverse(ret1.begin(),ret1.end());
				cout<<ret1<<endl;
			//	break;
			}
		//}while(next_permutation(v.begin(),v.end()));
	}


	return 0;
}

Measured memory_bytes: 0
"use strict";
exports.__esModule = true;
exports.main = function (_N, K, S) {
    var sList = S.split('');
    sList[K - 1] = sList[K - 1].toLowerCase();
    return sList.join('');
};
var exec = function () {
    var input = require('fs').readFileSync('/dev/stdin', 'UTF-8');
    var lines = input.split('\n');
    var _a = lines[0].split(' ').map(function (l) { return Number(l); }), N = _a[0], K = _a[1];
    var S = lines[1];
    console.log(exports.main(N, K, S));
};
exec();


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){int a,b,m,s,t,p,x,y,c;s=999999;t=s;cin>>a>>b>>m;int A[a],B[b];rep(i,a){cin>>A[i];s=min(A[i],s);}rep(i,b){cin>>B[i];t=min(B[i],t);}p=s+t;rep(i,m){cin>>x>>y>>c;p=min(p,A[x-1]+B[y-1]-c);}cout<<p;}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        //int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[][] sword = new int[a[0]][].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).OrderByDescending(x => x[0]).ToArray();
        int strongestA = sword[0][0];
        int[] strongerBthanA = sword.Select(x => x[1]).Where(x => x > strongestA).OrderByDescending(x => x).ToArray();
        int HP = a[1];
        int res = 0;
        for (int i = 0; i < strongerBthanA.Length; i++)
        {
            HP -= strongerBthanA[i];
            res++;
            if (HP <= 0) goto end;
        }
        res += HP / strongestA + (HP % strongestA != 0 ? 1 : 0);
        end:;
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 32704
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back
#define vv vector<ll>
#define MAX 105000
#define rr pow(10,9)+7
#define fr(i,x) for(int i=0;i<x;i++)
int dx[4] = {-1,0,0,1};
int dy[4] = {0,-1,1,0};

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    
    if(a.first == b.first) return a.second<b.second;
    return (a.first < b.first); 
}
ll ar[MAX];
void divisor(){
    for (int i = 1; i <= MAX; i++)
    {
        for (int j = i; j <= MAX;j+=i)
        {
            ar[j]++;
            
        }
        
        
    }
    
}
bool vi[100006] = {false};
ll n,m,x,u,v,c=0;

void dfs(ll r,vector<vector<ll>>&a){
    c++;
    vi[r] = true;
    for (int i = 0; i < a[r].size(); i++)
    {
        if(vi[a[r][i]]==false){
            //cout << a[r][i] << " ";
            dfs(a[r][i],a);
        }
    }
    
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cin >> n >> m;
    vector<vector<ll>>a(n+1);
    for (ll i = 0; i < m; i++)
    {
        cin >> u >> v;
        a[u].push_back(v);
        a[v].push_back(u);
    }
    for (ll i = 1; i <= n; i++)
    {
        if(a[i].size()==0) vi[i] = true;
    }
    ll re = INT_MIN;
    for (ll i = 1; i <= n; i++)
    {
        if(vi[i]==false){
            dfs(i,a);
            re = max(c,re);
            c = 0;
        }
    }
    if(m==0)cout << 1 << endl;
    else cout << re << endl;
}

Measured memory_bytes: 23840
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=300300;
const ll oo=1000000000000000000ll;
int i,j,k,n,m,ch,top;
int t[N],p[N],x[N];
ll ans[N],tmp[N],pret[N],suft[N],pre[N],suf[N];
struct cc { int x,id;};
vector<cc> Q[N];
struct dd { int x;ll y;} stack[N];
void R(int &x) {
	x=0;ch=getchar();
	while (ch<'0' || '9'<ch) ch=getchar();
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
}
void W(ll x) {
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
ll Js(dd a,dd b,dd c) {
	ll x1=b.x-a.x,y1=b.y-a.y;
	ll x2=c.x-b.x,y2=c.y-b.y;
	return x1*y2-x2*y1;
}
void solve(int L,int R) {
	if (L==R) return;
	int i,j,k,mid=(L+R)>>1;
	dd tt;
	ll ma;
	tt.x=0;tt.y=0;
	top=1;
	stack[top]=tt;
	for (i=L;i<=mid;i++) {
		tt.x=-i;tt.y=pre[i]+(ll) i*(i-1)/2+pret[i];
		while (top>1 && Js(stack[top-1],stack[top],tt)<=0) top--;
		stack[++top]=tt;
	}
	for (i=mid+1;i<=R;i++) {
		while (top>1 && (ll) stack[top].x*i+stack[top].y<=(ll) stack[top-1].x*i+stack[top-1].y) top--;
		tmp[i]=(ll) stack[top].x*i+stack[top].y+(ll) i*(i+1)/2-pret[i];
	}
	ma=-oo;
	for (i=R;i>mid;i--) {
		ma=max(ma,tmp[i]+suf[n-i]);
		for (k=0;k<Q[i].size();k++) ans[Q[i][k].id]=max(ans[Q[i][k].id],ma+t[i]-Q[i][k].x);
	}
	tt.x=0;tt.y=0;
	top=1;
	stack[top]=tt;
	for (j=R;j>mid;j--) {
		i=n-j+1;
		tt.x=-i;tt.y=suf[i]+(ll) i*(i-1)/2+suft[i];
		while (top>1 && Js(stack[top-1],stack[top],tt)<=0) top--;
		stack[++top]=tt;
	}
	for (j=mid;j>=L;j--) {
		i=n-j+1;
		while (top>1 && (ll) stack[top].x*i+stack[top].y<=(ll) stack[top-1].x*i+stack[top-1].y) top--;
		tmp[i]=(ll) stack[top].x*i+stack[top].y+(ll) i*(i+1)/2-suft[i];
	}
	ma=-oo;
	for (j=L;j<=mid;j++) {
		i=n-j+1;
		ma=max(ma,tmp[i]+pre[n-i]);
		for (k=0;k<Q[j].size();k++) ans[Q[j][k].id]=max(ans[Q[j][k].id],ma+t[j]-Q[j][k].x);
	}
	solve(L,mid);
	solve(mid+1,R);
}
int main() {
	R(n);
	for (i=1;i<=n;i++) R(t[i]);
	for (i=1;i<=n;i++) pret[i]=pret[i-1]+t[i];
	for (i=1;i<=n;i++) suft[i]=suft[i-1]+t[n-i+1];
	R(m);
	for (i=1;i<=m;i++) {
		R(p[i]);R(x[i]);
		cc tt;
		tt.x=x[i];
		tt.id=i;
		Q[p[i]].push_back(tt);
	}
	pre[0]=0;
	dd tt;
	tt.x=0;tt.y=0;
	top=1;
	stack[1]=tt;
	for (i=1;i<=n;i++) {
		while (top>1 && (ll) stack[top].x*i+stack[top].y<=(ll) stack[top-1].x*i+stack[top-1].y) top--;
		pre[i]=max(pre[i-1],(ll) stack[top].x*i+stack[top].y+(ll) i*(i+1)/2-pret[i]);
		tt.x=-i;tt.y=pre[i]+(ll) i*(i-1)/2+pret[i];
		while (top>1 && Js(stack[top-1],stack[top],tt)<=0) top--;
		stack[++top]=tt;
	}
	suf[0]=0;
	tt.x=0;tt.y=0;
	top=1;
	stack[1]=tt;
	for (i=1;i<=n;i++) {
		while (top>1 && (ll) stack[top].x*i+stack[top].y<=(ll) stack[top-1].x*i+stack[top-1].y) top--;
		suf[i]=max(suf[i-1],(ll) stack[top].x*i+stack[top].y+(ll) i*(i+1)/2-suft[i]);
		tt.x=-i;tt.y=suf[i]+(ll) i*(i-1)/2+suft[i];
		while (top>1 && Js(stack[top-1],stack[top],tt)<=0) top--;
		stack[++top]=tt;
	}
	for (i=1;i<=m;i++) ans[i]=pre[p[i]-1]+suf[n-p[i]];
	solve(1,n);
	for (i=1;i<=m;i++) W(ans[i]),puts("");
}

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

const ll MOD = 998244353;

ll n, k;
vector<pair<ll, ll>> v;
vector<ll> sum;
ll dp[200005];

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n >> k;
    v.resize(k);
    sum.resize(k);
    for (auto &i : v) {
        cin >> i.first >> i.second;
    }
    dp[1] = 1;
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j < k; j++) {
            if (i - v[j].first > 0) {
                sum[j] += dp[i - v[j].first];
                sum[j] = (sum[j] + MOD) % MOD;
            }
            dp[i] = (dp[i] + sum[j]) % MOD;
            if (i - v[j].second > 0) {
                sum[j] -= dp[i - v[j].second];
                sum[j] = (sum[j] + MOD) % MOD;
            }
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 5212
from sys import stdin

A, B, C = [int(x) for x in stdin.readline().rstrip().split()]

A_mod = A
B_mod = B

while B_mod != 0:
    A_mod = A_mod % B_mod
    if A_mod == 0:
        res_mod = B_mod
        break
    B_mod = B_mod % A_mod
    if B_mod == 0:
        res_mod = A_mod
        break

check = C % res_mod
if check == 0:
    print('YES')
else:
    print('NO')


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

using namespace std;
typedef long long ll;
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(int argc, char const *argv[]) {
  long long n, count = 0, ans = 0, perv;
  string s1, s2;
  cin >> n >> s1 >> s2;
  if (s1[0] == s2[0]) {
    ans = 3;
    count = 1;
    perv = 1;
  } else {
    ans = 6;
    count = 2;
    perv = 2;
  }

  while (count < s1.length()) {
    if (perv == 1) {
      ans *= 2;
    } else if (perv == 2 && s1[count] != s2[count]) {
      ans *= 3;
    }
    ans %= mod;

    perv = (s1[count] == s2[count] ? 1 : 2);
    count += perv;
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun h w ->
    let a = Array.init h (fun _ -> Scanf.scanf " %s" (fun a -> a)) in
    let flagh = Array.init h (fun i ->
        let rec loop j =
            if j = w then false else
                if a.(i).[j] = '.' then loop (j + 1) else true
        in
        loop 0
    )
    in
    let flagw = Array.init w (fun j ->
        let rec loop i =
            if i = h then false else
                if a.(i).[j] = '.' then loop (i + 1) else true
        in
        loop 0
    )
    in
    for y = 0 to h - 1 do
        if flagh.(y) then (
            for x = 0 to w - 1 do
                if flagw.(x) then print_char a.(y).[x]
            done;
            print_newline ()
        )
    done
)

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define int long long
#define INT INT_MAX
#define LONG LLONG_MAX
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
typedef long long ll;
using namespace std;

ll GCD(ll a, ll b) {
	if (b == 0)return a;
	return GCD(b, a%b);
}

ll LCM(ll a, ll b) {
	return a / GCD(a, b)*b;
}

ll mypow(ll a, ll b, ll c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	else return mypow(a, b / 2, c)*mypow(a, b / 2, c) % c;
}

signed main(){
	string s,t;
	map<char,char> m0;
	map<char,bool> m1;
	map<char,char> m2;
	map<char,bool> m3;
	cin>>s>>t;
	f(i,s.size()){
		if(m0[t[i]]!=s[i]&&m1[t[i]]){
			puts("No");
			return 0;
		}
		m0[t[i]]=s[i];
		m1[t[i]]=true;
	}
	f(i,s.size()){
		if(m2[s[i]]!=t[i]&&m3[s[i]]){
			puts("No");
			return 0;
		}
		m2[s[i]]=t[i];
		m3[s[i]]=true;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll p[550][550];

int main() {
  ll n,m,q; cin >> n >> m >> q;
  FOR(i,0,m-1){
    int l,r; cin >> l >> r;
    ++p[l][r];
  }
  FOR(i,1,n){
    FOR(j,1,n){
      p[i][j] += p[i][j-1];
      p[i][j] += p[i-1][j];
      p[i][j] -= p[i-1][j-1];
    }
  }

  FOR(i,0,q-1){
    int l,r; cin >> l >> r;
    cout << p[r][r] - p[l-1][r] - p[r][l-1] + p[l-1][l-1] << endl;
  }
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
 
    int h, a;
    cin >> h >> a;
 
    cout << (h+a-1)/a << endl;
 
    return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(float, input().split()))
dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
dp[1][0] = 1-p[0]
dp[1][1] = p[0]
for i in range(1, n):
	for j in range(i+2):
		dp[i+1][j] = dp[i][j] * (1-p[i]) + dp[i][j-1] * p[i]
ans = 0
for i in range(n//2 + 1):
	ans += dp[n][i]
print(1-ans)

Measured memory_bytes: 261384
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <sstream>
#include <iostream>
#include <iomanip>
 
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <cassert>
 
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
using namespace std;
#define f(i,a,b) for(int (i)=int(a);i<=int (b);i++)
#define ff(i,a,b) for(int (i)=int (a);i<int (b);i++)
#define F(i,a,b) for(int (i)=int (a);i>=int (b);i--)
#define fi first
#define se second
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
const int inf=1<<30,mod=1e9+7,N=1e6+7;
string s,t;
int main(){
	cin>>s>>t;
	int n=s.size(),m=t.size();
	F(i,n-m,0){
		string v=s.substr(0,i),u=s.substr(i,m),z=s.substr(i+m);
		bool check=1;
		ff(j,0,m){
			if(t[j]==u[j]||u[j]=='?') continue;
			else check=0;
		}
		if(check){
			ff(k,0,v.size()) {
				if(v[k]=='?') cout<<"a";
				else cout<<v[k];
			}
			cout<<t;
			ff(k,0,z.size()) {
				if(z[k]=='?') cout<<"a";
				else cout<<z[k];
			}
			return 0;
		}
	}
	cout<<"UNRESTORABLE";
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin>>s;
  if(s=="Sunny")cout<<"Cloudy"<<endl;
  if(s=="Cloudy")cout<<"Rainy"<<endl;
  if(s=="Rainy")cout<<"Sunny"<<endl;
}

Measured memory_bytes: 256
import sys
from collections import deque


def bfs(s):
    flag_list[s] = 1
    d_list[s] = 0
    q.append(s)
    while len(q)>0:
        u = q.popleft()
        for v in range(n):
            if m_list[u][v] == 1 and flag_list[v] == 0:
                flag_list[v] = 1
                d_list[v] = d_list[u] + 1
                q.append(v)
        flag_list[u] = 2


if __name__ == "__main__":
    input = sys.stdin.readline
    n = int(input())
    m_list = [[0]*n for _ in range(n)]
    d_list = [-1]*n
    flag_list = [0]*n # 0: 未到達, 1: 処理中, 2: 完了
    q = deque([])
    for _ in range(n):
        input_list = list(map(int, input().split()))
        index = input_list[0] - 1
        if input_list[1] > 0:
            for a in input_list[2:]:
                m_list[index][a-1] = 1
    bfs(0)
    for i, d in enumerate(d_list):
        print(i+1, d_list[i])



Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
}
void ran() {
	srand(chrono::steady_clock::now().time_since_epoch().count());
}
long long get_rand() {
	long long a = rand();
	long long b = rand();
	return a * (RAND_MAX + 1ll) + b;
}
void usaco() {
	freopen("problem.in", "r", stdin); 
	freopen("problem.out", "w", stdout);
}
// #define endl '\n'
// #define double long double
#define int long long
// int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

signed main() {

	ran(); fast();
	
	int k;
	cin >> k;
	
	int t = 0;
	
	for (int i=1; i<=10000000; i++) {
		t *= 10;
		t += 7;
		t %= k;
		if (t == 0) {
			cout << i << endl;
			exit(0);
		}
	}
	cout << -1 << endl;

}


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

int main(){
	ll n;
	cin >> n;
	ll n0 = n;
	int k = 0;
	while(n0 != 0){
		n0 /= 10;
		k++;
	}
	int mi = 1000;
	rep(i, k-2){
		n0 = n;
		rep(j, i) n0 /= 10;
		int n1 = n0%1000;
		if(mi > abs(n1 - 753)) mi = abs(n1 - 753);
	}
	cout << mi << endl;
	return 0;
}


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

int main(){
    int n,a=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        int p;
        cin>>p;
        if(i!=p) a++;
    }
    if(a<=2) cout<<"YES";
    else cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, m;
  cin >> n >> m;
  vector<vector<ll>> v(n, vector<ll>(3));
  rep(i, 0, n) cin >> v[i][0] >> v[i][1] >> v[i][2];

  ll ans = 0;
  rep(i, 0, 1 << 3) {
    vector<ll> x(n);
    rep(k, 0, n) {
      rep(j, 0, 3) {
        if (i >> j & 1)
          x[k] += v[k][j];
        else
          x[k] -= v[k][j];
      }
    }

    sort(x.rbegin(), x.rend());
    ll c = 0;
    rep(j, 0, m) c += x[j];
    chmax(ans, c);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3708
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b, c = rm()
if b-a == c-b:
  print('YES')
else:
  print('NO')










Measured memory_bytes: 27220
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String n = sc.next();
      	if(n.charAt(0) == n.charAt(2)){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
    }
}

Measured memory_bytes: 35532
S=input()
a=int(S[0]+S[1])
b=int(S[2]+S[3])
if (a==0 or a>12) and 0<b<=12:
    print("YYMM")
elif 0<a<=12 and 0<b<=12:
    print("AMBIGUOUS")
elif 0<a<=12 and (b==0 or b>12):
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
local n = io.read("*n")
local len = 0
local maxlen = 0
for i = 1, n do
  a, b = io.read("*n", "*n")
  if a == b then
    len = len + 1
  else
    len = 0
  end
  maxlen = math.max(maxlen, len)
end
print(3 <= maxlen and "Yes" or "No")


Measured memory_bytes: 2680
#!/usr/bin/env python3
from collections import deque


def main():
    d = deque()
    d.extend(list(input()))

    Q = int(input())
    reflag = False

    for i in range(Q):
        query = list(input().split())
        if query[0] == '1':
            reflag = not reflag
        elif (query[1] == '1' and not reflag) or (query[1] == '2' and reflag):
            d.appendleft(query[2])
        else:
            d.append(query[2])

    if reflag:
        print("".join(reversed(d)))
    else:
        print("".join(d))


if __name__ == "__main__":
    main()


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

#define LL long long

#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) (((l)+(r))>>1)

const int MOD = (int) 1e9 + 7;
const double eps = (double) 1e-8;
const int maxn = (int) 2e5 + 20;


void work()
{
    int a, b;
    cin >>a >>b;
    cout <<a - b + 1 <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r" ,stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416

    int tc = 1;
//    scanf("%d", &tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
class MaxFlow {
	struct edge {
		int to, cap, rev;
		edge(int to_, int cap_, int rev_) : to(to_), cap(cap_), rev(rev_) {};
	};

	int V;
	vector<vector<edge>> G;
	vector<int> level;
	vector<int> iter;

	void BFS(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (size_t i = 0; i < G[v].size(); i++) {
				edge &e = G[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}

	int DFS(int v, int t, int f) {
		if (v == t) return f;
		for (int &i = iter[v]; i < (int)G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				int d = DFS(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

public:
	MaxFlow(int _V) : V(_V), G(_V), level(_V), iter(_V) {}
	void add(int from, int to, int cap) {
		G[from].push_back(edge(to, cap, G[to].size()));
		G[to].push_back(edge(from, 0, G[from].size() - 1));
	}
	int Dinic(int s, int t) {
		int flow = 0;
		while (true) {
			BFS(s);
			if (level[t] < 0) return flow;
			fill(iter.begin(), iter.end(), 0);
			int f;
			while ((f = DFS(s, t, INF)) > 0) {
				flow += f;
			}
		}
	}
};



int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<pair<int, int>>R(N), B(N);
	rep(i, N)cin >> R[i].first >> R[i].second;
	rep(i, N)cin >> B[i].first >> B[i].second;

	int s = 2*N, t = 2*N + 1;
	MaxFlow mf(N * 2 + 2);

	rep(i, N)mf.add(s, i, 1);
	rep(i, N)mf.add(N + i, t, 1);

	rep(i, N) {
		rep(j, N) {
			if (B[i].first > R[j].first&&B[i].second > R[j].second) {
				mf.add(i, N + j, 1);
			}
		}
	}
	
	cout << mf.Dinic(s, t) << endl;

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c=getchar();int t=0,f=1;
	while((!isdigit(c))&&(c!=EOF)){if(c=='-')f=-1;c=getchar();}
	while((isdigit(c))&&(c!=EOF)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,m,a[105];
signed main(){
	n=read(),m=read();
	int tot=0;
	for(int i=1;i<=n;i++){
		a[i]=read();tot+=a[i];
	}
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(4*m*a[i]>=tot)cnt++;
	}
	if(cnt>=m)puts("Yes");
	else puts("No");
	return 0;
}


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

int main() {
  int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
  int yen;
  if (A + B > C * 2) {
    int num = min(X, Y); X -= num; Y -= num;
    yen = C * num * 2;
  } else {
    yen = 0;
  }
  yen += min(A, C * 2) * X;
  yen += min(B, C * 2) * Y;
  cout << yen << "\n";
  return 0;
}


Measured memory_bytes: 504
<?php  
$stdin = trim(fgets(STDIN));
// print_r($stdin);
 
$ns = explode(' ', $stdin);
// print_r($ns);
 
for ($i = 0; $i < 1000; ++$i) {
  if (shuffle($ns)) 
    if ($ns[0] == 1 && $ns[1] == 9 && $ns[2] == 7 && $ns[3] == 4) { echo "YES"; exit; }
}
 
echo "NO";


Measured memory_bytes: 3828
<?php
//error_reporting(0);
//$N = (int)trim(fgets(STDIN));
$S = trim(fgets(STDIN));
//list($N,$M) = explode(" ",trim(fgets(STDIN)));
//$a = array_map('intval',explode(" ",trim(fgets(STDIN))));

if ($S[2]==$S[3] && $S[4]==$S[5])
  printf("Yes\n");
else
  printf("No\n");


Measured memory_bytes: 4856
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                    if(i % 2 == 0){
                        if(j % 2 == 0){
                            System.out.printf("#");
                        }else{
                            System.out.printf(".");
                        }
                    }else{
                        if(j % 2 == 0){
                            System.out.printf(".");
                        }else{
                            System.out.printf("#");
                        }
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 62560
N, M = gets.split.map(&:to_i)
step = [0] * (N+1)
step[0] = 1
M.times { step[gets.to_i] = -1 }

1.upto(N) do |i|
  next if step[i] == -1
  if i == 1
    step[i] = 1
  else
    s1 = (step[i-1] == -1) ? 0 : step[i-1]
    s2 = (step[i-2] == -1) ? 0 : step[i-2]
    if s1 == 0 && s2 == 0
      puts 0
      exit
    else
      step[i] = (s1 + s2) % (10**9 + 7)
    end
  end
end

puts step[N]

Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
  
int main()
{
    string u,s,t;
    int a,b;
    cin >> s >> t;
    scanf("%d%d",&a,&b);
    
    cin >> u;
    if(u == s) a--;
    else b--;
	 
	cout << a << " " << b << endl;
    return 0;
}


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

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

    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());

    int alice = 0, bob = 0;
    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
        {
            alice += a[i];
        }
        else
        {
            bob += a[i];
        }
    }
    cout << alice - bob << endl;
    return (0);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  int a[n],i,sum=0,j;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      sum+=a[i]*a[j];
    }
  }
  printf("%d",sum);
  return 0;
}

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

using namespace std;

int main(){
    int n;
    vector<int> l;
    cin >> n;
    for(int i=0;i<n;i++){
        int tmp = 0;
        cin >> tmp;
        l.push_back(tmp);
    }
    int maxl = 0;
    int maxindex = 0;
    for(int i=0;i<n;i++){
        if(maxl < l[i]){
            maxl = l[i];
            maxindex = i;
        }
    }
    int sum = 0;
    for(int i=0;i<n;i++){
        if(i != maxindex){
            sum += l[i];
        }
    }
    if(maxl < sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
typedef pair<int, int> P;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  map<int, int> mi;
  int ac = 0;
  int wa = 0;
  FOR(i,0,M) {
    int p;
    string S;
    cin >> p >> S;
    if (S == "WA") {
      mi[p]++;
    }
    if (mi[p] >= 0 && S == "AC") {
      ac++;
      wa += mi[p];
      mi[p] = -M-1;
    }
  }
  cout << ac << " " << wa << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];

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

    }

    sort(a,a+n);
    int sum=0;

    for(int i=0;i<k;i++)
    {
        sum+=a[i];
    }

    cout<<sum<<endl;
    exit(0);
}


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

int n,w[105],v[105],W;

long long dp[100500],ans,INF = (long long)2e18;

int main(){
    cin >> n >> W;
    for(int i = 1; i <= n; i++){
        cin >> w[i] >> v[i];
    }
    /// dp[i] = minimum sum with value i
    for(int i = 0; i <= 100000; i++) dp[i] = INF;
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 100000 - v[i]; j >= 0; j--){
            dp[j + v[i]] = min(dp[j + v[i]],dp[j] + w[i]);
        }
    }
    for(int i = 0; i <= 100000; i++){
        if(dp[i] <= W) ans = i;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		String str = fs.next();
		
		int maxX = 0;
		int nowX = 0;
		
		for(int i = 0; i < str.length(); i++) {
			char nowChar = str.charAt(i);
			if(nowChar == 'D') {
				nowX--;
			}else {
				nowX++;
			}
			maxX = Math.max(nowX, maxX);
		}
		System.out.println(maxX);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 22612
#include <stdio.h>
int main(void){
    long int W, H, x, y;
    int p;
    scanf("%ld %ld %ld %ld", &W, &H, &x, &y);
    if (2*x==W && 2*y==H) p=1;
    else p=0;
    printf("%f %d", W*H/(double)2, p);
}


Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	Scanner sc = new Scanner(System.in);

	int INF = 1 << 28;
	double EPS = 1e-9;

	int n, w, h;
	int[] ps,ss;
	
	void run() {
		for(;;){
			n=sc.nextInt();
			w=sc.nextInt();
			h=sc.nextInt();
			if((n|w|h)==0){
				break;
			}
			ps=new int[n];
			ss=new int[n];
			for(int i=0;i<n;i++){
				ps[i]=sc.nextInt()-1;
				ss[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve() {
		LinkedList<R> list=new LinkedList<R>();
		list.add(new R(0,0,w,h));
		for(int i=0;i<n;i++){
			R r=list.remove(ps[i]);
			debug(i,r.x,r.y,r.w,r.h);
			// int s=ss[i]%(r.w*2+r.h*2);
			int x=r.x,y=r.y;
			for(int k=0;k<ss[i];k++){
				if(y==r.y&&x<r.x+r.w){
					x++;
				}else if(x==r.x+r.w&&y<r.y+r.h){
					y++;
				}else if(y==r.y+r.h&&x>r.x){
					x--;
				}else if(x==r.x&&y>r.y){
					y--;
				}else{
					debug("Error!");
				}
				// debug(x,y);
			}
			debug(x,y);
			R r1=null,r2=null;
			if(x==r.x||x==r.x+r.w){
				r1=new R(r.x,r.y,r.w,y-r.y);
				r2=new R(r.x,r.y+r1.h,r.w,r.h-r1.h);
			}else{
				r1=new R(r.x,r.y,x-r.x,r.h);
				r2=new R(r.x+r1.w,r.y,r.w-r1.w,r.h);
			}
			debug("r1",r1.x,r1.y,r1.w,r1.h);
			debug("r2",r2.x,r2.y,r2.w,r2.h);
			if(r1.w*r1.h<r2.w*r2.h){
				list.add(r1);
				list.add(r2);
			}else{
				list.add(r2);
				list.add(r1);
			}
		}
		R[] rs=list.toArray(new R[0]);
		sort(rs);
		String ans="";
		for(R r:rs){
			ans+=(r.w*r.h)+" ";
			debug(r.x,r.y,r.w,r.h,r.w*r.h);
		}
		println(ans.substring(0, ans.length()-1));
	}
	
	class R implements Comparable<R>{
		int x,y,w,h;
		R(int x,int y,int w,int h){
			this.x=x;
			this.y=y;
			this.w=w;
			this.h=h;
		}
		@Override
		public int compareTo(R r) {
			return w*h-r.w*r.h;
		}
	}

	void debug(Object... os) {
		// System.err.println(Arrays.deepToString(os));
	}

	void print(String s) {
		System.out.print(s);
	}

	void println(String s) {
		System.out.println(s);
	}

	public static void main(String[] args) {
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <string>
typedef long long ll;
using namespace std;
int main(){
  ll n,m;cin>>n>>m;
  string s;
  ll p,pa[n],a=0,w[n],wa=0;fill(pa,pa+n,0);fill(w,w+n,0);
  for(int i=0;i<m;i++){
    cin>>p>>s;
    if(s=="AC"){if(pa[p-1]==0){pa[p-1]=1;a++;wa+=w[p-1];}}
    if(s=="WA"){if(pa[p-1]==0){w[p-1]++;}}
  }
  cout << a<<" "<< wa<<endl;
}


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

using namespace std;

#define endl '\n'
#define cw(x) cout << (x) << endl
#define cww(x,y) cout << (x) << ' ' << y << endl
#define cwa(x) for(auto a:x) cout << a << ' ';cout << endl
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef unordered_set<int> usi;
typedef vector<pi> vpi;

int i;
string s,k="keyence";

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

    for(cin >> s;i<8;i++){
        if(s.substr(0,i) == k.substr(0,i))
            if(i==7 || s.substr(s.length()-7+i,-1)==k.substr(i,-1))
                return cw("YES"), 0;
    }
    cw("NO");

    return 0;
}


Measured memory_bytes: 3664
from itertools import product
N,M = map(int,input().split())
cc = []
for i in range(M):
  ll = list(map(int,input().split()))
  cc.append(ll)
p = list(map(int,input().split()))
count = 0
for i in product([0,1],repeat = N):
  bulb = []
  for j in range(M):
    on = 0
    for k in range(cc[j][0]):
      if i[cc[j][k+1]-1] == 1:
        on += 1
    if on % 2 == p[j]:
      bulb.append(1)
  if sum(bulb) == M:
    count += 1

print(count)

Measured memory_bytes: 9188
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>

using namespace std;

#define ll long long
#define f0(i,n)for(i=0;i<n;i++)
#define f1(i,n)for(i=1;i<=n;i++)
#define fc(i,c,n)for(i=c;i<=n;i++)
#define f0r(i,n)for(i=n-1;i>=0;i--)
#define f1r(i,n)for(i=n;i>0;i--)
#define fcr(i,c,n)for(i=n;i>=c;i--)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

static int i, j, q;

int main() {
    IO;
    //ifstream cin("In.txt");
    ll r,g,b,n,ans=0;
    cin>>r>>g>>b>>n;
    f0(i,n+1){
        f0(j,n+1){
            if(i*r+j*g<=n && (i*r+j*g - n)%b==0)
                ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<double> v(N); //価値
    rep(i, N) cin >> v[i];

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

    double tmp;
    rep(i, N-1){
        tmp = (v[i]+v[i+1]) / 2.0;
        v[i+1] = tmp;
    }

    cout << tmp << endl;

    return 0;
}

Measured memory_bytes: 3788
import java.io.*;
import java.util.*;

public class Main {

	
	public static void main(String[] args) {
		FastScanner in=new FastScanner();
		PrintWriter out=new PrintWriter(System.out);
	//	int t=in.nextInt();
	//	while(t-->0)
		solve(in,out);
		out.close();
	}

    static void solve(FastScanner in,PrintWriter out){
     long a=in.nextLong(), b=in.nextLong(), c=in.nextLong(),d=in.nextLong(),ans=Long.MIN_VALUE;
     ans=Math.max(ans,a*c);
     ans=Math.max(ans,a*d);
     ans=Math.max(ans,b*c);
     ans=Math.max(ans,b*d);
     out.println(ans);
    }    
	


	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


Measured memory_bytes: 32840
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
pair<int,int> ar[1005];
bool f(pair<int,int> p){
	return p.first>=a&&p.second>=b;
}
int main(){
	cin>>n>>a>>b;
  	for(int i=1;i<=n;i++){cin>>ar[i].first>>ar[i].second;}
  	cout<<count_if(ar+1,ar+n+1,f);
}

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

#define ll long long int

const ll mod=1e9+7;

using namespace std;

ll dfs(ll k, vector<vector<ll>> const & graph, ll now, ll from) {
    ll can_use_color_num;
    if (from == -1) {
        can_use_color_num = k - 1;
    } else {
        can_use_color_num = k - 2;
    }

    if (k < graph[now].size()) return 0;

    ll case_num = 1;

    for (auto e : graph[now]) {
        if (e == from) continue;

        case_num *= can_use_color_num;
        can_use_color_num--;
        case_num %= mod;
    }

    for (auto e: graph[now]) {
        if (e == from) continue;

        case_num *= dfs(k, graph, e, now);
        case_num %= mod;
    }

    return case_num;
}

int main() {
    ll n, k;
    cin >>n >>k;

    vector<vector<ll>> graph(n);

    for (ll i = 0; i < n-1; ++i) {
        ll a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    ll res = k*dfs(k, graph, 0, -1);
    res %= mod;
    cout << res << endl;
    return 0;   
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
     char a[100100];
     scanf("%s",a);
     long l,k=0;

     char s[100100];
     l=strlen(a);
     fr(i,l)
     {
         if(a[i]!='B')
         {
             s[k++]=a[i];
         }
         else
         {
             if(k>0)
                k--;
         }
     }
     fr(i,k)
     cout<<s[i];
        return 0;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int l, r, d; cin >> l >> r >> d;
  cout << r/d - (l+d-1)/d + 1 << endk;
  return 0;
}


Measured memory_bytes: 3528
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

signed main() {
	string s;
	cin >> s;
	
	int i;
	rep(i, s.length()) {
		if (i % 2 == 0 && s[i] == 'L') { cout << "No" << endl; return 0; }
		if (i % 2 == 1 && s[i] == 'R') { cout << "No" << endl; return 0; }
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

/*
問題文
AtCoder丘陵には N 個の展望台があり、展望台 i の標高は Hi です。
また、異なる展望台どうしを結ぶ M 本の道があり、道 j は展望台 Aj と展望台 Bj を結んでいます。

展望台 i が良い展望台であるとは、展望台 i から一本の道を使って辿り着けるどの展望台よりも展望台 i の方が
標高が高いことをいいます。
展望台 i から一本の道を使って辿り着ける展望台が存在しない場合も、展望台 i は良い展望台であるといいます。

良い展望台がいくつあるか求めてください。

制約
2≤N≤10^5
1≤M≤10^5
1≤Hi≤10^9
1≤Ai,Bi≤N
Ai≠Bi
同じ展望台の組を結ぶ道が複数あることもある。
入力中の値はすべて整数である。
*/

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        long[] hies = new long [n];

        for (int i = 0; i < n; i++) {
            hies[i] = sc.nextLong();
        }

        HashMap<Integer, ArrayList<Integer>> map =  new HashMap<>();

        for (int i = 0; i < n; i++) {
            ArrayList<Integer> array = new ArrayList<>();
            map.put(i+1, array);
        }

        int count = 0;

        for (int i = 0; i < m; i++) {
                int a = sc.nextInt();
                int b = sc.nextInt();
                map.get(a).add(b);
                map.get(b).add(a);
        }

        for(Entry<Integer,ArrayList<Integer>> entry : map.entrySet()){
            boolean flg = true;
            ArrayList<Integer> values = entry.getValue();
            if (values.size() == 0) {
                count++;
                continue;
            }

            for (int i = 0; i < values.size(); i++) {
                if (hies[entry.getKey()-1] <= hies[values.get(i)-1]) {
                    flg = false;
                    break;
                }
            }

            if (flg) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 76772
#include <cstdio>
#include <string>
#include <map>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	map <string, vector<int> > book;
	char s[30];
	int n;
	
	while(scanf("%s %d", s, &n) != EOF){
		string str = s;
		book[str].push_back(n);
	}
#ifdef ONLINE_JUDGE
	for (const auto& kv : book){
		puts(kv.first.c_str());
		sort(kv.second.begin(), kv.second.end());
		for (int i = 0; i < (int)it->second.size(); i++){
			printf("%d%c", kv.second[i], " \n"[i == (int)kv.second.size() - 1]);
		}
	}
#else
	for (map<string, vector<int> >::iterator it = book.begin(); it != book.end(); ++it){
		printf("%s\n", it->first.c_str());
		sort(it->second.begin(), it->second.end());
		for (int i = 0; i < (int)it->second.size(); i++){
			printf("%d%c", it->second[i], " \n"[i == (int)it->second.size() - 1]);
		}
	}
#endif
	return(0);
}

Measured memory_bytes: 1092