akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

string s;
int use;

void ReplaceAll(string &s,string a, string b){
  int p = s.find(a);
  while(p!=string::npos){
    s.replace(p,a.size(),b);
    p = s.find(a);
  }
}

bool parse(int l,int r){
  int p = 0;
  for(int i=l;i<r;i++){
    if(s[i] == '(')p++;
    if(s[i] == ')')p--;
    if(!p){
      if(s[i] == '*')return parse(l,i) && parse(i+1,r);
      if(s[i] == '+')return parse(l,i) || parse(i+1,r);
      if(s[i] == '-' && s[i+1] == '>')return !parse(l,i) || parse(i+2,r);
    }
  }

  if(s[l] == '-')return !parse(l+1,r);
  if(s[l] == '(' && s[r-1] == ')')return parse(l+1,r-1);
  if(s[l] == 'T')return true;
  if(s[l] == 'F')return false;
  return ( ( use >> (s[l]-'a') ) & 1);
}

int main(){
  while(cin >> s,s!="#"){
    ReplaceAll(s,"--","");
    int x = s.find("=");
    bool f = true;
    for(use=0;use<(1<<11);use++){
      f &= (parse(0,x) == parse(x+1,s.size()));
      if(!f)break;
    }
    cout << (f?"YES\n":"NO\n");
  }
}

Measured memory_bytes: 900
#include <iostream>
#include <stdlib.h>
#include <climits>
using namespace std;

int main(void) {
    int n, min = 0, maxpos=0;
    int h[100000];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        if (h[i] > h[maxpos]) maxpos = i;
        else if (h[maxpos]-h[i] >= 2) {
            cout << "No" << endl;
            return 0;
        }
    }
