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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, D;
    cin >> N >> D;

    vector<ll> X(N);
    vector<ll> Y(N);

    REP(i, N){
        cin >> X[i] >> Y[i];
    }

    two_sat ts(N);

    for(ll i=0; i<N; i++){
        for(ll j=i+1; j<N; j++){
            
            // x同士を選んでは行けないとき
            if(abs(X[i] - X[j]) < D){
                // iかjのいずれかはfalseをとらなくてはならない
                ts.add_clause(i, false, j, false);
            }
            if(abs(X[i] - Y[j]) < D){
                ts.add_clause(i, false, j, true);
            }
            if(abs(Y[i] - X[j]) < D){
                ts.add_clause(i, true, j, false);
            }
            if(abs(Y[i] - Y[j]) < D){
                ts.add_clause(i, true, j, true);
            }
        }
    }

    if(ts.satisfiable()){
        cout << "Yes" << endl;
        auto ans = ts.answer();
        ll count = 0;
        for(auto a: ans){
            // cout << a << endl;
            if(a) cout << X[count] << endl;
            else cout << Y[count] << endl;
            count++;
        }
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char s[525252];
int lft[525252], rgt[525252];

int dp[525252];

int main(){
  scanf("%d",&n);
  scanf("%s",s);
  FOR(i,n,n+10)s[i]='0';
  lft[0] = -1;
  FOR(i,1,n+10){
    if(s[i-1]=='1'){
      if(lft[i-1]==-1){
        lft[i] = i-1;
      }else{
        lft[i] = lft[i-1];
      }
    }else{
      lft[i] = -1;
    }
  }
  rgt[n-1+10] = -1;
  FORR(i,0,n-1+10){
    if(s[i+1]=='1'){
      if(rgt[i+1]==-1){
        rgt[i] = i+1;
      }else{
        rgt[i] = rgt[i+1];
      }
    }else{
      rgt[i] = -1;
    }
  }
  REP(i,n){
    // 何もしない
    CHMAX(dp[i+1],dp[i]);
    if(s[i]=='1' && s[i+1]=='0' && s[i+2]=='1'){
      // 101111
      int tcnt = rgt[i+1] - (i+1);
      CHMAX(dp[rgt[i+1]+1], dp[i]+tcnt);
      if(rgt[i+1]>i+2){
        CHMAX(dp[rgt[i+1]], dp[i]+tcnt-1);
      }
    }
    if(s[i]=='1'){
      int to = rgt[i];
      if(to==-1)to=i;
      if(s[to]=='1' && s[to+1]=='0' && s[to+2]=='1'){
        // 111101
        CHMAX(dp[to+3],dp[i]+(to+1-i));
      }
    }
  }
  printf("%d\n",dp[n]);
  return 0;
}


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

typedef long long int ll;
using namespace std;
const long long mod=1e9+7;
int main(){
	int N,M,s,num=0;
	ll count=1;
	cin >> N>>M;
	
	vector<int> oks(N+1,true);
	vector<ll> dp(N+1,0);
	for(int i=0;i<M;i++){
		cin>>s;
		oks[s]=false;
	}
	dp[0]=1;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<=min(N,i+2);j++){
			if(oks[j]){
				dp[j]+=dp[i];
				dp[j]%=mod;
			}
		}
	}
	/*for(int i=1;i<N+1;i++){
		if(oks[i]){
			if(i==1){
				dp[i]=1;
			}else{
				dp[i]=dp[i-1]+dp[i-2];
				dp[i]%=mod;
			}
		}else{
			dp[i]=0;
		}
	}*/
	cout << dp[N] <<endl;
	return 0;
		
}

Measured memory_bytes: 1408
#include<iostream>
#include<cmath> 
#include<algorithm>
using namespace std;
int main(){
	int n;
	int a[100010]={};
	cin>>n;
	for(int i=0;i<n;i++){
		int temp;
		cin>>temp;
		a[temp]++;
	}
	int count=0;
	int sum=0;
	for(int i=0;i<100010;i++){
		if(a[i]>0){
			count++;
			sum+=a[i]-1;
		}
	}
	if(sum%2==0)
		cout<<count;
	else cout<<count-1;
	return 0;
} 

Measured memory_bytes: 640
def main():
    N = int(input())
    a = [0] + [int(ele) for ele in input().split()]
    a.sort()
    ans_min = 0
    ans_min += 1 if len(list(filter(lambda x: 1 <= x <= 399, a ))) > 0 else 0
    ans_min += 1 if len(list(filter(lambda x: 400 <= x <= 799, a )))> 0 else 0
    ans_min += 1 if len(list(filter(lambda x: 800 <= x <= 1200, a )))> 0 else 0
    ans_min += 1 if len(list(filter(lambda x: 1200 <= x <= 1599, a )))> 0 else 0
    ans_min += 1 if len(list(filter(lambda x: 1600 <= x <= 1999, a )))> 0 else 0
    ans_min += 1 if len(list(filter(lambda x: 2000 <= x <= 2399, a )))> 0 else 0
    ans_min += 1 if len(list(filter(lambda x: 2400 <= x <= 2799, a )))> 0 else 0
    ans_min += 1 if len(list(filter(lambda x: 2800 <= x <= 3199, a )))> 0 else 0
    over = list(filter(lambda x: 3200 <= x, a ))

    ans_max = ans_min + len(over)

    if ans_min == 0 and len(over) > 0:
        ans_min = 1 

    print(ans_min, ans_max)


