akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main()
{
  int n,a[100001]={};
  cin >> n;
  rep(i,n)
  {
    cin >> a[i];
  }
  int i = 0, cnt = 0;
  while(i != 1)
  {
    i = a[i] - 1;
    cnt++;
    if(cnt == n)
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
#define M 1000000007
using namespace std;

long long pow[200001];
long long C[200000];

int main() {
    int n, i;
    scanf("%d", &n);

    for(i = 0; i < n; i++) scanf("%lld", &C[i]);
    sort(C, C + n);
    reverse(C, C + n);

    pow[0] = 1;
    for(i = 1; i <= n; i++) pow[i] = (pow[i - 1] * 2) % M;

    long long ans = 0;
    for(i = 0; i < n; i++) {
        long long res = pow[i];
        if (i > 0) res = (res + pow[i - 1] * i) % M;
        res = (res * C[i]) % M;
        res = (res * pow[n - i - 1]) % M;
        ans = (ans + res) % M;
    }

    printf("%lld\n", (ans * pow[n]) % M);
    return 0;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto& vv : V) os << vv << ","; os << "]";
  return os;
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

string s;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> s;
  int i = 0;
  while(i < SZ(s) && s[i] != 'C')i++;
  while(i < SZ(s) && s[i] != 'F')i++;
  if(i == SZ(s))
    cout << "No\n";
  else
    cout << "Yes\n";
}


Measured memory_bytes: 256
n, m, x = list(map(int, input().split()))
alist = list(map(int, input().split()))
leftcost = len(list(filter(lambda num: num < x, alist)))
rightcost = len(list(filter(lambda num: num > x, alist)))
print(leftcost if leftcost <= rightcost else rightcost)



Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	if(n == 1 && m == 1)
	{
		printf("1");
	}
	else if(n == 1)
	{
		printf("%d",m - 2);
	}
	else if(m == 1)
	{
		printf("%d",n - 2);
	}
	else
	{
		printf("%lld",(long long)(n - 2) * (m - 2));
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define mod 998244353

using namespace std;
typedef long long ll;
const int MAXN = 1000005; 
inline int readint()
{
	int res = 0, f = 1;
	char c = 0;
	while(!isdigit(c))
	{
		c = getchar();
		if(c=='-')
			f = -1;
	}
	while(isdigit(c))
		res = res*10+c-'0', c = getchar();
	return res*f;
}
int n,a[MAXN];
ll sum[MAXN],prd[MAXN];
inline void insert(int id, int x)
{
	prd[id] = (prd[id]+sum[id]*x)%mod;
	sum[id] = (sum[id]+x)%mod;
}
inline ll qpow(ll a, int b)
{
	ll res = 1;
	for(; b; a = a*a%mod, b >>= 1)
		if(b&1)
			res = res*a%mod;
	return res; 
}
inline ll getInv(int x)
    { return qpow(x,mod-2); }

int main()
{
	n = readint();
	for(int i = 1; i<=n; i++)
		a[i] = readint();
	for(int i = 1; i<=n; i++)
	{
		int x = a[i];
		for(int j = 1; j*j<=x; j++)
			if(x%j==0)
			{
				insert(j,x);
				if(j*j!=x)
					insert(x/j,x);
			}
	}
	for(int i = 1000000; i>=1; i--)
	    for(int j = 2*i; j<=1000000; j += i)
	    	prd[i] = (prd[i]-prd[j]+mod)%mod;
	ll ans = 0;
	for(int i = 1; i<=1000000; i++)
		ans = (ans+prd[i]*getInv(i))%mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 18688
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,k;
	cin>>n>>k;
	if(n%2){
		vi in(k,n/2+1);
		rep(q,k/2){
			int w=in.size();
			auto it=in.end();
			it--;
			if(in[w-1]==1)in.erase(it);
			else{
				in[w-1]--;
				while(in.size()!=k)in.pb(n);
			}
		}
		rep(i,in.size())cout<<in[i]<<" \n"[i==k-1];
	}else{
		cout<<n/2;
		rep(i,k-1)cout<<" "<<n;cout<<endl;
	}
}









Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    long long q,h,s,d;
    long long N;
    long long ans=0;
    cin>> q >> h >> s >> d>> N;
    pair<long long,double> pri[4];
    pri[0] = make_pair(q*8,0.25);
    pri[1] = make_pair(h*4,0.5);
    pri[2] = make_pair(s*2,1);
    pri[3] = make_pair(d,2);
    sort(pri,pri+4);
    for(int i=0;i<4;i++){
        if(pri[i].second==0.25){
            pri[i].second=1;
            pri[i].first /= 2;
        }else if(pri[i].second==0.5){
            pri[i].second=1;
            pri[i].first /= 2;
        }else if(pri[i].second==1){
            pri[i].first /= 2;
        }
        long long d = N/pri[i].second;
        ans+=pri[i].first*d;
        N=fmod(N,pri[i].second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    n, m = map(int, input().split())
    u = UnionFind(n)
    for _ in range(m):
        a, b = map(int, input().split())
        u.union(a - 1, b - 1)
    print(u.group_count() - 1)
    
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 13092
#include<stdio.h>
#define FREE 0
#define NOT_FREE 1
#define N 8
#define M 15

int r, c, row[N], col[N], dpos[M], dneg[M];

int putQueen(int i){

  int j;

  if(i == N){
    return 0;
  }  
  
  if(row[i] == -1){ 
    for(j = 0 ; j < N ; j++){
      if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE){
	continue;
      }
   
      row[i] = j;
      col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
      if(putQueen(i+1) == 0){
	return 0;
      }
      row[i] = -1;
      col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
    }
  }
  else{
    if(putQueen(i+1) == 0){
	return 0;
    }
  }

}

int main(){

  int i, j, k;

  for(i = 0 ; i < N ; i++){
    row[i] = -1;
  }
  
  scanf("%d", &k);
  for(i = 0 ; i < k ; i++){
    scanf("%d%d", &r, &c);
    row[r] = c;
    col[c] = NOT_FREE;
    dpos[r+c] = NOT_FREE;
    dneg[r-c+N-1] = NOT_FREE;
  }

  putQueen(0);

  for(i = 0 ; i < N ; i++){
      for(j = 0 ; j < N ; j++){
	if(row[i] == j){
	  printf("Q");
	}
	else{
	  printf(".");
	}
      }
      printf("\n");
    }
  
  return 0;
}

Measured memory_bytes: 572
import collections

N = int(input())

S = list(input())
ScountList = collections.Counter(S)
result = ScountList['R'] * ScountList['G'] * ScountList['B']

for i in range(0, N):
    for j in range(i + 1, N):
        k = 2 * j - i
        if k >= N:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            result -= 1
            
print(result)

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

int main(void) {
	int D, N; cin >> D >> N;
	int i;

	if (N == 100) {
		if (D == 0) {
			cout << "101" << endl;
			return 0;
		}
		else if (D == 1) {
			cout << "10100" << endl;
			return 0;
		}
		else if (D == 2) {
			cout << "1010000" << endl;
			return 0;
		}
	}else if (N != 100) {
		if (D == 0) {
			for (i = 1; i < N; i++) {}
		}
		else if (D == 1) {
			for (i = 100; i < N * 100; i += 100) {}
		}
		else if (D == 2) {
			for (i = 10000; i < N * 10000; i += 10000) {}
		}
	}

	cout << i << endl;
	return 0;
}



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

int main(){
  int n,L,i;
  cin>>n>>L;
  if(L>=0){
    cout<<n*L+n*(n-1)/2-L;
    return 0;
  }
  if(L+n-1>=0){
    cout<<n*L+n*(n-1)/2;
    return 0;
  }
  cout<<n*L+n*(n-1)/2-(L+n-1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll k;
  cin >> k;
  ll num = 7;
  for (ll i = 1; i <= k; i++){
    num %= k;
    if(num==0){
      print(i);
      return 0;
    }
    num *= 10;
    num += 7;
  }
  print(-1);
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(){
int n;
  cin >>n;
  int c[n],s[n],f[n];
  for(int i=0;i<n-1;i++){
    cin >>c[i]>>s[i]>>f[i];
  }
  for(int i=0;i<n-1;i++){
    int time =0;
      for (int j=i;j<n-1;j++){
        int m =max(time,s[j]);
        int a = (m-1)/f[j];
        time =(a+1)*f[j]+c[j];
      }
    cout << time << endl;
  }
  cout << "0" << endl;
  return 0;
}

    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n,s = 0;
  cin >> n;
  int a[n],b[n],c[n];
  for(int i = 0;i<n;i++) cin >> a[i];
  for(int i = 0;i<n;i++) cin >> b[i];
  for(int i = 0;i<n-1;i++) cin >> c[i];
  for(int i = 0;i<n;i++)
  {
      s += b[a[i]-1];
      if(i > 0)
      {
          if(a[i-1]+1 == a[i]) s+=c[a[i-1]-1];
      }
  }
  cout << s << endl;
  return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	string str;cin >> str;
	int l = 0;
	int r = str.size() - 1;
	int ans = 0;
	while(l < r){
		if(str[l] != str[r])ans++;
		l++;
		r--;
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

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

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

    cout << count << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	int n=nxi(),q1=nxi(),q2=nxi(),lst=nxi();
	lint ans=0;
	for(int i=2; i<=n; ++i){
		int cur=nxi();
		ans+=std::min((lint)q2,(lint)(cur-lst)*q1);
		lst=cur;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, q; cin >> n >> q;
	vector<int> WAnum(n+1,0);
	vector<bool> v(n+1, false);
	int ans1=0, ans2=0;
	rep(i, q) {
		int a; string s;
		cin >> a >> s;
		if (v[a]) continue;
		if (s == "WA") {
			WAnum[a]++;
		}
		else {
			v[a] = true;
			ans1++;
			ans2 += WAnum[a];
		}
	}
	cout << ans1 << " " << ans2 << "\n" << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <math.h>

using namespace std;

int main () {
	int A, B, X;
	cin >> A >> B >> X;
	if(X>=A && X <(A+B)) cout << "YES" <<endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
const int INF = 0x7fffffff;
const int maxn = 1e5+10;
const int MOD = 1e9 + 7;
const int M = 1e9+10;

long long a[maxn];

void init()
{
    a[0]=1;
    for(int i=1;i<=maxn;i++){
         a[i]=(a[i-1]*i)%MOD;
    }
}
int n;
int pos[maxn];
int main()
{
  //  freopen("acm.txt","r",stdin);
    init();
    while(scanf("%d",&n)!=EOF){
        for(int i=0;i<n;i++)
            scanf("%d",&pos[i]);
        int k=1;
        int cnt = 0;
        long long ans = 1;
        for(int i=0;i<n;i++){
          //  cout << "cnt: " << cnt<<" " << "k: " << k <<" " << pos[i] << endl;
            if(k <= pos[i] && i!=n-1){
                k+=2;
                cnt++;
            }else if(k <= pos[i] && i==n-1){
                ans = ans * a[cnt + 1] % MOD;
              //  cout << "ans1: " << ans <<  endl;
            }else if(i!=n-1){
                ans = ans * (cnt + 1) % MOD;
             //   cout << "ans2: " << ans <<  endl;
            }else{
                ans = (ans * a[cnt+1] ) % MOD;
              //   cout << "ans3: " << ans <<  endl;
            }
        }
        printf("%I64d\n",ans);
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define M   1000000007 // 1e9 + 7
#define MAXN 100100
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
	
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}
const int N = 3005;
double dp[N][N];
double p[N];

int32_t main(){
	fastio;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>p[i];
	}
	dp[0][0] = 1.0;
	for(int i=1;i<=n;i++){
		for(int c=n;c>=0;c--){
			if(c==0)dp[i][c] = 1.0*dp[i-1][c]*(1.0 - p[i]);
			else dp[i][c] = (1.0*dp[i-1][c]*(1.0 - p[i]) + 1.0*dp[i-1][c-1]*p[i]);
		}
	}
	double prob=0;
	for(int i=1;i<=n;i++){
		if(i>n-i)prob+=dp[n][i];
	}
	cout<<setprecision(10)<<fixed;
	cout<<prob<<endl; 
}

Measured memory_bytes: 70656
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main{

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

	private Scanner scan;
	private String str,index;
	
	Map<String ,List<String>> bookIndex;

	private void mainrun() {
		scan = new Scanner(System.in);

		bookIndex = new TreeMap<>();

		while(scan.hasNext()) {
			str = scan.next();
			index = scan.next();

			if(!bookIndex.containsKey(str)) {
				bookIndex.put(str, new ArrayList<String>());
			}
			bookIndex.get(str).add(index + " ");
		}

		bookIndex.forEach((k , v)->{
			System.out.println(k);
			int lastindex = v.size() - 1;

			v.sort((v1 , v2) -> Integer.parseInt(v1.trim()) - Integer.parseInt(v2.trim()));
			v.set(lastindex, v.get(lastindex).trim() + "\n");

			v.forEach(System.out::print);
		});
		scan.close();
	}
}


Measured memory_bytes: 32100
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define eps 1e-67
#define pf printf
#define sf scanf
#define sd(n) scanf("%d",&n)
#define sd2(n1,n2) scanf("%d %d",&n1,&n2)
#define slf(n) scanf("%lf",&n)
#define slf2(n1,n2) scanf("%lf %lf",&n1,&n2)
#define sLf(n1) scanf("%Lf",&n1)
#define sLf2(n1,n2) scanf("%Lf %Lf",&n1,&n2)
#define sl(n) scanf("%lld",&n)
#define sl2(n1,n2) scanf("%lld %lld",&n1,&n2)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define repb(i,a,b) for(long long int i=a;i>=b;i--)
#define repa(i,a,b,c) for(long long int i=a;i<b;i=i+c)
#define reps(i,a,b,c) for(long long int i=a;i>b;i=i-c)
#define asort(a) sort(a.begin(),a.end())
#define asortb(a,comp) sort(a.begin(),a.end(),comp)
#define arev(a) reverse(a.begin(),a.end())
#define all(v) (v).begin(),(v).end()
#define allc(v,comp) (v).begin(),(v).end(),comp
#define allrc(v,a,b,comp) (v).begin()+a,(v).end()-b,comp
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define pbb pop_back
#define mp make_pair
#define mt make_tuple
#define bs(v,x) binary_search(v.begin(),v.end(),x)
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define tl(c) towlower(c)
#define root(x) sqrt(x)
#define power(a,n) pow(a,n)
#define tu(c) towupper(c)
#define sq(a) ((a)*(a))
#define cube(a) ((a)*(a)*(a))
#define mx 1000
#define MX 100000
#define mod 1000000007
using namespace std;
typedef string str;
typedef long long int ll;
typedef double lf;
typedef long double llf;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef char ch;
typedef map<ll,ll> mpl;
void Solve()
{
    ll x,i,ans;
    cin>>x;
    ans=x;
    for(i=1; ;i++)
    {
        ll sum=(i*(i+1))/2;
        if(sum>=x)
        {
            break;
        }
    }
    ans=min(x,i);
    cout<<ans<<endl;
}
int main()
{
    Solve();
    return 0;
}

Measured memory_bytes: 256
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli x=0ll;
    cin>>x;
    lli sum=100;int ct=0;
    while(true)
    {
        ++ct;
        sum+=(1ll*sum)/100;
        if(sum>=x)
            break;
    }
    cout<<ct<<endl;
}

Measured memory_bytes: 3652
#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>
#include<complex>
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 = 4000001;
const double eps = 1E-18;

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 fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

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

ll N, M;
vector<vector<ll>> g;
vector<ll> con;

void dfs(ll v, ll i) {
	con[v] = i;
	
	for (ll w : g[v]) {
		if (con[w] != -1) { continue; }
		dfs(w, i);
	}
	return;
}


int main() {
	cin >> N >> M;
	vector<ll> a(N);
	rep(i, N) cin >> a[i];

	g.resize(N);
	con.assign(N, -1);

	repn(i, M) {
		ll x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	
	ll L = 0;
	rep(i, N) {
		if (con[i] != -1) { continue; }
		dfs(i, L);
		L++;
	}

	//rep(i, N) cout << con[i] << endl;

	vector<vector<pair<ll,ll>>> gr(L);
	rep(i, N) {
		gr[con[i]].push_back({ a[i],i });
	}

	rep(i, L)sort(gr[i].begin(), gr[i].end());

	if (2 * L - 2 > N) { cout << "Impossible" << endl; }
	else if (L == 1) { cout << 0 << endl; }
	else {
		ll ans = 0;
		rep(i, L) {
			ans += gr[i][0].first;
			a[gr[i][0].second] = INF;
		}

		sort(a.begin(), a.end());
		rep(i, L - 2) { ans += a[i]; }

		cout << ans << endl;

	}

	system("PAUSE");
}


Measured memory_bytes: 10360
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;
 
double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
 
#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif
 
#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
 
inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}
 
inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}
 
inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}
 
inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}
 
inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}
 
inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}
 
//end of jonathanirvings' template v3.0.3 (BETA)
 
int a,b;
 
int main()
{
  scanf("%d %d",&a,&b);
  printf("%d\n",(a+b)%24);
  return 0;
}

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

using namespace std;

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

int main() {
	ll mod = 1e9 + 7;
	int n;
	cin >> n;
	ll cnt[n + 1];
	for (int i = 0; i <= n; i++) {
		cnt[i] = 1;
	}
	for (int i = 2; i <= n; i++) {
		int k = i;
		for (int j = 2; j <= k; j++) {
			while(k % j == 0) {
				cnt[j]++;
				k /= j;
			}
		}
	}
	
	ll ans = 1;
	for (int i = 0; i <= n; i++) {
		ans = (ans * cnt[i]) % mod;
	}
	
	cout << ans << endl;
	
	return 0;	
}

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

using namespace std;

int main()
{
    char efa[10];
    cin>>efa;
    if(efa[2]==efa[3] && efa[4]==efa[5])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    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 = sc.nextInt();

        int a = 0;
        for (int i = 1; i <= n; i++) {
            a += i;
        }

        System.out.println(a);
    }
}


Measured memory_bytes: 21588
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n,x;
    cin >> n >> x;
    int minm = 1000;
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        int m;
        cin >> m;
        x -= m;
        minm = min(minm, m);
        ans++;
    }
    cout << ans+x/minm << endl;
}