#if 0
        if (i == 0) {
            min = h[i]; minpos = i;
            max = h[i]; maxpos = i;
        } else {
            if (min >= h[i]) {
                min = h[i];
                minpos = i;
            }
            if (max <= h[i]) {
                max = h[i];
                maxpos = i;
                min = INT_MAX;
                minpos = i;
                continue;
            }
            if ((maxpos < minpos) && (max - min >= 2)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
#endif
    cout << "Yes" << endl;
    return 0;
#if 0        
        if (i != 0) {
            if (h[i-1]-h[i] >= 2) {
                cout << "No" << endl;
                return 0;
            }
        }
        if (i >= 2) {
            //            if (h[i-2] > h[i-1] && h[i-1] > h[i]) {
            if (h[i-2] > h[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
#endif
}


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

int main(void){

  int i,j,k,t,tmp;
  string s;
  int a,b,c;
  int N,K;
  cin>>N>>K;

  a=K;
  a=a*pow(K-1,N-1);

  cout<<a<<endl;
  return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	ans := "NO"
	for x := 0; x < 101; x++ {
		if x == 0 && c == 0 {
			continue
		}
		if (a*x+c)%b == 0 {
			ans = "YES"
		}
	}
	fmt.Println(ans)
}


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

using namespace std;

int main() {
  int n, maxsofar=0, curr, s=0;
  cin >> n;
  while(n--) {
    cin >> curr;
    if(curr>=maxsofar) {
      maxsofar=curr;
      s++;
    }
  }
  cout << s;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> table(h);
    rep(i, h) {
        cin >> table[i];
    }
    int count = 0;
    rep(i, h) {
        rep(j, w) {
            if (table[i][j] == '#') {
                count++;
            }
        }
    }
    if (count == h+w-1) {
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
from collections import defaultdict
it = lambda: list(map(int, input().strip().split()))
INF = float('inf')

def solve():
    X, Y = it()
    if Y % 2:
        return False
    return 4 * X >= Y >= 2 * X

if __name__ == '__main__':
    if not solve():
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 9484
import math
import bisect
# 0以上整数x「未満」の素数をリストに格納して返す


def primes(x):
    if x < 2:
        return []

    primes = [i for i in range(x)]
    primes[1] = 0  # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x):
            break
        if prime == 0:
            continue
        for non_prime in range(2 * prime, x, prime):
            primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]


prime = primes(10**5+10)
X = int(input())
print(prime[bisect.bisect_left(prime, X)])


Measured memory_bytes: 45040
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


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


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,m;
  cin>>n>>m;
  set<ll> st;
  rep(i,m){
    ll a,b;cin>>a>>b;
    ll tmp=st.size();
    if(a==1){
      st.insert(b);
      if(tmp==st.size()){
        cout<<"POSSIBLE"<<endl;
        return 0;
      }
    }
    if(b==n){
      st.insert(a);
      if(tmp==st.size()){
        cout<<"POSSIBLE"<<endl;
        return 0;
      }
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 9600
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		int n = 0;
		int x = 0;
		int nokori = 0;
		int kosuu = 0;

		Scanner scan = new Scanner(System.in);
		n = Integer.parseInt(scan.next());
		x = Integer.parseInt(scan.next());
		nokori = x;
		kosuu = n;

		int okashi[] = new int[n];
		for(int i=0;i<n;i++) {
			okashi[i] = Integer.parseInt(scan.next());
			nokori = nokori - okashi[i];
		}

		int min = 0;
		for(int j=0;j<n;j++) {
			if(j==0) {
				min = okashi[j];
			}else if(min > okashi[j]) {
				min = okashi[j];
			}
		}
		int kosuu_a = nokori/min;

		kosuu = kosuu + kosuu_a;

		System.out.println(kosuu);
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long int> vec(100);
  vec[0] = 2;
  vec[1] = 1;
  for(long long int i = 2; i < 100; i++) {
    vec[i] = vec[i - 2] + vec[i - 1];
  }
  cout << vec[N] << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;


int main()
{
	int N, K;
	cin >> N >> K;

	ll ans = 0;
	FOR(a, N + 1, 1)
	{
		ll n = (N - (a%K)) / K;
		if (a%K != 0)n++;

		if ((a%K + a%K) % K == 0)
			ans += n*n;
	}

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (100010)
#define P ()
#define M ()
#define inf (0x3fffffff)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c){
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,m,a[N],b[N],ans; char s[N],t[N];
void solve(){
	int cnt1=0,cnt2=n,mn=inf;
	memset(b,0,sizeof(b));
	for(int i=1;i<n;i++)if(s[i]!=s[i+1]&&s[i]=='0')a[++cnt1]=i;
	for(int i=1;i<n;i++)if(t[i]!=t[i+1]&&t[i]=='0')b[++cnt2]=i;
	for(int i=1;i<=n;i++)b[++cnt2]=n;
	for(int i=1;i<=cnt2-cnt1+1;i++){
		int S=0; for(int j=1;j<i;j++)S+=b[j];
		for(int j=i;j<=i+cnt1-1;j++)S+=abs(b[j]-a[j-i+1]);
		for(int j=i+cnt1;j<=cnt2;j++)S+=(n-b[j]);
		mn=min(mn,S); 
	}
	ans+=mn;
}
void rev(){for(int i=1;i<=n;i++)s[i]^=1,t[i]^=1;}
int main(){
	read(n);
	for(int i=1;i<=n;i++)readc(s[i]);
	for(int i=1;i<=n;i++)readc(t[i]);
	if(n<=2){for(int i=1;i<=n;i++)ans+=(int)(s[i]!=t[i]); cout<<ans,exit(0);}
	solve(),rev(),solve(),cout<<ans;
}

Measured memory_bytes: 768
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
string s,v;
cin>>s>>v;
bool f=true;
rep(i,s.size()){
    if(s[i]!=v[i])f=false;
}
if(f){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}



    
return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

int n, a[100000];

int b[100000];
void sort(int l, int r) {
	if(r - l < 2) { return; }
	
	int m = (l + r) / 2;
	sort(l, m);
	sort(m, r);
	
	int ll = l, rr = m, bb = l;
	while(ll < m || rr < r) {
		bool flag;
		     if(rr == r) { flag = true;  }
		else if(ll == m) { flag = false; }
		else if(a[ll] < a[rr]) { flag = false; }
		else { flag = true; }
		if(flag) { b[bb++] = a[ll++]; }
		else     { b[bb++] = a[rr++]; }
	}
	
	for(bb = l; bb < r; bb++) { a[bb] = b[bb]; }
	
	return;
}

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) { scanf("%d", &a[i]); }
	
	sort(0, n);
	
	int p = -1;
	for(int i = 0; i < n; i++) { if(i + 1 <= a[i]) { p = i; } }
	int q = p;
	for(int i = p; i < n; i++) { if(p + 1 <= a[i]) { q = i; } }
	
	int x = a[p] - (p + 1);
	int y = q - p;
	
	printf("%s\n", (x % 2 == 1 || y % 2 == 1) ? "First" : "Second" );
	
	return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
#define maxn 100007
#define INF 0x3f3f3f3f
typedef long long ll;
#define IO ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
int main()
{
    IO;
    ll n,a,b;
    cin>>n>>a>>b;
    if(a>b)
    {
        cout<<"0"<<endl;
    }
    else if(n==1&&a!=b)
    {
        cout<<"0"<<endl;
    }
    else
    {
        ll mm=(n-1)*a+b;
        ll nn=(n-1)*b+a;
        cout<<nn-mm+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;
const long long MOD = 1000000007;

long long dat[2 * MAX_N - 1];

ll fact(ll n) {
	if (n == 1) return 1;
	if (n == 0) return 0;
	return n * fact(n - 1);
}

ll gcd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

//ABC152
//B
int main(void) {
	ll a, b;
	cin >> a >> b;
	ll mx = max(a, b);
	ll mn = min(a, b);
	rep(i, 0, mx-1) {
		cout << mn;
	}
	cout << mn << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	list := getStdinArr()
	N, _ := strconv.Atoi(list[0])
	M, _ := strconv.ParseFloat(list[1], 64)
	n := N
	m := int(math.Round(M * 100))
	fmt.Printf("%d\n", (n*m)/100)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func getStdin() string {
	return readLine()
}
func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 1784
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a[100010];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	if (n % 2 == 0) {
		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				if (i + 1 != a[i]) {
					cout << "0" << endl;
					return 0;
				}
			}
			else {
				if (i != a[i]) {
					cout << "0" << endl;
					return 0;
				}
			}
		}
	}
	else {
		if (a[0] != 0) {
			cout << "0" << endl;
			return 0;
		}
		for (int i = 1; i < n; i++) {
			if (i % 2 == 1) {
				if (i + 1 != a[i]) {
					cout << "0" << endl;
					return 0;
				}
			}
			else {
				if (i != a[i]) {
					cout << "0" << endl;
					return 0;
				}
			}
		}
	}
	long long ans = 1;
	for (int i = 0; i < n / 2; i++) {
		ans = ans * 2 % 1000000007;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import numpy as np

n, k = [int(a) for a in input().split()]
s = input()

def main():
    consecutive_ones = [len(x) for x in s.split("0") if x != '']
    consecutive_zeros = [len(x) for x in s.split("1") if x != '']

    if s[0] == "0":
        consecutive_ones.insert(0, 0)
    if s[-1] == "0":
        consecutive_ones.append(0)
    
    if len(consecutive_zeros) == 0:
        return n
    else:
        cumsum_ones = np.convolve(consecutive_ones, np.ones(k+1), mode='valid')
        cumsum_zeros = np.convolve(consecutive_zeros, np.ones(k), mode='valid')

        z = [x + y for x,y in zip(cumsum_ones, cumsum_zeros)]
        return int(max(z))


print(main())

Measured memory_bytes: 17748
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  bool jud=true;
  for(int i=0;i<s.size();i++){
    if((i+1)%2){
      if(s[i]=='L'){
        jud=false;
        break;
      }
    }
    else{
      if(s[i]=='R'){
        jud=false;
        break;
      }
    }
    
  }
  if(jud)cout<<"Yes";
  else cout<<"No";
}
      

      


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

int H,W;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
char t[500][500];
ll A[500][500],B[500][500];
ll INF=(1LL<<50);

void bfs(char ch,ll d[500][500]){
  fill(d[0],d[500], INF );
  queue<int> qy,qx;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(ch==t[i][j]){
        d[i][j]=0;
        qy.push(i);
        qx.push(j);
      }
    }
  }
  while(!qy.empty()){
    int y=qy.front();qy.pop();
    int x=qx.front();qx.pop();
    for(int dir=0;dir<4;dir++){
      int ny=y+dy[dir];
      int nx=x+dx[dir];
      if(t[ny][nx]=='#')continue;
      if(t[ny][nx]=='*')continue;
      if(d[ny][nx]>d[y][x]+1){
        d[ny][nx]=d[y][x]+1;
        qy.push(ny);
        qx.push(nx);
      }
    }
  }
}

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  
  cin>>W>>H;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cin>>t[i][j];
  
  bfs('*',A);
  bfs('g',B);

  vector<ll> v;
  ll sum=0,cnt=0,K=0;
  double base=1e100;
  double ans=1e100;

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(t[i][j]=='#')continue;
      if(t[i][j]=='*')continue;
      if(t[i][j]=='g')continue;
      
      cnt++;
      if(t[i][j]=='s'){
        if(A[i][j]==INF)base=1e100;
        else base=A[i][j];
        if(B[i][j]!=INF)ans=B[i][j];
      }
      if(A[i][j]==INF){
        sum+=B[i][j];
      }else if(B[i][j]==INF){
        sum+=A[i][j];
        K++;
      }else{
        sum+=B[i][j];
        v.push_back(A[i][j]-B[i][j]);
      }

    }
  }
  sort(v.begin(),v.end());
  for(int i=0;i<=(int)v.size();i++){
    double rate=(double)K/(double)cnt;
    double X=(double)sum/(double)cnt;
    X/=(1.0-rate);
    ans=min(ans,(double)base+X);
    K++;
    
    if(i==(int)v.size())break;
    sum+=v[i];
  }
  printf("%.12f\n",ans);
  return 0;
}

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

char shift(char in){
	if('a'<=in&&in<='y'){
		return in+1;
	}else if(in=='z'){
		return 'a';
	}else{
		return in;
	}	
}
int main(){
	char a[100];
	string data;
	while(cin.getline(a,100)){
//	cout<<a<<endl;
		while(true){
			data=a;
			if(data.find("the")!=-1 || data.find("this")!=-1 || data.find("that")!=-1)
				break;
			for(int i=0;a[i]!='\0';i++){
				a[i]=shift(a[i]);
			}
//		cout<<a<<endl;
		}
		cout<<data<<endl;
	}
}

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

using ll = long long;

int main() {
    vector<int> prime;
    vector<bool> is_prime(1e7+1, true);
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<is_prime.size(); ++i) {
        if(is_prime[i]) {
            prime.push_back(i);
            for(int j=i+i; j<is_prime.size(); j+=i) {
                is_prime[j] = false;
            }
        }
    }
    vector<int> quad;
    for(int i=3; i<prime.size(); ++i) {
        if(prime[i] == prime[i-1] + 2 && prime[i] == prime[i-2] + 6 && prime[i] == prime[i-3] + 8) {
            quad.push_back(prime[i]);
        }
    }
    int n;
    while(cin >> n, n) {
        cout << *(upper_bound(quad.begin(), quad.end(), n) - 1) << endl;
    }
}


Measured memory_bytes: 7948
while 1:
	a,L = raw_input().split()
	if a == L == "0": break
	a = a.zfill(int(L))
	his = [0]*21
	his[0] = a
	i = 0
	while 1:
		i += 1
		a = str(int("".join(sorted(a)[::-1])) - int("".join(sorted(a)))).zfill(int(L))
		if a in his: break
		his[i] = a
	print his.index(a),int(a),i-his.index(a)

Measured memory_bytes: 4228
/* #lev1 #문자열처리                          */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <functional>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/

void sol() {
    string s; cin >> s;
    int n = s.length();
    int half = (n + 1) / 2; 
    // 짝수개일 경우 반보다 하나 더 검사하긴 하겠지만,
    // 답은 구할 수 있다.


    for (int i = 0; i < half; i++)
        if (s[i] != s[n - 1 - i]) {
            cout << "No\n"; return;
        }

    int k = n/2;
    for (int i = 0; i < k; i++)
        if (s[i] != s[k - 1 - i] || 
            s[k+i+1] != s[n-1-i] ) {
            cout << "No\n"; return;
        }

    cout <<"Yes\n";
    return;
}

int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(nullptr);
    int T(1);
    while (T--)
        sol();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (max({a, b, c}) + max({a, b, c}) == a + b + c) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

ll gcd(ll a, ll b){
    if(a<b) swap(a,b);
    if(b==0) return a;
    return gcd(b,a %b);
}

int main(){
    int n;
    ll k;
    cin >> n >> k;
    ll g, max_a=0;
    for(int i=0; i<n; i++){
        ll a;
        cin >> a;
        if(i==0) g=a; 
        else g=gcd(g,a);
        max_a=max(max_a, a);
    }
    if(max_a>=k && k%g==0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 384
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	a := readInt()
	b := readInt()
	ans := a - 1
	if a <= b {
		ans++
	}
	println(ans)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm> 
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include  <ctime>
#include <iomanip>
using namespace std;

#define ll                    long long int
#define ull                   unsigned long long int
#define loop(i,a,b)           for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)          for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)          for(ll i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define count_1(n)            __builtin_popcountll(n)
#define pb                    push_back
#define eb                    emplace_back
#define ab(a)                 (a<0)?(-1*a):a
#define pc                    putchar
#define gc                    getchar
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define mp                    make_pair
#define itoc(c)               ((char)(((int)'0')+c))
#define all(p)                p.begin(),p.end()
#define max(x,y)              ((x>y)?x:y)
#define min(x,y)              ((x<y)?x:y)
#define mid(s,e)              (s+(e-s)/2)
#define vi                    vector<int>
#define vvi                   vector<vector<int>>
const ll MOD = 1000000007;

ll modpow(ll a, ll b, ll mod) { ll res = 1; for (; b; b >>= 1) { if (b & 1)res = res * a; res%=mod; a = a * a; a%=mod; }return res; }
ll p(ll a, ll b) { ll res = 1; for (; b; b >>= 1) { if (b & 1)res = res * a;a = a * a; }return res; }

ll fact[300000];
void pre() {
    fact[0] = 1;
    loop(i,1,300000) fact[i] = (i*fact[i-1])%MOD;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /* code */
    pre();
    ll s; cin >> s;
    ll ans = 0;
    loop(i,1,s + 1) {
        if(3*i > s) break;
        ll temp = fact[s - 1 - 2*i];
        temp *= modpow(fact[i-1],MOD-2,MOD);
        temp%=MOD;
        temp *= modpow(fact[s-3*i],MOD-2,MOD);
        temp%=MOD;
        ans += temp; ans%=MOD;
    }
    cout << ans << "\n";
    /* end code */
}

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

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;

#define rep(i, n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

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

    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main(){
	int n, m, i, t;
    vector<int> a, b;

	cin >> n;
	for (i = 0; i < n; i++){
      cin >> t;
      a.push_back(t);
	}

	cin >> m;
	for (i = 0; i < m; i++){
	  cin >> t;
	  b.push_back(t);
	}
    
    for (auto x : b){
      if(!binary_search(a.begin(), a.end(), x)){
    	cout << 0 << endl;
    	exit(0);
      }
    }

    cout << 1 << endl;
}


Measured memory_bytes: 5252
// ----------------------------------------------------------
// --https://kenkoooo.com/atcoder/#/table/soma62jp

// ----------------------------------------------------------
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef long double ld;

#define LL_MOD          (ll)1000000007
#define LL_INF          (ll)1 << 62
#define INT_INF         (int)1 << 30

#define rSort(a)        sort(a.rbegin(),a.rend())
#define Sort(a)         sort(a.begin(),a.end())
#define Reverse(a)      reverse(a.begin(),a.end())
#define Sum(a)          accumulate(a.begin(), a.end(), 0)
#define REP(i, n)       for(ui i = 0;i < n;i++)
#define REPR(i, n)      for(ui i = n;i >= 0;i--)
#define FOR(i, m, n)    for(ui i = m;i < n;i++)
#define pb(i)           push_back(i)
#define mp              make_pair
#define SWAP(x,y)       ((x!=y)&&(x^=y,y^=x,x^=y))


int main(int argc, char* argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,K;
    
    ll ans = 0;

    cin >> N >> K;
    
    while(N>0){
      N = N / K;
      ans++;
    }

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

Measured memory_bytes: 256
#include<stdio.h>

static const int N = 100;

int main(){
  int n,i,j,flag=0;
  int A[N+1];
  int minj,swap,sort=0;

  scanf("%d",&n); /*Input an integer n, the number of elements in sequence*/

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);/* Input N elements of the sequence*/
  }
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(A[j]<A[minj])
        minj = j;
     }  
    if(i!=minj){ swap=A[i];    
       A[i]=A[minj];
       A[minj]=swap;
       sort++;
      }
     }
    for(i=0;i<n;i++){
      if(i<n-1) printf("%d ",A[i]);/*Output the sorted sequence*/
      else printf("%d\n",A[i]);
    }
    printf("%d\n",sort);  /*Output the number of swap operations.*/

    return 0;
   } 

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793


int main(){
  int H, W; cin >> H >> W;
  string S[H];
  rep(i, H){
    cin >> S[i];
  }
  int cnt[30] = {};
  rep(i, H){
    rep(j, W){
      cnt[S[i][j]-'a']++;
    }
  }
  sort(cnt, cnt+30, greater<>());
  int ichi = 0, ni = 0, yon = 0;
  int ichiichi = ((H%2) && (W%2));
  int nini = ((H%2)*(W/2) + (W%2)*(H/2))*2;
  int yonyon = H*W - ichiichi - nini;
  rep(i, 30){
    if(cnt[i]%2) ichi++;
    else if(cnt[i]%4==2) ni+=2;
  }
  //cout << ichiichi << " " << nini <<" " << ichi << " " << ni <<  endl;
  if(ichi>ichiichi || ni>nini){
    cout << "No" << endl; return 0;
  }
  cout << "Yes" << endl;  
}

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

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


//v.push_back(123);
//sort(v.begin(), v.end(),greater<int>());
//for(int x : v) {cout << x << endl;}

//for(int x: v) cout << x << endl;
//vector<vector<char>> v(H, vector<char>(W));
//vector<int> v(1000);


using namespace std;
long long pow_mod(long long x, long long y, long long MOD){
	long long ret = 1;
	while(y){
		if (y & 1) ret = ret * x % MOD;
		x = x * x % MOD;
		y>>=1;
	}
	return ret;
}

signed main(){
  string S;
  int MOD=1000000007;
  cin>>S;

  char a1 = ' ';
  char a2 = ' ';
  char a3 = ' ';
  char a4 = ' ';
  int count = 0;
  int count2 = 0;
  int count3 = 0;
  int count4 = 0;

  rep(i, 4){
    if(i==0){
      a1 = S[i];
      count++;
      continue;
    }
    
    if(a1==S[i]){
      count++;
      continue;
    }
    if(a2==S[i]){
      count2++;
      continue;
    }else if(a2==' '){
      count2++;
      a2 = S[i];
      continue;
    }
    if(a3==S[i]){
      count3++;
      continue;
    }else if(a3==' '){
      count3++;
      a3 = S[i];
      continue;
    }
    if(a4==S[i]){
      count4++;
      continue;
    }else if(a4==' '){
      count4++;
      a4 = S[i];
      continue;
    }
  }
  
  if(count==count2 && count==2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

def tree(p):
    for x in neighbor[p]:
        if x==par[p]: continue
        par[x]=p
        descend[p]+=tree(x)
    return descend[p]

n=int(input())
neighbor=[set()  for _ in range(n+1)]
descend=[1]*(n+1)
par=[0]*(n+1)

for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].add(b)
    neighbor[b].add(a)
tree(1)

x=[descend[n]-1]
t=n
while t!=1:
    t,pret=par[t],t
    x.append(descend[t]-descend[pret]-1)

l=len(x)
p,q=sum(x[:l//2]),sum(x[l//2:])
if l%2==0: print("Fennec" if p<q else "Snuke")
else: print("Fennec" if p<=q else "Snuke")

Measured memory_bytes: 149920
#include<bits/stdc++.h>
using namespace std;
#define MN 200005
#define LL long long
#define mp make_pair
#define fir first
#define sec second
#define pii pair<int,int>
inline void chkmax(int &a,int b){if(a<b)a=b;}
inline void chkmin(int &a,int b){if(a>b)a=b;}
inline int read(){
	   int a=0,fh=1;char c=getchar();
	   while(c>'9'||c<'0'){if(c=='-')fh=-1;c=getchar();}
	   while('0'<=c&&c<='9'){
		   a=a*10+c-48;
		   c=getchar();
	   }
	   return a*fh;
}
const int py=6005;
int f[6005][16005],n,Mod;
void add(int &a,int b){((a+=b)>=Mod)?(a-=Mod):0;}
int main(){
	n=read()*3;Mod=read();
	f[0][py]=1;
	for(int i=0;i<n;++i){
		for(int j=-i;j<=i;++j){
			add(f[i+1][j+py+1],f[i][j+py]);
			add(f[i+2][j+py-1],(LL)f[i][j+py]*(i+1)%Mod);
			add(f[i+3][j+py],(LL)f[i][j+py]*(i+1)*(i+2)%Mod);
		}
	}
	LL ans=0;
	for(int i=0;i<=n;++i)ans+=f[n][i+py];
	printf("%lld\n",ans%Mod);
	return 0;
}

















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

using namespace std;
using ll = long long;

constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e15;
int main() {
    ll x, y;
    cin >> x >> y;
    ll ret = 0;
    if(x == 1) ret += 300000;
    else if(x==2)
        ret += 200000;
    else if(x==3)
        ret += 100000;
    if(y == 1)
        ret += 300000;
    else if(y == 2)
        ret += 200000;
    else if(y == 3)
        ret += 100000;
    if(x == 1 && y == 1) ret += 400000;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,m = map(int, input().split())
a_lis = list(map(int, input().split()))
b_lis = list(map(int, input().split()))
ans_lis = [min(a_lis)+min(b_lis)]
for _ in range(m):
    x,y,z = map(int, input().split())
    tmp = a_lis[x-1]+b_lis[y-1]-z
    ans_lis.append(tmp)
print(min(ans_lis))

Measured memory_bytes: 18612
s = list(input())
K = int(input())
j = 0
candidate = []
while True:
    if j > 26:
        break
    for i in range(len(s)):
        if s[i] == chr(ord("a") + j):
            for k in range(1, min(6, len(s) - i + 1)):
                candidate.append(s[i:i + k])
    j += 1
i = 1
candidate.sort()
while i < len(candidate):
    if candidate[i] == candidate[i - 1]:
        del candidate[i]
        i -= 1
    i += 1

for i in candidate[K - 1]:
    print(i, end = "")
print()


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

int main() {
  int x, y;
  cin >> x >> y;
  int a = 4 * x - y;
  int b = y - 2 * x;

  if (b >= 0 && b % 2 == 0 && a >= 0 && a % 2 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

/*
*/


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){

    long long n;
    cin>>n;
    string a="";
    while(n>0){
        n--;
        
        a.push_back('a'+n%26);
        n/=26;
    }
    reverse(a.begin(),a.end());
    cout<<a;

    return 0;
}

Measured memory_bytes: 3612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ATherefore {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long x = in.nextLong();
            if (x % 10 == 2 || x % 10 == 9 || x % 10 == 7 || x % 10 == 5 || x % 10 == 4) {
                out.print("hon");
            } else if (x % 10 == 3) {
                out.print("bon");
            } else {
                out.print("pon");
            }
        }

    }
}



Measured memory_bytes: 35808
N=int(input())
A=list(map(int,input().split()))
flag=0
answer=1
if N==1:
    print(1)
else:
    if A[0] < A[1]:
        flag = 1
    elif A[0]>A[1]:
        flag = -1
    for n in range(N - 1):
        if flag == 1:
            if A[n] <= A[n + 1]:
                pass
            else:
                flag = 0
                answer += 1
        elif flag == -1:
            if A[n] >= A[n + 1]:
                pass
            else:
                flag = 0
                answer += 1
        else:
            if A[n] == A[n + 1]:
                pass
            elif A[n] < A[n + 1]:
                flag = 1
            else:
                flag = -1
    print(answer)


Measured memory_bytes: 85032
n, m = map(int, input().split())

if n >= m:
    print(0)
    exit()
    
lis = list(map(int, input().split()))
lis.sort()

res = []
for i in range(m - 1):
    res.append(lis[i + 1] - lis[i])
res.sort()

l = len(res)
k = n - 1

print(sum(res[:l - k]))


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

using namespace std;
#define int long long 
#define rep(i,a,b) for(int i=a;i<(b);i++)
using VI=vector<int>;
using VVI=vector<VI>;
using pii=pair<int, int>;
#define DBG 0


int _calc(string hash, int& idx) {
	if (isdigit(hash[idx])) {
		return hash[idx] - '0';
	}
	else if (hash[idx] == '[') {
		idx++;
		char op = hash[idx];
		idx++;
		int l = _calc(hash, idx);
		idx++;
		int r = _calc(hash, idx);
		idx++;
		int ret;
		if (op == '+') {
			ret = l | r;
		}
		else if (op == '*') {
			ret = l & r;
		}
		else {
			ret = l ^ r;
		}
		return ret;
	}
	else {
		assert(0);
	}
}

int calc(string hash, string pw) {

	rep(i, 0, hash.size()) {
		if ('a' <= hash[i] and hash[i] <= 'd') {
			hash[i] = pw[hash[i] - 'a'];
		}
	}
	int idx = 0;
	return _calc(hash, idx);

}

void solve(string hash) {
	string pw; cin >> pw;

	map<int, int>mp;
	rep(i, 0, 10000) {
		string in = to_string(i);
		reverse(in.begin(), in.end());
		while (in.size() < 4) {
			in.push_back('0');
		}
		reverse(in.begin(), in.end());
		int h = calc(hash, in);
		if (DBG) {
			assert(i == stoi(in));
			if (h != 0) {
				cout << "i:" << i << ", in:" << in << ", h:" << h << endl;
			}
		}
		mp[h]++;
	}

	cout << calc(hash, pw) << " " << mp[calc(hash, pw)] << endl;
}

signed main(void) {
	while (1) {
		string hash;
		cin >> hash;
		if (hash == ".")break;
		solve(hash);
	}
}


Measured memory_bytes: 3252
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int N;
  ll T;
  cin >> N >> T;
  vector<ll> ts(N);
  for(int i = 0; i < N; ++i) {
    cin >> ts[i];
  }
  ll ans = 0;
  for(int i = 0; i < N - 1; ++i) {
    ans += min(ts[i + 1] - ts[i], T);
  }
  ans += T;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
long long ans;
int n, a[N], nxtdex[N];
set<int> st[30];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		nxtdex[i] = n;
		cin >> a[i];
		for (int j = 0; j < 20; j++)
			if(a[i] & (1 << j))
				st[j].insert(i);
	}
	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j < 20; j++) {
			if(st[j].find(i) != st[j].end())
				if(st[j].upper_bound(i) != st[j].end())
					nxtdex[i] = min(nxtdex[i], *st[j].upper_bound(i));
		}
		if(i != n - 1)
			nxtdex[i] = min(nxtdex[i], nxtdex[i + 1]);
	}
	for (int i = 0; i < n; i++)
		ans += nxtdex[i] - i;
	cout << ans;		
	return 0;
}

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

