akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int64_t> B(N);
  for(int i = 1; i < N; i++) cin >> B.at(i);
  int64_t ans=B.at(N-1);
  for(int i = N-1; i > 0; i--){
    ans+= min(B.at(i),B.at(i-1));
  }
  ans+=B.at(1);
  cout << ans;
}

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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)
	{
	cin>>a[i]>>b[i]>>c[i];	
	}
	int dp[n][3];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i=1;i<n;i++)
	{
	   	dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
	   	dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
	   	dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c[i];
	}
	int ans = max(dp[n-1][0],dp[n-1][1]);
		ans = max(ans,dp[n-1][2]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2560
import sys
input()
d={}
nc=np=0
for ln in sys.stdin:
    p,S=ln.split()
    if p not in d:
        d[p]=[0,0]
    if not d[p][0]:
        if S=='AC':
            d[p][0]=1
            nc+=1
            np+=d[p][1]
        else:
            d[p][1]+=1

print(nc,np)


Measured memory_bytes: 29000
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2199&lang=jp
//Differential Pulse Code Modulation
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int solve(){
	ll N,M; cin>>N>>M;
	if (N==0&&M==0) return -1;
	vector<ll> cm(M);
	for(auto&& c:cm){
		cin>>c;
	}

	vector<int> xn(N);
	for(auto&& x:xn) cin>>x;

	constexpr ll INF=2LL<<60;
	vector<vector<ll>> dp(N+1,vector<ll>(256,INF));
	dp[0][128]=0;
	FOR(i,0,N){
		auto x=xn.at(i);
		FOR(v,0,256){ //FIXME:0->
			FOR(c,0,cm.size()){
				ll cv= cm.at(c);
				ll next_v=v+cv;
				if (next_v<0) next_v=0;
				if (next_v>=255) next_v=255;
				ll ad=(next_v-x);
				if (dp[i][v]<INF) chmin(dp[i+1][next_v],dp[i][v]+ad*ad);
			}
		}
	}

	ll ret=INF;
	FOR(v,0,256){
		chmin(ret,dp[N][v]);
	}

	return ret;
}
int main() {
#if LOCAL&01
	std::ifstream in("./test/sample-1.in");
	//std::ifstream in("./input.txt");
	std::cin.rdbuf(in.rdbuf());
#else
	cin.tie(0);
	ios::sync_with_stdio(false);
#endif
	while(true){
		ll r=solve();
		if(r<0)break;
		cout<<r<<endl;
	}
	return 0;
}


Measured memory_bytes: 43848
import collections

n=int(input())	
s=input()

c = collections.Counter(s)

ans_count = c['R'] * c['G'] * c['B']

for i in range(1, (n+1)//2):
    for j in range(n):
        if j+(2*i) >= n:
            break

        if s[j] != s[j+i] and s[j+i] != s[j+(2*i)] and s[j] != s[j+(2*i)]:
            ans_count -= 1


print(ans_count)


Measured memory_bytes: 9412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  ll r;
  cin>>r;
  
  cout<<power(r,2)<<endl;
}


Measured memory_bytes: 256
Option Infer On
Imports System

Module Program
    Sub Main(args As String())
        Dim x = Console.ReadLine()

        Dim s = x.Replace("1", "").Length
        Dim t = x.Replace("0", "").Length
        Dim u = x.Length
        Console.WriteLine(u - Math.Abs(s - t))

    End Sub
End Module

Measured memory_bytes: 23632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    int cnt = 0, max_cnt=0;
    for(int i=0; i<s.size(); i++){
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            cnt ++;
            max_cnt = max(max_cnt, cnt);
        }
        else{
            cnt = 0;
        }
    }
    cout << max_cnt << endl;
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (n); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  int N, K;
  in(N, K);
  if (N <= K) {
    print(0);
    return;
  }
  priority_queue<ll> H;
  rep(i, N) {
    ll hi;
    in(hi);
    H.push(hi);
  }
  rep(i, K) {
    H.pop();
  }
  ll ans = 0;
  while (!H.empty()) {
    ans += H.top();
    H.pop();
  }
  print(ans);
}


Measured memory_bytes: 2420
#include <iostream>

