akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String a=scan.next();
		int count=0;
		int ans[]=new int[a.length()];
		Arrays.fill(ans,-1);
		for(int i=0;i!=a.length();i++) {
			char b=a.charAt(i);
			if(b=='0') {
				ans[count]=0;
				count++;
			}if(b=='1') {
				ans[count]=1;
				count++;
			}
			if(b=='B'){
				count--;
				if(count<0) {
					count=0;
				}
				ans[count]=-1;
			}
			if(count<0) {
				count=0;
			}
		}
		for(int i=0;i!=a.length();i++) {
			if(ans[i]==-1) {
				break;
			}
			System.out.print(ans[i]);
		}
		System.out.println();
		
	}
	}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

lli n;
map<lli,vector<lli>> d;
map<pair<lli,lli>,lli> p;
vector<lli> ans;

lli cnt[100100];

void func(lli beforeColor,lli now,lli from){
	lli color=0;
	for(lli e:d[now]){
		if(color==beforeColor)color++;
		if(e==from)continue;
		lli index = p[mp(min(now,e),max(now,e))];
		ans[index] = color;
		func(color,e,now);
		color++;
	}
	return;
}

signed main(){

	lli n;
	cin>>n;
	ans.resize(n-1);
	REP(i,0,100100)cnt[i]=0;
	lli maxCnt=0;

	REP(i,0,n-1){
		lli a,b;
		cin>>a>>b;
		a--,b--;
		cnt[a]++;
		cnt[b]++;
		d[a].push_back(b);
		d[b].push_back(a);
		p[make_pair(a,b)]=i;
	}
	REP(i,0,n)maxCnt = max(maxCnt,cnt[i]);

	lli start;
	REP(i,0,n){
		if(cnt[i]==1){
			start = i;
			break;
		}
	}
	func(-1,start,-1);
	cout<<maxCnt<<endl;
	REP(i,0,ans.size()){
		cout<<ans[i]+1<<endl;
	}

	return 0;
}

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