using namespace std;

int main()
{
    int n, l, sum = 0, x = 1010;
    int a[205], tg[205] = {0};
    scanf("%d%d",&n, &l);
    for(int i = 1; i <= n; i ++)
    {
        a[i] = l + i - 1;
        sum += a[i];
        if(abs(a[i]) < abs(x)) x = a[i];
    }
    printf("%d\n", sum - x);
    return 0;
}


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

int isprime(int num){
  int i;

  if(num == 2) return 1;

  if(num < 2 || num % 2 == 0) return 0;


    i = 3;
    while(i <= sqrt((double)num) ){
      if(num % i == 0) return 0;
      i = i + 2;
    }

    return 1;
}

int main(){
  int i,N,A[10000],c=0;

  scanf("%d", &N);
  for(i = 0 ; i < N ; i++){
    scanf("%d", &A[i]);
    c += isprime(A[i]);
  }

  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 2076
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD (ll) (1e9+7)
int main()
{
   ll a,b,c;
   cin>>a>>b>>c;
   ll k;
   cin>>k;
   ll fl = 0;
   for(int i=0;i<k;i++)
   {
   	   if(c>b && b>a)
   	   {
   	   	 fl=1;
   	   	 break;
   	   }
   	   else if(c<=b)
   	   {
   	   	  c= c*2;
   	   }
   	   else if(b<=a)
   	   {
   	   	 b=b*2;
   	   }
   }
   if(c>b && b>a || fl==1)
   {
   	cout<<"Yes\n";
   }
   else{
   	cout<<"No\n";
   }
}

Measured memory_bytes: 3592
using System;

	class Program
	{
		public static void Main(string[] args)
		{
			int n=int.Parse(Console.ReadLine());
			int[] array= new int[n];
			for(int k=0;k<n;k++)
			{
				array[k]=int.Parse(Console.ReadLine());
			}
			int cnt=0;
			int m=1;//?????£??????????????°???h=3???m?????????/??? h<n???

			for(int gap=2;(int)((Math.Pow(3,gap)-1)/2)<n;gap++)
			{			
				m++;
			}
			
			int []  G=new int[m];//?????£??????????´???????????????£???????????????????????????????????????????????£??????
			for(int i=0;i<m;i++)
			{
				G[i]=(int)((Math.Pow(3,i+1)-1)/2);
			}
			for(int j=0;j<m;j++)
			{
				cnt+=sort( array, n, G[m-1-j]);//?????\?????????????????????
			}
			//?????????????????????m???????????????G[i]????????????????????§???????????????G?????¨????????´??????count?????????
			//????????????????????????????????????
			Console.WriteLine(m);
			for(int o=0;o<m-1;o++)
			{
				Console.Write(G[m-1-o]+" ");
			}
			Console.Write(G[0]+"\r\n");//???????????§?????????
			Console.WriteLine(cnt);//?????????
			for(int l=0;l<n;l++)
			{
				Console.WriteLine(array[l]);
			
			}
			
			
		}
		public static int sort(int [] A,int n,int g)
		{
			int count=0;//??????????????°
			for (int k=0;k<g;k++)
			{
				
			for(int i=k+g;i<n;i+=g)
			{
				
				int v=A[i];
				int j=i-g;
				while(j>=0&&A[j]>v)
				{
					A[j+g]=A[j];
					j=j-g;
				count ++; //????????????????????§????????????????????§??????????????¢??????
				A[j+g]=v;//????????????A[j]???????????????????§?????????????????????\????????????
				//??????????????????????°?????????????????????´?????????????????£?????????????????????????´??????´???????????????????°?????????????????????????0
				//?????????????????????????????\???
				}
				
			}
			}
			return count;
		}
		
	}
	

Measured memory_bytes: 16672
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}