int main(){
   std::string S;
   std::cin >> S;

   int ans = 0;
   int n = S.size();
   for(int i=0; i<n/2; ++i){
      if(S[i]!=S[n-1-i]) ++ans;
   }
   std::cout << ans << std::endl;
   return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> tako(N);

  for(int i = 0; i < N; i++)
  cin >> tako.at(i);

  int sum = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(N > i + j + 1)
      sum += tako.at(i) * tako.at(i + j + 1);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
s = list(input() for i in range(n))
m = 0
a = 0
r = 0
c = 0
h = 0
for j in range(n):
  if s[j][0] == "M":
    m += 1
  elif s[j][0] == "A":
    a += 1
  elif s[j][0] == "R":
    r += 1
  elif s[j][0] == "C":
    c += 1
  elif s[j][0] == "H":
    h += 1
  
x = [m**i + a**i + r**i + c**i + h**i for i in range(1,4)]
print(int((x[0]**3-3*x[1]*x[0]+2*x[2])/6))

Measured memory_bytes: 9764
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

template <typename It>
vector<int> zAlgorithm(It s, It t)
{
    int n = t - s;
    vector<int> z(n);
    if (n == 0) {
        return z;
    }

    int l = 0;
    z[0] = 0;
    for (int i = 1; i < n; i++) {
        int r = l + z[l];

        if (r > i + z[i - l]) {
            z[i] = z[i - l];
        } else {
            z[i] = max(0, r - i);
            l = i;
            for (int j = z[i]; i + j < n && s[i + j] == s[j]; j++) {
                z[i]++;
            }
        }
    }
    z[0] = n;

    return move(z);
}

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

    vector<int> a(n), b(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    rep(i, n)
    {
        cin >> b[i];
    }

    vector<int> c(n), d(n);
    rep(i, n)
    {
        c[i] = a[i] ^ a[(i + 1) % n];
        d[i] = b[i] ^ b[(i + 1) % n];
    }

    vector<int> e;
    copy(d.begin(), d.end(), back_inserter(e));
    copy(c.begin(), c.end(), back_inserter(e));
    copy(c.begin(), c.end(), back_inserter(e));

    vector<int> z = zAlgorithm(e.begin(), e.end());
    rep(i, n)
    {
        if (z[n + i] >= n) {
            cout << i << " " << (b[0] ^ a[i]) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 11372
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <numeric>


using namespace std;

int main()
{
    long long n,k;
    cin >> n>>k;
    
    //if(n<k){
    //    cout<<n;
    //    exit(0);
    //}

    long long ans1,ans2;
    ans1=n%k;
    ans2=abs(ans1-k);
    //cout<<ans1<<" "<<ans2<<endl;
    
    cout << ((ans1<ans2) ? ans1 : ans2);
}



Measured memory_bytes: 256
MOD=1000000007
N=int(input())
S=[input() for _ in range(2)]
i=0
ans=1
flag=True
if S[0][0]==S[1][0]:
    ans=3
    i+=1
else:
    ans=6
    i+=2
    flag=False
while i<N:
    if S[0][i]==S[1][i]:
        if flag==True:
            ans*=2
            ans%=MOD
        i+=1
        flag=True
    else:
        if flag:
            ans*=2
        else:
            ans*=3
        ans%=MOD
        i+=2
        flag=False
print(ans)


Measured memory_bytes: 9084
import java.util.Scanner;

public class Main {

    static long[][] dp;

    static long max(long a, long b){
        if( a > b )
            return a;
        return b;
    }

    static long max(long a, long b, long c){
        if( a > b && a > c)
            return a;
        else if( b > a && b > c )
            return b;
        return c;
    }

    static long calculate(int[][] arr,int pos,int selection){
        if(pos >= arr.length)
            return 0;
        if(selection == -1){
            dp[pos][0] = arr[pos][0] + calculate(arr,pos+1,0);
            dp[pos][1] = arr[pos][1] + calculate(arr,pos+1,1);
            dp[pos][2] = arr[pos][2] + calculate(arr,pos+1,2);
            return max(dp[pos][0],dp[pos][1],dp[pos][2]);
        }else{
            if(selection == 0){
                if(dp[pos][1] == -1)
                dp[pos][1] = arr[pos][1] + calculate(arr,pos+1,1);
                if(dp[pos][2] == -1)
                dp[pos][2] = arr[pos][2] + calculate(arr,pos+1,2);
                return max(dp[pos][1],dp[pos][2]);
            }else if(selection == 1){
                if(dp[pos][0] == -1)
                dp[pos][0] = arr[pos][0] + calculate(arr,pos+1,0);
                if(dp[pos][2] == -1)
                dp[pos][2] = arr[pos][2] + calculate(arr,pos+1,2);
                return max(dp[pos][0],dp[pos][2]);
            }else{
                if(dp[pos][0] == -1)
                dp[pos][0] = arr[pos][0] + calculate(arr,pos+1,0);
                if(dp[pos][1] == -1)
                dp[pos][1] = arr[pos][1] + calculate(arr,pos+1,1);
                return max(dp[pos][0],dp[pos][1]);
            }
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        dp = new long[n][3];
        int[][] arr = new int[n][3];
        for(int i =0; i < n; i++){
            arr[i][0] = sc.nextInt();
            arr[i][1] = sc.nextInt();
            arr[i][2] = sc.nextInt();
            dp[i][0] = -1;
            dp[i][1] = -1;
            dp[i][2] = -1;
        }

        System.out.println(calculate(arr,0,-1));

    }
}


Measured memory_bytes: 129192
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

const double eps = 1e-8;
const int M = 256;

int main(){
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		
		vector<int> l(n);
		for(int i=0; i<n; i++){
			cin >> l[i];
		}
		
		int ans[3]={0,0,0};
		double minH = 1e18;
		for(int s=0; s<=15; s++){
			for(int a=0; a<=15; a++){
				for(int c=0; c<=15; c++){
					vector<int> count(M,0);
					int r=s;
					for(int i=0; i<n; i++){
						r = (a*r +c) %M;
						count[(r+l[i]) %M]++;
					}
					
					double H=0;
					for(int i=0; i<M; i++){
						if(count[i]!=0){
							H += -count[i]*log((double)count[i]/n);
						}
					}
					if(H + eps < minH){
						minH = H;
						ans[0]=s; ans[1]=a; ans[2]=c;
					}
				}
			}
		}
		
		cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
	}
	return 0;
}

Measured memory_bytes: 3376
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    string s,t,u;
    ll a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(u==s)
        cout<<(a-1)<<" "<<b<<endl;
    else
        cout<<a<<" "<<(b-1)<<endl;
}
return 0;
}

Measured memory_bytes: 256
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N = ir()
    pos = []
    neg = []
    tot = 0
    for i in range(N):
        tmp = 0
        b = 0
        for c in sr():
            if c == '(':
                tmp += 1
            else:
                tmp -= 1
                b = min(b, tmp)
        if tmp > 0:
            pos.append([tmp, b])
        else:
            neg.append([-tmp, b-tmp])
        tot += tmp
    if tot != 0:
        print('No')
        return
    pos = sorted(pos, key=lambda x: (x[1], x[0]))[::-1]
    neg = sorted(neg, key=lambda x: (x[1], x[0]))[::-1]
    c = 0
    for p in pos:
        t, b = p
        if c+b < 0:
            print('No')
            return
        c += t
    c = 0
    for n in neg:
        t, b = n
        if c+b < 0:
            print('No')
            return
        c += t
    print('Yes')
    return
resolve()

Measured memory_bytes: 216160
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

void check(vector<string> &keep, string pa) {
    bool flag = true;
    for (int i = 0; i < keep.size(); i++) {
        if (keep[i] == pa) {
            flag = false;
            break;
        }
    }
    if (flag) keep.push_back(pa);
}

int solve(string s) {
    vector<string> keep;
    keep.push_back(s);
    string left;
    string right;
    string pa;
    for (int i = 0; i < s.size(); i++) {
        left  = s.substr(0, i);
        right = s.substr(i, s.size() - i);

        string lr = left;
        string rr = right;
        reverse(rr.begin(), rr.end());
        reverse(lr.begin(), lr.end());
        pa = lr + right;
        check(keep, pa);
        pa = left + rr;
        check(keep, pa);
        pa = lr + rr;
        check(keep, pa);

        pa = right + left;
        check(keep, pa);
        pa = rr + left;
        check(keep, pa);
        pa = right + lr;
        check(keep, pa);
        pa = rr + lr;
        check(keep, pa);
        // cout << iyada << endl;
    }
    return keep.size();
}

int main() {
    int n;
    cin >> n;
    string s;
    vector<int> ans;

    for (int i = 0; i < n; i++) {
        cin >> s;
        ans.push_back(solve(s));
    }
    for (int i : ans) cout << i << endl;
}


Measured memory_bytes: 3212
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int main(void) {
	int h, w;
	char s[2001][2001] = { 0 };
	int left, temp, top;
	int s_cnt[2001][2001] = { 0 };
	int max = 0;

	scanf("%d %d", &h, &w);
	for (int i = 0; i < h; i++) scanf("%s", s[i]);

	for (int i = 0; i < h; i++) {
		left = 0, temp = 0;
		for (int j = left; j <= w; j++) {
			if (s[i][j] == '.') {
				temp++;
			}
			else {
				for (int k = left; k < j; k++) s_cnt[i][k] = temp;
				left = j + 1;
				temp = 0;
			}
		}
	}

	for (int i = 0; i < w; i++) {
		top = 0, temp = 0;
		for (int j = top; j <= h; j++) {
			if (s[j][i] == '.') {
				temp++;
			}
			else {
				for (int k = top; k < j; k++) s_cnt[k][i] += temp;
				top = j + 1;
				temp = 0;
			}
		}
	}
	/*
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) printf("%d ", s_cnt[i][j]);
		printf("\n");
	}
	*/
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (max < s_cnt[i][j])max = s_cnt[i][j];
		}
	}
	printf("%d", max - 1);
	return 0;
}


