akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;

    int64_t r;
    if (w % 3 == 0) {
        r = 0;
    } else {
        r = h;
    }
    if (h % 3 == 0) {
        r = 0;
    } else {
        r = min(r, (int64_t)w);
    }
    for (int i = 1; i < h; i++) {
        int64_t a[3] = { w * (int64_t)i, (w / 2) * (int64_t)(h - i), ((w + 1) / 2) * (int64_t)(h - i) };
        int64_t b = *max_element(a, a + 3) - *min_element(a, a + 3);
        r = min(r, b);
    }
    for (int i = 1; i < w; i++) {
        int64_t a[3] = { h * (int64_t)i, h / 2 * (int64_t)(w - i), (h + 1) / 2 * (int64_t)(w - i) };
        int64_t b = *max_element(a, a + 3) - *min_element(a, a + 3);
        r = min(r, b);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

//https://beta.atcoder.jp/contests/abc048/tasks/abc048_b 

int main() {

    ll a, b, x;
    cin >> a >> b >> x;

    if (a % x == 0) {
        cout << b/x - a/x + 1 << "\n";
    } else {
        cout << b/x - a/x << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define C getchar()
#define LL long long
using namespace std;
inline int read() {
	int num = 0;
	char c=C;
	for(;c<'0' || c>'9';c=C);
	for(;c>='0'&&c<='9';c=C) num = (num << 1) + (num << 3) + (c ^ 48);
	return num;
}

int n;
int a[200010],st[200010];
int l[200010],r[200010];

int main() {
	
	n = read();
	LL ans = 0;
	for(int i=1;i<=n;++i) a[i] = read();
	int top = 0;
	l[1] = 1;st[++top] = 1;
	for(int i=2;i<=n;++i) {
		while (a[i] < a[st[top]] && top) -- top;
		l[i] = st[top] + 1;
		st[++top] = i;
	}
	top = 1;
	r[n] = n;st[top] = n;
	for(int i=n-1;i>=1;--i) {
		while (a[i] < a[st[top]] && top) -- top;
		if (top == 0) r[i] = n;
		 else r[i] = st[top] - 1;
		st[++top] = i;
	}
	
	for(int i=1;i<=n;++i) {
		LL tmp = (LL)(i - l[i] + 1) * (LL)(r[i] - i + 1);
		ans += (LL)tmp * (LL)a[i];
	}
	
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,L;
  cin >>N>>L;
  vector<string> vec(N);
  
  for(int i=0;i<N;i++){
    cin >> vec[i];
  }
  
  sort(vec.begin(),vec.end());
  for(int i=0;i<N;i++){
    cout << vec[i];
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#ifndef ONLINE_JUDGE
#define OJ \
    freopen("input.txt", "r", stdin); \
    //freopen("output.txt", "w", stdout);
#else
#define OJ ;
#endif
#define fo(int, i, l, r) for ( int i = l ; i < r ; ++ i)
#define srtV(a) sort(a.begin(),a.end())
void solve()
{
    int d,t,s;
    cin>>d>>t>>s;
    if(s*t >= d)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    
}
signed main()
{
    OJ
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //int _t;cin>>_t;while(_t--)
    solve();
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if(a>b) {
      cout << "a > b" << endl;
  }
  else if(a<b) {
      cout << "a < b" << endl;
  }
  else {
      cout << "a == b" << endl;
  }
}


Measured memory_bytes: 3100
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 100000;

long long GCD(long long a,long long b){
    if(a < b)swap(a,b);
    if(a % b)return GCD(b,a % b);
    return b;
}

int main(){
    int N;
    long long A[MAX];
    long long L[MAX];
    long long R[MAX];

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

    L[0] = A[0];
    for(int i = 1;i < N;i++){
        L[i] = GCD(L[i - 1],A[i]);
    }

    R[N - 1] = A[N - 1];
    for(int i = N - 2;i >= 0;i--){
        R[i] = GCD(R[i + 1],A[i]);
    }
    
    long long ans = max(L[N - 2],R[1]);
    for(int i = 0;i < N - 2;i++){
        ans = max(ans,GCD(L[i],R[i + 2]));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,a;
  cin>>n;
  vector<int> count(1000000,0);
  rep(i,n){
    cin>>a;
    if(a==0){
      count[a]++;
      count[a+1]++;
    }
    else{
      count[a-1]++;
      count[a]++;
      count[a+1]++;
    }
  }
  int max=0;
  rep(i,1000000){
    chmax(max,count[i]);
  }
  cout<<max<<'\n';
  return(0);
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<double,int> P;

int h,w,sum=1,ans;
string s[1111];

int main(){
    cin>>h>>w;
    r(i,h)cin>>s[h-i];
    r(i,h)s[i+1]="."+s[i+1]+".";
    r(i,w+2)s[h+1]+='.',s[0]+='.';
    vector<P>v;
    for(int i=1;i<=h+1;i++){
        for(int j=1;j<=w+1;j++){
            double x=atan2(j-1,i-1);
            string t=s[i].substr(j-1,2)+s[i-1].substr(j-1,2);
            if(t=="###."||t=="...#")v.push_back(P(x,1));
            if(t==".###"||t=="#...")v.push_back(P(x,-1));
        }
    }
    sort(v.begin(),v.end());
    r(i,v.size()){
        sum+=v[i].second;
        ans=max(sum,ans);
    }
    cout<<ans<<endl;
 }



Measured memory_bytes: 6256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int x, y, z, k;
int a[2000], b[2000], c[2000];
vector<int>v, u;
signed main() {
	cin >> x >> y >> z >> k;
	for (int i = 0; i < x; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < y; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < z; i++) {
		cin >> c[i];
	}
	sort(a, a + x);
	sort(b, b + y);
	sort(c, c + z);
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			v.push_back(a[i] + b[j]);
		}
	}
	sort(all(v));
	reverse(all(v));
	for (int i = 0; i < min(3000ll, (ll)v.size()); i++) {
		for (int j = 0; j < z; j++) {
			u.push_back(v[i] + c[j]);
		}
	}
	sort(all(u));
	reverse(all(u));
	for (int i = 0; i < k; i++) {
		cout << u[i] << endl;
	}
}

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int N;
  cin >> N;
  int cnt = 0;
  for(int i = 0; i < 100; i++){
    for(int j = 0; j < 100; j++){
      if(4 * i + 7 * j == N){
        cout << "Yes" <<endl;
        return 0;
      }
    }
  }
  cout << "No" <<endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int dp[1000005][10][2];
string s;
int main(){
    cin>>s;reverse(s.begin(),s.end());s="%"+s;s+='0';
    memset(dp,63,sizeof(dp));
    dp[0][0][0]=0;
    for(int i=0;i<s.size()-1;i++)
        for(int j=0;j<=9;j++)
            for(int k=0;k<2;k++){
                if(k==1 && j>s[i]-'0') continue;
                if(k==1){
                    for(int l=s[i+1]-'0'+1;l<=9;l++)
                        dp[i+1][l][0]=min(dp[i+1][l][0],dp[i][j][1]+l+l-(s[i+1]-'0')-1);
                    for(int l=0;l<=s[i+1]-'0';l++)
                        dp[i+1][l][1]=min(dp[i+1][l][1],dp[i][j][1]+l+10+l-(s[i+1]-'0')-1);
                }
                else{
                    for(int l=0;l<s[i+1]-'0';l++)
                        dp[i+1][l][1]=min(dp[i+1][l][1],dp[i][j][0]+l+10+l-(s[i+1]-'0'));
                    for(int l=s[i+1]-'0';l<=9;l++)
                        dp[i+1][l][0]=min(dp[i+1][l][0],dp[i][j][0]+l+l-(s[i+1]-'0'));
                }
            }
    int ans=1000000000;
    for(int i=0;i<=9;i++) ans=min(ans,dp[s.size()-2][i][0]);
    for(int i=0;i<=9;i++) ans=min(ans,dp[s.size()-1][i][0]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 79536
#include<iostream>
using namespace std;
enum POSITION{ONLINE_BACK = -2, CLOCKWISE = -1, ON_SEGMENT = 0,
              COUNTER_CLOCKWISE = 1, ONLINE_FRONT = 2};
struct Point{
    double x;
    double y;
    Point(double x, double y) : x(x), y(y){}
    Point operator-(Point p){
        return Point(x - p.x, y - p.y);
    }
};
typedef Point Vector;
double get_cross(Vector v1, Vector v2){
    return v1.x * v2.y - v1.y * v2.x;
}
double get_dot(Vector v1, Vector v2){
    return v1.x * v2.x + v1.y * v2.y;
}
struct Segment{
    Point p1;
    Point p2;
    Segment(Point p1, Point p2) : p1(p1), p2(p2){}
};
POSITION get_position(Point p, Segment s){
    Vector base = s.p2 - s.p1;
    Vector obj  = p    - s.p1;
    double cross = get_cross(base, obj);
    if (cross >  1e-10) return CLOCKWISE;
    if (cross < -1e-10) return COUNTER_CLOCKWISE;
    if (get_dot(base, obj) < 0) return ONLINE_BACK;
    if (get_dot(base, base) < get_dot(obj, obj)) return ONLINE_FRONT;
    return ON_SEGMENT;
}
bool is_intersection(Segment s1, Segment s2){
    if (get_position(s2.p1, s1) * get_position(s2.p2, s1) <= 0 &&
        get_position(s1.p1, s2) * get_position(s1.p2, s2) <= 0) {
        return true;
    }
    return false;
}

int main(){
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int x_p0, y_p0, x_p1, y_p1, x_p2, y_p2, x_p3, y_p3;
        cin >> x_p0 >> y_p0 >> x_p1 >> y_p1;
        cin >> x_p2 >> y_p2 >> x_p3 >> y_p3;
        Point p0(x_p0, y_p0);
        Point p1(x_p1, y_p1);
        Point p2(x_p2, y_p2);
        Point p3(x_p3, y_p3);
        Segment s1(p0, p1);
        Segment s2(p2, p3);
        int ans = 0;
        if (is_intersection(s1, s2)) ans = 1;
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3108
#include<iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
	typedef long long ll;
	using namespace std;

	
	int main() {
		char a;
		cin >> a;
		
		for (char i = 'a'; i < 'z'; i++) {
			if (i == a) {
				cout << (char)(i + 1);
			}
			}
	}

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

int main(){
  long int a,b;
  string s;
  cin >> a >> b >> s;
  bool f = true;
  if(s.size() == a + b + 1){
    if(s[a] == '-'){
      for(int i = 0; i < a; ++i){
        if(s[i] < '0' || s[i] > '9'){
          f = false;
        }
      }
      for(int i = a + 1; i < a + b + 1; ++i){
        if(s[i] < '0' || s[i] > '9'){
          f = false;
        }
      }
    }else{
      f = false;
    }
  }else{
    f = false;
  }

  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifndef ONLINE_JUDGE
#define debug(a) cout<<#a<<" --> "<<(a)<<"\n";
#define debug2(a) cout<<#a<<" --> "<<(a)<<" ";
#define HERE cout<<"here - "<<__LINE__<<"\n";
#else
#define debug(a)
#define debug2(a)
#define HERE
#endif
const ll mod = 100000007;
const int N = 15;
typedef pair<int,int> pii;
ll len ;
vector<ll>koto(13);
void print(ll idx, ll n)
{
    if(idx==0)
    {
        printf("\n");
        return;
    }
    ll val = 1;
    for(ll i=1; i<=idx-1; i++)
        val*=26;
    //debug(val);
    for(ll i=0; i<26; i++)
    {
        if(n>=val)
        {
            n-= val;
        }
        else
        {
            //debug(n);
            printf("%c",i+'a');
            print(idx-1,n);
            return;
        }
    }
}
void TEST_CASES(int cas)
{
    ll n;
    cin>>n;
    n--;
    ll now = 1;
    for(ll i=1; i<13; i++)
    {
        now*=26;
        koto[i]= now;
        if(koto[i]>n)
        {
            len = i;
            break;
        }
        else{
            n-=koto[i];
        }
    }
//    debug(n);
//    debug(len);
    print(len, n);

}


/*
*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 3764
#include <stdio.h>
#include <string.h>

int head = 0;
int tail = 0;
char name[1000000][11];
int timea[1000000];

int main(){
  int n ,q,i,j,count = 0;
  scanf("%d%d",&n,&q);

  for(tail=0;tail<n;tail++){
    scanf("%s%d",name[tail],&timea[tail]);
  }

  while(head!=tail){
    if(q < timea[head]){
      timea[tail] = timea[head]-q;
      strcpy(name[tail],name[head]);
      count += q;
      tail = (tail + 1)%1000000;
      head = (head + 1)%1000000;
    }
    else{
      count += timea[head];
      printf("%s %d\n",name[head],count);
      head = (head + 1)%1000000;
    }
  }

  return 0;
}



Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define lo ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

int main() {
    lo
    int n; cin >> n;
    vector<int> alturas(n), costos(n,-1);
    for(int i=0; i<n; i++){
        cin >> alturas[i];
    }
    costos[0]=0;
    int aux;
    for(int i=0; i<n; i++){
        if(i+1<n){
            aux=costos[i]+abs(alturas[i]-alturas[i+1]);
            if(costos[i+1]==-1 or aux<costos[i+1]) costos[i+1]=aux;
        }
        if(i+2<n){
            aux=costos[i]+abs(alturas[i]-alturas[i+2]);
            if(costos[i+2]==-1 or aux<costos[i+2]) costos[i+2]=aux;
        }
    }
    cout << costos[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main(void){
    int i,count,mode,count2;
    count = i = mode = count2 = 0;
    char s[100001];
    scanf("%s",s);
    while(s[i] != '\0'){
        if (s[i] == s[i + 1]){
            count++;
            if (s[i] == '0'){
                s[i + 1] = '1';
            }else{
                s[i + 1] = '0';
            }
        }
        i++;
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;
const long INF=2000000000;
const long SIZE=110;
long V,E,from,to,dist,table[SIZE][SIZE],i,j,k;
bool flag;

void warshall_floyd(){
  for(k=0;k<V;k++){
    for(i=0;i<V;i++){
      if(table[i][k]==INF)continue;
      for(j=0;j<V;j++){
        if(table[k][j]==INF)continue;
        table[i][j]=min(table[i][j],table[i][k]+table[k][j]);
      }
    }
  }
}

int main(){
  scanf("%ld %ld",&V,&E);

  for(i=0;i<V;i++){
    for(j=0;j<V;j++){
      if(i!=j)table[i][j]=INF;
      else table[i][j]=0;
    }
  }

  for(i=0;i<E;i++){
    scanf("%ld %ld %ld",&from,&to,&dist);
    table[from][to]=dist;
  }

  warshall_floyd();

  for(i=0;i<V;i++){
    if(table[i][i]<0){
      flag=true;
      break;
    }
  }

  if(flag)printf("NEGATIVE CYCLE\n");
  else{
    for(i=0;i<V;i++){
      if(table[i][0]==INF)printf("INF");
      else{
        printf("%ld",table[i][0]);
      }
      for(j=1;j<V;j++){
        if(table[i][j]==INF)printf(" INF");
        else{
          printf(" %ld",table[i][j]);
        }
      }
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 2848
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    String U = s.next();
    int a = 0;
    int b = U.length() - 1;
    while (U.charAt(a) != 'A'){
      a++;
    }
    while (U.charAt(b) != 'Z'){
      b--;
    }
    System.out.println(b - a + 1);
  }
}


Measured memory_bytes: 26068
N = int(input())
X = [int(x) for x in input().split()]

L = min(X)
R = max(X)

ans = 10000000
for P in range(L, R + 1):
    tmp = 0
    for Xi in X:
        tmp += (Xi - P) ** 2
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  string N; cin >> N;
  rep(i,3){
    if(N[i]=='7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

template<typename T> T GCD(T a, T b) {
    if (b == 0) return a;
    if (a % b == 0) return b;
    return (GCD(b, a % b));
}

template<class T, class U> struct SegmentTree {
    using F = function<T(T, T)>;
    using G = function<T(U, T)>;
    int n;
    T id;
    vector<T> data;
    F f;
    G g;
    
    SegmentTree(int sz, F f, G g, T def) : f(f), g(g) {
        n = 1; id = def;
        while (n < sz) n *= 2;
        data = vector<T>(2*n-1, id);
    }
    void update (int i, T x) {
        i += n - 1;
        data[i] = g(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return id;
        if (a <= l && r <= b) return data[k];
        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
    T operator[](int i) { return data[i + n - 1]; }
};

int main() {
    int N;
    cin >> N;
    auto f = [](long long a, long long b) { return GCD(a, b); };
    auto g = [](int i, long long x) { return x; };
    SegmentTree<long long, int> sg(N, f, g, 0);
    for (int i = 0; i < N; i++) {
        long long A;
        cin >> A;
        sg.update(i, A);
    }
    
    long long ans = max(sg.query(1, N), sg.query(0, N-1));
    for (int i = 1; i < N; i++) {
        long long res = GCD(sg.query(0, i), sg.query(i+1, N));
        if (res > ans) ans = res;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2304
fun main(arr: Array<String>) {
    val (h,w) = readLine()!!.split(" ").map { it.toInt() }
    val map = (1..h).map { readLine()!!.toMutableList() }.toMutableList()
    (0 until w).reversed().forEach {idx-> if(map.all { it[idx] == '.' }) map.forEach{it.removeAt(idx)} }
    (0 until h).reversed().forEach { idx -> if(map[idx].all { it == '.' }) map.removeAt(idx) }
    map.forEach{ println(it.joinToString(""))}
}

Measured memory_bytes: 38892
//                             ¯\_(ツ)_/¯   
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mma,ava,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define ll long long

using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;

const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	int a,b,c,d;

	cin>>a>>b>>c>>d;
	bool turn = 0;
	while(a>0 && c>0){
		if(turn)a-=d;
		else c-=b;
		turn = !turn;
	}
	if(a<=0)cout<<"No\n";
	else	cout<<"Yes\n";
	
}


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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;


const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve()
{
	ll n;
	cin>>n;
	vector<pair<ll, ll>> v;
	rep(i, 0, n)
	{
		ll x, r;
		cin>>x>>r;
		v.pb(make_pair(x+r, x-r));
	}
	sort(all(v));
	ll r = v[0].f;
	ll ans = 1;
	rep(i, 1, n)
	{
		ll nxtr = v[i].f;
		ll nxtl = v[i].s;
		if(nxtl >= r)
		{
			r = nxtr;
			ans++;
		}
	}
	cout<<ans<<endl;

}


int main()
{
	ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 2420
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CColon solver = new CColon();
        solver.solve(1, in, out);
        out.close();
    }

    static class CColon {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            double a = in.nextInt(), b = in.nextInt();
            double h = in.nextInt(), m = in.nextInt();

            double x1 = a * Math.cos((h + m / 60) / 12 * 2 * Math.PI);
            double y1 = a * Math.sin((h + m / 60) / 12 * 2 * Math.PI);
            double x2 = b * Math.cos(m / 60 * 2 * Math.PI);
            double y2 = b * Math.sin(m / 60 * 2 * Math.PI);

            out.println(Util.formatDouble(Math.hypot(x1 - x2, y1 - y2)));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

    static class Util {
        public static String formatDouble(double x) {
            return String.format("%.15f", x);
        }

        private Util() {
        }

    }
}



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

int main(){
int a,b,sum,i;
while(cin>>a>>b){
	i=0;
	sum=a+b;
	while(1){
		i++;
		sum=sum/10;
		if(sum<1)break;
	}
	cout<<i<<endl;
}
return 0;
}

Measured memory_bytes: 1160
import sys
import numpy as np
x, n = map(int, input().split())
if n == 0:
    print(x)
    sys.exit()
p = np.array([int(i) for i in input().split()])
a = abs(p - x)
for i in range(101):
    if i == 0 and x not in p:
        print(x)
        break
    if x - i not in p:
        print(x - i)
        break
    elif x + i not in p:
        print(x + i)
        break

Measured memory_bytes: 27328
#include<iostream>
using namespace std;
int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	int sum = a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500;
	if (sum >= 1000) cout << 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 3072
#pragma GCC optimize("-O3","-funroll-all-loops")
#pragma GCC target("avx","tune=native","sse4","sse")
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int n,c=0,T=0;
char a[505][505];
pii u[2][505][505];
inline pii operator + (pii a,pii b)
{return pii(min(a.fi,b.fi),max(a.se,b.se));}
int vis[505][505];
inline void dfs(int x,int y)
{
	if(vis[x][y]==T||!isdigit(a[x][y]))
		return;
	vis[x][y]=T; dfs(x,y+1); dfs(x+1,y);
}
int su[505][505];
int main()
{
	scanf("%d",&n);
	ll aa=0;
	for(int i=1;i<=n;++i)
	{
		scanf("%s",a[i]+1);
		for(int j=1;j<=n;++j)
		{
			if(isdigit(a[i][j]))
			{
				int u=a[i][j]-'0';
				aa-=u*u;
			}
		}
	}
	pii GG(2e9,-2e9);
	for(int i=0;i<=n+1;++i)
	for(int j=0;j<=n+1;++j)
		u[0][i][j]=u[1][j][i]=GG;
	for(int i=n;i>=1;--i)
	{
		T=i; c^=1;
		for(int j=1;j<=n;++j) dfs(i,j);
		for(int k=i;k<=n;++k)
			for(int w=1;w<=n;++w)
				if(vis[k][w]==T)
					su[k][w]=su[k][w-1]+a[k][w]-'0';
				else su[k][w]=su[k][w-1];
		for(int j=n;j>=1;--j)
		{
			pii*ucj=u[c][j],*ucp=u[c][j+1],*rcj=u[c^1][j];
			if(!isdigit(a[i][j]))
			{
				for(int k=i;k<=n;++k)
					ucj[k]=GG;
				continue;
			}
			ucj[i]=pii(j,j)+ucp[i];
			ll ap=0;
			if(ucj[i].fi<=ucj[i].se)
				ap+=su[i][ucj[i].se]-su[i][ucj[i].fi-1];
			for(int k=i+1;k<=n;++k)
			{
				ucj[k]=rcj[k]+ucp[k];
				if(ucj[k].fi<=ucj[k].se)
				ap+=su[k][ucj[k].se]-su[k][ucj[k].fi-1];
			}
			aa+=ap*(a[i][j]-'0');
		}
	}
	cout<<aa<<"\n";
}


Measured memory_bytes: 6528
import java.util.*

class UnionFind(n: Int) {
    private val rank = IntArray(n) { 0 }
    private val parent = IntArray(n) { -1 }

    fun find(x: Int): Int {
        if (parent[x] < 0) {
            return x
        }
        parent[x] = find(parent[x])
        return parent[x]
    }

    fun unite(x: Int, y: Int) {
        val x1 = find(x)
        val y1 = find(y)
        if (x1 == y1) {
            return
        }
        if (rank[x1] < rank[y1]) {
            parent[y1] += parent[x1]
            parent[x1] = y1
        } else {
            parent[x1] += parent[y1]
            parent[y1] = x1
            if (rank[x1] == rank[y1]) {
                rank[x1]++
            }
        }
    }

    fun same(x: Int, y: Int): Boolean {
        return find(x) == find(y)
    }

    fun size(x: Int): Int {
        return -parent[find(x)]
    }
}

fun main(args: Array<String>) {
    val (n, q) = readLine()!!.split(' ').map { it.toInt() }
    val uf = UnionFind(n)
    for (i in 0 until q) {
        val (com, x, y) = readLine()!!.split(' ').map { it.toInt() }
        if (com == 0) {
            uf.unite(x, y)
        } else {
            println(if (uf.same(x, y)) 1 else 0)
        }
    }
}


Measured memory_bytes: 78268
#include <cstdio>
#include <cstring>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
using namespace std;



int main(){
  long long int  n,k,sum;
  sum = 0;
  cin >> n >> k;
  long long int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum += a[i];
  }

  sort(a,a+n);

//枝刈
  if(n==1){
    if(k<=a[0])
      cout << 0 << endl;
    else
      cout << 1 << endl;
    return 0;
  }

  if(sum < k){
    cout << n << endl;
    return 0;
  }

  if(a[0]>=k){
    cout << 0 << endl;
    return 0;
  }


//本作業
  int need[5001]={};

  for(int i=0;i<n;i++){
    if(i>0 && a[i] == a[i-1]){
      need[i] = need[i-1];
    }else if(a[i]>=k){
      need[i] = 1;
    }
    else{
      int min;
        if(k - a[i] < 0 )
          min = 0;
        else
          min = k - a[i];
      int max = k - 1;

      bool flag = false;
      bool prob[5001]={};
      prob[0] = 1;
      int edge = 0;

      for(int j=0;j<n;j++){

        if(i!=j){
          if(edge + a[j] <= k)
            edge += a[j];
          else
            edge = k;

          for(int l= edge ;l>=0;l--){

            if((l - a[j] >=0) && (prob[l - a[j]] == 1)){

              prob[l] = 1;

              if(min <= l && l <= max){
                need[i] = 1;
                flag = true;
              }
            }

            if(flag) break;
          }
        }

        if(flag) break;
      }
    }
  }
  int ans = 0;
  for(int i=0;i<n;i++)
    if(need[i] == 0)
      ans++;

  cout << ans <<endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long X = scan.nextLong();
        for (int A = 0; A <= 1000; A++) {
            for (int B = 0; B <= 1000; B++) {
                if (A*A*A*A*A - B*B*B*B*B == X) {
                    System.out.printf("%d %d\n", A, B);
                    return;
                }
                if (A*A*A*A*A + B*B*B*B*B == X) {
                    System.out.printf("%d %d\n", A, -B);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 35880
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X1, Y1, X2, Y2, X3, Y3, X4, Y4;
		X1 = sc.nextInt();
		Y1 = sc.nextInt();
		X2 = sc.nextInt();
		Y2 = sc.nextInt();
		sc.close();

		int dx = X2 - X1;
		int dy = Y2 - Y1;
		X3 = X2 - dy;
		Y3 = Y2 + dx;
		X4 = X3 - dx;
		Y4 = Y3 - dy;
		System.out.println(X3 + " " + Y3 + " " + X4 + " " + Y4);
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vvi vector <vector<int> >
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>=b;i--)
#define init(i,k) memset(i,k,sizeof i)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
inline ll add(ll a, ll b){ return ((a%MOD)+(b%MOD))%MOD;}
inline ll mul(ll a, ll b){ return ((a%MOD)*(b%MOD))%MOD;}
inline ll sub(ll a, ll b){ return ((a%MOD)-(b%MOD)+MOD)%MOD;}
// const int N = 1e5+7;
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
///---------------------------------------------------------------

void solve()
{
	int n;cin>>n;
	while(n){
		if(n%10 == 7){
			cout<<"Yes\n";return;
		}
		n/=10;
	}
	cout<<"No\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	
	#ifdef local
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	clock_t qwertyuiop = clock();
	#endif
 
	int t=1;
	// cin>>t;
	rep(a,0,t)
	{
		// cout<<"Case #"<<a+1<<": ";
		solve();
	}

	// solve();
	
	#ifdef local
	{qwertyuiop = clock() - qwertyuiop;
	double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;
	cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "
	<<time_taken<<" seconds\n";}
	#endif
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,s;cin >> n >> k >> s;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    if(i<k){
      a[i]=s;
    }
    else{
      if(s==1e9){
        a[i]=1;
      }
      else{
        a[i]=1e9;
      }
    }
    cout << a[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1664
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

while (line = lines.shift()) {
    const numbers = line.split(' ').map(Number);

    // Edit from here
    let a = numbers[0];
    let b = numbers[1];

    if ( a === 0 && b === 0 ) { break; }

    if ( a > b ) {
        const tmp = a;
        a = b;
        b = tmp;
    } 

    const output = a + ' ' + b;
    
    console.log(output);
    // to here
}



Measured memory_bytes: 18988
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    s = int(sqrt(n)) + 1
    ans = 0
    for i in range(1, s+1):
        x = n - i
        m = x // i
        if m > i and x % i == 0 :
            ans += m
    print(ans)

    return


#main
if __name__ == '__main__':
    solve()


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

bool dp(int n){
  if(n== 0) return true;
  if(n < 0) return false;
  return dp(n-4) || dp(n-7);
}

int main(){
  int n; cin>> n;
  auto str = dp(n)? "Yes" : "No";
  cout << str << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
string str;
 
void change(){
    for(char i = 'a' ; i <= 'z' ; i++) str[i] = i;
    for(char i = 'A' ; i <= 'Z' ; i++) str[i] = i;
    for(char i = '0' ; i <= '9' ; i++) str[i] = i;
}
 
int main(){
    int n;
     
    while(cin >> n,n){
        str = "";
        change();
        char a,b;
        for(int i = 0 ; i < n ; i++){
            cin >> a >> b;
            str[a] = b;
        }
        string tmp = "";
        int m; char c;
        cin >> m;
        for(int i = 0 ; i < m; i++){
            cin >> c;
            tmp += str[c];
        }
        cout << tmp << endl;
    }
     
    return 0;
}

Measured memory_bytes: 1336
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int32_t main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k; cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;++i) cin>>a[i];
    // pre + cycle length
    vector<int> cycle;
	int hash[n+1]={0};
	int curr=1;
	hash[1]=1;
	cycle.push_back(curr);
	while(true){
		curr=a[curr];
		cycle.push_back(curr);
		if(hash[curr])
			break;
		hash[curr]=1;
	}
	int pre=0; 
	int np=cycle.size();
	for(int i=0;i<np;++i){
		if(cycle[i]==cycle[np-1]){
			pre=i; break;
		}
	}
	int cl=np-pre-1;
	int tt=pre+cl;
	if(tt>=k){
		int xx=1;
		while(k--)
			xx=a[xx];
		cout<<xx<<"\n";
		return 0;
	}
	int ip=k-pre;
	int mul=ip/cl;
	int final=cycle[np-1];
	cl*=mul; cl+=pre;
	k-=cl;
	while(k--) final=a[final];
	cout<<final<<"\n";
    return 0;
}



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

std::vector<int> heads, bodies, legs;
int n;
long long c = 0;

int main() {
    std::cin >> n;
    heads.assign(n, 0);
    bodies.assign(n, 0);
    legs.assign(n, 0);
    
    for (int i = 0; i < n; i++) {
        std::cin >> heads[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> bodies[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> legs[i];
    }
    
    std::sort(heads.begin(), heads.end());
    std::sort(bodies.begin(), bodies.end());
    std::sort(legs.begin(), legs.end());
    
    for (int i = 0; i < n; i++) {
        auto head_it = std::lower_bound(heads.begin(), heads.end(), bodies[i]);
        auto head_dis = std::distance(heads.begin(), head_it);
        auto legs_it = std::upper_bound(legs.begin(), legs.end(), bodies[i]);
        auto legs_dis = std::distance(legs_it, legs.end());
        c += (head_dis * legs_dis);
    }
    std::cout << c << std::endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vvi a(n, vi(n));
    rep(i, n) rep(j, n) cin >> a[i][j];
    vector<ll> dp(1 << n);
    for(int b = 1; b < 1 << n; b++) {
        ll r = 0;
        rep(i, n) rep(j, i) if (b >> i & b >> j & 1) {
            r += a[i][j];
        }
        for(int s = b; s >= 0; s--) {
            s &= b;
            chmax(r, dp[s] + dp[s^b])
        }
        dp[b] = r;
    }
    cout << dp.back() << endl;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<pll> vp;

const ll mod = 1e9+7;
inline ll lcm(ll a, ll b){return a/__gcd(a,b)*b;}

//Segment Tree for Range Maximum Query
class SegmentTree{
  int n;
  vp node;
public:
  SegmentTree(vp a){
    int n_ = a.size();
    n=1;
    while(n<n_)n*=2;
    node.resize(2*n-1, pll(1, 0));
    for(int i=0;i<n_;i++)node[n-1+i] = a[i];
    for(int i=n-2;i>=0;i--){
      pll vl = node[2*i+1], vr = node[2*i+2];
      ll len = lcm(vl.first, vr.first);
      ll cost = ( (len/vl.first%mod) * vl.second) % mod
	+ ( (len/vr.first%mod) * vr.second) % mod;
      node[i] = pll(len,cost%mod);
    }
  }
  
  //return maximum value in [a,b). ( [l,r) is interval in which k is.)
  pll INTV_LCM(int a,int b,int k=0,int l=0,int r=0){
    if(l>=r)r = n;
    if(r<=a || b<=l)return pll(1,0);
    if(a<=l && r<=b)return node[k];
    pll vl = INTV_LCM(a,b,2*k+1,l,(l+r)/2);
    pll vr = INTV_LCM(a,b,2*k+2,(l+r)/2,r);
    ll len = lcm(vl.first, vr.first);
    ll cost = ( (len/vl.first%mod) * vl.second) % mod
      + ( (len/vr.first%mod) * vr.second) % mod;
    return pll(len, cost%mod);
  }
};

int main(){
  int n,q;
  cin >> n >> q;
  vector<int> p(n+1);
  for(int i=1;i<=n;i++)cin >> p[i];

  vector<pll> val(n);
  vector<int> use(n+1,0);
  for(int i=1;i<=n;i++){
    if(!use[i]){
      int cur = i;
      ll len = 0, sum = 0;
      
      do{
	len++; sum += p[cur];
	cur = p[cur];
      }while(cur != i);
      
      do{
	val[cur-1] = pll(len,sum%mod);
	use[cur] = 1;
	cur = p[cur];
      }while(cur != i);
    }
  }

  SegmentTree st(val);
  for(int i=0;i<q;i++){
    int l,r;
    cin >> l >> r;
    cout << (st.INTV_LCM(l-1,r)).second << endl;
  }
}

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

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	ll x[n];
	rep(i,0,n) cin >> x[i];

	ll y[n];
	rep(i,0,n) y[i]=x[i];

	sort(y,y+n);
	reverse(y,y+n);

	ll z=y[n/2-1];

	rep(i,0,n){
		if(x[i]<z) cout << z << "\n";
		else cout << y[n/2] << "\n";
	}
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
// #include <atcoder/all>

using boost::multiprecision::cpp_int;
using namespace std;
// using namespace atcoder;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];
  sort(ALL(v));
  ll sum = v[0];
  ll count = 1;
  for (int i = 1; i < n; ++i) {
    if(sum*2 >= v[i]){
      count++;
    }else{
      count = 1;
    }
    sum += v[i];
    // cout << count << endl;
  }

  cout << count << endl;
}


Measured memory_bytes: 3912