/*int main()
{
    int a;
    cin >> a;
    cout << (a-2) * 180 << endl;
    return 0;
}*/
int main()
{
    int n, k;
    cin >> n >> k;
    if(k == 1){
        cout << 0 << endl;
    }
    else{
        cout << n-k << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef unsigned long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

ll N;

int main() {
    cin >> N;

    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = N / 10;
    N /= 10;

    while (N > 0) {
        ans += N / 5;
        N /= 5;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n,c,k=[int(i) for i in input().split()]
people=list(reversed(sorted([int(input()) for _ in range(n)])))
start=people[0]
cnt=1
ans=1
for i in people[1:]:
    if start-i<=k and i>=start-k and cnt<c:
        cnt+=1
    else:
        cnt=1
        ans+=1
        start=i
print(ans)

Measured memory_bytes: 8280
Q = int(input())
l_r = [[int(_) for _ in input().split()] for _ in range(Q)]
prime = [False]*(10**5+1)
Csum = [0]*(10**5+1)

for i in range(2, 10**5+1):
    if not prime[i]:
        for j in range(i*2, 10**5+1, i):
            prime[j] = True

cnt = 0
for i in range(3, 10**5+1, 2):
    if (not prime[i]) and (not prime[(i+1)//2]):
        cnt += 1
    Csum[i] = cnt

for i in l_r:
    print(Csum[i[1]]-Csum[i[0]-2])

Measured memory_bytes: 23572
#include<iostream>
using namespace std;
int a[101];
int j,v;
void sort(int N){
	for(int i=1;i<N;i++){
		v=a[i];
		j=i-1;
		while(a[j]>v&&j>=0){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		for(int k=0;k<N;k++){
			if(k>0) cout<<" ";
			cout<<a[k];
		} 
		cout<<"\n";
	}
	
}
int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	for(int k=0;k<N;k++){
			if(k>0) cout<<" ";
			cout<<a[k];
		}
	cout<<"\n"; 
	sort(N);
	
	
} 


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i, N) { cin >> A[i]; }
    rep(i, N) { cin >> B[i]; }
    vector<ll> over;
    ll shortage = 0;
    ll lessCnt = 0;
    rep(i, N) {
        ll a = A[i] - B[i];
        if(a < 0) {
            shortage += a * (-1);
            lessCnt++;
        } else {
            over.pb(a);
        }
    }
    sort(over.rbegin(), over.rend());
    vector<ll> sum(over.size() + 1);
    rep(i, over.size()) { sum[i + 1] = over[i] + sum[i]; }
    for(int i = 0; i <= sum.size(); i++) {
        if(sum[i] >= shortage) {
            cout << lessCnt + i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3316
from collections import defaultdict
n, k = map(int, input().split())

a = [int(input()) - k for _ in range(n)]
s = [0] * (n + 1)
for i in range(n):
	s[i + 1] = s[i] + a[i]

mp = defaultdict(int)
b = sorted(list(set(s)))
num = 1
for c in b:
	mp[c] = num
	num += 1
m = len(mp)
d = [0] * (m + 1)

def add(i):
	while i <= m:
		d[i] += 1
		i += i & -i
def qqq(i):
	res = 0
	while i > 0:
		res += d[i]
		i -= i & -i
	return res

ans = 0
for i in range(n + 1):
	ans += qqq(mp[s[i]])
	add(mp[s[i]])
print(ans)


Measured memory_bytes: 56372
A, B, C = map(int, input().split())
res = 0

if (A == B == C) and all([A % 2 ==0, B % 2 == 0, C % 2 ==0]):
  res = -1
else:
  while all([A % 2 ==0, B % 2 == 0, C % 2 ==0]):
    at, bt, ct = A/2, B/2, C/2
    A = bt + ct
    B = at + ct
    C = at + bt
    res += 1

print(res)

Measured memory_bytes: 9264
#include<cstdio>
using namespace std;
int main(){
  int h,w,g[8][8]={},l=0,flag=1;
  char s[8][10];
  scanf("%d %d",&h,&w);
  for(int i=0;i<h;i++)
    scanf("%s",s[i]);
  g[0][0]=1;
  for(int i=0;i<h;i++)
    for(;l<w;l++){
      if(l!=w-1&&g[i][l]&&s[i][l+1]=='#'){
        g[i][l+1]=1;
      }
      else if(i!=h-1&&g[i][l]&&s[i+1][l]=='#'){
        g[i+1][l]=1;
        break;
      }
    }
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(s[i][j]=='#'&&g[i][j]==0)
        flag=0;
  if(flag)
    printf("Possible\n");
  else
    printf("Impossible\n");
}
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
//#define int long long
//#define abs Abs
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int SMOD = 1000000007;
const int NMOD = 1000000009;
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
ll Abs(ll x){return (x<0 ? -x : x);}
bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
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 qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct xyz{
    xyz(){
        cin.tie(0), ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
    };
}xyzzy;


signed main(){
    int n;
    int m;
    int x[100005];
    cin >> n >> m;
    FOR(i,m){
        cin >> x[i];
    }
    sort(x,x+m);
    int ans = 0;
    int diff[100005];
    FOR(i,m-1){
        diff[i]=x[i+1]-x[i];
    }
    sort(diff,diff+m-1,greater<int>());
    iFOR(i,n-1,m)
        ans+=diff[i];
    cout << ans fin;
  return 0;
}


Measured memory_bytes: 1024
import string
import sys

#??????????????\????????????ip?????\??????
ip = sys.stdin.readlines()
for i in range(len(ip)):
    ip[i] = int(ip[i].strip("\n"))

#??????3??????????????????
h = [0]*3

#?????????????????????
for i in range(len(ip)):
    for j in range(len(ip)):
        if ip[i] > ip[j]:
            tmp = ip[i]
            ip[i] = ip[j] 
            ip[j] = tmp            

for i in range(3):
    if h != 0:
        print(ip[i])

Measured memory_bytes: 8248
#include <cmath>
#include <vector>
#include <iostream>
#include <limits>
#include <iostream>
#include <vector>
#include <cassert>
#include <complex>
#include <cstdio>
#include <set>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <queue>
#include <bitset>
#include <ctime>
#include <unordered_map>
#include <numeric>
#include <climits>

using namespace std;
typedef long long Long;
typedef long double Double;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
typedef pair<Long,Long> PLL;

int read(int &x) { return scanf("%d", &x); }
int read(int &x, int &y) { return scanf("%d%d", &x, &y); }
int read(int &x, int &y, int &z) { return scanf("%d%d%d", &x, &y, &z); }
int read(Long &x) { return scanf("%lld", &x); }
char buff[1000010];
int read(string &s) { int r = scanf("%s", buff); s = buff; return r; }

#define dlog2(n) (31-__builtin_clz(n))



int main() {

	int K, X;
	read(K, X);
	for (int i = X - K + 1; i <= X + K - 1; ++i) {
		cout << i << " ";
	}
	cout << endl;

	return 0;
}

/*
3 -> 2 -> 1
3 -> 1 -> 1
2 -> 1 -> 1
1 -> 2 -> 1
1 -> 1 -> 1



*/

Measured memory_bytes: 256
#include <stdio.h>


int main(int argc, char const *argv[])
{
    int a[6];
    for (size_t i = 0; i < 6; i++){scanf("%d",&a[i]);}
    if (a[4]-a[0]<=a[5]){
        printf("Yay!");
    }else{
        printf(":(");
    }
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int N;
  cin>>N;
  vector<int> L;
  REP(i,N){
    int a;
    cin>>a;
    L.PB(a);
  }
  SORT(L);
  
  bool CAN=true;
  
  if(L.at(N-1)==L.at(0)){
    if(L.at(0)!=N-1){
      if(L.at(0)>N/2) CAN=false;
    }
  }
  else if(L.at(N-1)==L.at(0)+1){
    int cnt=0;
    REP(i,N){
      if(L.at(i)==L.at(N-1)){
        cnt=i+(N-i)/2;
        break;
      }
    }
    if(cnt<L.at(N-1)) CAN=false;
    if(L.at(N-2)==L.at(0)) CAN=false;
    if(L.at(1)==1) CAN=false;
  }
  else CAN=false;
  
  if(CAN) COYe;
  else CONo;
  return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100005
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897
#define db long double  /* print with %Lf */
#define EPS 1e-9
#define flu fflush(stdout)
#define imp {cout<<"0\n"; return 0;}
#define yup {cout<<"YES\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}
#define debug_vecvec(vec,n) {rep(idxi,n) {for(auto idxi2:vec[idxi]) cout<<idxi2<<" "; cout<<"\n";}}

int main() {

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


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if(i*j==n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> a(n);
  std::cin >> a;

  int64_t ans = 1, min = a[0];

  for (int64_t i = 1; i < n; i++) {
    if (a[i] < min) {
      ans++;
    }
    min = std::min(min, a[i]);
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
  int N, M, k, tmp;
  cin >> N >> M;
  vector<vector<int>> s;
  vector<int> p;
  int ret = 0;
  for (int i=0; i<M; i++){
    cin >> k;
    vector<int> tmp2;
    for (int j=0; j<k; j++){
      cin >> tmp;
      tmp2.push_back(tmp);
    }
    s.emplace_back(tmp2);
  }
  for (int i=0; i<M; i++){
    cin >> tmp;
    p.push_back(tmp);
  }
  for (int i=0; i<pow(2, N); i++){
    vector<int> state;
    int Ntmp = i;
    for (int i=0; i<N; i++){
      state.push_back(Ntmp % 2);
      Ntmp /= 2;
    }
    reverse(state.begin(), state.end());
    int sum = 0;
    int on = 1;
    for (int i=0; i<M; i++){
      vector<int> v = s[i];
      sum = 0;
      for (int j=0; j<v.size(); j++){
        sum += state[v[j] - 1];
      }
      if (sum % 2 != p[i]){
        on = 0;
        break;
      }
    }
    ret += on;
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 384
from functools import reduce

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def gcd_list(numbers):
    return reduce(gcd, numbers)


N = input()
A = input().split()
for i in range(len(A)):
    A[i] = int(A[i])
answer = gcd_list(A)
print("{}".format(answer))

Measured memory_bytes: 11596
def main():
    import math
    n, m = map(int, input().split())
    if n - m <= -2 or n - m >= 2:
        print(0)
        exit()

    else:
        if n != m:
            ans = math.factorial(n) % (10**9 + 7) * math.factorial(m) % (10**9 + 7)
        else:
            ans = math.factorial(n) * 2 % (10**9 + 7) * math.factorial(m) % (10**9 + 7)

    print(ans)


    

 
    
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 4096
n = int(input())
lsn = [input() for _ in range(n)]
m = int(input())
lsm = [input() for _ in range(m)]
 
from collections import defaultdict
 
d = defaultdict(int)
 
for i in lsn:
    d[i] += 1
for j in lsm:
    d[j] -= 1
 
print(max(max(d.values()),0))

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

// マクロ
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x));
#define cou(x) cout << x << endl;
#define y() cout << "Yes" << endl;
#define n() cout << "No" << endl;
#define x2(x) x * x

// 型エイリアス
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

int main() {

	int N, T;
	cin >> N >> T;

	vi time(N);
	int p;
	rep(i, N) {
		cin >> p;
		time[i] = p;
	}
	time.push_back(time[N - 1] + T);

	lint timesum = 0;
	int laststart = 0;

	rep(i, N) {
		if (time[i + 1] - time[i] < T) {
			continue;
		}
		else {
			timesum += time[i] - time[laststart] + T;
			laststart = i + 1;
		}
	}

	cou(timesum)
}

Measured memory_bytes: 1792
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;

void solve() {
    int n;
    cin >> n;
    int t = n % 10;
    if (n % 10 == 3)
        cout << "bon";
    else if (t == 0 || t == 1 || t == 6 || t == 8)
        cout << "pon";
    else
        cout << "hon";
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007


void solve() {
        int n, m; cin >> n>> m;
        vector<int> v(n);

        lp(i, n) cin >> v[i];

        for (int i = m, j= 0; i< n; i++, j++) {
                if (v[j]< v[i]) {
                        cout << "Yes\n";
                } else cout << "No\n";
        }
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
struct node{
	string s;
	int name;
	int id;
}b[101];
int cmp(node a,node b){
	if(a.s==b.s){
		return a.name>b.name;
    }
	return a.s<b.s;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin>>b[i].s;
		cin>>b[i].name;
		b[i].id=i+1;
	}
	sort(b,b+n,cmp);
	for(int i=0;i<n;i++)
		printf("%d\n",b[i].id);
}

Measured memory_bytes: 3744
use std::io;
fn read<T: std::str::FromStr>() -> T {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn main() {
    let _n: u64 = read();
    let a: Vec<i64> = read_vec();
    let mut max = std::i64::MIN;
    let mut min = std::i64::MAX;
    let mut sum = 0;
    for x in &a {
        if max < *x {
            max = *x;
        }
        if min > *x {
            min = *x;
        }
        sum += *x;
    }
    println!("{} {} {}", min, max, sum);
}



Measured memory_bytes: 5036
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  long double a,b,h,m;
  cin >> a>>b>>h>>m;
  long double degh = (h*30 + 0.5*m);
  long double degm = m*6;
  //if(degh<degm)swap(degh,degm);
  long double theta = abs(degh-degm);
  theta = min(theta,abs(360-theta));
  // show(degh);
  // show(degm);
  //show(theta);
  theta = theta*M_PI/180.0;
  long double ans = sqrt(a*a+b*b-(2.0*a*b* cosl(theta)));
  if(h ==m){
    ans = abs(a-b);
  }
  if(h == 6 && m == 0){
    ans = a+b;
  }
  printf("%.20Lf\n",ans);
  return 0;
}

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

#include <cmath>

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

// {x. y}
vector<pair<int, int>> town;

void print_path(const vector<int> &path) {
    for (int i = 0; i < (int) path.size(); i++) {
        cout << path[i] <<  " ";
    }
    cout << endl;
}

double calc_path(const vector<int> &path) {
    double acc = 0;
    for (int i = 0; i < (int) path.size() - 1; i++) {
        ll d_x = town[path[i]].first - town[path[i + 1]].first;
        ll d_y = town[path[i]].second - town[path[i + 1]].second;
        acc += sqrt((d_x * d_x) + (d_y * d_y));
    }
    // print_path(path);
    // printf("%.7f\n", acc);
    return acc;
}

void solve(vector<int> &path, vector<bool> &visited, double &sum, const int N) {
    if ((int) path.size() == N) {
        sum += calc_path(path);
        return;
    }

    for (int i = 0; i < N; i++) {
        if (!visited[i]) {
            visited[i] = true;
            path.push_back(i);
            solve(path, visited, sum, N);
            path.pop_back();
            visited[i] = false;
        }
    }
}

ll factorial(const int n) {
    if (n <= 1) {
        return 1;
    }
    return n * factorial(n - 1);
}

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

    town.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> town[i].first >> town[i].second;
    }

    vector<int> path;
    vector<bool> visited(N, false);
    double sum = 0;
    solve(path, visited, sum, N);

    printf("%.7f\n", sum / double(factorial(N)));

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a<b)
  {
      cout<<"a < b"<<endl;
  }
  else if(a>b)
  {
      cout<<"a > b"<<endl;
  }
  else
  {
      cout<<"a == b"<<endl;
  }
}



Measured memory_bytes: 3024
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;
#define MAX_N 100000
int N, K;
int p[MAX_N+1];
int ans = 0;
vector<int> gp[MAX_N+1];

int d[MAX_N+1];

void dfs(int x){
	d[x] = 1;
	for(int i=0; i<gp[x].size(); i++){
		dfs(gp[x][i]);
		if(d[gp[x][i]]==K && x!=1){
			ans++;
		}else if(x!=1){
			d[x] = max(d[x], d[gp[x][i]]+1);
		}
	}
}


int main(){
	scanf("%d%d", &N, &K);
	for(int i=1; i<=N; i++){
		scanf("%d", &p[i]);
	}	
	if(p[1] != 1){
		p[1] = 1; ans++;
	}
	for(int i=2; i<=N; i++){
		gp[p[i]].push_back(i);
	}
	dfs(1);
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

const int N = 3;
vector<vi> c;
int a[N];
int b[N];

bool dfs(int d){
    if(d == N){
        rep(i, N){
            b[i] = c[0][i] - a[0];
        }
        rep(i, N){
            rep(j, N){
                if(c[i][j] != a[i] + b[j]) return false;
            }
        }
        return true;
    }

    bool ret = false;
    rep(k, -100, 101){
        a[d] = k;
        ret |= dfs(d + 1);
    }

    return ret;
}

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

    c = vector<vi>(N, vi(N));
    rep(i, N) rep(j, N) cin >> c[i][j];

    cout << (dfs(0) ? "Yes":"No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define INF 1000000000
using namespace std;

int minCost(vector<int>&v,int index,int k,vector<int>&cost){
    if(cost[index]!=-1){
        return cost[index];
    }
    if(index<=0){
        return 0;
    }
    else if(index==1){
        return cost[index] = abs(v[1]-v[0]); 
    }
    else{
        int c = 0;
        int minimum = INF;
        for(int i=1;i<=k;i++){
            if(index-i>=0){
                c = abs(v[index] - v[index-i]) + minCost(v,index-i,k,cost);
                minimum = min(minimum,c);
            }
        }
        return cost[index] = minimum;
    }
}

int32_t main(){
    int n,k;
    cin>>n>>k;
    vector<int> v;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    vector<int> cost;
    for(int i=0;i<n;i++){
        cost.push_back(-1);
    }
    cost[0] = 0;
    cout<<minCost(v,v.size()-1,k,cost)<<endl;
    return 0;
}

Measured memory_bytes: 11380
#include <iostream>
using namespace std;
int main(void){
    string a; 
    int b; b=0;
    cin>>a;
    if  (a[0]=='o'){
        b++;
    }
    if (a[1]=='o'){
        b++;
    }
    if (a[2]=='o'){
        b++;
    }
    cout<<b*100+700<<endl;
    
}


Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}
int keta(int a) {
	return to_string(a).size();
}
string s[55];
int a[55];
signed main() {
	int n;
	cin >> n;
	rep(i, n) {
		cin >> s[i] >> a[i];
	}
	string t;
	cin >> t;
	int ans = 0;
	bool b = false;
	rep(i, n) {
		if (b)ans += a[i];
		if (s[i] == t)b = true;
		
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int dp[105][3][2],a[105],n,m,p,q;
int main(){
	cin>>n>>m;for(int i=0;i<m;i++){cin>>p>>q;a[p]=q;}
	if(a[1]==0){dp[1][0][0]=1;dp[1][1][0]=1;dp[1][2][0]=1;}
	if(a[1]>=1)dp[1][a[1]-1][0]=1;
	for(int i=2;i<=n;i++){
		if(a[i]==0 || a[i]==1){
			dp[i][0][0]+=(dp[i-1][1][0]+dp[i-1][1][1]+dp[i-1][2][0]+dp[i-1][2][1]);dp[i][0][0]%=10000;
			dp[i][0][1]+=dp[i-1][0][0];dp[i][0][1]%=10000;
		}
		if(a[i]==0 || a[i]==2){
			dp[i][1][0]+=(dp[i-1][0][0]+dp[i-1][0][1]+dp[i-1][2][0]+dp[i-1][2][1]);dp[i][1][0]%=10000;
			dp[i][1][1]+=dp[i-1][1][0];dp[i][1][1]%=10000;
		}
		if(a[i]==0 || a[i]==3){
			dp[i][2][0]+=(dp[i-1][0][0]+dp[i-1][0][1]+dp[i-1][1][0]+dp[i-1][1][1]);dp[i][2][0]%=10000;
			dp[i][2][1]+=dp[i-1][2][0];dp[i][2][1]%=10000;
		}
	}
	cout<<(dp[n][0][0]+dp[n][0][1]+dp[n][1][0]+dp[n][1][1]+dp[n][2][0]+dp[n][2][1])%10000<<endl;
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	complex<double> Ans;
	complex<double> P[3];
	for(int i=0;i<3;i++){
		cin>> P[i].real()>> P[i].imag();
	}
	complex<double> T[2];
	complex<double> K[2];
	for(int i=0;i<2;i++){
		T[i].real() = (P[i].real() + P[i+1].real()) / 2;
		T[i].imag() = (P[i].imag() + P[i+1].imag()) / 2;
		complex<double> N;
		N = (P[i+1]-P[i])/abs(P[i+1]-P[i]);
		K[i].real() =  N.imag();
		K[i].imag() = -N.real();
	}
	double a = (T[1]-T[0]).real();
	double b = (T[1]-T[0]).imag();
	double x0 = K[0].real();
	double y0 = K[0].imag();
	double x1 = K[1].real();
	double y1 = K[1].imag();
	double m = ( a * y0 - b * x0 ) / ( x0 * y1 - x1 * y0 );
	K[1] *= m;
	Ans = K[1] + T[1];

	printf("%.3f %.3f %.3f", Ans.real(), Ans.imag(), abs(Ans-P[0]));
	printf("\n");
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(5);
	int n;
	cin>> n;
	for(int i=0;i<n;i++){
		solve();
	}
	return 0;
}

 

Measured memory_bytes: 1264
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x1;
        if (a % 2 == 0) {
            x1 = a * 25 / 2;
        } else {
            x1 = a * 25 / 2 + 1;
        }
        int x2 = b * 10;
        int result = -1;
        for (int i = Math.min(x1, x2); i <= Math.max(x1, x2); i++) {
            if (i * 2 / 25 == a && i / 10 == b) {
                result = i;
                break;
            }
        }
        System.out.println(result);
        sc.close();
    }
}

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

int main() {
   int a, b, c;
   cin >> a >> b >> c;

   if (b >= (c - a) && c >= a) {
       cout << "YES" << endl;
   } else {
       cout << "NO" << endl;
   }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<vector<ll>> matrix;

vector<int> edges[200005];
int dp[200005];
int n;
int dist;

int bfs(int s) {
  for(int i = 1; i <= n; i++) dp[i] = 1e9;
  dp[s] = 0;
  queue<int> q;
  int last = -1, curr;
  q.push(s);
  while(!q.empty()) {
    last = (curr = q.front());
    q.pop();
    dist = dp[last];
    for(int out: edges[curr]) {
      if(dp[out] == 1e9) {
        dp[out] = 1 + dp[curr];
        q.push(out);
      }
    }
  }
  return last;
}

void solve() {
  cin >> n;
  for(int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  bfs(bfs(1));
  if(dist % 3 == 1) cout << "Second\n";
  else cout << "First\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 13556
import sys
input = sys.stdin.readline
from collections import *

def judge(x):
    B = [x//Fi for Fi in F]
    cnt = 0
    
    for Ai, Bi in zip(A, B):
        cnt += max(0, Ai-Bi)
    
    return cnt<=K

def binary_search():
    l, r = 0, 10**14
    
    while l<=r:
        m = (l+r)//2
        
        if judge(m):
            r = m-1
        else:
            l = m+1
    
    return l

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
F = list(map(int, input().split()))
F.sort(reverse=True)
print(binary_search())

Measured memory_bytes: 137712
object Main extends App {
  val n = io.StdIn.readLine().toInt
  var arr = io.StdIn.readLine().split(" ").map(_.toInt)
  var count = 0
  while (arr.sum != 0) {
    count += arr.foldLeft((0, true))((acc, a) => {
      if (acc._2 && a != 0) (acc._1 + 1, false)
      else if (a == 0) (acc._1, true)
      else acc
    })._1
    arr = arr.map(x => if (x != 0) x - 1 else 0)
  }
  println(count)
}

Measured memory_bytes: 25664
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 500010
#define endl '\n'
#define mp make_pair
#define INF INT_MAX
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)            //counts no of ones in binary representation
#define w(t)     int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

bool isprime(ll n){			//to check whteher no is prime or not
	if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

int main(){
	fast;
	ll n,k;
	cin>>n>>k;
	ll a[n];
	ll temp=1;
	
	forn(i,n)	cin>>a[i];
	bool flag=1;
	for(ll i=k;i<n;i++){
		
		if(a[i]>a[i-k])	cout<<"Yes";
		else	cout<<"No";
		cout<<endl;
		//temp=temp2;
	}
	//cout<<"Case #"<<x<<": "<<y<<endl;
}

Measured memory_bytes: 5212
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization ("Ofast")
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define siz(s) (int)s.size()

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;
}
template<class T> inline int getidx(vector<T> &v, T a) {
	return lower_bound(all(v), a) - v.begin();
}

constexpr int mod=1e9+7;
constexpr int inf=3e18;


signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N,M;
	cin>>N>>M;
	int sum=0;
	rep(i,M){
		int a;cin>>a;sum+=a;
	}
	if(N<sum)cout<<"-1\n";
	else cout<<N-sum<<"\n";
}


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

int main(void){
    int n, k;
    cin >> n >> k;
    map<int,bool> ng;
    rep(i,k){
        int x;
        cin >> x;
        ng[x] = true;
    }
    while(true){
        string s = to_string(n);
        bool ok = true;
        rep(i,s.size()){
            if(ng[s[i]-'0']){
                ok = false;
            }
        }
        if(ok){
            cout << s << endl;
            break;
        }
        n++;
    }
    return 0;
}


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

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

    std::string s;
    std::cin >> s;

    std::string s_big_const   = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    std::string s_small_const = "abcdefghijklmnopqrstuvwxyz";

    int i = 0;
    while ( 1 ) {
        if ( i == 26 ) {
            break;
        }
        if ( s.substr(k-1 , 1) == s_big_const.substr(i, 1) ) {
            std::cout << s.replace(k-1, 1, s_small_const.substr(i, 1)) << std::endl;
            break;
        }
        i++;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>

using namespace std;

int main(){
    string s;
    getline(cin, s);
    int n = std::stoi(s);
    int x = n / 100;
    int y = n % 100;

    bool is_mmyy = (x >= 1) && (x <= 12);
    bool is_yymm = (y >= 1) && (y <= 12);

    if(is_yymm && is_mmyy){
        printf("AMBIGUOUS\n");
    }else if(is_yymm){
        printf("YYMM\n");
    }else if(is_mmyy){
        printf("MMYY\n");
    }else{
        printf("NA\n");
    }
    return 0;
}

Measured memory_bytes: 256
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 T = Long.parseLong(sc.next());
    long[] t = new long[N];
    for (int i = 0; i < N; i++) {
      t[i] = Long.parseLong(sc.next());
    }
    long ans = N * T;
    for (int i = 0; i < N - 1; i++) {
      ans -= Math.max(0L, t[i] + T - t[i + 1]);
    }
    System.out.println(ans);
  }
}

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

#define rep(n) for(ll i=0;i<n;i++)
#define repp(j, n) for(ll j=0;j<n;j++)
#define reppp(i, m, n) for(ll i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll h, w, tmp, d, l, r;
    cin >> h >> w >> d;
    Pll mp[h*w+1];
    ll p[h*w+1];
    rep(h){
        repp(j, w){
            cin >> tmp;
            mp[tmp] = Pll((ll)i, (ll)j);
        }
    }

    rep(d) p[i] = 0;
    reppp(i, d, 2*d){
        for(ll j=(ll)i;j<=w*h;j+=d){
            p[j] = abs(mp[j].first - mp[j-d].first) + abs(mp[j].second - mp[j-d].second) + p[j-d];
        }
    }

    int q;
    cin >> q;
    rep(q){
        cin >> l >> r;
        if(l == r) cout << 0 << endl;
        else cout << p[r] - p[l] << endl;
    }
}


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

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long cfunc(long long c)
{
  return c*(c-1)/2;
}

int main()
{
  long long n;
  cin >> n;
  
  long long l,a[n],c[n];
  long long i = 0;
  while(i<n)
  {
    cin >> a[i];
    c[i] = 0;
    i++;
  }

  i = 0;
  while(i < n)
  {
    c[a[i]-1]++;
    i++;
  }

  i = 0;
  long long count = 0;
  while(i<n)
  {
    count += cfunc(c[i]);
    i++;
  }

  i= 0;
  while(i< n)
  {
    cout << count - c[a[i]-1] + 1 << endl;
    i++;
  }

  return 0;
}


Measured memory_bytes: 5760
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

main = do
  [s] <- getString
  let xs = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
  print $ 7 - fromJust (findIndex (== s) xs)


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

ll N, M;

int main(void) {
  cin >> N >> M;
  cout << (100 * (N - M) + 1900 * M) * pow(2LL, M) << endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int A[100];
    int n, i;
    cin >> n;
    for (i = 0; i < n; i++)
        cin >> A[i];
    for (i = n-1; i >= 0; i--) {
        if (i < n-1)
            cout << ' ';
        cout << A[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3068
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<cstring>
#include<climits>
#include<queue>
using namespace std;
int N;
int main()
{
    scanf("%d",&N);
    if(N>999)printf("ABD");
    else printf("ABC");
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int K, N;
  while (cin >> K >> N) {
    vector<int> A(N);
    for (auto &x : A) cin >> x;
    int mx = 0;
    for (int i = 0; i < N; i++) {
      chmax(mx, (K + A[(i + 1) % N] - A[i]) % K);
    }
    int res = K - mx;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1152