Measured memory_bytes: 19712
N = int(input())
lists_S = []
lists_P = []
for i in range(N):
    S,P = map(str,str(input()).split())
    lists_S.append(S)
    lists_P.append(int(P))
c = list(zip(lists_S,lists_P))
c = sorted(c,key=lambda x:(x[0],-x[1]))
s,p = zip(*c)
lists_index = []
for i in range(N):
    for j in range(N):
        if s[i] == lists_S[j] and p[i] == lists_P[j]:
            lists_index.append(p.index(p[j]) + int(1))
for i in range(len(lists_index)):
    print(lists_index[i])

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

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define endl '\n'
#define eps  1e-9
const double pi=acos(-1);
const int mod=1e9+7;
//------------------------
const int N=1e5+4;
int pref[N];

int32_t main()
{ 
  io;
 
  
  int n,q,l,r,cnt;
  string s;
  cin>>n>>q;
  cin>>s;
  s=s+'#';
  for(int i=0;i<n;i++)
  {
    if(s[i]=='A' && s[i+1]=='C')
      pref[i]++;
    if(i>0)
      pref[i]+=pref[i-1];
  }
  
  while(q--)
  {
    cin>>l>>r;
    r--;
    l--;
    if(l!=0)
    cnt=pref[r]-pref[l-1];
    else
    cnt=pref[r];

    if(s[r]=='A' and s[r+1]=='C')
      cnt--;
    cout<<cnt<<endl;
  }
 return 0;
}