class SCC{
public:
  int V,K;                      //頂点数, scc後の頂点数
  vector<vector<int> > G;       //グラフの隣接リストの表現
  vector<vector<int> >rG;       //辺の向きを逆にしたグラフ
  vector<vector<int> >DAG;      //scc後のグラフの隣接リストの表現
  vector<vector<int> >rDAG;     //scc後の辺の向きを逆にしたグラフ
  vector<int> vs;               //帰りがけ順の並び
  vector<int>used;              //すでに調べたか
  vector<int> cmp;              //属する強連結成分のトポロジカル順

  void init(){G.resize(V);rG.resize(V);used.resize(V,0);cmp.resize(V,0);}
  SCC(){V = K = -1;}
  SCC(int V):V(V){init();};
  
  void add_edge(int from,int to){
    assert(from<V && to<V);
    G[from].push_back(to);
    rG[to].push_back(from);
  }

  void dfs(int v){
    used[v]=true;
    for(int nx:G[v]) if(!used[nx]) dfs(nx);
    vs.push_back(v);
  }

  void rdfs(int v,int k){
    used[v]=true;
    cmp[v]=k;
    for(int nx:rG[v]) if(!used[nx]) rdfs(nx,k);
  }

  int scc(bool makeDAG = 0){ //DAGのグラフも作りたかったらmakeDAGを1にする
    used.clear(); used.resize(V,0);
    vs.clear();
    for(int v=0;v<V;v++) if(!used[v]) dfs(v);
  
    used.clear(); used.resize(V,0);
    int &k= K = 0;
    for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]]) rdfs(vs[i],k++);

    if(makeDAG) DAG = getDAG(G), rDAG = getDAG(rG); //O(ElogE)

    return k;
  }

  vector<vector<int> >getDAG(const vector<vector<int> > &G){
    assert(K>=0);
    vector<vector<int> >res(K);
    for(int from=0;from<V;from++)
      for(int to:G[from]) if(cmp[from]!=cmp[to]) res[cmp[from]].push_back(cmp[to]);
    
    for(int i=0;i<K;i++){
      sort(res[i].begin(),res[i].end());
      res[i].erase(unique(res[i].begin(),res[i].end()),res[i].end());
    }
    return res;
  }
};

