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

#define REP(i,N) for(int (i)=0;i<(int)(N);i++)

template <class T> bool minn(T &a,T b) { return (a > b ? (a = b, 1) : 0); }
template <class T> bool maxn(T &a,T b) { return (a < b ? (a = b, 1) : 0); }

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

int dis[805][805],cur;
string f[805];

int nceil(int a,int b)
{
	return (a+b-1)/b;
}
int main(void)
{
	int N,M,K;

	cin >> N >> M >> K;

	int sx = -1,sy = -1;
	REP(i,N)
	{
		cin >> f[i];
		REP(j,M)
			if(f[i][j] == 'S')
			{
				sx = i;
				sy = j;
			}
	}

	queue<pair<int,int> > q;
	REP(i,N)
		REP(j,M)
			dis[i][j] = 1e9;
	dis[sx][sy] = 0;

	q.push({sx,sy});
	while(!q.empty())
	{
		int x=q.front().first, y=q.front().second;
		int ncur=dis[x][y];
		q.pop();

		REP(d,4)
		{
			int xx = x+dx[d],yy = y+dy[d];
			if(min(xx,yy) < 0 || min(N-xx,M-yy) <= 0 || dis[xx][yy] < 1e8 || f[xx][yy] == '#') continue;
			dis[xx][yy] = ncur+1;
			q.push({xx,yy});
		}
	}

	int ans=1e9;
	REP(i,N)
		REP(j,M)
		{
			if(dis[i][j] > K) continue;
			int res = 1e9;
			minn(res,nceil(i,K));
			minn(res,nceil(j,K));
			minn(res,nceil(N-i-1,K));
			minn(res,nceil(M-j-1,K));
			minn(ans,res+1);
		}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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

    map<int, int> ma;
    map<int, int> mb;

    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;
        if (i % 2 == 0) {
            ma[v]++;
        } else {
            mb[v]++;
        }
    }

    // {count, number}
    vector<pair<int, int>> va;
    for (auto &p : ma) {
        va.push_back({p.second, p.first});
    }
    sort(va.begin(), va.end());
    reverse(va.begin(), va.end());

    // {count, number}
    vector<pair<int, int>> vb;
    for (auto &p : mb) {
        vb.push_back({p.second, p.first});
    }
    sort(vb.begin(), vb.end());
    reverse(vb.begin(), vb.end());

    int ans;
    if (va[0].second != vb[0].second) {
        // input2.txt
        ans = n / 2 - va[0].first + n / 2 - vb[0].first;
    } else {
        if ((int) va.size() == 1 && (int) vb.size() == 1) {
            // input3.txt
            ans = n / 2; // min((int) va[0].first, (int) vb[0].first);
        } else if ((int) va.size() == 1) {
            // input4.txt
            ans = n / 2 - vb[1].first;
        } else if ((int) vb.size() == 1) {
            // input5.txt
            ans = n / 2 - va[1].first;
        } else {
            // input6.txt
            ans = min(n / 2 - va[0].first + n / 2 - vb[1].first, n / 2 - va[1].first + n / 2 - vb[0].first);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6136
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll n, k, a[200010];

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n >> k;
  REP(i, n) cin >> a[i];
  sort(a, a + n, greater<ll>());
  ll ans = 0;
  for(int i = k; i < n; ++i) ans += a[i];
  cout << ans;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int k, q, d[5005], dd[5005];
void init(){
    k = read(), q = read();
    for (int i = 0; i < k; ++i)
        d[i] = read();
}
void solve(){
    while (q--){
        int n = read(), x = read(), m = read();
        int ans = 0;
        int t1 = (n - 1) / k, t2 = (n - 1) % k;
        long long sum = x % m;

        for (int i = 0; i < k; ++i){
            int dd = d[i] % m;
            if (dd == 0){
                ans += t1;
                if (i < t2) ++ans; 
            }
            sum += 1ll * t1 * dd;
            if (i < t2) sum += dd;
        }
            
        ans += sum / m;
        ans = n - 1 - ans;
        printf("%d\n", ans);
    }
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int dp[3][100005];
int main()
{
    int n,a,b,c;
    cin >> n;
    for(int i=0;i<n;i++) {
            cin >> dp[0][i] >> dp[1][i] >> dp[2][i];
    }
    for(int i=1;i<n;i++) {
            dp[0][i]=max(dp[1][i-1],dp[2][i-1])+dp[0][i];
            dp[1][i]=max(dp[0][i-1],dp[2][i-1])+dp[1][i];
            dp[2][i]=max(dp[1][i-1],dp[0][i-1])+dp[2][i];
    }
    cout <<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
    return 0;
}


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

#define PI (acos(-1.0))
#define DBG printf("Hi\n")
#define loop(i,n) for(i =1 ; i<=n; i++)
#define mp make_pair
#define pb push_back
#define mod 1000000007LL
#define INF 1000000000
#define xx first
#define yy second
#define sq(x) ((x)*(x))
#define eps 0.0000000001
#define i64 long long int
#define ui64 unsigned long long int

using namespace std ;

#define maxn 100005

vector < pair< pair<int,int> ,int > > vp ;

int main()
{
    int i , j , k , l , m , n ;

    scanf("%d",&l) ;

    for(i=1 ; i<=20 ; i++)
    {
        if(  (1<<i) - 1 >= l ) break ;
    }

    n = i ;

    for(i=1 ; i<n ; i++)
    {
        vp.pb( mp( mp(i,i+1) , 0 ) ) ;
        vp.pb( mp( mp(i,i+1) , (1<<(i-1)) ) ) ;
    }

    l -= ( (1<<(n-1))  ) ;

    int offset = (1<<(n-1)) ;

    for(i=n-1 ; i>=1 ; i--)
    {
        j = i-1 ;
        if( (1<<j) <= l )
        {
            vp.pb( mp(  mp(i,n) , offset ) ) ;
            l -= (1<<j) ;
            offset += (1<<j) ;
        }
    }

    printf("%d %d\n", n , (int)vp.size() ) ;

    for(i=0 ; i<(int)vp.size() ; i++) printf("%d %d %d\n", vp[i].xx.xx,vp[i].xx.yy, vp[i].yy ) ;

    return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){ 
       int m, f, r; 
     while(1){ 
         scanf("%d %d %d ", &m, &f, &r); 
         if(m==-1&&f==-1&&r==-1)break; 
         if(m==-1||f==-1){ 
             printf("F\n"); 
         }else if(m+f>=80){ 
             printf("A\n"); 
         }else if(m+f>=65){ 
             printf("B\n"); 
         }else if(m+f>=50){ 
             printf("C\n"); 
         }else if(m+f>=30){ 
             if(r>=50){ 
                 printf("C\n"); 
             }else{ 
                 printf("D\n"); 
             } 
         }else{ 
             printf("F\n"); 
         } 
     } 
     return 0; 

 }
 



Measured memory_bytes: 2044
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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(){
ll a,b,t;
cin>>a>>b>>t;
ll d=a;
ll ans=0;
while(1){
if(t<d)break;
ans+=b;
d+=a;
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
As = list(map(int, input().split()))

ct = Counter(As)
S = sum(As)

Q = int(input())
for _ in range(Q):
    b, c = map(int, input().split())
    n = ct[b]
    ct[b] = 0
    ct[c] += n
    S += (c-b)*n
    print(S)


Measured memory_bytes: 24320
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;

struct Path{
  set<int> edges;
  int now;
  Path(){}
};
bool state[9][9];
int main(void){
  int N, M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    state[a][b] = state[b][a] = true;
  }
  queue<Path>que;
  Path p = Path();
  p.now = 1;
  p.edges.insert(1);
  que.push(p);
  int ans = 0;
  while(!que.empty()){
    Path np = que.front();que.pop();
    if(np.edges.size() == N){
      ans++;
      continue;
    }
    for(int i = 1; i <= N; i++){
      if(i == np.now)continue;
      if(!state[np.now][i])continue;
      decltype(np.edges)::iterator it = np.edges.find(i);
      if(it != np.edges.end())continue;
      Path next = np;
      next.edges.insert(i);
      next.now = i;
      que.push(next);
    }
  }cout << ans << endl;

}


Measured memory_bytes: 2432
H = 0
W = 0
Data = []
Ans  = []

def check(h,w):
    if Data[h][w] == '#':
        return '#'

    num = 0
    dx = [-1,-1,-1,0 ,0, 1,1,1]
    dy = [-1, 0, 1,-1,1,-1,0,1]
    for i in range(8):
        if Data[h+dx[i]][w+dy[i]] == '#':
            num += 1
    return str(num)

H,W = map(int,input().split())
Data.append([0]*(W+2))
for _ in range(H):
    s = list(input())
    s.insert(0,0)
    s.append(0)
    Data.append(s)
Data.append([0]*(W+2))

for h in range(1,H+1):
    s = ''
    for w in range(1,W+1):
        s += check(h,w)
    Ans.append(s)

for a in Ans:
    print(a)

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef pair<int,int> P;
int main(void)
{
	int n,m,i,j;
	P a[100000];
	priority_queue<int> qu;
	long long sum;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)	{
		scanf("%d %d",&a[i].first,&a[i].second);
	}
	sort(a,a+n);
	sum=0;
	j=0;
	for(i=1;i<=m;i++)	{
		while(a[j].first<=i)	{
			qu.push(a[j].second);
			j++;
			if(j>=n)	break;
		}
		if(qu.size()!=0)	{
			sum+=(long long)qu.top();
			qu.pop();
		}
//		printf("%lld\n",sum);
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1660
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int maxn=10111;
int n,k;
char s[maxn],t[maxn],ans[maxn];
int main()
{
	get2(n,k);
	scanf("%s",s+1);memcpy(s+n+1,s+1,sizeof(char)*n);reverse(s+n+1,s+n+n+1);
	
	char mn=*min_element(s+1,s+n+1);
	
	if(k>=14)
	{
		while(n--)putchar(mn);puts("");
		return 0;
	}
	
	memcpy(ans,s,sizeof(char)*(n+1));
	int mnl=0;
	for(int i=1;i<=n+n;i++)
	{
		if(s[i]==mn)mnl++;
		else mnl=0;
		if(!mnl||i<n)continue;
		if((mnl<<k-1)>=n)
		{
			while(n--)putchar(mn);puts("");
			return 0;
		}
		int tot=0,cur=i-mnl;
		for(int j=1;j<=(mnl<<k-1);j++)t[++tot]=mn;
		while(tot<n)t[++tot]=s[cur--];
		if(strcmp(t+1,ans+1)<0)memcpy(ans,t,sizeof(char)*(n+1));
	}
	printf("%s\n",ans+1);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

using namespace std;
using ll = long long;

const int kInf = 1e9;
const ll kLInf = 1e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
   int N, K;
   cin >> N >> K;
   int h[100010];
   REP(i, N) {
      cin >> h[i];
   }
   vector<ll> *dp = new vector<ll>(N+K+3, kInf);
   dp->at(0) = 0;
   REP(i, N+K) {
      REP(j, K) {
         chmin(dp->at(i), dp->at(max(i-j-1, 0)) + abs(h[i]-h[max(i-j-1, 0)]));
      }
   }
   cout << dp->at(N-1) << endl;
   return 0;
}


Measured memory_bytes: 1408
#include <cstdio>

using namespace std;
int main(){
    int n;
    scanf("%d", &n);
    long long a = 0;
    for (long long i = 1; i <= n; i++){
        if (i % 3 ==0 || i % 5 == 0) continue;
        a += i;
    }
    printf("%lld\n", a);
}

Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<cassert>
#include<string>
#include<algorithm>
#include<functional>
#include<ctype.h>
using namespace std;

#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) {
    for(T &a : v) is >> a; return is;
}

int calc_depth(string &s) {
    rep(i, s.size()) if(s[i] != '.') return i;
    assert(0);
}

int calc(vector<string> &line, int &now, int depth) {
    char c = line[now].back();
    if(isdigit(c)) {
        now++;
        return c - '0';
    } else {
        function<int(int, int)> f;
        int ret;
        if(c == '+') {
            f = [](int a, int b) { return a + b; };
            ret = 0;
        } else if(c == '*') {
            f = [](int a, int b) { return a * b; };
            ret = 1;
        } else assert(0);
        now++;
        
        while(now < line.size() and calc_depth(line[now]) > depth) {
            ret = f(ret, calc(line, now, depth + 1));
        }
        return ret;
    }
}


bool solve() {
    int n; cin >> n;
    if(n == 0) return 0;
    vector<string> line(n); cin >> line;
    int i = 0;
    cout << calc(line, i, 0) << endl;
    return 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(solve());
    return 0;
}

Measured memory_bytes: 3240
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int l; readV(l);

  auto r = l.bsr, n = r+1;

  struct Edge { int u, v, w; }
  Edge[] e;

  foreach (i; 1..n) {
    e ~= Edge(i, i+1, 0);
    e ~= Edge(i, i+1, 1<<(i-1));
  }

  l -= (1<<r);
  auto t = (1<<r);

  while (l > 0) {
    r = l.bsr;
    e ~= Edge(r+1, n, t);
    l -= (1<<r);
    t += (1<<r);
  }

  writeln(n, " ", e.length);
  foreach (ei; e) writeln(ei.u, " ", ei.v, " ", ei.w);
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  pure T bitSet(T)(T n, size_t s, size_t e) { return n | ((T(1) << e) - 1) & ~((T(1) << s) - 1); }
  pure T bitReset(T)(T n, size_t s, size_t e) { return n & (~((T(1) << e) - 1) | ((T(1) << s) - 1)); }
  pure T bitComp(T)(T n, size_t s, size_t e) { return n ^ ((T(1) << e) - 1) & ~((T(1) << s) - 1); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
int n; 
int S[111111];
int query(int x)
{
	if(S[x%n]!=-1) return S[x%n];
	cout<<x%n<<'\n';
	fflush(stdout);
	string s; cin>>s;
	if(s=="Vacant") exit(0);
	if(s=="Male") return (S[x%n]=0);
	else return (S[x%n]=1);
}
int main()
{
	memset(S,-1,sizeof(S));
	cin>>n;
	query(0);
	query(1);
	int l = 2; int r = n;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		int x=query(mid);
		int R = query(r);
		if(((mid%2==r%2)&&(x!=R))||((mid%2!=r%2)&&(x==R)))
		{
			l = mid + 1;
		}
		else
		{
			r = mid;
		}
	}
}


Measured memory_bytes: 1356
#include<stdio.h>
int main()
{
	int n,s,x = 0,i,max = 0;
	char a[102];
	scanf("%d",&n);
	scanf("%s",a + 1);
	for(i = 1;i <= n;i++)
	{
		if(a[i] == 'I')
			x++;
		else
			x--;
		if(max < x)
			max = x;
	}
	printf("%d\n",max);
	return 0;
}



Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long A, long long B, long long N){
  ll x;
  if(B<=N) {
    x = B-1;
  } else {
    x = N;
  }
  std::cout << (A*x)/B - A*(x/B) << std::endl;
}

int main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long N;
  scanf("%lld",&N);
  solve(A, B, N);
  return 0;
}



Measured memory_bytes: 3252
#include<iostream>
#include<bitset>
using namespace std;
int main(){
    string s;
    cin>>s;
    bitset<9>b(0);
    long ans=0,l,r;
    for(int i=0;i<(1<<s.size()-1);i++){
        b=i;
        l=0,r=1;
        for(int i=0;i<s.size();i++,r++,b>>=1)if(b[0])ans+=stol(s.substr(l,r-l)),l=r;
        ans+=stol(s.substr(l,r-l));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  rep(i,10000){
    if(i % 2 == 0){
      c -= b;
      if(c <= 0){
        cout << "Yes" << endl;
        return 0;
      }
    }
    else{
      a -= d;
      if(a <= 0){
        cout << "No" << endl;
        return 0;
      }

    }
  }
  return 0;
}


Measured memory_bytes: 3636
A, B, C, D, E, limit = map(int, input().rstrip("\n").split())

target_concent = E * 100 / (100 + E)
water_vars = {(i * A + j * B) * 100 for i in range(limit // (100 * A) + 1) for j in range(limit // (100 * B) + 1) if (i * A + j * B) * 100 <= limit}
water_vars = sorted(water_vars)[1:]

ans_solution = 0
ans_sugar = 0
max_concent = 0

break_all = False

for water in water_vars:
    sugar_limit = limit - water
    sugar_vars = {i * C + j * D for i in range(sugar_limit // C + 1) for j in range(sugar_limit // D + 1) if i * C + j * D <= sugar_limit}
    sugar_vars = sorted(sugar_vars)
    for sugar in sugar_vars:
        concent = sugar * 100 / (sugar + water)
        if concent == target_concent:
            ans_solution = water + sugar
            ans_sugar = sugar
            break_all = True
            break
        elif max_concent <= concent < target_concent:
            ans_solution = water + sugar
            ans_sugar = sugar
            max_concent = concent
        elif concent > target_concent:
            break
    if break_all:
        break

print(ans_solution, ans_sugar)


Measured memory_bytes: 3312
N = int(input())
L = []
for _ in range(N):
    l = list(map(int,input().split()))
    L.append(l)
L = sorted(L,key=lambda x:x[1])
time = 0
for x in L:
    time += x[0]
    if time > x[1]:
        print("No")
        quit()
print("Yes")


Measured memory_bytes: 89820
#include<iostream>

using namespace std;

int main(){
	int a,b;
	while(cin>>a>>b && a&&b){
		int ans[2]={150,150};
		for(int i=1;i<150;i++){
			for(int j=i+1;j<=150;j++){
				if(a*a+b*b<i*i+j*j){
					if(ans[0]*ans[0]+ans[1]*ans[1]>i*i+j*j){
						ans[0]=i;ans[1]=j;
					}
					else if(ans[0]*ans[0]+ans[1]*ans[1]==i*i+j*j && i<ans[0]){
						ans[0]=i;ans[1]=j;
					}
				}
				else if(a*a+b*b==i*i+j*j && a<i){
					if(ans[0]*ans[0]+ans[1]*ans[1]>i*i+j*j){
						ans[0]=i;ans[1]=j;
					}
					else if(ans[0]*ans[0]+ans[1]*ans[1]==i*i+j*j && i<ans[0]){
						ans[0]=i;ans[1]=j;
					}
				}
			}
		}
		cout<<ans[0]<<" "<<ans[1]<<endl;
	}
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

const int INF = 1<<30;

int N,M;

int main(){
  while(scanf("%d%d", &N,&M) && N||M){
    vector<int>a,v;
    a.push_back(0);
    for(int i=0;i<N;i++){
      int x;scanf("%d", &x);
      a.push_back(x);
    }
    for(int i=0;i<=N;i++) for(int j=0;j<=N;j++){
	if(a[i]+a[j] <= M) v.push_back(a[i]+a[j]);
    }
    v.push_back(INF);

    sort(v.begin(), v.end());
    int res = 0;
    for(int i=0;i<v.size()-1;i++){
      int x = M-v[i];
      vector<int>::iterator it = upper_bound(v.begin(), v.end(), x); if(it != v.begin()) it--;
      res = max(res, v[i] + *it);
    }
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 9024
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var s2 = rev(s);
        var s3 = change(s2, 'b', 'd');
        var s4 = change(s3, 'p', 'q');
        Console.WriteLine(s == s4 ? "Yes" : "No");
    }
    public static string rev(string s)
    {
        var c = s.ToCharArray();
        Array.Reverse(c);
        return new string(c);
    }
    public static string change(string s, char a, char b)
    {
        var s2 = s.Replace(a, '*');
        var s3 = s2.Replace(b, '?');
        s2 = s3.Replace('*', b);
        return s2.Replace('?', a);
    }
}


Measured memory_bytes: 13280
#include<stdio.h>

int binary_search(int* A, int n, int i){
  int left  = 0, right = n;
  while(left < right){
    int mid = (left+right)/2;
    if(A[mid] == i) return 1;
    if(A[mid] < i) left = mid+1;
    else right = mid;
  }
  return 0;
}

int main(){
  int S[100000], T[50000], n, m, i, num = 0;
  scanf("%d",&n);
  for(i = 0; i < n; i++) {
    scanf("%d",&S[i]);
  }
  scanf("%d",&m);
  for(i = 0; i < m; i++){
    scanf("%d",&T[i]);
  }
  for(i = 0; i < m; i++) {
    num += binary_search(S, n, T[i]);
  }
  printf("%d\n", num);
  return 0;
}



Measured memory_bytes: 2308
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;

ll a, b, h, m;
double pi;

int main()
{
    cin>>a>>b>>h>>m;
    pi = acos(-1.0);
    ll x = m * 6;
    double y = h * 30 + m * 0.5;
    double cs = cos((x - y) / 180 * pi);
    double ans2 = a * a + b * b - 2 * cs * a * b;
    double ans = sqrt(ans2);
    printf("%.12f", ans);
    return 0;
}


Measured memory_bytes: 4148
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()

# エラストテネスの篩
prime = [2]
max = 55555
limit = int(math.sqrt(max))
data = [i + 1 for i in range(2, max, 2)]

while limit > data[0]:
    prime.append(data[0])
    data = [j for j in data if j % data[0] != 0]
prime = prime + data

prime = sorted(prime)

prime = [i for i in prime if i % 5 == 1]
print(*prime[:N])

Measured memory_bytes: 65896
n,k = map(int,input().split())
#n * 2まで
counter = 0
while True:
    if n * 2 < k:
        print(n)
        exit()
    if counter == 0:
        n = abs(n - (k * (n//k)))
        counter += 1
    else:
        n = abs(n - k)
        

Measured memory_bytes: 2940
#ABC053b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

s = input()
left = 0
right = 0
for i in range(len(s)):
    if (s[i] == "A"):
        left = i
        break
for i in range(len(s) - 2, 0, -1):
    if (s[i] == "Z"):
        right = i
        break
print(right - left + 1)

Measured memory_bytes: 3444
// Aizu Vol-2 0297: The Last One is the Best
// 2017.8.6

#include <stdio.h>

int main()
{
	int k, p, cn;

	scanf("%d", &cn);
	while (cn--) {
		scanf("%d%d", &k, &p);
		k %= p;
		if (k == 0) k = p;
		printf("%d\n", k);
	}
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int a,b,t;
    cin>>a>>b>>t;
  	int ans=t/a;
    ans*=b;
  
    cout<<ans<<"\n";

    return 0;

}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
int a[200010];
int ans[200010];
vector<int> v[200010];
int segtree[800010];
set<int> st;
map<int, int> mp;
int pos[200010];
int tac;
void upd(int x,int y)
{
	int t=pos[x];
	segtree[t]=y;
	while (t)
	{
		t=(t-1)/2;
		segtree[t]=max(segtree[t*2+1],segtree[t*2+2]);
	}
}
int calc(int t,int x,int y,int xi,int yi)
{
	if (yi<xi || y<xi || yi<x) return 0;
	if (xi<=x && y<=yi) return segtree[t];
	int mid=(x+y)/2; 
	return max(calc(t*2+1,x,mid,xi,yi),calc(t*2+2,mid+1,y,xi,yi));
}
void build(int t,int x,int y)
{
	if (x==y)
	{
		pos[x]=t;
		return;
	}
	int mid=(x+y)/2; 
	build(t*2+1,x,mid),build(t*2+2,mid+1,y);
}
void dfs(int x,int par)
{
	int t=calc(0,0,tac-1,0,a[x]-1)+1;
	//cout <<x<<" "<<t<<" ##\n";
	ans[x]=max(t,(par<0 ? 0 : ans[par]));
	int pre=segtree[pos[a[x]]];
	upd(a[x],t);
	for (int i=0;i<v[x].size();i++) if (v[x][i]!=par) dfs(v[x][i],x);
	upd(a[x],pre);
}
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;i++) scanf("%d",&a[i]),st.insert(a[i]);
	for (set<int>::iterator it=st.begin();it!=st.end();it++) mp[*it]=tac++;
	for (int i=0;i<n;i++) a[i]=mp[a[i]]; 
	/*for (int i=0;i<n;i++) cout <<a[i]<<" ";
	cout <<"\n";*/
	for (int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	build(0,0,tac-1);
	dfs(0,-1);
	for (int i=0;i<n;i++) cout <<ans[i]<<"\n";
	return 0;
} 

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


int N,A,B,C,D;
string S;

int sub_solve1(){
	int count = 0;
	for(int i=A;i<D;i++){
		if(S[i] == '#'){
			count++;
			if(count == 2){
				cout << "No" << endl;
				return 0;
			}
		}else{
			count = 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


int sub_solve2(){
	int count = 0;
	for(int i=A;i<C;i++){
		if(S[i] == '#'){
			count++;
			if(count == 2){
				cout << "No" << endl;
				return 0;
			}
		}else{
			count = 0;
		}
	}

	count = 0;

	for(int i=B-1;i<=D+1;i++){
		if(S[i] == '.'){
			count++;
			if(count == 3){
				cout << "Yes" << endl;
				return 0;
			}
		}else{
			count = 0;
		}
	}

	cout << "No" << endl;
	return 0;

}




void solve(){
	A--;B--;C--;D--;
	if(C < D) sub_solve1();
	else sub_solve2();
}


int main(){
	cin >> N >> A >> B >> C >> D;
	cin >> S;
	solve();
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	getline(cin,s);
	for(int i=0;i<s.length();i++)
		{
			if(s[i]=='C')
				{
					for(int j=i+1;j<s.length();j++)
						{
							if(s[j]=='F')
								{
									cout<<"Yes";
									return 0;
								}
						}
				}
		}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
//我是菜鸡
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto p:st)
#define debug(q,x) cout<<q<<x<<endl
//#define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 10+5;
const int MOD = 9973;
const double exps = 1e-6;
void deprint() {
	ofstream cout("E:\\acm dream\\debug.txt");
	return;
}
int main() {
#ifdef _LOCAL_
	ifstream cin("E:\\acm dream\\in.txt");
	ofstream cout("E:\\acm dream\\out.txt");
#endif
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n, r, ans; cin >> n >> r;
	if (n < 10)ans = r + 100 * (10 - n);
	else ans = r;
	cout << ans << endl;
	return 0;
}

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

int main()
{
 int i;
 vector<int> a;
 int c;
 for(i=0;i<10;i++)
 {
  cin>>c;
  a.push_back(c);
 }

  sort(a.begin(),a.end());

  cout<<a[9]<<endl<<a[8]<<endl<<a[7]<<endl;

  return(0);
}


Measured memory_bytes: 3168
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  bool prime[1000005]={};//true   
  int n,x,i,j,k;

  rep(i,1000005)
    prime[i]=true;
  for(i=2;i<1000005;i++){
    if(prime[i])
      for(j=2;i*j<1000005;j++)
	prime[i*j]=false;
  }

  while(1){
    int price[30]={};
    int cost[2000005]={};
    cin>>n>>x;
    if(n==0 && x==0)break;
    rep(i,n){
      cin>>price[i];
      cost[price[i]]++;
    }

    rep(i,x)
      if(cost[i])
	rep(j,n)
	  cost[i+price[j]]++;


    for(i=x;i>0;i--)
      if(cost[i]>0 && prime[i])break;

    if(i)
      cout<<i<<endl;
    else
      cout<<"NA"<<endl;
  }
}

Measured memory_bytes: 11784
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
struct D {
    
    int left;
    int right;
    int attr;
};
int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;
    vector<D> vc;
    int left = 0;
    int target = s[0] - '0';
    //ランレングス
    for(int i=0;i<n;i++) {
        if(i==n-1) {
            int target = s[i] - '0';
            vc.push_back({left, i, target});
        }
        else if(s[i] - '0' == s[i+1] - '0') {
        }else{
            int target = s[i] - '0';
            vc.push_back({left, i, target});
            left = i+1;
        }
    }
    /*rep(i, vc.size()) {
        printf("%d %d %d\n",vc[i].left,vc[i].right,vc[i].attr);
    }*/
    vector<D> vc0;
    rep(i, vc.size()) {
        if(vc[i].attr == 0) {
            D x = {vc[i].left,vc[i].right,vc[i].attr};
            if(i!=0)
                x.left = vc[i-1].left;
            if(i!=vc.size()-1)
                x.right = vc[i+1].right;
            vc0.push_back(x);
        }
    }
    int mx = 0;
    int sz = vc0.size();
    if(sz == 0) mx = n;
    if(k >= sz) k= sz;
    rep(i,sz) {
        if(i+k-1>=sz) break;
        mx = max(mx,vc0[i+k-1].right - vc0[i].left + 1);
    }
    cout << mx;
}


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

int main()
{
    int k,n;
    long int ans = 0;
    cin >> k >> n;
    int arr[n];
    for(int i=0; i<n ;i++)
    {
        cin >> arr[i];
        if(i == 0 && arr[i]> ans)
        ans = arr[i];
        if(i!=0 && arr[i]-arr[i-1] > ans)
        ans = arr[i]-arr[i-1];
    }
    if(ans < k - arr[n-1]+arr[0])
    ans = k - arr[n-1]+arr[0];

    cout << k-ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
int main() {
    int m,f,r;
    while (scanf("%d%d%d", &m, &f, &r)) {
        if (m == -1 && f == -1 && r == -1) break;
        else if (m == -1 || f == -1) puts("F");
        else if (m + f >= 80) puts("A");
        else if (m + f >= 65) puts("B");
        else if (m + f >= 50 || (m + f >= 30 && r >= 50)) puts("C");
        else if (m + f >= 30) puts("D");
        else puts("F");
    }
    return 0;
}

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

A = []
for i in range(N):
    A.append(list(map(int, input().split())))

for i in range(M):
    bi = int(input())
    for j in range(N):
        A[j][i] *= bi

for i in range(N):
    print(sum(A[i]))



Measured memory_bytes: 6012
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>

#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 VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main() {
	llong a;
	cin >> a;
	for (int i = sqrt(a); i > 0; --i) {
		if (a % i == 0) {
			llong ans = i + a / i - 2;
			cout << ans << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	ld a, b, x; scanf("%Lf%Lf%Lf", &a, &b, &x);
	ld v = a*a*b;
	ld ans;
	if(x * 2 >= v){
		ld h = (v - x) * 2 / a / a;
		ans = atan(h / a) / M_PI * 180;
	} else {
		ld h = x * 2	/ a / b ;
		ans = 90 - atan(h / b) / M_PI * 180;
	}
	printf("%.30Lf\n", ans);
}


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


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int amax=-1;
  for(int i=0;i<n;++i){
    cin >> a[i];
    amax=max(amax,a[i]);
  }
  sort(a.begin(),a.end());
  vector<int> tmp(amax+10,0);
  for(int i=0;i<n;++i){
    if(tmp[a[i]]==0){
      for(int j=a[i];j<=amax;j+=a[i]) tmp[j]++;
    }else{
      tmp[a[i]]++;
    }
  }
  int ans=0;
  for(int i=0;i<n;++i){
    if(tmp[a[i]]==1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7976
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	ll n;
	cin >> n;
	
	vector<pair<ll, ll>> p(n);
	for(int i = 0; i < n; i++) cin >> p[i].ff >> p[i].ss;
	
	vector<ll> sum, dif;
	for(int i = 0; i < n; i++) {
		sum.pub(p[i].ff + p[i].ss);
		dif.pub(p[i].ff - p[i].ss);
	}
	
	sort(all(sum));
	sort(all(dif));
	
	ll l = 0, r = 3 * inf, ans = 0;
	while(l <= r) {
		ll mid = l + (r - l) / 2, ok = 0;
		for(int i = 0; i < n; i++) {
			ll val1 = p[i].ff - p[i].ss - mid, val2 = p[i].ff + p[i].ss - mid;
			if(val1 >= dif[0] || val2 >= sum[0]) {
				ok = 1;
				break;
			} 
		}
		
		if(ok) {
			l = mid + 1;
			ans = max(ans, mid);
		} else r = mid - 1;
	}
	
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 9788
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=505;
ll f[N],k;int c[N];
inline ll calc(R int x){
	R ll res=1;
	fp(i,x,x+6)res*=i;
	return res/5040;
}
int main(){
	scanf("%lld",&k);
	fp(i,1,500)f[i]=calc(i);
	fd(i,500,1)if(k>=f[i])c[i]=k/f[i],k%=f[i];
	fp(i,1,500){
		printf("FESTIVA");
		fp(k,1,c[i])putchar('L');
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
s = map(int,input().split())

ls2 = [i // 400 for i in list(s)]
ls3 = [ 8 if i >8 else i for i in ls2]
ls4 = [i for i in ls3 if i  != 8 ]

import collections
c3 = collections.Counter(ls3)
c4 = collections.Counter(ls4)
print(str(max(len(c4),1)) + " " + str(len(c4)+c3[8]))

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

typedef pair<bool, int> P;

int main(){
    int N;
    string S;
    cin >> N >> S;
    
    int compensate = 0;
    int now = 0;
    for(int i = 0; i < N; ++i){
        if(S[i] == '(')     now++;
        
        else{
            if(now == 0)    compensate++;
            else            now--;
        }
    }
    
    string l_temp = "", r_temp = "";
    for(int i = 0; i < compensate; ++i){
        l_temp += "(";
    }
    for(int i = 0; i < now; ++i){
        r_temp += ")";
    }
    
    S.insert(0, l_temp);
    S += r_temp;
    cout << S << endl;
}

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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> ans(n);
    int cntW = 0;
    int cntE = 0;

    for (int i = 1; i < n; i++)
    {
        if (s[i - 1] == 'W')
        {
            ans[i] = ans[i - 1] + 1;
        }
        else
        {
            ans[i] = ans[i - 1];
        }
    }

    ll cnt = 0;
    for (int i = s.size() - 2; i >= 0; i--)
    {
        if (s[i + 1] == 'E')
        {
            cnt++;
        }
        ans[i] += cnt;
    }

    int fans = 300001;

    for (int i = 0; i < n; i++)
    {
        fans = min(fans, ans[i]);
    }
    cout << fans << endl;
}

Measured memory_bytes: 1796
#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()

typedef int64_t ll;
typedef long double ld;

const ll INF = 1e12;
const ld EPS = 1e-8;

int main(){
  int A, B, Q;
  cin >> A >> B >> Q;
  vector<ll> s(A), t(B), x(Q);
  REP(i, A) cin >> s[i];
  REP(i, B) cin >> t[i];
  REP(i, Q) cin >> x[i];

  sort(ALL(s));
  sort(ALL(t));

  REP(i, Q) {
    int pos_s = lower_bound(ALL(s), x[i]) - s.begin();
    int pos_t = lower_bound(ALL(t), x[i]) - t.begin();

    ll ret = INF;
    if(pos_s >= 0 && pos_s < A && pos_t >= 0 && pos_t < B) {
      ret = min(ret, max(s[pos_s] - x[i], t[pos_t] - x[i]));
    }
    if(pos_s - 1 >= 0 && pos_s - 1 < A && pos_t - 1 >= 0 && pos_t - 1 < B) {
      ret = min(ret, max(x[i] - s[pos_s - 1], x[i] - t[pos_t - 1]));
    }
    if(pos_s >= 0 && pos_s < A && pos_t - 1 >= 0 && pos_t - 1 < B) {
      ret = min(ret, s[pos_s] - t[pos_t - 1] + min(s[pos_s] - x[i], x[i] - t[pos_t - 1]));
    }
    if(pos_s - 1 >= 0 && pos_s - 1 < A && pos_t >= 0 && pos_t < B) {
      ret = min(ret, t[pos_t] - s[pos_s - 1] + min(t[pos_t] - x[i], x[i] - s[pos_s - 1]));
    }
    cout << ret << endl;
  }

  return 0;
}



Measured memory_bytes: 3712
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
using namespace std;
using ll = long long int;

int main() {
	int N;
	cin >> N;
	vector<int> p(N+2);
	vector<int> pinv(N+2);
	for (int i = 1; i <= N; i++) {
		int x; cin >> x;
		p[i] = x; pinv[x] = i;
	}
	int maxness = 0;
	int ness=0;
	for (int i = 1; i <= N; i++) {
		if (pinv[i] < pinv[i + 1]) {
			ness++;
		}
		else {
			maxness = max(ness, maxness);
			ness = 0;
		}
	}

	cout << N - maxness - 1;

	return 0;
}

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


int vis [10];

bool check( int n)
{  
     //check n if it have any undesired digit
     //if not return true
	while( n)
	{
	    int x= n%10;
	   if(vis[x]==1) return false ;
		n= n/10;
	}
	return true ;
}


int main()
{
   int n,k ;
   cin>>n>>k;
   
   for( int i=0;i<k;i++)
   {    
        int x;
     	cin>>x;
     	vis[x]=1;  //for marking undesired digit
   	
   	
	}	
	
	for( int i=n ; ; i++)  //look for digit greater than n which have no digit of k
	{
		if( check(i))
		{
			cout<<i<<endl;
			return 0;
		}
	}
	
}

Measured memory_bytes: 3504
n = gets.to_i

h = {}
a = []
n.times do |i|
  k = gets.to_i
  h[i] = k
  a << k
end
a.sort!
(0..n-1).each do |i|
  unless h[i] == a[-1]
    puts a[-1]
  else
    puts a[-2]
  end
end

Measured memory_bytes: 19944
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1e10;

int main(){
    ll n, w;
    cin >> n >> w;
    vector<P> wv(n);
    rep(i,n)cin >> wv[i].fi >> wv[i].se;
    vector<vector<ll>> dp(n+1, vector<ll>(1e5+1,INF));
    int MAX = dp[0].size();
    dp[0][0] = 0;
    rep(i,n){
        ll w0 = wv[i].fi, v0 = wv[i].se;
        rep(sum_v, MAX){
            if(sum_v-v0>=0) {
                dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v-v0]+w0);
            }
            dp[i+1][sum_v] = min(dp[i+1][sum_v],dp[i][sum_v]);
        }
    }
    ll ans;
    rep(sum_v, MAX){
        if(dp[n][sum_v] <= w) ans = sum_v;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80256
use strict;

my $n = <STDIN>;
chomp(my $s = <STDIN>);

my $i = 0;
while(1){
    my $start = index($s,"ABC");
    if($start >= 0){
        substr($s,$start, 3, ".");
        $i ++;
    }else{
        last;
    }
}

print $i;

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int N,A,B,ans;
    string S;
    bool F=true;
int main(){
    cin>>S;
    for(auto x:S)if(x=='1')ans++;
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];
ll dp[2][MAXN+5];
string dps[2][MAXN+5];
ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	string s;
	sc(s);
	s="&*"+s;
	dps[0][0]="&";
	dps[1][1]="&*";
	dps[1][0]="*";
	fu(i,2,le(s)-1){
		dps[0][i]=dps[1][i]="";
		dps[0][i].pb(s[i]);
		dps[1][i].pb(s[i-1]);
		dps[1][i].pb(s[i]);
	}
	fu(i,2,le(s)){
		if(dps[0][i]!=dps[0][i-1])mxz(dp[0][i],dp[0][i-1]+1);
		if(i>3)mxz(dp[0][i],dp[1][i-1]+1);
		if(i>2)mxz(dp[1][i],dp[0][i-2]+1);
		if(i>4 and dps[1][i]!=dps[1][i-2])mxz(dp[1][i],dp[1][i-2]+1);
	}
	pr(max(dp[0][le(s)-1],dp[1][le(s)-1]));
	
	re 0;
	// Hack it if you can :)
}

int main(){
//	INPUT;	
ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 41680