Measured memory_bytes: 256
from collections import Counter
import bisect
N=int(input())
A=list(map(int,input().split()))
C=list(Counter(A).values())
C.sort()
L=len(C)

# Cのうちx以上のものの個数D[x]を計算(x=0,...,N)
D=[L-bisect.bisect_left(C,x) for x in range(N+1)]
S=[0]
for n in range(1,N+1):
    S.append(S[-1]+D[n])

# T[x]=S[x]/x(x=1,...,N)としてKをbisect_rightで挿入した時のindexが答え
T=[x/S[x] for x in range(1,N+1)]
for K in range(1,N+1):
    print(bisect.bisect_right(T,1/K))

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

int main() {
   int n;
   cin >> n;
   int ans=0,h,hmax=-1;
   rep(i,n){
      cin >> h;
      if(h>=hmax)
      ans++;
      hmax=max(h,hmax);
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
int main(){
 
 ll n,k;
 cin>>n>>k;
 ll a[n+1];
 for(ll i=1;i<=n;i++) cin>>a[i];
 ll dp[n+1][k+1];
 ll prefix[n+1][k+1];
 memset(dp,0,sizeof(dp));
  for(ll i=0;i<=n;i++) dp[i][0]=1;
 memset(prefix,0,sizeof(prefix));
for(ll i=0;i<=n;i++) {
		prefix[i][0]=dp[i][0];
	
}
for(ll i=1;i<=k;i++) {
	prefix[0][i]=prefix[0][i-1]+dp[0][i];
}
  for(ll i=1;i<=n;i++){
  	for(ll j=1;j<=k;j++){
         ll r=j-a[i]-1;
         if(r>=0)
         dp[i][j]=((prefix[i-1][j]-prefix[i-1][r])+mod)%mod;
         else
         dp[i][j]=prefix[i-1][j];
         prefix[i][j]=(prefix[i][j-1]+dp[i][j])%mod;

       //  cout<<dp[i][j]<<" ";
  	}
  	//cout<<endl;
  }

  cout<<dp[n][k]<<endl;
}

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

using namespace std;

const int INF = 1e8;
const int MAX_V = 1010;
const double eps = 1e-10;

double cost[MAX_V][MAX_V];
double d[MAX_V];
int prev[MAX_V];
bool used[MAX_V];
int V;

void dijkstra(int s) {
    fill(d, d + V, INF);
    fill(used, used + V, false);
    fill(prev, prev+V, -1);
    d[s] = 0;
    while(true) {
        int v = -1;
        for(int u=0; u < V; u++){
            if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
        }
        if (v == -1) break;
        used[v] = true;

        for(int u=0; u < V; u++){
            if(d[u] > d[v] + cost[v][u]){
                d[u] = d[v] + cost[v][u];
                prev[u] = v;
            }
        }
    }
}

vector<int> get_path(int t){
    vector<int> path;
    for(; t != -1; t = prev[t]) path.push_back(t);
    reverse(path.begin(), path.end());
    return path;
}

int main(){
    while(cin >> V, V){
        for(int i=0; i< 1010; i++) for(int j=0; j< 1010; j++) cost[i][j] = INF;
        int b[1010];
        int bb[1010];
        double x[1010], y[1010];
        for(int i=0; i< V; i++){
            cin >> b[i] >> x[i] >> y[i];
            bb[b[i]] = i;
        }
        for(int i=0; i < V; i++){
            for(int j=0; j < V; j++){
                if(i == j) continue;
                double d = sqrt(pow(abs(x[i]-x[j]), 2)+pow(abs(y[i]-y[j]), 2));
                if(d-eps <=  50.0){
                    cost[i][j] = d;
                }
            }
        }
        int m;
        cin >> m;
        for(int p=0; p < m; p++){
            int s, g;
            cin >> s >> g;
            dijkstra(bb[s]);
            vector<int> path = get_path(bb[g]);
            if(path.size() ==1) cout << "NA" << endl;
            else{
                for(int i=0; i< path.size(); i++) cout << (i==0?"": " ") << b[path[i]];
                cout << endl;
            }
        }
    }
}

Measured memory_bytes: 9244
/*
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
//*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int n , x;

int32_t main(){
    migmig
    cin >> n >> x;
    if(x == 1 or x == n*2-1)
        dokme("No");
    cout << "Yes" << endl;
    int i , cnt;
    for(i = 1 , cnt = 0 ; cnt != n-2 ; i ++)
        if(i!=x and i!=x-1 and i!=x+1)  
            cout << i << endl,
            cnt++;
    cout << x-1 << endl;
    cout << x << endl;
    cout << x+1 << endl;
    for(; i < 2*n ; i ++)
        if(i!=x and i!=x-1 and i!=x+1)  
            cout << i << endl;
    return(0);
}

Measured memory_bytes: 3664
A,B = map(int, input().split())
ans = []
if A % 2 == 1:
  ans.append(A)
  s = A + 1
else:
  s = A

if B % 2 == 0:
  ans.append(B)
  g = B - 1
else:
  g = B

if (g-s+1) %  4 == 0:
  ans.append(0)
else:
  ans.append(1)

if len(ans) == 1:
  print(ans[0])
if len(ans) == 2:
  print(ans[0]^ans[1])
if len(ans) == 3:
  print(ans[0]^ans[1]^ans[2])

Measured memory_bytes: 3064
package main

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

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

func main() {
	list := getStdinIntArr64()
	N := list[0]
	var base int64 = 'z' - 'a' + 1

	n := N - 1
	/*
		fmt.Printf("%c", 'a'+((N/base/base)%base))
		fmt.Printf("%c", 'a'+(N/base)%base)
	*/
	/*
		if N >= 475255 {
			if ('a' - 1 + (n/base/base)%base) < 'a' {
				fmt.Printf("%c", 'z')
			} else {
				fmt.Printf("%c", 'a'-1+(n/base/base)%base)
			}
		}
		if N >= 18279 {
			if ('a' - 1 + (n/base/base)%base) < 'a' {
				fmt.Printf("%c", 'z')
			} else {
				fmt.Printf("%c", 'a'-1+(n/base/base)%base)
			}
		}
		if N >= 703 {
			if ('a' - 1 + (n/base/base)%base) < 'a' {
				fmt.Printf("%c", 'z')
			} else {
				fmt.Printf("%c", 'a'-1+(n/base/base)%base)
			}
		}
		if N >= 26 {
			if ('a' - 1 + (n/base)%base) < 'a' {
				fmt.Printf("%c", 'z')
			} else {
				fmt.Printf("%c", 'a'-1+(n/base)%base)
			}
		}
		fmt.Printf("%c", 'a'+(n%base))
		fmt.Printf("\n")
	*/

	//m := n
	str := ""
	for {
		mod := n % base
		str2 := fmt.Sprintf("%c", 'a'+mod)
		str = str2 + str

		n /= base
		if n == 0 {
			break
		}
		n--
	}
	fmt.Printf("%s\n", str)
	/*
		var decimalNum int64 = n                 // 変換元の10進数
		var baseNum int64 = int64('z' - 'a' + 1) // 何進数に変換するか
		var tmpNum int64 = int64(decimalNum)     // 途中計算を保存する用
		conversionNum := ""                      // 変換後の値格納用　11進以上はアルファベットのため、文字列で扱う必要がある

		for digitNum := 1; ; {

			remainder := tmpNum % baseNum
			if tmpNum/baseNum == 0 {
				conversionNum = string('A'+remainder) + conversionNum
			} else {
				conversionNum = string('a'+remainder) + conversionNum
			}

			tmpNum = tmpNum / baseNum
			if tmpNum == 0 {
				break
			}
			digitNum *= 10
		}
		fmt.Println(conversionNum)
	*/
	/*
		} else if N <= 702 {
			N -= 702

		} else if N <= 18278 {

		} else if N <= 475254 {

		} else {

		}
	*/

}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

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

    int A,B,C; cin >> A >> B >> C;
    if((A <= C and C <= B) or(B <= C and C <= A) ) {
        cout << "Yes" << endl;
        return 0;
    }
    else {
        cout << "No" << endl;
        return 0;
    }
}