Measured memory_bytes: 1772
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>

int main(void) {
	int n, m, a[(int)1e+5] = {}, ans = 1, ans_1 = 1, ans_2 = 1, t;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d", &t);
		a[t] = 1;
	}
	for (int i = 2; i <= n; i++) {
		if (a[i - 1]) {
			ans = ans_2;
			if (a[i - 2]) {
				ans = 0;
				break;
			}
		}
		else if (a[i - 2]) {
			ans = ans_1;
		}
		else {
			ans = (ans_1 + ans_2) % 1000000007;
		}
		ans_2 = ans_1;
		ans_1 = ans;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
int main(){
    int H,W;
    cin >> H >> W;
    string S[50];
    for(int i=0; i<H; i++) cin >> S[i];
    int white = 0;
    int cost[50][50];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cost[i][j] = 3000;
            if(S[i][j] == '.') white++;
        }
    }
    
    int dy[4] = {-1,1,0,0};
    int dx[4] = {0,0,-1,1};
    queue<pair<int,int>> que;
    cost[0][0] = 1;
    que.push(make_pair(0,0));
    while(!que.empty()){
        int y = que.front().first;
        int x = que.front().second;
        que.pop();
        for(int i=0; i<4; i++){
            if(y+dy[i] < 0 || y+dy[i] >= H || x+dx[i] < 0 || x+dx[i] >= W) continue;
            if(S[y+dy[i]][x+dx[i]] == '.'){
                if(cost[y+dy[i]][x+dx[i]] > cost[y][x]+1){
                    cost[y+dy[i]][x+dx[i]] = cost[y][x]+1;
                    que.push(make_pair(y+dy[i],x+dx[i]));
                }
            }
        }
    }

    if(cost[H-1][W-1] == 3000) cout << -1 << endl;
    else cout << white - cost[H-1][W-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int_Max 2147483647
#define ll_Max 9223372036854775807
#define REP(i,f,n) for(int i=f; i<(n); i++)

int main()
{
  int ans = 0, h, w;
  cin >> h >> w;
  int a[h][w], bad_h[h] = {0}, bad_w[w] = {0};
  REP(i,0,h){
    int cnt = 0;
    REP(j,0,w){
      char inter;
      cin >> inter;
      if(inter=='.'){a[i][j]=0; cnt++;}
      else a[i][j]=1;
    }
    if(cnt==w)bad_h[i] = 1;
    else bad_h[i] = 0;
  }
  REP(j,0,w){
    int cnt = 0;
    REP(i,0,h){
      if(a[i][j]==0)cnt++;
    }
    if(cnt==h)bad_w[j] = 1;
    else bad_w[j] = 0;
  }

  REP(i,0,h){
    if(bad_h[i]==1)continue;
    REP(j,0,w){
      if(bad_w[j]==1)continue;
      if(a[i][j]==1)cout << "#";
      else cout << ".";
    }
    cout << endl;
  }

  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

Measured memory_bytes: 3612
# -*- coding: utf-8 -*-
N = int(input())

edges = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edges[a].append((b, 1))
    edges[b].append((a, 1))

dists1 = [float('inf') for _ in range(N)]
used = [False for _ in range(N)]
dists1[0] = 0
used[0] = True

buf = [0]
while buf:
    src = buf.pop()
    for dst, w in edges[src]:
        if not used[dst]:
            dists1[dst] = dists1[src] + w
            used[dst] = True
            buf.append(dst)

dists2 = [float('inf') for _ in range(N)]
used = [False for _ in range(N)]
dists2[N - 1] = 0
used[N - 1] = True

buf = [N - 1]
while buf:
    src = buf.pop()
    for dst, w in edges[src]:
        if not used[dst]:
            dists2[dst] = dists2[src] + w
            used[dst] = True
            buf.append(dst)

num1, num2 = 0, 0
for d1, d2 in zip(dists1, dists2):
    if d1 <= d2:
        num1 += 1
    elif d1 > d2:
        num2 += 1

if num1 > num2:
    print('Fennec')
else:
    print('Snuke')

Measured memory_bytes: 79520
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;

char a[10000], b[1000];
int main()
{
	int t = 0;
	scanf("%s", a);
	for (int i = 0; a[i] != '\0'; i++)
	{
		if (t < 0)t = 0;
		if (a[i] == '0')
		{
			b[t++] = '0';
		}
		else if (a[i] == '1')
		{
			b[t++] = '1';
		}
		else
		{
			t--;
		}
	}
	
	for (int i = 0; i < t; i++)
		printf("%c", b[i]);
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val n: Int = sc.nextLine.toInt
    val Array(d, x) = sc.nextLine.split(" ").map(_.toInt)
    val participants: List[Int] = List.fill(n)(sc.nextInt)
    println(participants.map(
      day => (0 to d).map(i => i * day + 1).takeWhile(i => i<=d).length
    ).sum + x)
  }

}


Measured memory_bytes: 27336
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[][] arr = new int[n][3];
      for(int i = 0; i < n; i++) {
        arr[i][0] = sc.nextInt();
        arr[i][1] = sc.nextInt();
        arr[i][2] = sc.nextInt();
      }


      for(int cx = 0; cx <= 100; cx++) {
        loop:
        for(int cy = 0; cy <= 100; cy++) {
            int H = Integer.MAX_VALUE;
            for(int[] a : arr) {
              int x = a[0];
              int y = a[1];
              int h = a[2];
              if(h == 0) continue;
              H = h + Math.abs(x - cx) + Math.abs(y - cy);
              break;
            }
            for(int[] a : arr) {
              int x = a[0];
              int y = a[1];
              int h = a[2];
              if(Math.max(H - Math.abs(x - cx) - Math.abs(y - cy), 0) != h) {
                  continue loop;
              }
            }
 
            System.out.println(cx + " " + cy + " " + H);
            return;
        }
      }
  }
}

