akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String input;
        try {
            input = reader.readLine();
            char[] inputCharArray = input.toCharArray();
            String out = "";
            for(int i=0; i<inputCharArray.length; i++){
                out += inputCharArray[inputCharArray.length - 1 - i];
            }
            System.out.println(out);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 16864
#include <stdio.h>

int main(void)
{
	int time, hour, minute, second;
	
	while (1){
		scanf("%d%d%d", &hour, &minute, &second);
		
		if (hour == -1 && minute == -1 & second == -1){
			break;
		}
		time = 7200 - (hour * 3600 + minute * 60 + second);
		
		printf("%02d:%02d:%02d\n",time / 3600, time % 3600 / 60, time % 3600 % 60);
		
		time *= 3;
		
		printf("%02d:%02d:%02d\n",time / 3600, time % 3600 / 60, time % 3600 % 60);
	}
	
	return (0);
}

Measured memory_bytes: 0
#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);

  int a, b, t;
  cin >> a >> b >> t;

  int sum = 0;
  int time = 0;
  while (time <= t + 0.5) {
    time += a;
    if (time <= t + 0.5) {
      sum += b;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

ll N,X,Y;

int main(void){
    scanf("%lld",&N);
    vector<ll> a(N);for(int i = 0;i < N;i++)scanf("%lld",&a[i]);
    vector<ll> b(N);for(int i = 0;i < N;i++)scanf("%lld",&b[i]);
    for (int i = 0; i < N; ++i)
    {
        X += max(0LL,a[i] - b[i]);
        Y += max(0LL,b[i] - a[i])/2;
    }
    if(Y >= X)printf("Yes\n");else printf("No\n");
}


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

int main(){
    string S;
    int n0 = 0, n1 = 0;
    cin >> S;
    for(int i=0;i<S.length();i++){
        if(S[i] == '0') n0++;
        if(S[i] == '1') n1++;
    }
    cout << min(n0, n1)*2 << endl;

    return 0;
}

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

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N, M = map(int, input().split())

ans = 0
if N >=2:
    ans += N*(N-1)//2
if M >=2:
    ans += M*(M-1)//2

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int H,W; cin>>H>>W;
  map<char,char> M;
  rep(i,0,H){
    string S; cin>>S;
    rep(j,0,W) M[S[j]]++;
  }
  int sum1=0,sum2=0;
  for(auto p:M){
    int X=p.second;
    if(X%4==0) continue;
    else if(X%2==0) sum1++;
    else{
      sum2++;
      X--;
      if(X%4==2) sum1++;
    }
  }
  int max1=0,max2=0;
  if(H%2==1) max1+=W/2;
  if(W%2==1) max1+=H/2;
  if(H%2==1&&W%2==1) max2++;
  string ans="No";
  if(max2>=sum2&&max1>=sum1) ans="Yes";
  cout<<ans<<endl;
  }


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

long long data[4][100] = {};

int data_sort(const void *x, const void *y)
{
	long long *X = (long long*)x;
	long long *Y = (long long*)y;
	if (*X < *Y) return 1;
	if (*X > *Y) return -1;
	return 0;
}

int main()
{
	long long n, w;
	long long base_w;
	long long v_max = 0, total_w = 0;
	long long data1_max = 0, data2_max = 0, data3_max = 0, data4_max = 0;
	int i = 0, j = 0, k = 0, l = 0;
	scanf("%lld %lld", &n, &w);
	for (int x = 0; x < n; x++)
	{
		long long tmp_w, tmp_v;
		scanf("%lld %lld", &tmp_w, &tmp_v);
		if (x == 0)
		{
			base_w = tmp_w;
			data[0][0] = tmp_v;
		}
		else
		{
			if (base_w == tmp_w)
			{
				data[0][x] = tmp_v;
			}
			else if (base_w + 1 == tmp_w)
			{
				data[1][x] = tmp_v;
			}
			else if (base_w + 2 == tmp_w)
			{
				data[2][x] = tmp_v;
			}
			else
			{
				data[3][x] = tmp_v;
			}
		}
	}

	qsort(data[0], 100, sizeof(long long), data_sort);
	qsort(data[1], 100, sizeof(long long), data_sort);
	qsort(data[2], 100, sizeof(long long), data_sort);
	qsort(data[3], 100, sizeof(long long), data_sort);

	for (int i = 0; i < 100; i++)
	{
		for (int j = 0; j < 100; j++)
		{
			for (int k = 0; k < 100; k++)
			{
				for (int l = 0; l < 100; l++)
				{
					int data1_w, data2_w, data3_w, data4_w;
					data1_w = 0;
					data2_w = 0;
					data3_w = 0;
					data4_w = 0;
					data1_max = 0;
					data2_max = 0;
					data3_max = 0;
					data4_max = 0;

					for (int ii = 0; ii < i; ii++)
					{
						data1_max = data1_max + data[0][ii];
					}
					if (data1_max != 0) data1_w = 1;
					for (int jj = 0; jj < j; jj++)
					{
						data2_max = data2_max + data[1][jj];
					}
					if (data2_max != 0) data2_w = 1;
					for (int kk = 0; kk < k; kk++)
					{
						data3_max = data3_max + data[2][kk];
					}
					if (data3_max != 0) data3_w = 1;
					for (int ll = 0; ll < l; ll++)
					{
						data4_max = data4_max + data[3][ll];
					}
					if (data4_max != 0) data4_w = 1;
					total_w = base_w * i * data1_w + (base_w + 1) * j * data2_w + (base_w + 2) * k * data3_w + (base_w + 3) * l * data4_w;
					if (total_w > w) break;
					if (v_max < data1_max + data2_max + data3_max + data4_max)
					{
						v_max = data1_max + data2_max + data3_max + data4_max;
					}

					if (data[3][l] == 0) break;
				}
				total_w = base_w * i + (base_w + 1) * j + (base_w + 2) * k + (base_w + 3) * l;
				if (total_w > w) break;
				if (data[2][k] == 0) break;
			}
			total_w = base_w * i + (base_w + 1) * j + (base_w + 2) * k + (base_w + 3) * l;
			if (total_w > w) break;
			if (data[1][j] == 0) break;
		}
		if (data[0][i] == 0) break;
	}
	printf("%lld", v_max);
	return 0;
}

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

int main(){
  
  int q, lcs[1010][1010] = {};
  string a, b;

  //input
  cin >> q;
  for(int i = 0;i < q;i++){
    cin >> a;
    cin >> b;

    for(int r = 0;r < (int)a.size();r++){
      for(int c = 0;c < (int)b.size();c++){
	//if a_i = b_j, chain a_i to LCS of a_{i-1} and b_{j-1}
        if(a[r] == b[c]) lcs[r + 1][c + 1] = lcs[r][c] + 1;
	//else LCS of a_{i-1} and b_j or a_i and b_{j-1}
        else lcs[r + 1][c + 1] = max(lcs[r + 1][c], lcs[r][c + 1]);
      }
    }
    
    //output
    cout << lcs[a.size()][b.size()] << endl;
  }
  
  return 0;
}




Measured memory_bytes: 7180
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
import math

#### START
n = int(input())

for i in range(1, 1000000):
  a = i*i
  if a > n:
    print((i-1)*(i-1))
    break

Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<map>
#define PRE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
const int Max = 1e6 + 5;
const int Mod = 1e9 + 7;

struct node
{
	node() { a = 0;b = 0; }
	int a, b;
};
node lst[Max];
bool compare(node a, node b)
{
	if (a.b < b.b)return true;
	return false;
}

int main()
{
	PRE;
	int n, k;
	cin >> n >> k;
	int sum = 0;
	map<int, int> ma;
	int t;
	for (int i = 1;i <= n;i++)
	{
		cin >> t;
		if (ma[t] == 0) sum++;
		ma[t]++;
	}
	int g = 0;
	for (auto i = ma.begin();i != ma.end();i++)
	{
		lst[++g].a = i->first;
		lst[g].b = i->second;
	}
	if (sum <= k)cout << 0;
	else
	{
		sort(lst + 1, lst + 1 + g,compare);
		int ans = 0, f = 0;
		for (int i = 1;i <= g;i++)
		{
				ans += (lst[i].b) ;
				f++;
			if (f == sum - k)break;
		}
		cout << ans;
	}

}

Measured memory_bytes: 13952
import qualified Data.Map.Strict as M
import Data.Array
import Data.STRef
import Control.Monad
import Control.Monad.ST

{-
地図、スタート座標が与えられる。
スタート座標はすでに消されている。
-}
connected_part::Array (Int,Int) Char->(Int,Int)->STRef s (M.Map (Int,Int) ())->ST s (Int,Int)
connected_part ar (i,j) ref = do
                              let (_,(h,w)) = bounds ar
                              let nexts' = next h w (i,j)
                              m<-readSTRef ref
                              let nexts  = filter (\ c -> M.member c m) nexts'
                              if ar!(i,j)=='#' then do
                                                    let able = filter (\c -> ar!c == '.') nexts
                                                    forM_ able (\ c -> do
                                                                      m<-readSTRef ref
                                                                      writeSTRef ref (M.delete c m))
                                                    ls <- forM able (\c -> connected_part ar c ref)
                                                    return ((sum (map fst ls)),1+(sum (map snd ls)))
                                               else do
                                                    let able = filter (\c -> ar!c == '#') nexts
                                                    forM_ able (\ c -> do
                                                                      m<-readSTRef ref
                                                                      writeSTRef ref (M.delete c m))
                                                    ls <- forM able (\c -> connected_part ar c ref)
                                                    return (1+(sum (map fst ls)),(sum (map snd ls)))

loop::Array (Int,Int) Char->STRef s (M.Map (Int,Int) ())->ST s [(Int,Int)]
loop ar ref = do
              m<-readSTRef ref
              if m == M.empty then return []
                              else do
                                    let ((i,j),_) = M.findMin m
                                    writeSTRef ref (M.delete (i,j) m)
                                    d<-connected_part ar (i,j) ref
                                    rest<-loop ar ref
                                    return (d:rest)

next::Int->Int->(Int,Int)->[(Int,Int)]
next h w (i,j) = filter (\(a,b)-> a>0 && a<=h && b>0 && b<=w) [(i+1,j),(i-1,j),(i,j+1),(i,j-1)]


solver::Array (Int,Int) Char -> Int
solver ar = runST $ do
                    let (_,(h,w)) = bounds ar
                    ref<-newSTRef (M.fromList [((i,j),())|i<-[1..h],j<-[1..w]])
                    dat<-loop ar ref
                    return (sum (map (\(x,y)->x*y) dat))


main::IO()
main=do
  (h:w:_)<-return.(map read).words=<<getLine
  dat<-forM [1..h] (\_ -> getLine)
  print (solver (listArray ((1,1),(h,w)) (concat dat)))


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

num = [0] * N

L = 1
R = N

for _ in range(M):
    l, r = list(map(int, input().split()))
    if l > L:
        L = l
    if r < R:
        R = r

print(max(R - L + 1, 0))


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

int main()
{
	int a, n;
	int i=0;
	int t=5;
	while(t--)
	{
		cin >> a;
		if(!a)
			n=i+1;
		i++;
	}
	cout<<n<<endl;
}	


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    int d[100] = {0};
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d, d + n);
    int cnt = 1;
    for (int i = 1; i < n; i++) {
        if (d[i] != d[i - 1]) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
S=input()
x=int(S[0:2])
y=int(S[2:4])
if (x==0 or x>12) and (y==0 or y>12):
    print('NA')
elif x==0 or x>12:
    print('YYMM')
elif y==0 or y>12:
    print('MMYY')
else:
    print('AMBIGUOUS')

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

using namespace std;
int main(){
   int N;
   cin >> N;
   vector<long long> l(N);
   for(int i = 0; i < N; i++){
       cin >> l.at(i);
   }
   int count = 0;
   for(int i = 0; i < N - 2; i++){
       for(int j = i + 1; j < N - 1; j++){
           for(int k = j + 1; k < N; k++){
               if(l.at(i) + l.at(j) > l.at(k) && l.at(j) + l.at(k) > l.at(i) && l.at(k) + l.at(i) > l.at(j)){
                   if(l.at(i) == l.at(j) || l.at(j) == l.at(k) || l.at(k) == l.at(i)) continue;
                   count++;
               }
           }
       }
   }
   cout << count << endl;

    return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int n,k;
vector<pair<int,int> >v;
int dp[10001][1001];
int cal(int i,int j)
{
	if(j==k)return INT_MAX;
	if(i<=0)return 0;
	if(dp[i][j]!=-1)return dp[i][j];
	dp[i][j]=min(v[j].ss+cal(i-v[j].ff,j),cal(i,j+1));
	return dp[i][j];
}
int main()
{
	IOS;
	cin>>n>>k;
	rep(i,0,k)
	{
		int x,y;
		cin>>x>>y;
		v.pb({x,y});
	}
	memset(dp,-1,sizeof(dp));
	int ans=cal(n,0);
	cout<<ans;
}


Measured memory_bytes: 39936
// AOJ 2198

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main(void)
{
	int n;
	while (cin >> n, n){
		string l;
		int a, b, c, d, e, f, s, m, p;
		vector < double > data;
		vector < pair <string, double> > name;
		bool done[128] = {false};
		for (int i = 0; i < n; i++){
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			int t = a+b+c+((d+e) * m);
			int money = (f * m) * s;
			money -= p;
			data.push_back((double)money / t);
			name.push_back(make_pair(l, (double)money / t));
		}
		sort(data.rbegin(), data.rend());
		sort(name.begin(), name.end());
		
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				if (!done[j] && data[i] == name[j].second){
					cout << name[j].first << endl;
					done[j] = true;
					break;
				}
			}
		}
		cout << '#' << endl;
	}

	return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MOD = 1000000007;

void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

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

const int MAX = 210;

int N, M, R;
long long dist[MAX][MAX];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> p(N);
    rep(i,N) cin >> p[i];
    int ans = 0;
    rep(i,N){
      if(i + 1 == p[i]) {
        if(i != N-1){
          swap(p[i],p[i+1]);
          ans++;
        } else{
          swap(p[i-1],p[i]);
          ans++;
        }
      }
    }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    //cout << "s " << s << endl;
    //cout << "t " << t << endl;

    if(s < t){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int32_t main(){
    boost;
    
    //code
    char n;
    cin >> n;

    cout << ((n == 'a' || n == 'e' || n == 'i' || n == 'o' || n == 'u') ? "vowel" : "consonant");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

int n, m, q, x1, x2, y1, y2;
char a[2005][2005];
int dp1[2005][2005], dp2[2005][2005], s[2005][2005];

int sum(int x1, int y1, int x2, int y2) {
    return s[x2][y2] - s[x2][y1 - 1] - s[x1 - 1][y2] + s[x1 - 1][y1 - 1];
}

int edges(int x1, int y1, int x2, int y2) {
    return (dp1[x2][y2] - dp1[x2][y1] - dp1[x1 - 1][y2] + dp1[x1 - 1][y1]) +
    (dp2[x2 - 1][y2] - dp2[x2 - 1][y1 - 1] - dp2[x1 - 1][y2] + dp2[x1 - 1][y1 - 1]);
}

int main() {
    cin >> n >> m >> q;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
            s[i][j] = s[i][j - 1] + s[i - 1][j] + (a[i][j] == '1') - s[i - 1][j - 1];
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            dp1[i][j] = dp1[i][j - 1] + dp1[i - 1][j] + (a[i][j - 1] == '1' && a[i][j] == '1') - dp1[i - 1][j - 1];
            dp2[i][j] = dp2[i][j - 1] + dp2[i - 1][j] + (a[i + 1][j] == '1' && a[i][j] == '1') - dp2[i - 1][j - 1];
        }
    }
    for (int i = 1; i <= q; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        cout << sum(x1, y1, x2, y2) - edges(x1, y1, x2, y2) << "\n";
    }
}


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

void insertionSort(int A[], int N) {
  int v, j;
  for (int i = 1; i <= N - 1; i++) {
    v = A[i];
    j = i - 1;

    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
      A[j + 1] = v;
    }

    for (int i = 0; i < N - 1; i++) 
      cout << A[i] << " ";
    
    cout << A[N - 1] << endl;
  }
}

int main()
{
  int N;
  cin >> N;
  int A[N];

  for (int i = 0; i < N; i++) cin >> A[i];

  for (int i = 0; i < N - 1; i++) cout << A[i] << " ";
  
  cout << A[N - 1] << endl;

  insertionSort(A, N);
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;

long long qq(int n)
{
	int i;
	long long a = 2,b = 1,c = 0;
	if(n == 0){
		a  = 2;
		return 2;
	}
	if(n == 1){
		b = 2;
		return 1;
	}
	if(n > 1){
		for(i = 2; i <= n; i++)
		{//a b c
			c = a + b;
			a = b;
			b = c;
		}
	return c;
	}
}
			

int main()
{
	int n;
	scanf("%d",&n);
	printf("%lld",qq(n));
	return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
  Scanner sc;

  class Plant {
    String name;
    double v;

    Plant(String s, double c) {
      name = s;
      v = c;
    }
  }

  int pow(int n, int r) {
    if ( r == 0 ) {
      return 1;
    } else {
      return n * pow( n, r - 1 );
    }
  }

  void run() {
    for ( ;; ) {
      int n = ni();
      if ( n == 0 ) {
        break;
      }

      Plant[] list = new Plant[n];
      for ( int i = 0; i < n; ++i ) {
        String l = sc.next();
        int p, a, b, c, d, e, f, s, m;
        p = ni();
        a = ni();
        b = ni();
        c = ni();
        d = ni();
        e = ni();
        f = ni();
        s = ni();
        m = ni();

        int v = 0;
        int time = 0;
        time += ( a + b + c );
        time += ( d + e ) * m;
        v += s * f * m;
        v -= p;

        list[ i ] = new Plant( l, ((double) v) / time );
      }

      Arrays.sort( list, new Comparator<Plant>() {
        public int compare(Plant o1, Plant o2) {
          if( Math.abs(o1.v - o2.v) < 1e-9) {
            return o1.name.compareTo( o2.name );
          }
          else if ( o1.v < o2.v ) {
            return 1;
          } else {
            return -1;
          }
        }
      } );

      for ( Plant v : list ) {
        System.out.println( v.name );
      }
      System.out.println( "#" );
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

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

}

Measured memory_bytes: 38120
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {
	ll n, k;

	cin >> n >> k;

	ll ans = 0;
	while (n != 0)
	{
		n = n / k;
		ans++;
	}

	cout << ans << endl;

}


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

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());

	int ai = a.back();
	int aj = a[0];
	for(int i=0; i<n-1; i++)
		if(abs(ai - 2*a[i]) < abs(ai - 2*aj))
			aj = a[i];

	cout << ai << " " << aj << endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define M 200005
struct hh{
	int p,w,id;
};
vector<hh>d[M];
int sz[M],son[M],fa[M],tp[M],dp[M],rt[M],ls[M*20],rs[M*20],sum[M*20],n,cnt,Sz[M*20],dis[M];
long long ans;
void update(int rt1,int &rt2,int l,int r,int x,int w){
	rt2=++cnt;ls[rt2]=ls[rt1];rs[rt2]=rs[rt1];sum[rt2]=sum[rt1]+w;Sz[rt2]=Sz[rt1]+1;
	if(l==r)return;
	int mid=(l+r)>>1;
	if(x<=mid)update(ls[rt1],ls[rt2],l,mid,x,w);
	else update(rs[rt1],rs[rt2],mid+1,r,x,w);
}
void dfs(int x,int f,int w,int p){
	sz[x]=1;dp[x]=dp[f]+1;fa[x]=f;dis[x]=dis[f]+w;
	if(w)update(rt[f],rt[x],1,n,p,w);
	for(int i=0;i<(int)d[x].size();++i){
		int v=d[x][i].p;
		if(v==f)continue;
		dfs(v,x,d[x][i].w,d[x][i].id);sz[x]+=sz[v];
		if(sz[v]>sz[son[x]])son[x]=v;
	}
}
void Dfs(int x,int top){
	tp[x]=top;
	if(son[x])Dfs(son[x],top);
	for(int i=0;i<(int)d[x].size();++i){
		int v=d[x][i].p;
		if(v==fa[x]||v==son[x])continue;
		Dfs(v,v);
	}
}
int Lca(int x,int y){
	while(tp[x]!=tp[y]){
		if(dp[tp[x]]>dp[tp[y]])x=fa[tp[x]];
		else y=fa[tp[y]];
	}
	return dp[x]>dp[y]?y:x;
}
void query(int rt1,int rt2,int rt3,int l,int r,int x,int w){
	if(l==r){
		ans-=sum[rt1]+sum[rt2]-sum[rt3]*2;
		ans+=(Sz[rt1]+Sz[rt2]-Sz[rt3]*2)*w;
		return;
	}
	int mid=(l+r)>>1;
	if(x<=mid)query(ls[rt1],ls[rt2],ls[rt3],l,mid,x,w);
	else query(rs[rt1],rs[rt2],rs[rt3],mid+1,r,x,w);
}
int main(){
	int q;
	scanf("%d%d",&n,&q);
	for(int i=1,a,b,c,f;i<n;++i){
		scanf("%d%d%d%d",&a,&b,&c,&f);
		d[a].push_back((hh){b,f,c});
		d[b].push_back((hh){a,f,c});
	}
	dfs(1,0,0,1);
	Dfs(1,1);
	for(int i=1,x,y,u,v;i<=q;++i){
		scanf("%d%d%d%d",&x,&y,&u,&v);
		int lca=Lca(u,v);ans=dis[u]-2*dis[lca]+dis[v];
		query(rt[u],rt[v],rt[lca],1,n,x,y);
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 55296
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    string s;
    cin >> s;
    int n = s.size();
    if(s[n-1] == '1') {
        cout << -1 << endl;
        return 0;
    }
    s = s.substr(0,n-1);
    string rev(rall(s));
    if(s != rev) {
        cout << -1 << endl;
        return 0;
    }
    if(s[0] == '0') {
        cout << -1 << endl;
        return 0;
    }
    auto add = [](int u,int v) {
        cout << u << ' ' << v << '\n';
    };
    int par = n;
    rrep(i,n-1) {
        add(par,i+1);
        if(s[i] == '1') {
            par = i+1;
        }
    }
}


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

using namespace std;
typedef long long ll;

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

    double rad = (double)(60*h + m - 12*m) / 720 * 2 * M_PI;
    double cosine = cos(rad);
    double c = (double)a*a + b*b -2*a*b*cosine;
    double ans =sqrt(c);
    cout << std::fixed << std::setprecision(20) << ans << endl;
}

Measured memory_bytes: 4164
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

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

	int ans = 0;
	for(int i=1;i<n-1;i++){
		if(p[i-1]<p[i]&&p[i]<p[i+1]) ans++;
		else if(p[i-1]>p[i]&&p[i]>p[i+1]) ans++;
	}

	cout << ans << endl;


	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const int N=100000;
vector<int> G[N];

int main()
{
    int n,m;
    scanf(" %d %d", &n, &m);
    rep(i,m)
    {
        int a,b;
        scanf(" %d %d", &a, &b);
        --a;
        --b;
        G[a].pb(b);
        G[b].pb(a);
    }

    vector<bool> vis(n,false);

    vector<int> x,y;

    int start=0;
    rep(i,n)
    {
        if(G[i].size()>0)
        {
            start = i;
            break;
        }
    }

    int now=start;
    x.pb(now);
    vis[now]=true;
    while(1)
    {
        int tmp=now;
        rep(i,G[now].size())
        {
            int nx=G[now][i];
            if(!vis[nx])
            {
                vis[nx]=true;
                now=nx;
                x.pb(now);
            }
        }

        if(now==tmp) break;
    }

    now=start;
    while(1)
    {
        int tmp=now;
        rep(i,G[now].size())
        {
            int nx=G[now][i];
            if(!vis[nx])
            {
                vis[nx]=true;
                now=nx;
                y.pb(now);
            }
        }

        if(now==tmp) break;
    }

    // printf(" X= %d Y= %d\n", x.size(),y.size());

    reverse(all(y));
    rep(i,x.size()) y.pb(x[i]);

    printf("%d\n", y.size());
    rep(i,y.size())
    {
        if(i) printf(" ");
        printf("%d", y[i]+1);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 7032
#include <iostream>
#include <iomanip>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    repi(i, n, 0) cin >> a[i];
    ll ans = 0;
    repi(i, 60, 0)//桁を全部試す
    {
        ll x = 0;
        repi(j, n, 0) if (a[j] >> i & 1)++ x;
        ll now = x * (n - x) % MOD;// x*y
        repi(j, i, 0) now = now * 2 % MOD;//個数分足す
        ans += now;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
n=int(input())
cnt=[[0]*10 for i in range(10)] #(10,10)サイズの配列
ret = 0

def hoge(m):
    #return m[-1],m[0]
    return (m%10, int(str(m)[0]))

for k in range(1,n+1):
    a,b = hoge(k)
    cnt[a][b] += 1    

for i in range(1,10):
    for j in range(1,10):
        ret += cnt[i][j] * cnt[j][i]

print(ret)

Measured memory_bytes: 3188
function Main(input) {
  input = input.split("\n");
  var length = input[1].split(" ");
  var count = 0;
  
  function compare(a, b) {
    return a - b;
  }

  length.sort(compare);
  
  for(i = 0; i < input[0]; i++){
  	for(j = (i+1); j < input[0]; j++){
    	for(k = (j+1); k < input[0]; k++){
        	if(length[i] != length[j] && length[j] != length[k] && length[k] != length[i]){
            	if((parseInt(length[i], 10) + parseInt(length[j], 10)) > length[k]){
                	count++;
                }
            }
        }
    }
  }
  
  console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32868
# -*- coding:utf8

N,M = [int(x) for x in raw_input().split(' ')]

A = [raw_input() for x in range(N)]
B = [raw_input() for x in range(M)]

def getpattern(image, s = 0, x = 0, y = 0):
    if s == 0:
        s = len(image)

    return ''.join([image[i][x:x+s] for i in range(y, y + s)])

def match(N,M,A,B):
    size = M

    bpattern = getpattern(B)
    for j in range(0, N - M + 1):
        for i in range(0, N - M + 1):
            if getpattern(A, size, i, j) == bpattern:
                return 'Yes'

    return 'No'

print match(N,M,A,B)

Measured memory_bytes: 2692
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<ll> a(N);
	for(auto i = 0; i < N; ++i)
	{
		cin >> a[i];
	}

	vector<ll> sum(N + 1);
	vector<ll> sumPlus(N + 1);
	for (auto i = 0; i < N; ++i)
	{
		sum[i + 1] = sum[i] + a[i];
		sumPlus[i + 1] = sumPlus[i];
		if (a[i] > 0)
		{
			sumPlus[i + 1] += a[i];
		}
	}

	auto ans = 0ll;
	for (auto i = 0; i <= N - K; ++i)
	{
		auto temp = sumPlus[i] + sumPlus[N] - sumPlus[i + K];
		auto temp2 = sum[i + K] - sum[i];
		if (temp2 > 0)
		{
			temp += temp2;
		}
		ans = max(temp, ans);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h> 
using namespace std; 
#define deb(x) cout <<"\n"<< (#x) << " = " << (x) << "\n"
const long long  INF = 1e18;
const long long mod=1e9+7 ;
void inputoutput()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); 
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	    
}


vector<int> adj[200500];
vector<int> vis(200500);

void dfs(int v,int& ans)
{
	++ans;
	vis[v]=true;
	for(auto u : adj[v])
	{
		if(!vis[u])
			dfs(u,ans);
	}
}



void solve()
{
		// dfs implementation in undirected graph
	int n ;   // no. of vertices
	cin>>n ;
	int e;    // no. of edjes
	cin>>e;
	for(int i=0 ; i<e ; ++i)
	{
		int a,b;
		cin>>a>>b;
		--a;
		--b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	int sol=INT_MIN ;
	for(int i=0 ; i<n ; ++i)
	{
		if(!vis[i])
		{
			int ans=0;
			dfs(i,ans);
			sol=max(sol,ans);
		}
	}

	cout<<sol<<"\n";


}

int32_t main()
{ 
	inputoutput() ;
	solve();


	return 0;
}


Measured memory_bytes: 21084
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int A, B, C;

    static void input()
    {
        cin = new Scanner();
        A = cin.nextInt();
        B = cin.nextInt();
        C = cin.nextInt();
    }
    static void solve()
    {
        input();
        WriteLine(Max(C - Max(A - B, 0), 0));
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <map>
using namespace std;

#pragma warning(disable:4996)

typedef long long ll;
typedef pair<ll, ll> pll;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1000000007;

int main() {
	int A, B;
	scanf("%d %d", &A, &B);
	int mx = max({ A + B, A - B, A*B });
	return !printf("%d\n", mx);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
Graph G;
  
/*------------------------------------------------------------------*/

int main(){
    string s; cin >> s;
    int n = s.size();
    if(s[n - 1] == '2' or s[n - 1] == '4' or s[n - 1] == '5' 
    or s[n - 1] == '7' or s[n - 1] == '9'){
        cout << "hon" << endl;
    }else if(s[n - 1] == '0' or s[n - 1] == '1' or s[n - 1] == '6' 
    or s[n - 1] == '8'){
        cout << "pon" << endl;
    }else cout << "bon" << endl;
    
}

Measured memory_bytes: 3632
n = int(input())
s=input()
if ('.' not in s) or ('#' not in s):
    print(0)
    exit()
bc = [0 for i in range(n)]
wc = [0 for i in range(n)]
for i in range(n):
  if s[i] == '#':
    bc[i] = 1
  else:
    wc[i] = 1
for i in range(n-1):
  bc[i+1] += bc[i]
for i in range(n-1,0,-1):
  wc[i-1] += wc[i]
ans = min(wc[0],bc[-1])
for i in range(n-1):
  ans = min(ans,bc[i]+wc[i+1])
print(ans)

Measured memory_bytes: 19304
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  string S;
  cin >> S;
  rep(i, S.size()) {
    if (i == 5 || i == 13) {
      cout << " ";
    } else {
      cout << S[i];
    }
  }
  ENDL;
  return 0;
}

Measured memory_bytes: 3604
from fractions import gcd
MOD = 1000000007
def pw(x, y):
    ans = 1
    while y > 0:
        if y % 2:
            ans = ans * x % MOD
        x = x * x % MOD
        y //= 2
    return ans
H, W, T = map(int, input().split())
HT = gcd(H, T)
WT = gcd(W, T)
H //= HT
W //= WT
print(pw(pw(2, H) + pw(2, W) + pw(2, gcd(H, W)) - 3, HT * WT))

Measured memory_bytes: 5244
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;




int main(){
    int n,a,b,c,d;
    string s;
    cin>>n>>a>>b>>c>>d>>s;
    a--;b--;c--;d--;
    for (int i=a;i<max(c,d);i++){
        if(s[i]=='#' && s[i+1]=='#') {
            cout<<"No"<<endl;
            return 0;
        }
    }
    if (c<d) {
        cout<<"Yes"<<endl;
        return 0;
    } else {
        for (int i=b-1;i<d;i++){
            if (s[i]=='.' && s[i+1]=='.' && s[i+2]=='.'){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    
    //cout<<n<<s;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end

int r,c,n;
int calc(int x,int y){
	if(y==0)return x;
	else if(x==r)return r+y;
	else if(y==c)return r+c+r-x;
	else if(x==0)return r+c+r+c-y;
	else return -1;
}

int main(){
    int n; scanf("%d%d%d",&r,&c,&n);
    vector<P> idx;
    rep(i,0,n){
    	int x1,y1,x2,y2; scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    	int f1=calc(x1,y1),f2=calc(x2,y2);
    	if(f1==-1||f2==-1)continue;
    	idx.push_back({f1,i});
    	idx.push_back({f2,i});	
	}
	sort(ALL(idx));
	vector<int> st; //stack
	rep(i,0,idx.size()){
		int val=idx[i].second;
		if(st.size()&&st.back()==val)st.pop_back();
		else st.push_back(val);
	}
	printf(st.size()?"NO":"YES");
    return 0;
}


Measured memory_bytes: 6384
n = int(input())
results = [input() for i in range(n)]

ac = 0
wa = 0
tle = 0
re = 0

for i in results:
  if i == 'AC' :
    ac += 1
  elif i == 'WA' :
    wa += 1
  elif i == 'TLE' :
    tle += 1
  else :
    re += 1

print('AC','x',ac)
print('WA','x',wa)
print('TLE','x',tle)
print('RE','x',re)

Measured memory_bytes: 16316
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 19 16:05:26 2019
DP_G
@author: maezawa
"""
import sys
sys.setrecursionlimit(10**6)

n, m = list(map(int, input().split()))
v = [-1]*(n+1)
adj = [[] for _ in range(n+1)]
for _ in range(m):
    i, j = list(map(int, input().split()))
    adj[i].append(j)
    
def dfs(vi):
    if v[vi] != -1:
        return v[vi]
    res = 0
    for nb in adj[vi]:
        res0 = dfs(nb) +1
        if res < res0:
            res = res0
    v[vi] = res
    return res

ans = 0
for node in range(1, n+1):
    current = dfs(node)
    if current > ans:
        ans = current
print(ans)
    


Measured memory_bytes: 65200
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
/*
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
 
using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")
 
 
 
#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------


int modexp(int x,int y,int P)
{
	int res=1;
	while(y>0)
	{
		if (y&1)res=(res*x)%P;
		y>>=1;
		x=(x*x)%P;
	}
	return res;
}

int modinv(int x,int P)
{
	return modexp(x,P-2,P);
}


int fac[100005];

int n,k;
vi adj[100005];
int ncr(int n,int r)
{
	return (((fac[n]*modinv(fac[r],MOD))%MOD)*modinv(fac[n-r],MOD))%MOD;
}


int dfs(int so,int P,int lim)
{
	int ret=1;
	int cct=0;
	for (auto x:adj[so])
	{
		if(x!=P)cct++;
	}

	if (cct>lim-1)return 0;

	ret=(ret*ncr(lim-1,cct))%MOD;
	ret=(ret*fac[cct])%MOD;

	for (auto x:adj[so])
	{
		if (x!=P)ret=(ret*dfs(x,so,k-1))%MOD;
	}
	return ret;

}

void solve()
{
	fac[0]=1;
	rep(i,1,100005)fac[i]=(fac[i-1]*i)%MOD;

	cin>>n>>k;int u,v;
	rep(i,0,n-1)cin>>u>>v,adj[u-1].pb(v-1),adj[v-1].pb(u-1);

	int ans=(k*dfs(0,-1,k))%MOD;
	cout<<ans<<"\n";
	
}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
 
    #ifdef local
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 
    int t=1;
    ///cin>>t;
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

Measured memory_bytes: 12416
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        long a = Integer.parseInt(sc.next());
        long b = Integer.parseInt(sc.next());
        long k = Long.parseLong(sc.next());
        
        int mod = 998244353;
        int max = 300_003;
        Mod_nCr mn = new Mod_nCr(mod, max);
        
        long ans = 0;
        for(int red=0; red<=n; red++){
            int blue = (int)((k-red*a)/b);
            if(red*a + blue*b == k && 0<=blue){
                ans += mn.nCr(n, red) * mn.nCr(n, blue);
                ans %= mod;
            }
        }
        
        System.out.println(ans);
    }
}

class Mod_nCr{
    int mod;
    long[] fact;
    long[] rfact;
    
    public Mod_nCr(int mod, int max){
        this.mod = mod;
        fact = new long[max];
        rfact = new long[max];
        
        fact[0] = 1;
        rfact[0] = 1;
        
        for(int i=1; i<max; i++){
            fact[i] = (fact[i-1]*i)%mod;
            rfact[i] = mod_inverse(fact[i], mod);
        }
    }
    
    //
    private long mod_pow(long x, long p, long m){
        long a = 1;
        while(p>0){
            if(p%2==1){
                a = a*x%m;
            }
            x = x*x%m;
            p /= 2;
        }
        return a;
    }
    
    private long mod_inverse(long a, long m){
        return mod_pow(a, m-2, m);
    }
    
    //
    public long nCr(int n, int r){
        if(n < r) return 0;
        return fact[n]*rfact[r]%mod * rfact[n-r]%mod;
    }
}


Measured memory_bytes: 26068
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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; }

ll keta(ll n){
  ll k=0;
  while(n!=0){
    n/=10;
    k++;
  }
  return k;
}  

int main()
{
  ll N; cin>>N;
  ll K=keta(N);
  
  ll ans=0;
  rep(i,1<<(K-1)){
    ll N2=N;
    ll hoge=1;
    rep(j,K-1){
      hoge*=10;
      if(i&(1<<j)){
        ans+=N2%hoge;
        N2/=hoge;
        hoge=1;
      }
      //cout<<N2<<" "<<ans<<endl;
    }
    ans+=N2;
  }
  cout<<ans<<endl;
  return 0;
}


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

long long MOD=1000000007LL;

int N,K;
long long ans=1LL;
vector<vector<int>> graph(111111);
vector<int> c(111111);

long long DFS(int K,int cur,int from){
	int can_use;
	if(from==-1)can_use=K-1;
	else can_use=K-2;
	
	if(K<graph[cur].size())return 0;
	
	long long ret=1;
	for(auto t:graph[cur]){
		if(t==from)continue;
		ret*=can_use;
		ret%=MOD;
		can_use--;
	}
	for(auto t:graph[cur]){
		if(t==from)continue;
		ret*=DFS(K,t,cur);
		ret%=MOD;
	}
	return ret;
}

int main(){
	cin >> N >> K;
	for(int i=0;i<N-1;i++){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	
	ans=K*DFS(K,0,-1);
	ans%=MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12288