if __name__=="__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define rep(i, n) for(int i = 0; i < n; i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ

//型名省略
typedef long long ll;
//値
static const ll MX = 1e18;
#define NIL = -1;

using namespace std;

//#include "./lib/generic/search.h"

int main(){
    string s, t;
    cin >> s >> t;
    int ans=0;
    rep(i, s.length()){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3916
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String N = scanner.next();
        //各行の数字の和
        int sum = 0;

        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < N.length(); i++) {
        	//Nの各行を数値に変換し足す
        	int x = Integer.parseInt(N.substring(i, i+1));
        	sum += x;
        }

        int n = Integer.parseInt(N);
        String judge = n % sum == 0 ? "Yes" : "No";

        System.out.println(judge);
	}
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int n, h;

struct SWORD {
	int a;
	int b;
};

SWORD s[N];

bool cmp (SWORD a, SWORD b) {
	return a.b > b.b;
}

int main() {

	FAST;

	cin >> n >> h;
	for (int i = 0; i < n; i ++) {
		cin >> s[i].a >> s[i].b;
	}
	int maxx = 0;
	for (int i = 0; i < n; i ++) {
		maxx = max(maxx, s[i].a);
	}
	sort(s, s + n, cmp);
	int ans = 0;
	for (int i = 0; i < n; i ++) {
		if (s[i].b < maxx) {
			break;
		}
		else {
			h -= s[i].b;
			ans ++;
			if (h <= 0) {
				cout << ans << '\n';
				return 0;
			}
		}
	}
	ans += (h + maxx - 1) / maxx;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstdio>
#include <queue>
using namespace std;

typedef pair<int, int> lake;

int main(void){
  int n, q;
  cin >> n;
  vector<int> s(n);
  for(int i=0;i<n;i++) cin >> s[i];
  cin >> q;
  vector<int> t(q);
  for(int i=0;i<q;i++) cin >> t[i];
  //sort(s.begin(), s.end());
  //sort(t.begin(), t.end());
  int count =0;
  for(int i=0;i<q;i++){
    for(int j=0;j<n;j++){
      if(t[i] == s[j]){
        count++;
        break;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1232
import numpy as np
import sys

A = np.zeros((3, 3), dtype=np.int64)
for i in range(3):
    l, m, n = map(int, input().split())
    A[i][0] = l
    A[i][1] = m
    A[i][2] = n
N = int(input())
b = []
for i in range(N):
    k = int(input())
    b.append(k)
for k in range(N):
    for i in range(3):
        for j in range(3):
            if b[k] == A[i][j]:
                A[i][j] = 0


row = np.sum(A, axis=1)
for i in range(3):
    if row[i] == 0:
        print('Yes')
        sys.exit()


col = np.sum(A, axis=0)
for i in range(3):
    if col[i] == 0:
        print('Yes')
        sys.exit()

c = 0
for i in range(3):
    c += A[i][i]
if c == 0:
    print('Yes')
    sys.exit()

c = 0
for i in range(3):
    c += A[3-i-1][i]
if c == 0:
    print('Yes')
    sys.exit()

print('No')

Measured memory_bytes: 12504
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  while(1){
    int n,mod;
    cin>>n>>mod;
    if(n == 0 && mod == 0) break;
    
    vector<int> A(n);
    cin>>A;

    multiset<int> S;
    vector<int> Mod(n);
    for(int i=0,s=0;i<n;i++){
      s += A[i];
      S.insert(s%mod);
      S.insert(s%mod + mod);
      Mod[i] = s%mod;
    }

    int ans = 0;
    int ofset = 0;
    for(int i=0;i<n;i++){
      int num = *(--S.upper_bound(ofset + mod - 1));
      Max(ans,num-ofset);
      S.erase(S.find(Mod[i]));
      S.erase(S.find(Mod[i]+mod));
      ofset = (ofset + A[i])%mod;
      
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 6164
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	string S;
	cin >> S;
	rep(i, S.size()) {
		cout << 'x';
	}
	cout << endl;
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    long long a[N];
    for (int n = 0; n < N; n++) {
        cin >> a[n];
        if (a[n] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    long long prod = 1;
    for (int i = 0; i < N; i++) {
        if (a[i] <= 1000000000000000000 / prod) {
            prod *= a[i];
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << prod << endl;
}


Measured memory_bytes: 4312
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll n;
  cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  vi l(n),r(n);
  rep(i,n){
    l[i]=a[i]+i;
    r[i]=i-a[i];
  }
  //outv(l);
  //outv(r);
  ll p=0;
  rep(i,n) if(l[i]==r[i]) p++;
  sort(all(l)); sort(all(r));
  ll ans=0;
  rep(i,n) ans+=ub(r,l[i])-lb(r,l[i]);
  rep(i,n) ans+=ub(l,r[i])-lb(l,r[i]);
  //out(ans);
  out((ans-p)/2);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


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

typedef long long ll;

ll N;
map<ll, ll> A;
vector<ll> C;
map<ll, ll> D;

int main() {
  cin >> N;
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    ++A[a];
  }
  for (auto ac : A) C.push_back(ac.second);
  sort(C.begin(), C.end(), greater<ll>());
  for (ll i = 0; i < C.size(); ++i) {
    ll d = C[i] - (i + 1 < C.size() ? C[i + 1] : 0);
    if (d != 0) D[i + 1] = d;
  }
  ll limit = D.rbegin()->first;
  for (ll k = 1; k <= N; ++k) {
    ll res = 0;
    if (k <= limit) {
      map<ll, ll> d = D;
      while (!d.empty() && d.rbegin()->first >= k) {
        auto it = d.find(k);
        if (it != d.end()) {
          if (--it->second == 0) d.erase(it);
        } else {
          auto it2 = d.upper_bound(k);
          ll j = it2->first;
          if (it2 == d.begin()) {
            d[j - k] = 1;
            if (--it2->second == 0) d.erase(it2);
          } else {
            auto it1 = prev(it2);
            ll i = it1->first;
            d[j - (k - i)] = 1;
            if (--it1->second == 0) d.erase(it1);
            if (--it2->second == 0) d.erase(it2);
          }
        }
        ++res;
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

void out(int64_t a, int64_t b, int64_t c) {
  printf("a: %lld, b: %lld, c: %lld\n", a, b, c);
}

int main() {
  int64_t a, b, c; cin >> a >> b >> c;
  if (a == b && b == c) {
    cout << (a % 2 ? 0 : -1) << "\n";
    exit(0);
  }
  int counter = 0;
  while (1) {
    if (a % 2 || b % 2 || c % 2) break;
    int64_t pa = a / 2;
    int64_t pb = b / 2;
    int64_t pc = c / 2;
    a = pb + pc;
    b = pc + pa;
    c = pa + pb;
    counter++;
//    out(a, b, c);
  }
  cout << counter << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <ctime>
#include <list>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef pair<int,int> PI;
#ifndef M_PI
const double M_PI=acos(-1);
#endif
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int((a).size()))
#define F first
#define S second
int dx[]={0,1,0,-1,0,0},dy[]={1,0,-1,0,0,0};
int dz[]={0,0,0,0,1,-1};

int n;
double sx[30],sy[30],sz[30];

double dist(double x,double y,double z,int id){
  double tx=x-sx[id];
  double ty=y-sy[id];
  double tz=z-sz[id];
  return sqrt(tx*tx+ty*ty+tz*tz);
}

double rad(double x,double y,double z){
  double ret=dist(x,y,z,n-1);
  rep(i,n-1)ret=max(ret,dist(x,y,z,i));
  return ret;
}

typedef struct _node{
  double x,y,z,r;
  int wh;
  _node(double x,double y,double z,int wh):
    x(x),y(y),z(z),wh(wh),r(rad(x,y,z)){};

  bool operator<(const _node& rn)const{
    if(rn.wh!=wh)return rn.wh<wh;
    return rn.r<r;
  }
}node;

int tx[]={1,1,1,1,-1,-1,-1,-1};
int ty[]={1,1,-1,-1,1,1,-1,-1};
int tz[]={1,-1,1,-1,1,-1,1,-1};
double len[1000];

void solve(){
  rep(i,n)cin>>sx[i]>>sy[i]>>sz[i];
  len[0]=100;
  for(int i=1;i<1000;++i)
    len[i]=len[i-1]/2;
  double ans=10000;
  priority_queue<node> q;
  q.push(node(50,50,50,0));
  int cu=0;
  int bwh=-1;
  while(!q.empty()){
    node cur=q.top();
    q.pop();
    if(cu==1000 && cur.wh==bwh)continue;
    if(cu==1000)cu=0,bwh=cur.wh;
    ++cu;
    double rr=len[cur.wh];    
    if(ans<cur.r-rr*sqrt(3)*2+EPS)continue;
    ans=min(ans,cur.r);
    if(cur.wh>25)continue;
    //printf("%.5f %.5f %.5f %.5f %.7f %d\n",cur.x,cur.y,cur.z,cur.r,ans,cur.wh);

    rep(i,8)
      q.push(node(cur.x+rr*tx[i],cur.y+rr*ty[i],cur.z+rr*tz[i],cur.wh+1));
  }

  printf("%.5f\n",ans);
}

main(){
  while(cin>>n,n)
    solve();
}

Measured memory_bytes: 0
#include <iostream>
#include <string>

using namespace std;

int main() {
	long long int a;
	while (cin >> a) {
		if (a == 0) {
			break;
		}
		string abc = "0123456789";
		string b = "";
		int counter = 0;
		int c;
		while (a != 0) {
			c = a % (-10);
			c += counter;
			if (c == 10) {
				counter = -1;
				c = 0;
			} else if (c == -10) {
				counter = 1;
				c = 0;
			} else if (c < 0) {
				c += 10;
				counter = 1;
			} else {
				counter = 0;
			}
			b += abc[c];
			a /= (-10);
		}
		if (counter == 1) { 
			b += abc[1];
		} else if (counter == -1) {
			b += abc[9];
			b += abc[1]; 
		}
		for (int i = b.size()-1; i >= 0; i--) {
			cout << b[i];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

int x, y;
int main( ) {
	scanf("%d %d", &x, &y);
	// a + b = x
	// a + 2b = y / 2
	// b = y / 2 - x

	if (y & 1) printf("No\n");
	else {
		int b = y / 2 - x;
		int a = x - b;
		if (a < 0 || b < 0) printf("No\n");
		else printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 3764
K,N = map(int,input().split())
A = list(map(int,input().split()))
max = 0
for i in range(1,N):
    if max < A[i]-A[i-1]:
        max = A[i]-A[i-1]
if max < K-A[N-1]+A[0]:
    max =  K-A[N-1]+A[0]
print(K-max)

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

int main() {
  int n,x;
  cin >> n >> x;
  int base=0;
  int MIN=1000;
  int dou;
  for(int i=0; i<n; i++){
    cin >> dou; 
    base += dou;
    MIN = min(dou, MIN);
  }
  cout << n+(x-base)/MIN << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define f first
#define s second
using namespace std;
ll n;
ll a[100000],dp[100000];
ll f(ll i)
{
    if(dp[i]!=-1)
        return dp[i];
    if(i==n-1)
        return 0;
    ll left=f(i+1)+abs(a[i+1]-a[i]);
    ll r=INT_MAX;
    if(i+2<n)
        r=f(i+2)+abs(a[i+2]-a[i]);
        return dp[i]=min(left,r);
}

int main() {
    cin>>n;
    for(ll i=0;i<n;i++)
        cin>>a[i];
    memset(dp,-1,sizeof(dp));
    cout<<f(0);
	return 0;
}


Measured memory_bytes: 9880
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, w;

  cin >> h >> w;

  string s[h];

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

  for (int iH=0; iH<h; iH++) {
    for (int iW=0; iW<w; iW++) {
      if (s[iH][iW] == '#') {
        continue;
      }

      int cnt = 0;
      for (int tmpH=iH-1; tmpH<=iH+1; tmpH++) {
        for(int tmpW=iW-1; tmpW<=iW+1; tmpW++) {
          if (
            tmpH >= 0 && tmpH < h &&
            tmpW >= 0 && tmpW < w
          ) {
            if (s[tmpH][tmpW] == '#') {
              cnt += 1;
            }
          }
        }
      }

      string sCnt = to_string(cnt);
      s[iH][iW] = sCnt[0];
    }
  }

  for (int iH=0; iH<h; iH++) {
    cout << s[iH] << endl;
  }
}


Measured memory_bytes: 256
import javax.print.attribute.IntegerSyntax;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] str = new String[n];
        Map<String, Integer> m = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] cs = sc.next().toCharArray();
            Arrays.sort(cs);
            String hash = String.valueOf(cs);

            m.put(hash, m.getOrDefault(hash, 0) + 1);
        }
//        debug(m);
        long ans = 0;
        for (Map.Entry<String, Integer> entry: m.entrySet()) {
            ans += 1L * entry.getValue() * (entry.getValue() - 1) / 2;
        }
        System.out.println(ans);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 58396
a,b,c = map(int,input().split())
k = int(input())

# 貪欲法による解法
"""
Aは小さいほうが嬉しいので、操作をする必要はありません。
BはAAより大きくないといけないので、A≥Bである限り操作をする必要があります。
Cも同様にB≥Cである限り操作をする必要があります。
最低何回の操作で目的を達成できるか、実際に操作をシミュレートしてカウントします。
その後、KK回以内であるか判定すればいいです。
"""
cnt =  0

while a >= b:
    b *=2
    cnt += 1

while b >= c:
    c *=2
    cnt += 1

if cnt <= k:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var a = new List<long>();

            a.AddRange(
                Console.ReadLine()
                .Split(' ')
                .Select(long.Parse)
                );

            var ans = a.Sum() - a.LongCount();

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b;
 cin >> a >> b;
 if(a>9||b>9){
     cout << -1 << endl;
 }else{
     cout << a*b << endl;
 }
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{
    string s;cin>>s;
    int ret=1000;
    for(int i=0;i<=s.length()-3;++i){
        int x;
        x=stoi(s.substr(i,3));
        ret=min(ret,abs(x-753));
    }
    cout << ret <<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    private void execute() throws Exception {
        HashSet<Integer> set = new HashSet<>();
        for (int i = 1; i <= 9; i++) {
            for (int k = 1; k <= 9; k++) {
                set.add(i * k);
            }
        }
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        if (set.contains(n)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static void main(String[] args) {
        try {
            new Main().execute();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> A(N), B(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i] >> B[i];
  }
  vector<ll> C = A;
  vector<ll> D = B;
  sort(C.begin(), C.end());
  sort(D.begin(), D.end(), greater<ll>());
  if (N % 2 == 0)
  {
    ll medmin = C[N / 2 - 1] + C[N / 2]; // 中央値の下限を2倍したもの
    ll medmax = D[N / 2 - 1] + D[N / 2]; // 中央値の上限を2倍したもの
    ll ans = medmax - medmin + 1;
    cout << ans << endl;
  }
  else
  {
    ll medmin = C[N / 2];
    ll medmax = D[N / 2];
    cout << medmax - medmin + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 9552
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

vector<pair<string,bool>> hoge( string s ){
	vector<pair<string,bool>> arr;
	string tmp = "";
	bool f1 = 0;
	rep(i,0,s.size()){
		if( !f1 && s[i] == '"' ){
			f1 = 1;
			arr.push_back( make_pair(tmp,0));
			tmp = "";
		}
		else if( f1 && s[i] == '"' ){
			f1 = 0;
			arr.push_back( make_pair(tmp,1));
			tmp = "";
		}
		else{
			tmp += s[i];
		}
	}
	if( tmp.size() > 1 )
		arr.push_back( make_pair(tmp,0));
	ret arr;
}

int main(){
	while(1){
		string s1,s2;
		cin >> s1;
		if( s1 == ".") break;
		cin >> s2;
		vector<pair<string,bool>> arr1 = hoge(s1) , arr2 = hoge(s2);

		/*
		rep( i,0,arr1.size()) cout << arr1[i].fir << " " << arr1[i].sec << endl;
		rep( i,0,arr2.size()) cout << arr2[i].fir << " " << arr2[i].sec << endl;
		*/

		int cnt = 0;

		if( arr1.size() != arr2.size() ) cnt += 100;
		rep(i,0,min( arr1.size() , arr2.size() )){
			if( arr1[i].sec != arr2[i].sec ) cnt += 100;
			else if( arr1[i].fir != arr2[i].fir){
				if( arr1[i].sec == 1 )
					cnt++;
				else
					cnt += 100;
			}
		}

		if( cnt == 0 ) cout << "IDENTICAL" << endl;
		else if( cnt == 1 ) cout << "CLOSE" << endl;
		else cout << "DIFFERENT" << endl;
	}
	ret 0;
}


Measured memory_bytes: 3212
from collections import deque
S = [list(map(int, input().split())) for _ in range(3)]

l=[0,0,0,0]

for i in range(3):
    for j in range(2):
        l[S[i][j]-1]+=1
#print(l)
if max(l)==3:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3316
S = input()
index = 0
for n in S:
  if index % 2 == 0:
    if n == "R" or n == "U" or n == "D":
      pass
    else:
      print("No")
      exit()
  else:
    if n == "L" or n == "U" or n == "D":
      pass
    else:
      print("No")
      exit()
  index += 1
print("Yes")

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

int gcd(int a,int b) {
  if(b == 0) return a;
  else return gcd(b,a % b);
}

int main() {

 int N,X;
 cin >> N >> X;

 vector<int> x(N),dif(N + 1);
 for(int i = 0;i < N;i++) {
   cin >> x.at(i);
 }

 x.push_back(X);
 sort(x.begin(),x.end());
 
  

 for(int i = 1;i <= N;i++) {
   dif.at(i) = x.at(i) - x.at(i - 1);
 }

 for(int i = 1;i < N;i++) {
   dif.at(i + 1) = gcd(dif.at(i),dif.at(i + 1));
 }

 cout << dif.at(N) << endl;

}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,tmp,i;
    cin>>a>>b;
    if(a>b){
    	for(i=b;i<=a;i++){
			tmp=i*a*b;
			if(tmp&1){
				cout<<"Yes";
				return 0;
			}
		}
	}
	if(a==b){
		if(a&1){
			cout<<"Yes";
			return 0;
		}
	}
	if(a<b){
    	for(i=a;i<=b;i++){
			tmp=i*a*b;
			if(tmp&1){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <istream>

using namespace std;
int main()
{
    std::string input = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
    std::string separator = ", ";
    auto separator_length = separator.length();
    auto v = std::vector<std::string>();

    auto offset = 0u;
    auto pos = input.find(separator, offset);
    while (pos != std::string::npos) {
        v.push_back(input.substr(offset, pos - offset));
        offset = pos + separator_length;
        pos = input.find(separator, offset);
    }
    v.push_back(input.substr(offset));

    int k = 0;
    cin >> k;
    cout << v[k - 1] << endl;
  
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 200005
#define LL long long
using namespace std;
const int mod = 1e9+7;
int n,Q,pre,now;
struct Seg{
	LL mn[maxn<<2],tag[maxn<<2]; int flg;
	Seg(){memset(mn,0x3f,sizeof mn);}
	inline void add(int i,LL v){mn[i]+=v,tag[i]+=v;}
	inline void down(int i){if(tag[i]) add(i<<1,tag[i]),add(i<<1|1,tag[i]),tag[i]=0;}
	void ins(int i,int l,int r,int x,LL v){
		if(l==r) {mn[i]=min(mn[i],v+l*flg);return;}
		int mid=(l+r)>>1; down(i);
		x<=mid?ins(i<<1,l,mid,x,v):ins(i<<1|1,mid+1,r,x,v);
		mn[i]=min(mn[i<<1],mn[i<<1|1]);
	}
	LL qry(int i,int l,int r,int x,int y){
		if(x<=l&&r<=y) return mn[i];
		int mid=(l+r)>>1; LL ret=mn[0]; down(i);
		if(x<=mid) ret=min(ret,qry(i<<1,l,mid,x,y));
		if(y>mid) ret=min(ret,qry(i<<1|1,mid+1,r,x,y));
		return ret;
	}
	LL whole(int i,int l,int r){
		if(l==r) return mn[i]+l;
		int mid=(l+r)>>1; down(i);
		return min(whole(i<<1,l,mid),whole(i<<1|1,mid+1,r));
	}
}T1,T2;
int main()
{
	scanf("%d%d%d%d",&n,&Q,&pre,&now),T1.flg=-1,T2.flg=1;
	T1.ins(1,1,n,now,0),T2.ins(1,1,n,now,0);
	for(int i=1;i<=Q;i++,pre=now){
		scanf("%d",&now); if(now==pre) continue;
		LL tmp=min(T1.qry(1,1,n,1,now)+now,T2.qry(1,1,n,now,n)-now);
		T1.add(1,abs(now-pre)),T2.add(1,abs(now-pre));
		T1.ins(1,1,n,pre,tmp),T2.ins(1,1,n,pre,tmp);
	}
	printf("%lld\n",T1.whole(1,1,n));
}

Measured memory_bytes: 24960
#include<stdio.h>
#include<string.h>
int N,K,i,j,n[1005][1005];
char S[1005][55];

void dfs(int p,int d)
{
	int i;
	if(p!=0)
	{
		for(i=0;i<d;i++)putchar('.');
		puts(S[p]);
	}
	for(i=0;n[p][i]!=-1;i++)
	{
		dfs(n[p][i],d+1);
	}
}

int main()
{
	memset(n,-1,sizeof(n));
	scanf("%d",&N);
	for(i=1;i<=N;i++)
	{
		scanf("%d\n",&K);
		gets(S[i]);
		for(j=0;n[K][j]!=-1;j++);
		n[K][j]=i;
	}
	dfs(0,-1);
	return 0;
}

Measured memory_bytes: 4628
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);i--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;i--)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repnd0(i,m,n) for(i=(n)-1;i>=(m);i--)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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



int main() {
	string str;
	cin>>str;
	string s="";
	int i=0;
	while(i<sz(str)){
		if(str[i]=='e'){
			s+="e";
			i+=3;
		}else{
			s+="c";
			i+=7;
		}
	}
	int j=0,r=1;
	string res=s.substr(0,1);
	rep0(i,sz(s)){
		if(i!=0&&s[i-1]==s[i]){
			if(r<i-j){
				r=i-j;
				res=s[i-1];
			}
			j=i;
		}
	}
	if(r<i-j){
		res=s[i-1];
	}
	if(res=="e")cout<<"egg"<<endl;
	else cout<<"chicken"<<endl;
	return 0;
}

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

int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> S(H, vector<int>(W));
    for(int i=0;i<H;i++){
        string s;
        cin >> s;
        for(int j=0;j<W;j++){
            S[i][j] = s[j] - '0';
        }
    }
    vector<vector<int>> sum(H, vector<int>(W+1, 0));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            sum[i][j+1] = sum[i][j] + S[i][j];
        }
    }

    int res = numeric_limits<int>::max();
    for(unsigned int bit=0; bit<(1<<(H-1)); bit++){
        int count = __builtin_popcount(bit);
        vector<vector<int>> sum_list = {sum[0]};
        for(int i=1; i<H; i++){
            if((bit >> (i-1)) & 1){
                sum_list.push_back(sum[i]);
            }else{
                for(int j=0; j<W+1; j++){
                    sum_list.back()[j] += sum[i][j];
                }
            }
        }

        auto N = sum_list.size();
        size_t i_base = 0;
        while(i_base <= W){
            size_t i_base_min = W+1;
            for(int i=0; i<N; i++){
                const auto& s = sum_list[i];
                auto itr = upper_bound(s.begin(), s.end(), K + s[i_base]);
                size_t j = distance(s.begin(), itr) - 1;
                i_base_min = min(i_base_min, j);
            }
            if(i_base == i_base_min){
                count = numeric_limits<int>::max();
                break;
            }
            if(i_base_min == W) break;
            count++;
            i_base = i_base_min;
        }
        res = min(res, count);
    }
    cout<<res<<endl;
    
    return 0;
}   

Measured memory_bytes: 384
N = int(input())

card = [[True for i in range(13)] for j in range(4)]
for i in range(N):
    S,n = input().split()
    n = int(n)
    if S == 'S':
        card[0][n-1] = False
    elif S == 'H':
        card[1][n-1] = False
    elif S == 'C':
        card[2][n-1] = False
    else:
        card[3][n-1] = False
for i in range(4):
    for j in range(13):
        if card[i][j]:
            if i == 0:
                print('S',j+1)
            elif i == 1:
                print('H',j+1)
            elif i == 2:
                print('C',j+1)
            else:
                print('D',j+1)



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    ll k;
    cin>>k;
    string s;
    cin>>s;
    ll n=s.length();
    if(k>=n){
        cout<<s;
    }else{
        cout<<s.substr(0,k)<<"...";
    }
}

Measured memory_bytes: 3596
S = input()
N = len(S)
i = int((N - 1) / 2)
j = int((N + 3) / 2)
T = S[0:i]
U = S[j-1:N]

if S == S[::-1]  and T == T[::-1] and U == U[::-1]:
    print('Yes')
else:
    print('No')


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

vector<P> dp(200010);

int main(){
    int n, m; cin>>n>>m;
    vector<P> arm(m);
    for(int i=0; i<m; i++){
        int dist, id; cin>>dist>>id;
        arm[i]=P(dist, id);
    }
    sort(arm.begin(), arm.end());

    for(int i=1; i<=n; i++){
        dp[i]=P(i, i);
    }

    for(int i=0; i<m; i++){
        int dist, id;
        tie(dist, id)=arm[i];
        dp[id+1]=P(min(dp[id+1].first, dp[id].first), max(dp[id+1].second, dp[id].second));
        dp[id]=P(min(dp[id+1].first, dp[id].first), max(dp[id+1].second, dp[id].second));
    }

    for(int i=1; i<=n; i++){
        int dpmin, dpmax;
        tie(dpmin, dpmax)=dp[i];
        if(i==n) cout << dpmax-dpmin+1 << endl;
        else cout << dpmax-dpmin+1 << " ";
    }
}


Measured memory_bytes: 5220
import Data.List
import Control.Monad

main = do
  [a, b, c] <- map read . words <$> getLine
  print $ solve a b c

solve a b c =
  let
    [x, y, z] = sort [a, b, c]
    v1 = (y - x) `div` 2
    v2 = if odd (y - x) then 2 else 0
    v3 = z - y
  in
    v1 + v2 + v3

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

int main() {
  int h,w,n,m;
  cin >> w >> h >> m >> n;
  string s[h],t[n];
  for(int i=0; i<h; i++) cin >> s[i];
  for(int i=0; i<n; i++) cin >> t[i];
  bitset<600> b[n][256];
  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      if(t[i][j]!='?') b[i][t[i][j]].set(j);
      else for(int k=0; k<256; k++) b[i][k].set(j);
    }
  }
  int ans=0;
  for(int i=0; i<h-n+1; i++) {
    bitset<600> r[n];
    for(int j=0; j<w; j++) {
      int cnt=0;
      for(int k=0; k<n; k++) {
        r[k]=(r[k]<<1).set(0);
        if(s[i+k][j]!='?') r[k]&=b[k][s[i+k][j]];
        if(r[k][m-1]) cnt++;
      }
      if(j>=m-1&&cnt==n) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5828
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a;
    b=a%10;
    if(b==3)
    {
        cout<<"bon"<<endl;
    }
    else if(b==2||b==4||b==5||b==7||b==9)
    {
        cout<<"hon"<<endl;
    }
    else
    {
        cout<<"pon"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3580
def main():
    n, *a = map(int, open(0).read().split())
    
    g = 0
    t = 1
    for x in a:
        if x == t:
            t += 1
        else:
            g += 1

    print(g if g != n else -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25116
// C - Marks
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	int N,K; cin>>N>>K;
	vector<int> A(N);
	rp(i, 0, K) cin>>A[i];
	rp(i, K, N){
		cin>>A[i];
		if(A[i-K] < A[i]) puts("Yes");
		else puts("No");
	}
}


Measured memory_bytes: 4052
<?php

$s = trim(fgets(STDIN));
$length = strlen($s);
$max = $length - 3;
$min = 100000;

for ($i=0; $i <= $max ; $i++) { 
	$tmp = substr($s, $i, 3);
	$diff = abs(753 - (int)$tmp);
	if ($diff < $min) {
		$min = $diff;
	}
}

echo $min;

Measured memory_bytes: 4728
#include <iostream>

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

using namespace std;

bool good(char map[][302], int n, int a, int b){
	REP(i,n){
		REP(k,n){
			if (map[(i+a)%n][(k+b)%n] != map[(k+a)%n][(i+b)%n]) return false;
		}
	}
	
	return true;
}

int main(){
	int n, ans;
	char map[302][302];
	
	cin >> n;
	ans = 0;
	
	REP(i,n){
		REP(k,n){
			cin >> map[i][k];
		}
	}
	
	REP(a,n){
		if (good(map, n, a, 0)) ans += n;
	}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int calc(int n){
  int ans = 0;
  while(n!=0){
    ans+=n%10;
    n/=10;
  }
  return ans;
}
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  if(n%calc(n)==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <queue>

std::priority_queue<int, std::vector<int>, std::greater<int> > Q;
int x[100010],y[100010],z[100010];
int main()
{
	int a,b,c,d,e;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	for(int i=1;i<=c;i++) scanf("%d",&x[i]);
	for(int i=1;i<=d;i++) scanf("%d",&y[i]);
	for(int i=1;i<=e;i++) scanf("%d",&z[i]);
	std::sort(x+1,x+c+1);
	std::sort(y+1,y+d+1);
	std::sort(z+1,z+e+1);
	for(int i=c;i>=c-a+1;i--) Q.push(x[i]);
	for(int i=d;i>=d-b+1;i--) Q.push(y[i]);
	
	long long int ans = 0;
	for(int i=e;i>=1;i--)
	{
		int f = Q.top();
		if(f<z[i])
		{
			Q.pop();
			ans += z[i];
		}
		else break;
	}
	while(!Q.empty())
	{
		ans += Q.top();
		Q.pop();
	}
	printf("%lld",ans);
}

Measured memory_bytes: 2552
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
using namespace std;
long long i[10000000];
long long u[11111110];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=140,h=170,now=1;
  cin >>a;
  if(a==25) cout <<"Christmas\n";
  else{
    if(a==24) cout <<"Christmas Eve\n";
    else{
      if(a==23) cout <<"Christmas Eve Eve\n";
      else cout <<"Christmas Eve Eve Eve\n";
    }
  }
  return (0);
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

bool compy(pii a, pii b){
	return a.second>b.second;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
	vector<int>a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	vector<pii> b(100001), c(100001);
	for(int i = 0; i < 100001; ++i){
		b[i].second = i;
		c[i].second = i;
	}
	for(int i = 0; i < n; i += 2){
		b[a[i]].first++;
	}
	for(int i = 1; i < n; i += 2){
		c[a[i]].first++;
	}
	int m=0, mm=0;

	sort(begin(b), end(b), greater<pii>());
	sort(begin(c), end(c), greater<pii>());
	int ans = INF;
	if(b[0].second != c[0].second){
		cout << n - b[0].first - c[0].first << "\n";
		return 0;
	}
	for(int i = 0; i < 100000; ++i){
		
		if(b[i].second != c[i].second){
			ans = min(ans, n - b[i].first - c[i].first);
		}
		if(b[i + 1].second != c[i].second){
			ans = min(ans, n - b[i + 1].first - c[i].first);
		}
		if(b[i].second != c[i + 1].second){
			ans = min(ans, n - b[i].first - c[i + 1].first);
		}
	}
	
	cout << ans << "\n";

/*
	vector<int> q, r;
	for(auto && i : b){
		if(m < i.second){
			q = vector<int>();
			m = max(m, i.second);
			q.push_back(i.first);
		}
		else if(m == i.second){
			q.push_back(i.first);
		}
	}
	for(auto && i : c){
		if(mm < i.second){
			r = vector<int>();
			mm = max(mm, i.second);
			r.push_back(i.first);
		}
		else if(mm == i.second){
			r.push_back(i.first);
		}
	}

	for(auto && i : q){
		for(auto && j : r){
			if(q != r){
				cout << n - m - mm  << "\n";
				return 0;
			}
		}
	}

	int tm, tmm;
	
	for(auto && i : b){
		if(m < i.second && ){
			q = vector<int>();
			m = max(m, i.second);
			q.push_back(i.first);
		}
		else if(m == i.second){
			q.push_back(i.first);
		}
	}
	for(auto && i : c){
		if(mm < i.second){
			r = vector<int>();
			mm = max(mm, i.second);
			r.push_back(i.first);
		}
		else if(mm == i.second){
			r.push_back(i.first);
		}
	}

	cout << n - m - mm  << "\n";
	*/
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int m, d;
    int ans = 0;

    cin >> m >> d;

    for (int i = 22; i <= d; i++) {
        string s = to_string(i);
        int d1 = s[1] - '0';
        int d2 = s[0] - '0';
        if (d1 >= 2 && d2 >= 2 && d1 * d2 <= m) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn str_to_ints(s: String) -> std::vec::Vec<i64> {
    let mut ret = std::vec::Vec::new();
    let ws = s.split_whitespace();
    for w in ws {
        ret.push(w.parse().unwrap());
    }
    ret
}

fn read_ints() -> std::vec::Vec<i64> {
    str_to_ints(read_line())
}

fn main() {
    let nk = read_ints();
    let n = nk[0];
    let k = nk[1];

    let mut t = std::vec::Vec::new();
    let mut d = std::vec::Vec::new();
    for i in 0..n {
        let mut td = read_ints();
        t.push(td[0]);
        d.push(td[1]);
    }

    let mut dts :std::vec::Vec<(i64, i64)> = std::vec::Vec::new();
    
    for i in 0..n {
        dts.push((d[i as usize], t[i as usize]));
    }
    dts.sort();

    let mut eated :std::collections::HashMap<i64, std::vec::Vec<i64>> = std::collections::HashMap::new();
    let mut s_x = 0;
    for dt in dts.iter().rev().take(k as usize) {
        if !eated.contains_key(&dt.1) {
            eated.insert(dt.1, std::vec::Vec::new());
        }
        eated.get_mut(&dt.1).unwrap().push(dt.0);
        s_x += dt.0;
    }

    let mut uneated :std::collections::HashMap<i64, std::vec::Vec<i64>> = std::collections::HashMap::new();
    for dt in dts.iter().take((n - k) as usize) {
        if eated.contains_key(&dt.1) {
            continue;
        }
        if !uneated.contains_key(&dt.1) {
            uneated.insert(dt.1, std::vec::Vec::new());
        }
        uneated.get_mut(&dt.1).unwrap().push(dt.0);
    }

    let mut nakuseru :std::vec::Vec<i64> = std::vec::Vec::new();
    for eated_ in eated.iter_mut() {
        eated_.1.sort();
        for i in 0..eated_.1.len()-1 {
            nakuseru.push(eated_.1[i]);
        }
    }
    nakuseru.sort();

    let mut tsuketaseru :std::vec::Vec<i64> = std::vec::Vec::new();
    for uneated_ in uneated.iter_mut() {
        uneated_.1.sort();
        tsuketaseru.push(*uneated_.1.iter().rev().next().unwrap());
    }
    tsuketaseru.sort();

    let mut s_s :std::vec::Vec<i64> = std::vec::Vec::new();
    s_s.push(s_x);
    for i in 0..std::cmp::min(nakuseru.len(), tsuketaseru.len()) {
        let s = s_s[s_s.len() - 1] - nakuseru[i] + tsuketaseru[tsuketaseru.len() - i - 1];
        s_s.push(s);
    }

    let mut x: i64 = eated.len() as i64;
    let mut f_s_max = 0;
    for i in 0..s_s.len() {
        if f_s_max < (s_s[i] + (x + i as i64) * (x + i as i64)) {
            f_s_max = s_s[i] + (x + i as i64) * (x + i as i64);
        }
    }

    println!("{}", f_s_max);
}

Measured memory_bytes: 20692