Measured memory_bytes: 22356
class UnionFind:
    def __init__(self, max_size):
        self.parent = [i for i in range(max_size+1)]
        self.depth = [0 for _ in range(max_size+1)]
        self.cnt = [1 for i in range(max_size+1)]
    def find(self, x):
        if self.parent[x]==x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x]) 
            return self.parent[x]
    
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        elif self.depth[x]<self.depth[y]:
            self.parent[x] = y
            self.cnt[y] += self.cnt[x]
        else:
            self.parent[y] = x
            self.cnt[x]+=self.cnt[y]
            if self.depth[x]==self.depth[y]:
                self.depth[x]+=1
    def same(self, x, y):
        return self.find(x)==self.find(y)
    def size(self,x):
        return self.cnt[self.find(x)]

n,m = map(int,input().split())
utree = UnionFind(n+10)
for _ in range(m):
    x,y,z = map(int,input().split())
    utree.unite(x,y)
s = {utree.find(i) for i in range(1,n+1)}
print(len(s))

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

int main() {
  int n, m;
  cin >> n >> m;
  ll k;
  cin >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  reverse(a.begin(), a.end());
  vector<ll> ab(n + m);
  rep(i, n) ab[i] = a[i];
  rep(i, m) cin >> ab[n + i];

  vector<ll> t(n + m + 1);
  ll tmp = 0;
  rep(i, n + m + 1) {
    t[i] += tmp;
    tmp += ab[i];
  }

  int s = 0;
  int g = n;
  int ans = 0;
  while (g <= n + m) {
    if (s > n) break;
    if (t[g] - t[s] <= k) {
      ans = max(ans, g - s);
      g++;
    } else {
      s++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 11176
import sys
input = sys.stdin.readline
from collections import deque

N,M = map(int,input().split())
dp = [-1]*N
ad = [deque() for _ in range(N)]
num = [0]*N
for _ in range(M):
    x,y = map(int,input().split())
    x -= 1; y -= 1
    ad[x].append(y)
    num[y] += 1

L = []
S = deque()

for v in range(N):
    if num[v] == 0:
        S.append(v)
        dp[v] = 0

while S:
    v = S.popleft()
    L.append(v)
    for _ in range(len(ad[v])):
        nv = ad[v].popleft()
        num[nv] -= 1
        if num[nv] == 0:
            S.append(nv)
            if dp[nv] < dp[v] + 1:
                dp[nv] = dp[v] + 1

ans = max(dp)
print(ans)

Measured memory_bytes: 74996
#include<iostream>

struct P{
	double x, y;
};

int main(){
	P ps[4];
	while(std::cin >> ps[0].x >> ps[0].y >> ps[1].x >> ps[1].y >> ps[2].x >> ps[2].y >> ps[3].x >> ps[3].y, !std::cin.eof()){
		if(ps[1].x < ps[2].x || ps[3].x < ps[0].x || ps[3].y < ps[0].y || ps[1].y < ps[2].y){
			std::cout << "NO" << std::endl;
		}else{
			std::cout << "YES" << std::endl;
		}
	}
}

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

using namespace std;

typedef long long int ll;

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

    int n;
    int v[100], c[100];

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

    int ans = 0;
    for(int i = 0; i < n; i++){
        int m = v[i] - c[i];

        ans += m > 0 ? m : 0;
    }

cout << ans << endl;

    return 0;
}

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

#define ll long long int

bool dp[100005];
ll a[105];

ll f(ll m, ll n){

    for(ll z=1;z<=m;z++){
        for(ll x=0;x<n;x++){
            if(a[x] <= z){
                if(! dp[z - a[x]]) dp[z] = true;
            }
        }
    }

    return dp[m];
}

int main() {

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    ll n,k;
    cin>>n>>k;

    for(ll x=0;x<n;x++) cin>>a[x];

    memset(dp, false, sizeof dp);

    bool res = f(k, n);

    if(! res) cout<<"Second\n";
    else cout<<"First\n";

    return 0;
}

Measured memory_bytes: 3776
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int,input().split()))
d = 1000
for i in range(102):
  if i in p:
    continue
  if abs(x-i) < d:
    ans = i
    d = abs(x-i)
