akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int h, w;
  while(cin >> h >> w, h||w){
    int taikaku0 = 0;
    taikaku0 = h*h + w*w;
    int min = 400000;
    int mh = 151;
    int mw = 151;
    //bool bf = false;
    for(int i=1; i<=150; i++){ //yoko
      for(int j=1; j<i; j++){ //takasa
	int taikaku = i*i+j*j;
	if(taikaku0 == taikaku && h < j && mh > j){
	  mh = j;
	  mw = i;
	  min = taikaku;
	  //bf = true;
	  //break;
	}else if(taikaku0 < taikaku && min > taikaku){
	  mh = j;
	  mw = i;
	  min = taikaku;
	  //bf = true;
	  //break;
	}else if(taikaku0 < taikaku && min == taikaku && mh > j){
	  mh = j;
	  mw = i;
	  min = taikaku;
	  //bf = true;
	  //break;
	}
      }
      //if(bf){
      //break;
      //}
    }
    cout << mh << " " << mw << endl;
  }
  return 0;
}

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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int t; cin >> t;
  if(t < 1200) cout << "ABC" << endl;
  else if(t < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        var list = new int[26];
        for (int i = 0; i < n; i++)
        {
            list[s[i] - 'a']++;
        }
        long ans = 1;
        for (int i = 0; i < 26; i++)
        {
            if (list[i] > 0) ans *= (list[i] + 1);
            ans %= 1000000007;
        }
        Console.WriteLine(ans - 1);
    }
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

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

    int N;
    cin >> N;
    unordered_map<string, ll> m;
    REP(i, N) {
        string s;
        cin >> s;
        sort(all(s));
        m[s]++;
    }
    ll result = 0;
    for (pair<string, ll> p: m) {
        ll x = p.second;
        if (x >= 2) {
            result += x * (x - 1) / 2;
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 10660
A,B,C,D = map(int,input().split())
time = 0

if C <= B and A <= C:
    if D <= B:
        time = D - C
    else:
        time = B - C

if D >= A and A >= C:
    if D <= B:
        time = D - A
    else:
        time = B - A

print(time)

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int r[N], cnt[N], a[N], b[N];
int n, m;
ll ans[N], res;

int find_set(int x) {
    int rx = r[x];
    if (x == rx) return x;
    return r[x] = find_set(rx);
}

void union_set(int x, int y) {
    int rx = find_set(x);
    int ry = find_set(y);
    if (rx == ry) return;

    res -= cnt[rx] * cnt[ry];

    if (cnt[rx] > cnt[ry]) {
        cnt[rx] += cnt[ry];
        r[ry] = rx;
    } else {
        cnt[ry] += cnt[rx];
        r[rx] = ry;
    }
}

int main() {
    cin >> n >> m;
    iota(r, r + n, 0);
    fill(cnt, cnt + n, 1);
    res = 1LL * n * (n - 1) / 2;
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
    }
    for (int i = m - 1; i >= 0; --i) {
        ans[i] = res;
        union_set(a[i] - 1, b[i] - 1);
    }
    for (int i = 0; i < m; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 5996
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int A,B,C,X;
    cin>>A>>B>>C>>X;
    int ans=0;
    REP(i,A+1){
        REP(j,B+1){
            REP(k,C+1){
                if(500*i+100*j+50*k==X)ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int W, H, x, y, r;

int main(){
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    
    if((x-r < 0) || (x+r > W) || (y-r < 0) || (y + r > H))
        printf("No\n");
    else
        printf("Yes\n");
        
    return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



// http://sesenosannko.hatenablog.com/entry/2017/09/01/214852
// https://beta.atcoder.jp/contests/abc061/submissions/3322496
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3166760#1
// 0-index
struct Bellman_Ford{
  struct edge{ll from, to, cost;};
  ll inf = 1e16;
  vector<edge> es;
  vector<ll> d;
  ll V,E;
  void init(ll v,ll e){
    V = v; E = e;
    d.resize(V);
  }
  void shortest_path(ll s){
    FOR(i,0,V) d[i] = inf;
    d[s] = 0;
    FOR(i,0,V){
      FOR(j,0,E){
        edge e = es[j];
        if(d[e.from]!=inf && d[e.to]>d[e.from] + e.cost){
          d[e.to] = d[e.from] + e.cost;
        }
      }
    }
  }
  bool find_negative_loop(){// all graph
    FOR(i,0,V)d[i] = 0;
    FOR(i,0,V){
      FOR(j,0,E){
        edge e = es[j];
        if(d[e.to]>d[e.from] + e.cost){
          d[e.to] = d[e.from] + e.cost;
          if(i == V-1) return true;
        }
      }
    }
    return false;
  }
  bool find_negative_loop(ll s){// from s
    ll cnt = 0;
    FOR(i,0,V)d[i]=inf;
    d[s]=0;
    while(true){
      bool update = false;
      cnt++;
      FOR(i,0,E){
        edge e = es[i];
        if(d[e.from] != inf && d[e.to]>d[e.from] + e.cost){
          d[e.to] = d[e.from] + e.cost;
          if(cnt == V){
            return true;
          }
          update = true;
        }
      }
      if(! update)break;
    }
    return false;
  }
  bool shortest_path(int s, int t){ // t: destination
    FOR(i,0,V)d[i] = inf;
    d[s] = 0;
    FOR(i,0,2*V){
      FOR(j,0,E){
        edge e = es[j];
        if(d[e.from]!=inf && d[e.to]>d[e.from] + e.cost){
          d[e.to] = d[e.from] + e.cost;
          if(i>=V-1 && e.to==t) return true;
        }
      }
    } 
    return false;
  }
};


int main(){

  ll N,M;
  cin >> N >> M;
  Bellman_Ford bf;
  bf.init(N+1,M);
  FOR(i,0,M){
    ll a,b,c;
    cin >> a >> b >> c;
    bf.es.push_back({a,b,-c});
  }
  if(bf.shortest_path(1,N)){
    cout << "inf" << endl;
  }else{
    cout << -bf.d[N] << endl;
  }

}




Measured memory_bytes: 3668
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

#define INF 1000000000
#define MAX 100000

bool isprime[MAX];
vector<int> primes;

void make_list(){
    fill(isprime, isprime+MAX, true);
    isprime[0]=isprime[1]=false;
    for(int i=2; i<=MAX/2; i++){
        if(isprime[i]){
            for(int j=i*2; j<=MAX; j+=i) isprime[j]=false;
            primes.pb(i);
        }
    }
}

int main(){
    make_list();
    int m,a,b;
    int n=primes.size();
    while(cin>>m>>a>>b, m|a|b){
        bool flg=true;
        int p,q;
        while(flg){
            rep(i,n){
                if(m/2 < primes[i]) break;
                if( m%primes[i]==0 && isprime[m/primes[i]]==true ){
                    p = primes[i];
                    q = m/primes[i];
                    if(p>q) swap(p,q);
                    if(a*q>b*p) break;
                    flg=false;
                    break;
                }
            }
            m--;
        }
        cout<<p<<" "<<q<<endl;
    }

    return 0;
}

Measured memory_bytes: 1368
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

signed main() {
  ll A, B;
  cin >> A >> B;
  COUT(lcm(A, B));
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,A[200005];
int main(){
	scanf("%d",&n);
	int mx=0,se=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&A[i]);
		if(A[i]>mx)se=mx,mx=A[i];
		else se=max(se,A[i]);
	}
	for(int i=1;i<=n;i++)
		if(A[i]==mx)printf("%d\n",se);
		else printf("%d\n",mx);
	return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

ll a,b,sum=1;


void init(){
	cin>>a>>b;
}

int main(void){
	init();
	int ans;
	for(ans=0;sum<b;ans++){
		sum+=a-1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#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()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    int allE = 0, allW = 0;
    rep(i, s.size()) {
        if (s[i] == 'E')
            allE++;
        else
            allW++;
    }

    int res = s.size();
    int curE = 0, curW = 0;
    rep(i, s.size()) {
        int rightE = allE - curE;
        if (s[i] == 'E')
            rightE--;
        res = min(res, curW + rightE);

        if (s[i] == 'E')
            curE++;
        else
            curW++;
    }

    cout << res << endl;
}

Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n, m; cin >> n >> m;
    vector<vector<char>> a(n, vector<char>(n)), b(m, vector<char>(m));
    REP(i, n) REP(j, n) cin >> a[i][j];
    REP(i, m) REP(j, m) cin >> b[i][j];
    REP(i, n-m+1)
        REP(j, n-m+1){
            bool match = true;
            REP(k, m){
                REP(l, m){
                    if(a[i+k][j+l] != b[k][l]) match = false;
                }

            }
            if(match){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const double pi = 3.141592653589793;

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

  int h,w; cin >> h >> w;
  vector<string> g(h);
  rep(i, h) cin >> g[i];
  vector<vector<bool>> visited(h, vector<bool>(w, 0));

  ll ans = 0;

  rep(H, h) {
    rep(W, w) {
      if(g[H][W] == '.' || visited[H][W]) continue;
      queue<pair<P,char>> q;
      q.push({{H,W}, '#'});
      visited[H][W] = 1;

      ll black = 1, white = 0;

      while(!q.empty()) {
        auto cur = q.front(); q.pop();
        char nextT = cur.second == '#' ? '.' : '#';

        rep(i, 4) {
          int nextH = cur.first.first + dy[i];
          int nextW = cur.first.second + dx[i];
          if(nextH >= 0 && nextH < h && nextW >= 0 && nextW < w && g[nextH][nextW] == nextT && !visited[nextH][nextW]) {
            if(nextT == '.') {
              ++white;
            } else {
              ++black;
            }

            visited[nextH][nextW] = 1;
            q.push({{nextH,nextW}, g[nextH][nextW]});
          }
        }
      }

      ans += black * white;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int i,j,a,x[101];
	while(1){
		scanf("%d",&a);
		if(a<0) break;
		i=-1;
		while(1){
			i++;
			if(a<4){
				x[i]=a;
				break;
			}
			x[i]=a%4;
			a/=4;
		}
		for(j=i;j>=0;j--){
			printf("%d",x[j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1032
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#include<algorithm>
#include<queue>
typedef long long ll;
#include<vector>
#define cin(n) scanf("%lld",&(n))
#define cout(n) printf("%lld",(n))
#define couc(c) printf("%c",(c))
#define coutn printf("\n")
#define cout_ printf(" ")
const int MAXN= 1e4 + 5 ;
ll n;
int main()
{
    cin(n);
    if(n==7||n==5||n==3)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define mp make_pair
    #define pb push_back
    #define fp first
    #define sp second
    typedef long long int ll;
    typedef pair<ll,ll> pp;
    #define check(x, i) ((x>>i)&1LL)
    #define set(x,i) (x|(1LL<<i))
    #define unset(x,i) (x&~(1LL<<i))
    #define INF LONG_MAX
    #define MAX_N 20
    #define MAX 4000005
    #define mod 1000000007
    #define REP(i,n) for(i=0;i<n;i++)
    #define FOR(i,a,b) for(i=a;i<=b;i++)
    #define RFOR(i,a,b) for(i=a;i>=b;i--)
    #define len(i,s) for(i=0;s[i];i++)
    #define T() ll t;cin>>t;while(t--)
    ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
    ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
    ll modInverse(ll a,ll p){return pow1(a,p-2,p);}
 
    int main()
    {
      boost
      #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);    
        freopen("output.txt", "w", stdout);
    #endif 
    char c;
    cin>>c;
    if(c>='A'&&c<='Z')
    cout<<"A";
    else
    cout<<"a"; 
        }

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader (
			new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		int a = Integer.parseInt(input[0]);
		int b = Integer.parseInt(input[1]);
		int c = Integer.parseInt(input[2]);
		int d = Integer.parseInt(input[3]);
		int area1 = a*b;
		int area2 = c*d;

		if(area1<area2){
			System.out.println(area2);
		}else if(area1 == area2){
			System.out.println(area1);
		}else{
			System.out.println(area1);
		}
	}
}

Measured memory_bytes: 21204
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("YES");
	else say("NO");
}

int main() {
	makei(N);
	makev(a, N);
	sort(all(a));
	say(a.back() - a.front());
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
    n <- getInt
    print $ sum [i| i <- [1..n], i `mod` 3 /= 0, i `mod` 5 /= 0]

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

using namespace std;

int main(){
    long long X;
    long long K; 
    long long D;
    cin >> X >> K >> D;
    X=abs(X);
    long long q=min(K,X/D);
    K -=q;
    X -=q*D;
    if( K%2==0 ){
        cout << X << endl;
    }
    else{
        cout << D-X << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()



int main(void){
    
    int H,W;
    cin >> H >> W;
    
    vector<string> S;
    string s;
    rep(i,H){
        cin >> s;
        S.push_back(s);
    }
	
    /* cout << H << endl;
    cout << W << endl;
    cout << S[0][2] << endl; */

    int T[H][W];
    int a;
    string x;

    rep(i,H){
        a = 0;
        rep(j,W){
            x = S[i][j]; 
            if(x == "#"){
                if(a == 0){
                    T[i][j] = 0;
                }else{
                    rep(k,a){
                        T[i][k+j-a] = a;
                    }
                    T[i][j] = 0;
                }
                a = 0;
            }else{
                a = a + 1;
            }
        }
        rep(k,a){
            T[i][k+W-a] = a;
        }
    }

    int max = 0;
    rep(i,W){
        a = 0;
        rep(j,H){
            if(T[j][i] == 0){
                if(a > 0){
                    rep(k,a){
                        T[k+j-a][i] = T[k+j-a][i] + a;
                        if(T[k+j-a][i] > max) {
                            max = T[k+j-a][i];
                        }
                    }
                }
                a = 0;
            }else{
                a = a + 1;
            }
        }
        rep(k,a){
            T[k+H-a][i] = T[k+H-a][i] + a;
            if(T[k+H-a][i] > max) {
                max = T[k+H-a][i];
            }
        }
    
    }

    cout << max-1 << endl;

 /*    rep(i,H){
        rep(j,W){
            cout << T[i][j] << endl;
        }
    } */

    return 0;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int MN = 100010;

int dp[MN][3];

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

    rep(i, N) {
        int a[3];
        rep(j, 3) cin >> a[j];
        if (i == 0) {
            rep(j, 3) dp[i][j] = a[j];
        } else {
            rep(j, 3) {
                rep(k, 3) if (j != k) {
                    dp[i][j] = max(dp[i][j], dp[i-1][k] + a[j]);
                }
            }
        }   
    }
    cout << max({dp[N-1][0], dp[N-1][1], dp[N-1][2]}) << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>

using namespace std;

int main() {
	vector<int> f(330000, 0);
	vector<int> dd(330000, 0);
	f[0] = f[1] = 1;
	for (int i = 2; i*i <= 330000; i++) {
		for (int j = 2; i*j < 330000; j++) {
			f[i*j] = 1;
		}
	}
	for (int i = 1; i < 330000; i++) {
		dd[i] = dd[i-1];
		if (f[i] == 0) {
			dd[i]++;
		}
	}
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		cout << dd[n * 2] - dd[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 5196
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
a, b, c, d = map(int, input().split())
t = b - a + 1

e = (b//c - a//c)
if a % c == 0:
  e += 1
f = (b//d - a//d)
if a % d == 0:
  f += 1

h = lcm(c, d)  
g = b//h - a//h
if a % h == 0:
  g += 1
print(t - (e+f-g))

Measured memory_bytes: 5048
str = gets
    CNT = str.length
    i = 0
    min = 753
    while CNT - i >= 3 do
        if (str[i,3].to_i - 753).abs < min then
            min = (str[i,3].to_i - 753).abs
        end
        i = i + 1
    end
    print min

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll>retu(n);
    for(int i=0;i<n;i++){
        cin >> retu.at(i);
        retu.at(i)--;
    }
    map<ll,ll>ma;
    ll now = 0;
    ll next = 0;
    ll che;
    ll value;
    vector<ll>za;
    while(1){
        if(ma.count(next)){
            che = ma.at(next);
            value = next;
            za.push_back(next);
            break;
        }
        ma[next]=now;
        za.push_back(next);
        next= retu.at(next);
        now++;
    }
    if(k<=za.size()){
        ll ans = za.at(k)+1;
        cout<<ans<<endl;
        return 0;
    }
    if(che==0){
        ll d = za.size()-1;
        k = k%d;
        ll ans = za.at(k)+1;
        cout << ans << endl;
    }
    else{
        k-=che;
        vector<ll>dd;
        bool w =0;
        for(int i=0;i<za.size();i++){
            if(za.at(i)==value){
                w=1;
            }
            if(w){
                dd.push_back(za.at(i));
            }
        }
        ll ddd = dd.size()-1;
        if(k>=ddd){k = k%ddd;}

        ll ans = dd.at(k)+1;
        cout<<ans<<endl;
    }
}
    



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

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0, ct = 0;
	cin >> n;
	vector<lli> l(n);
	for (auto &i : l)
		cin >> i;
	auto canForm = [&](lli a, lli b, lli c)
	{
		return ((a + b > c) && (a + c > b) && (b + c > a));
	};
	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j)
			for (int k = j + 1; k < n; ++k)
			{
				if (l[i] != l[j] && l[j] != l[k] && l[i] != l[k])
				{
					if (canForm(l[i], l[j], l[k]))
						++ct;
				}
			}
	cout << ct << endl;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;


	void doIt() {
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		int ans[] = new int[n];
		for(int i = 0; i < n; i++) {
			ans[a[i] - 1] = i + 1;
		}
		for(int i = 0; i < n; i++) {
			System.out.print(ans[i] + " ");
		}
		System.out.println();
		
	}

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


Measured memory_bytes: 60812
import sys

# import re
# import math
# import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
# import copy
# import heapq
# import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()

    lim = 60
    zero = [0 for _ in range(lim)]
    one = [0 for _ in range(lim)]

    for ai in a:
        for i in range(lim):
            if ai >> i & 1:
                one[i] += 1
            else:
                zero[i] += 1

    ans = 0
    for i in range(lim):
        ans += 2 ** i * zero[i] * one[i]
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 122088
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int y = sc.nextInt();
      int area = x*y;
      int length = (x+y)*2;
      System.out.println(area+" "+length);
      sc.close();
  } 
} 


Measured memory_bytes: 26000
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100;

int main(void){
    ll N, T;
    vector<pair<ll, ll>> ct;

    cin >> N >> T;
    rep(i, N){
        ll c, t;
        cin >> c >> t;
        ct.push_back(make_pair(c, t));
    }

    sort(all(ct));

    rep(i, N) if (ct[i].second <= T) {cout << ct[i].first << endl; return 0;}

    cout << "TLE" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll mod = 1e9+7;

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> as;
    rep(i, n) {
        int a; cin >> a;
        as.push(a);
    }
    rep(i, m) {
        int v = as.top(); as.pop();
        v /= 2;
        as.push(v);
    }
    ll ret = 0; 
    while (!as.empty()) {
        int v = as.top(); as.pop();
        ret += v;
    } 
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 892
import sys

n,m=map(int,input().split())
broken=set(map(int,sys.stdin))

if n==1:
  print (1)
  sys.exit()
if n==2:
  if 1 not in broken and 2 not in broken:
    print (2)
  elif 2 in broken:
    print(0)
  elif 1 in broken and 2 not in broken:
    print(1)
  sys.exit()

way = [0]*n
if 1 not in broken:
  way[0]=1
if 1 not in broken and 2 not in broken:
  way[1]=2
elif 1 in broken and 2 not in broken:
  way[1]=1
for i in range(2,n):
  if i+1 in broken:
    way[i]=0
    continue
  way[i]=(way[i-1]+way[i-2])%1000000007
print(way[n-1])
  

Measured memory_bytes: 11884
#include <stdio.h>
#include <stdbool.h>
#pragma GCC optimize ("O3")

inline static long gl(void){
    long x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

inline static void pl(unsigned int s){
    char str[9];
    int pos=9;
    if(s==0){
        putchar_unlocked('0');
        return;
    }
    do{
        pos--;
        str[pos]=s%10+48;
        s/=10;
    }while(s!=0);
    for(; pos<9; pos++){
        putchar_unlocked(str[pos]);
    }
}

inline static int sp(unsigned char* str, unsigned short i){
    if(i>99){
        str[2] = i%10+48; i/=10;
        str[1] = i%10+48;
        str[0] = i/10+48;
        return 3;
    }else if(i>9){
        str[1] = i%10+48;
        str[0] = i/10+48;
        return 2;
    }else{
        str[0] = i+48;
        return 1;
    }
}

unsigned char a[2*500*500];
unsigned char buffer[8*1024*1024];

int main(void){
    const unsigned long h=gl(), w=gl();
    unsigned long p=0, pos=0;
    unsigned char *aa = a-2; 
    fread(a, 1, 2*w*h, stdin);
    {
        bool haveCoin = false;
        unsigned short old_y, old_x;
        for(unsigned long i=1; i<=h; i++){
            if(i%2==1){
                for(unsigned long j=1; j<=w; j++){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin = aa[2*j]&1 ? !haveCoin : haveCoin;
                    old_y = i;
                    old_x = j;
                }
            }else{
                for(long j=w; j>0; j--){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin = aa[2*j]&1 ? !haveCoin : haveCoin;
                    old_y = i;
                    old_x = j;
                }
            }
            aa+=2*w;
        }
    }
    pl(pos); putchar_unlocked('\n');
    fwrite(buffer, 1, p, stdout);
    return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;

using int64 = long long;

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

struct Arc {
  int to;

  Arc() = default;
  Arc(int to): to(to) {}
};

vector<Arc> graph[100000];
int in_deg[100000], parent[100000]; //, out_deg[100000];

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

  int n, m;
  cin >> n >> m;

  repeat (i, n + m - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;

    graph[a].emplace_back(b);
    in_deg[b]++;
  }

  int r = -1;
  repeat (u, n) {
    if (in_deg[u] == 0) {
      r = u;
      break;
    }
  }

  using P = pair<int, int>; // (現在ノード, 親)
  queue<P> que;
  que.push(P(r, -1));

  while (!que.empty()) {
    P p = que.front(); que.pop();

    parent[p.first] = p.second;

    for (Arc& arc : graph[p.first]) {
      in_deg[arc.to]--;
      if (in_deg[arc.to] == 0) {
        que.push(P(arc.to, p.first));
      }
    }
  }

  repeat (u, n) {
    cout << parent[u] + 1 << "\n";
  }

  return 0;
}



Measured memory_bytes: 7040
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int n,k;
    cin >> n >> k;
    if (n % k == 0){
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    S = input()

    ans = 0
    for i, c in enumerate(S):
        if i < ceil(len(S), 2):
            h = "g"
        else:
            h = "p"

        if c == h:
            continue
        elif c == "g" and h == "p":
            ans += 1
        elif c == "p" and h == "g":
            ans -= 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4204
fn read() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_string()
}

fn main() {
    let n: usize = read().parse().unwrap();
    let a: Vec<i64> = read()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let mut sum = (0, 0);
    let mut cnt = (0, 0);
    use std::cmp::{max, min};
    for i in 0..n {
        sum.0 += a[i];
        sum.1 += a[i];
        let f = if i % 2 == 0 { (1, -1) } else { (-1, 1) };

        cnt.0 += max(0, 1 - sum.0 * f.0);
        sum.0 = max(1, sum.0 * f.0) * f.0;
        cnt.1 += max(0, 1 - sum.1 * f.1);
        sum.1 = max(1, sum.1 * f.1) * f.1;
    }
    println!("{}", min(cnt.0, cnt.1));
}


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

int main(){
    bool A=1;
    while(A){
        int H,W;
        cin >> H >> W;
        if (H==0 && W==0) {A=0;}
        else {
            string s="";
            for (int i=0; i<W; i++) {
                if (i%2==0) {s+="#";}
                else {s+=".";}
            }
            string t="";
            for (int i=0; i<W; i++) {
                if (i%2==0) {t+=".";}
                else {t+="#";}
            }

            for (int i=0; i<H; i++){
                if (i%2==0) {cout << s << endl;}
                else {cout << t << endl;}
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3196
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BChocolate {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, d, x;
	    in >> n >> d >> x;
	    vector<int> a(n);
	    for(int i=0; i<n; i++){
	        in >> a[i];
	    }

	    int eat = 0;
	    for(int i=0; i<n; i++){
	        int cnt = 1;
	        int day = 2;
	        while(day <= d){
                if(day == cnt*a[i] + 1) cnt++;
                day++;
	        }
	        eat += cnt;
	    }

	    out << x + eat << endl;
	}
};


int main() {
	BChocolate solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
 using namespace std;
	int main()
	{
		ll n;
		cin>>n;
		int d=n%10;
		if(d==3)
		{
			cout<<"bon"<<endl;
			return 0;
		}
		if(d==2 || d==4 || d==5 || d==7 || d==9)
		{
			cout<<"hon"<<endl;
			return 0;
		}
		cout<<"pon"<<endl;
	}


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
   ll k, a, b;
   cin >> k >> a >> b;
   if(a>=b){
      cout << k+1 << endl;
      return 0;
   }else{
     if(k<=a-1){
        cout << k+1 << endl;
        return 0;
     }else{
        ll tempk = k;
        k -= (a-1);
        ll p = k/2;
        cout << max(a+(b-a)*p+k%2,tempk+1) << endl;
        return 0;
     }
   }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N;
    ll ans = 1;
    while(ans*2 <= N) ans *= 2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#define SuC_VaT              Doc_code_ban_khac
#define Nhan_cach_bang_0     Doc_code_ban_khac

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef pair<ll, pair<ll,ll> > iii;

const int kn = 2e5 + 5, N = 1e5+5;
const ll mod = 1e9 + 7, mod2 = 1e9+9;
const ll base = 31, base1 = 37;

#define x first
#define y second
#define lwb lower_bound
#define upb upper_bound

#define pb push_back
#define popb pop_back
#define pf push_front
#define popf pop_front

#define log2(X) (31-__builtin_clz(X))
#define log2ll(X) (63-__builtin_clzll(X))
#define numbit(X) __builtin_popcount(X)
#define numbitll(X) __builtin_popcountll(X)

#define ms(val,a) memset(a,val,sizeof(a))

#define ff(i,n) for(int i=1;i<=n;i++)
#define _ff(i,n) for(int i=n;i>=1;i--)
#define f(i,a,b) for(int i = a; i <=b; i++)
#define _f(i,a,b) for(int i = b; i>=a;i--)

#define In(X) freopen(X,"r",stdin)
#define Out(X) freopen(X,"w",stdout)

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll n, a[kn];
vector<ii> ans;

int main()
{
	scanf("%lld",&n);
	ff(i,n) scanf("%lld", &a[i]);
	sort(a+1,a+n+1);
	if(n==2)
	{
		printf("%d\n",a[2]-a[1]);
		printf("%d %d",a[2],a[1]);
		return 0;
	}
	int j = 1;
	while(j<n && a[j] < 0)
	{
		j++;
	}
	if(j>1) j--;
	for(int i = j; i <n-1; i++)
	{
		ans.pb({a[i],a[i+1]});
		a[i+1] = a[i] - a[i+1];	
	}
	for(int i = 1; i<j; i++)
	{
		ans.pb({a[n],a[i]});
		a[n] -= a[i];
	}
	printf("%lld\n", a[n] - a[n-1]);
	for(ii tmp : ans) printf("%lld %lld\n", tmp.x,tmp.y);
	printf("%lld %lld", a[n], a[n-1]);
	
	
}


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


Measured memory_bytes: 256
my $line = <STDIN>;
chomp($line);
my @vals = split(" ",$line);

my $X = $vals[0];
my $Y = $vals[1];
if($X*4 < $Y) {
  print "No";
}elsif($X*2 > $Y) {
  print "No";
}else {
  for(my $i=0; $i <= $X; $i++) {
    my $cnt = $i*2 + ($X - $i)*4;
    if($cnt == $Y) {
      print "Yes";
      exit;
    }
  }
  print "No";
}

Measured memory_bytes: 4792
n = int(input())
cost = list(map(int, input().split()))

dp = [0]*n
dp[1] = abs(cost[0] - cost[1])

for i in range(2,n):
    dp[i] = min(dp[i-2] + abs(cost[i] - cost[i-2]), dp[i-1] + abs(cost[i] - cost[i-1]))

print(dp[n-1])


Measured memory_bytes: 13980
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll L = 0, R =0, d=0;
    cin >> L >> R >> d;

    //本文
    ll cnt =0;
    for(int i = L; i < R+1;i++){
      if(i%d==0)cnt++;
    }
    //出力
    cout << cnt << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3524