Measured memory_bytes: 256
function Main(input) {
  const array = input.trim().split('\n')
  const N = parseInt(array[0])
  const A = array[1].split(' ').map(s => parseInt(s))

  var res = 0
  var right = 0
  var sum = 0

  for(var left = 0; left < N; ++left) {
    while(right < N && (sum ^ A[right]) === (sum + A[right])) {
      sum += A[right]
      ++right
    }

    res += right - left
        
    // しゃくとり法
    if (left === right) ++right
    else sum -= A[left]  // a[left] を削除 (sum ^= a[left] でも OK)
  }

  console.log(res)
  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

int main() {
    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<ll> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end(), greater<ll>());
    vector<ll> plusM(n);
    for (int i=0; i<n; i++) {
        plusM.at(i) = a.at(i) + m;
    }
    ll cnt = p;
    ll larger_cnt = 0;
    ll larger_sum = 0;
    for (ll i=p; i<n; i++) {
        ll cur = plusM.at(i);
        if (a.at(p-1) > cur) {
            break;
        }
        ll point = m * (v - (p-1) - (n-i));
        ll cur_larger = plusM.rend() - upper_bound(plusM.rbegin()+n-i, plusM.rend()-p+1, cur) - (p-1);
        ll cur_smaller = i - p + 1 - cur_larger;
        for (int j=p-1+larger_cnt; j<p+cur_larger-1; j++) {
            larger_sum += cur - a.at(j);
        }
        larger_cnt = cur_larger;
        if (point <= cur_smaller * m + larger_sum) {
            cnt++;
            if (i != n-1) {
                larger_sum -= larger_cnt * (cur - plusM.at(i+1));
            }
        } else {
            break;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int INF = 1001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vvll grid(101, vll(101, -1));
    ll a, b;
    rep(i, n) {
        ll x, y, h;
        cin >> x >> y >> h;
        if (h > 0) {
            a = x;
            b = y;
        }
        grid[x][y] = h;
    }
    
    rep(cx, 101) {
        rep(cy, 101) {
            bool flag = true;
            ll h = grid[a][b] + abs(a - cx) + abs(b - cy);
            rep(i, 101) {
                rep(j, 101) {
                    if (grid[i][j] == -1) continue;
                    if (grid[i][j] !=  max(h - abs(i - cx) - abs(j - cy), 0LL)) {
                        flag = false;
                    }
                }
            }
            if (flag) {
                cout << cx << " " << cy << " " << h << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)
using Graph = vector<vector<int>>;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  Graph G(N);
  for (int i = 0; i < M; ++i) {
      int a, b;
      cin >> a >> b;
      G[a-1].push_back(b-1);
      G[b-1].push_back(a-1);
  }
  vector<int> dist(N,-1); 
  queue<int> que;
  dist[0] = 0;
  que.push(0); 
  for (int nv : G[0]) {
          if (dist[nv] != -1) continue; 
          que.push(nv);}
  while (!que.empty()) {
      int v = que.front(); 
      que.pop();
      for (int nv : G[v]) {
          if (dist[nv] != -1) continue; 
          if(nv==N-1){
            cout<<"POSSIBLE";
            exit(0);
          }
      }
  }
  cout<<"IMPOSSIBLE";
}

Measured memory_bytes: 13168
A = int(input())
B = int(input())
C = int(input())
X = int(input())

a, b, c = [500, 100, 50]
count = 0

for _A in range(A+1):
  if (_A*a > X):
    break
  for _B in range(B+1):
    d = X - _A*a - _B*b
    if (d/c <= C and d>=0):
      count = count + 1

print("{}".format(count))

Measured memory_bytes: 3064
from decimal import *
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

M = mod = 10**9 + 7
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]
def li4():return [float(i) for i in input().rstrip('\n').split(' ')]

n,m = li()
l = []

for i in range(n):l.append(li2())
l[0][0] = 1


for i in range(1,n):l[i][0] = 1*l[i-1][0] if l[i][0] != '#' else 0

for j in range(1,m):l[0][j] = 1*l[0][j-1] if l[0][j] != '#' else 0

for i in range(1,n):
    for j in range(1,m):
        if l[i][j] != '#':
            l[i][j] = l[i-1][j] + l[i][j-1]
        else:l[i][j] = 0
        l[i][j]%=mod

print(l[-1][-1])

Measured memory_bytes: 141016
B_arr = [-1, 2, 5, 5, 4, 5, 6, 3, 7, 6]

N, M = (int(x) for x in input().split())
A_arr = [int(x) for x in input().split()]

d = [-1]*(10*N)
d[0] = 0

for i in range(1, N+1):
    for A in A_arr:
        d[i] = max(d[i], d[i-B_arr[A]]*10+A)

print(d[N])


Measured memory_bytes: 15156
s = tuple(input())
n = len(s)
count_0start = 0
count_1start = 0

for i in range(n)[::2]:
    if s[i] == '0':
        count_0start += 1
    else:
        count_1start += 1
    
for i in range(n)[1::2]:
    if s[i] == '1':
        count_0start +=1
    else:
        count_1start += 1

print(count_0start if count_0start < count_1start else count_1start)


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

using namespace std;

int main(){
  int n;
  int h[40] = {};
  cin >> n;
  for(int i = 0;i < n;i++)
    cin >> h[i];

  int max = h[0];
  int ans = 1;
  for(int i = 1;i < n;i++) {
    if(max <= h[i]){
      max = h[i];
      ans++;
    }
  }
  cout << ans << endl;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){

    int n;
    string s;
    cin >> n >> s;

    int ans = 0;

    for(int i = 0;i < s.length();i++){


        vector<int> tmp1_alpha(26,0),tmp2_alpha(26,0);

        string tmp1 = s.substr(0,i+1);
        string tmp2 = s.substr(i+1,n-tmp1.length());
        
        REP(j,tmp1.length()){
            tmp1_alpha[tmp1[j]-'a']++;
        }
        REP(j,tmp2.length()){
            tmp2_alpha[tmp2[j]-'a']++;
        }

        int count = 0;
        REP(j,26){
            if(tmp1_alpha[j] > 0 && tmp2_alpha[j] > 0){
                count++;
            }
        }

        ans = max(ans,count);

    }

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

Measured memory_bytes: 256
# vim: set fileencoding=utf-8:


def main():
    A, B, C, D = map(int, raw_input().split())
    l = A + B
    r = C + D

    if l == r:
        print("Balanced")
    elif l > r:
        print("Left")
    else:
        print("Right")


if __name__ == "__main__":
    main()


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main(){
  string w;
  bool contin = true;
  cin >> w;
  vecll a((unsigned char)'z' - (unsigned char)'a' + 1);
  forll(i, 0, w.size())
	a[(unsigned char)w[i] - (unsigned char)'a'] += 1;
  forll(i, 0, a.size())
	if ((a[i] % 2) != 0){
	  cout << "No" << endl;
	  contin = false;
	  break;
	}
  if (contin)
	cout << "Yes" << endl;
}

Measured memory_bytes: 256