print(ans)

Measured memory_bytes: 61660
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

ll gcd(ll a, ll b){
  ll temp;
	while (a % b != 0){
		temp = b;
		b = a % b;
		a = temp;
	}
	return b;
}

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

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};


int main(){
    string S;
    cin >> S;
    if (S=="Sunny"){
    cout << "Cloudy"<< endl;
    }else if (S=="Cloudy"){
    cout << "Rainy"<< endl;        
    }else{
    cout << "Sunny"<< endl;        
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int a,b,i,j,s;
	char c[1000];
	scanf("%d%d",&a,&b);
	scanf("%s",c);
	s=strlen(c);
	if(a+b+1!=s||c[a]!='-')
	{
		puts("No");
		return 0;
	}
	for(i=0;i<s;i++)
	{
		if(i==a)
		continue;
		if(!(c[i]>='0'&&c[i]<='9'))
		{
			break;
		}
	}
	if(i==s)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
}

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

using namespace std;
using ll = long long int;

void inv(vector<int>& v) {
    int length = v.size();
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}
void inv(vector<int>& v, int length) {
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}

int judge(const int& x, const int& y, const int& z, const int& n) {
    int result = x * x + y * y + z * z + x * y + y * z + z * x;
    if (result < n) {
        return 1;
    } else if (result == n) {
        return 0;
    } else {
        return -1;
    }
}

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

    int maxval = 0;
    int temp = 0;
    while (judge(++temp, 1, 1, n) != -1) {
        maxval++;
    }

    int result;
    for (int i = 1; i <= n; i++) {
        int cnt = 0;
        for (int x = 1; x <= maxval; x++) {
            for (int y = 1; y <= maxval; y++) {
                for (int z = 1; z <= maxval; z++) {
                    result = judge(x, y, z, i);
                    if (result == 1) {
                        continue;
                    } else if (result == 0) {
                        cnt++;
                    }
                    break;
                }
            }
        }

        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
import scala.io.StdIn

object Main {
	def main(args: Array[String]): Unit ={
		val num = StdIn.readLine.split(" ").map(_.toInt)
		val A = num(0)
		val B = num(1)

		val result = if(A * B % 2 == 1) "Yes" else "No"
		println(result)
	}
}


Measured memory_bytes: 25536
import sys

for line in sys.stdin:
    l = list(map(int, line.split(",")))
    total_length = sum(l[:-2])
    a_v = l[-2]
    b_v = l[-1]
    crosspointtime = total_length / (a_v + b_v)
    crosspoint = crosspointtime * a_v
    ans = 0
    for i, length in enumerate(l[:-2]):
        ans += length
        if ans >= crosspoint:
            print(i+1)
            break



Measured memory_bytes: 5596
N = gets.to_i
list=[]
N.times{list<<gets.to_i}
list.sort!

def calc(list)
	prev = list[0]
	sum = 0
	list[1..-1].each{|n|
		sum += (prev - n).abs
		prev = n
	}
	sum
end



def arrange(list)
	first = 0
	last = N - 1
	result = [list[first]]
	first += 1
	while first <= last
		result << list[last]
		last -= 1
		break if first > last
		result.unshift(list[last])
		last -= 1
		break if first > last
		result << list[first]
		first += 1
		break if first > last
		result.unshift(list[first])
		first += 1
	end
	result
end
 
c1 = calc(arrange(list))
c2 = calc(arrange(list.reverse))
 
puts [c1, c2].max

Measured memory_bytes: 7024
#include<bits/stdc++.h>
#define int long long
using namespace std;
int x;
signed main()
{
	scanf("%lld",&x);
	for(int i=0;i<=1000;i++)for(int j=i;j<=1000;j++)
	{
		int i5=i*i*i*i*i,j5=j*j*j*j*j;
		if(i5+j5==x)
		{
			printf("%lld %lld",i,-j);
			return 0;
		}
		if(i5-j5==x)
		{
			printf("%lld %lld",i,j);
			return 0;
		}
		if(-i5+j5==x)
		{
			printf("%lld %lld",j,i);
			return 0;
		}
		if(-i5-j5==x)
		{
			printf("%lld %lld",-i,j);
			return 0;
		}
	}
	return 0;
}

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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

int main(){
    int x;
    cin>>x;

    if(x==0)cout<<1<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000; // 読み取り専用（書き換え不可)

int lcs(string X, string Y){
    int c[N+1][N+1];
    int m = X.size();
    int n = Y.size();
    int maxv = 0;
    X = ' ' + X; //X[0]に空白を挿入
    Y = ' ' + Y; //Y[0]に空白を挿入
    for(int i=0;i<=m;i++){
        c[i][0] =0;
    }
    for(int j=1;j<=n;j++){
        c[0][j] =0; 
    }
    for(int i = 1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(X[i] == Y[j]){
                c[i][j] = c[i-1][j-1]+1;
            }
            else{
                c[i][j] = max(c[i-1][j],c[i][j-1]);
            }
         maxv = max(maxv,c[i][j]);   
        } 
    }
    return maxv;
}

int main(){
    string s1,s2;
    int n; 
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s1 >> s2;
        cout << lcs(s1,s2) << endl;
    }
    return 0;
}



Measured memory_bytes: 7088
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, m = sc.nextInt()
  val broken = Array.fill(n+1)(false)
  for (_ <- 1 to m) broken(sc.nextInt()) = true
  val dp = Array.fill(n+1)(-1L)
  dp(0) = 1L
  dp(1) = if (broken(1)) 0L else 1L
  for (i <- 2 to n) {
    if (broken(i)) {
      dp(i) = 0L
    } else {
      dp(i) = (dp(i-1) + dp(i-2)) % 1000000007
    }
  }
  println(dp.last)
}