int n;
vector<int> D;
bool check(int mn){
  SCC scc(150);
  int ofset = 51;
  for(int i=0;i<=n;i++)
    for(int j=0;j<=n;j++){
      for(int a=0;a<2;a++)
        for(int b=0;b<2;b++){
          int da = a==0? D[i]:24-D[i];
          int db = b==0? D[j]:24-D[j];
          int cost = min(abs(da - db), 24 - abs(da - db));
          if(cost >= mn || i == j) continue;
          //cout<<char(i+'a')<<a<<" "<<char(j+'a')<<b<<endl;
          scc.add_edge(i + a * ofset, j + (!b) * ofset);
        }
    }
  scc.scc();
  for(int i=0;i<=n;i++) if(scc.cmp[i] == scc.cmp[i+ofset]) return 0;
  return 1;
}

signed main(){
  
  cin>>n;
  D.resize(n);
  for(int i=0;i<n;i++) cin>>D[i];
  sort(D.begin(),D.end());
  int flag = 0;
  for(int i=0;i<n-2;i++) if(D[i] == D[i+2])flag = 1;
  for(int i=0;i<n;i++) if(D[i] == 0) flag = 1;
  for(int i=0;i<n;i++) if(D[i] == 1) flag = 2;
  //if(flag == 1) cout<<0<<endl,exit(0);
  //if(flag == 2) cout<<1<<endl,exit(0);
  
  D.push_back(0);
  int ans = 0;
  check(2);
  for(int i=0;i<=12;i++)if(check(i)) ans = i;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 516
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int out = 0;
        for(int i = 1; i <= n; i += 2){
            if(isTrue(i)) out++;
        }
        System.out.println(out);
        scan.close();
    }
    
    public static boolean isTrue(int n){
        int c = 0;
        for(int i = 1; i < Math.sqrt(n); i++){
            if(n % i == 0) c++;
            if(c > 4) return false;
        }
        if(n % Math.sqrt(n) == 0) c++;
        if(c == 4) return true;
        else return false;
    }
}


Measured memory_bytes: 27128