Measured memory_bytes: 58492
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;


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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    vector<ll> v(n);
    vector<ll> w(n);
    rep(i,n) cin>>v[i];
    rep(i,n) sum+=v[i]-1;
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

int main() {

	ll n, m;
	cin >> n>> m;

	vector<ll> x(n + 1), y(m + 1);

	repn(i, n) cin >> x[i];
	repn(i, m) cin >> y[i];

	vector<ll> a(n), b(m);

	repn(i, n - 1) a[i] = x[i + 1] - x[i];
	repn(i, m - 1) b[i] = y[i + 1] - y[i];

	ll A = 0;
	repn(i, n - 1) {
		ll x = a[i] * i%MOD*(n - i) % MOD;
		A = (A + x) % MOD;
	}

	ll B = 0;
	repn(i, m - 1) {
		ll x = b[i] * i%MOD*(m - i) % MOD;
		B = (B + x) % MOD;
	}

	cout << A * B%MOD;
	
	system("PAUSE");
}


Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const int MOD = (int) 1e9 + 7;

vector<int> factors;

void func(int n) {
    for (int i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            ++factors[i];
            n /= i;
        }
    }
    if (n != 1) ++factors[n];
}

int main() {
    int n;
    cin >> n;
    factors = vector<int>(n + 1, 0);
    for (int i = 2; i <= n; ++i) {
        func(i);
    }

    ll ans = 1;
    for (int i = 2; i <= n; ++i) {
        if (factors[i] > 0) (ans *= factors[i] + 1) %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<math.h>
#include<algorithm>

using namespace std;


int main(){

    long long n;
    string s;
    cin >> n;
    cin >> s;

    long long ans[n+1];
    for(long long i=0;i<n+1;i++)ans[i] = 0;

    for(long long i=0;i<n;i++){
        if(s[i]=='.')ans[0]++;
    }
    for(long long i=0;i<n;i++){
        if(s[i]=='#')ans[i+1]=ans[i]+1;
        else ans[i+1]=ans[i]-1;
    }

    sort(ans, ans+n+1);
    cout << ans[0] << endl;
}


Measured memory_bytes: 2180
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    if(((a-1)/d+1)*b>=c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define plll pair<ll, pll>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}

using pss = pair<string, string>;

int main(){
	int n;
	cin >> n;
	string str;
	cin >> str;
	map<pss, int> left;
	rep(i, bit(n)){
		string r;
		string b;
		rep(j, n){
			if(bit(j)&i)r+=str[j];
			else b+=str[j];
		}
		++left[pss(r, b)];
	}
	ll ans = 0;
	rep(i, bit(n)){
		string r;
		string b;
		rep(j, n){
			if(bit(j)&i)r+=str[j+n];
			else b+=str[j+n];
		}
		reverse(all(r));
		reverse(all(b));
		pss d(b, r);
		if(left.count(d))ans += left[d];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 46080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int mod = 1000000007;

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

ll dp[100005][5];

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

    dp[0][0] = 1;
    for(int i=0; i<s.size(); i++){
        for(int j=0; j<5; j++){
            if(s[i] == '?') add(dp[i+1][j], dp[i][j] * 3 % mod);
            else add(dp[i+1][j], dp[i][j]);
        }
        if(s[i] == 'A' || s[i] == '?') add(dp[i+1][1], dp[i][0]);
        if(s[i] == 'B' || s[i] == '?') add(dp[i+1][2], dp[i][1]);
        if(s[i] == 'C' || s[i] == '?') add(dp[i+1][3], dp[i][2]);
    }

    cout << dp[s.size()][3] << endl;
}

Measured memory_bytes: 4352
//coded by not_surrender

#pragma GCC optimize( "Ofast" )

#include <bits/stdc++.h>

#define MAXN 404
#define oo (1ll<<60)
#define MOD 1000000007
#define mid ((a+b)/2)
#define L (nod*2)
#define R (nod*2+1)
#define pb push_back

using namespace std;

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

ll N, A[MAXN], dp[MAXN][MAXN], tab[MAXN];

bool mk[MAXN][MAXN];

void solve( int a, int b ){
	mk[a][b] = true;
	if ( a == b ){
		dp[a][b] = A[a];
		return;
	}
	dp[a][b] = oo;
	for ( int i = a; i < b; ++i ){
		if ( !mk[a][i] )
			solve( a, i );
		if ( !mk[i+1][b] )
			solve( i+1, b );
		dp[a][b] = min( dp[a][b], dp[a][i]+dp[i+1][b] );
	}
	dp[a][b] += tab[b]-tab[a-1];
}

int main(){

    #ifndef ONLINE_JUDGE
        //~ freopen( "a.txt", "r", stdin );
    #endif // ONLINE_JUDGE

    ios_base::sync_with_stdio( false );
    cin.tie( NULL ), cout.tie( NULL );
    
    cin >> N;
    
    for ( ll i = 1; i <= N; ++i )
		cin >> A[i], tab[i] = A[i]+tab[i-1];
		
	solve( 1, N );
	
	cout << dp[1][N]-tab[N] << '\n';
	
return 0;
}


Measured memory_bytes: 1792
n = int(input())
abc = []
dp = [[0 for i in range(3)]for j in range(n)]
for i in range(n):
    abc.append(list(map(int,input().split())))
dp[0] = abc[0]
for i in range(1,n):
    for j in range(3):
        for k in range(3):
            if j != k :
                dp[i][k] = max(dp[i][k],dp[i-1][j]+abc[i][k])
print(max(dp[-1]))


Measured memory_bytes: 51952
N, M = map(int, input().split())
*H, = map(int, input().split())
d = {i:[] for i in range(1, N+1)}
for _ in range(M):
    A, B = map(int, input().split())
    d[A].append(B)
    d[B].append(A)

ans = 0
for i in range(1, N+1):
    cd = [H[j-1] for j in d[i]]
    v = max(cd) if cd else 0
    if H[i-1]>v:
        ans += 1

print(ans)


Measured memory_bytes: 37744
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 1e5;
int arr[N + 5];
int state[N + 5];
int n;

int calc(int x) {
	if(state[x] != -1) return state[x];
	state[x] = 0;
	for(int i = 0;i < n;i++) {
		int nx = x - arr[i];
		if(nx < 0) continue;
		state[x] = max(state[x], 1 - calc(nx));
	}
	return state[x];
}

void hora(int tc) {
	int k;
	cin>>n>>k;
	for(int i = 0;i < n;i++) cin>>arr[i];
	sort(arr,arr + n);
	memset(state,-1,sizeof state);
	for(int i = 0;i < arr[0];i++) state[i] = 0;
	int res = calc(k);
	if(res == 1) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}



Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
ll n,h[100005],dp[100005];
int main(){
   cin>>n;
   for(int i=1;i<=n;i++) cin>>h[i];
   dp[2]=abs(h[1]-h[2]);
   for(int i=3;i<=n;i++) dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
   cout<<dp[n];
   return 0;
}

Measured memory_bytes: 5092
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    ll n,c;
    cin >> n >> c;
    vector<vector<ll>> p(c,vector<ll>(100010));
    rep(i,n){
        ll s,t,ch;
        cin >> s >> t >> ch;
        ch--;
        p[ch][s]++;
        p[ch][t+1]--;
    }
    rep(i,c){
        for(ll j=0;j<=100005;j++){
            p[i][j+1]+=p[i][j];
        }
    }
    ll ans=0;
    for(ll i=0;i<=100000;i++){
        ll cnt=0;
        rep(j,c){
            if(p[j][i]==1) cnt++;
        }
        ans=max(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 27524