akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  int n, k;
  cin >> n >> k;
  int c = 0, d = 0;
  ll ans;
  if (k%2 == 0){
    for(int i = 1; i <= n; i++){
      if (i%k == 0) c++;
      else if (i%k == k/2) d++;
    }
    ans = pow(c, 3) + pow(d, 3);
  }else {
    for (int i = 1; i <= n; i++){
      if (i%k == 0) c++;
    }
    ans = pow(c, 3);
  }
  cout << ans << endl;
}


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

using namespace std;

bool vector_finder(vector<int> vec, int number) {
    auto itr = find(vec.begin(), vec.end(), number);
    size_t index = distance( vec.begin(), itr );
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}


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

    vector<int> P;
    for (size_t i = 0; i < N; i++) {
        int pi;
        cin >> pi;
        P.push_back(pi);
    }

    if (vector_finder(P, X) == false) {
        cout << X << endl;
    } else {
        int d = 1;
        while (true) {
            if (vector_finder(P, X - d) == false) {
                cout << X - d << endl;
                break;
            }
            if (vector_finder(P, X + d) == false) {
                cout << X + d << endl;
                break;
            }
            d++;
        }
    }
}

Measured memory_bytes: 3628
#include<iostream>
#include<cmath>

using namespace std;

int n;
double x[300];
double y[300];

double dist(double x1, double y1, double x2, double y2) {
    double dx = abs(x1 - x2);
    double dy = abs(y1 - y2);
    return sqrt(dx * dx + dy * dy);
}

int count(double cx, double cy, int i, int j) {
    int ans = 0;
    for (int k = 0; k < n; ++k) {
        if (k == i || k == j || dist(cx, cy, x[k], y[k]) < 1) ans++;
    }
    return ans;
}

void solve() {
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
    }

    int ans = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i == j) continue;
            double d = dist(x[i], y[i], x[j], y[j]);
            if (d > 2.) continue;
            double dx = x[j] - x[i];
            double dy = y[j] - y[i];
            double r = sqrt(1 - (d * d / 4));
            // cout << r << endl;
            double cx = x[i] + dx / 2 - dy * r / d;
            // cout << d << endl;
            double cy = y[i] + dy / 2 + dx * r / d;
            // cout << x[i] << ", " << y[i] << " - " << x[j] << ", " << y[j] << " : " << cx << ", "<< cy << endl;
            ans = max(ans, count(cx, cy, i, j));
        }
    }
    cout << ans << endl;
}

int main() {
    while (1) {
        cin >> n;
        if (n == 0) break;
        solve();
    }
}


Measured memory_bytes: 3128
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         // if (siz[rx] < siz[ry]) swap(rx,ry);
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1LL) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

int main(void) {
    int N, M;
    cin >> N >> M;

    if (N%2) {
        for (int i=1;i<=M;i++) cout << i << " " << N-i << endl;
    } else if (M == 1) {
        cout << 1 << " " << N << endl;
    } else {
        for (int i=1;i<=M/2;i++) cout << i << " " << N-i+1 << endl;  // << "; " << min(2*i-1,N-2*i+1) << endl;
        for (int i=M/2+2;i<=M;i++) cout << i << " " << N-i << endl; // << "; " << min(2*i,N-2*i) << endl;
        if (M%2) cout << M/2+1 << " " << N+M/2+1-M << endl;
        else cout << M/2+1 << " " << M/2+1+M << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include<set>
#include<queue>
#include<cstdio>
#include<algorithm>

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

using namespace std;

const int INF=1<<29;

int main(){
	int n,q; scanf("%d%d",&n,&q);
	static int a[200000];
	rep(i,n) scanf("%d",a+i);

	const int B=10000;
	deque<int> buc[11000];
	multiset<int> S[11000];
	rep(i,(n+B-1)/B){
		rep(j,B){
			if(i*B+j>=n) break;
			buc[i].push_back(a[i*B+j]);
			S[i].insert(a[i*B+j]);
		}
	}

	while(q--){
		int type; scanf("%d",&type);
		if(type==0){
			int l,r; scanf("%d%d",&l,&r);
			int i1;
			for(i1=0;(i1+1)*B<=l;i1++);
			int j1=l-i1*B;
			int i2;
			for(i2=0;(i2+1)*B<=r;i2++);
			int j2=r-i2*B;

			int left=buc[i1][j1],right=buc[i2][j2];
			buc[i2].erase(buc[i2].begin()+j2);
			S[i2].erase(S[i2].find(right));
			buc[i1].insert(buc[i1].begin()+j1,right);
			S[i1].insert(right);
			for(int i=i1;i<i2;i++){
				int tmp=buc[i].back();
				buc[i].pop_back();
				S[i].erase(S[i].find(tmp));
				buc[i+1].push_front(tmp);
				S[i+1].insert(tmp);
			}
		}
		else if(type==1){
			int l,r; scanf("%d%d",&l,&r);
			int i1;
			for(i1=0;(i1+1)*B<=l;i1++);
			int j1=l-i1*B;
			int i2;
			for(i2=0;(i2+1)*B<=r;i2++);
			int j2=r-i2*B;

			int val=INF;
			if(i1==i2){
				for(int j=j1;j<=j2;j++) val=min(val,buc[i1][j]);
			}
			else{
				for(int j=j1;j< B;j++) val=min(val,buc[i1][j]);
				for(int j=j2;j>=0;j--) val=min(val,buc[i2][j]);
				for(int i=i1+1;i<i2;i++) val=min(val,*S[i].begin());
			}
			printf("%d\n",val);
		}
		else{
			int pos,val; scanf("%d%d",&pos,&val);
			int i;
			for(i=0;(i+1)*B<=pos;i++);
			int j=pos-i*B;
			int pre=buc[i][j];
			buc[i][j]=val;
			S[i].erase(S[i].find(pre));
			S[i].insert(val);
		}
	}

	return 0;
}

Measured memory_bytes: 20008
#define _GLIBCXX_DEBUG
#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,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<29;

int dp[210][210];

int main(){
  int n; cin >> n;
  vector<string> g(n);
  rep(i,n){
    cin >> g[i];
  }
  rep(i,n)rep(j,n) dp[i][j]=inf;
  rep(i,n) dp[i][i]=0;
  rep(i,n)rep(j,n){
    if(g[i][j]=='1') dp[i][j]=1;
  }
  rep(k,n)rep(i,n)rep(j,n) chmin(dp[i][j],dp[i][k]+dp[k][j]);
  int ans=-1;
  rep(i,n){
    bool f=0;
    int mx=0;
    rep(j,n)if(i!=j){
      rep(k,n)if(j!=k){
        chmax(mx,dp[i][j]);
        if(dp[i][j]==dp[i][k]&&g[j][k]=='1'){
          f=1;
        }
      }
    }
    if(f==0){
      chmax(ans,mx+1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <cstdlib>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>

#include <boost/algorithm/string/predicate.hpp>

using namespace std;

#if 0
// memo
abs()

start_with(str, "hoge");
ends_with(str, "hoge");

std::sort(d.begin(), d.end());
d.erase(std::unique(d.begin(), d.end()), d.end());
#endif

using namespace boost;
using namespace boost::algorithm;

static inline bool isOdd(int v)
{
    return v & 0x01;
}

int main()
{
    int A, B, C, X;
    scanf("%d%d%d%d", &A, &B, &C, &X);

    int count = 0;
    for (int a = 0; a <= A; ++a) {
        for (int b = 0; b <= B; ++b) {
            for (int c = 0; c <= C; ++c) {
                auto sum = 500*a + 100*b + 50*c;
                if (a==0 && b==0 &&c==0) {
                    continue;
                }
                if (sum == X) {
                    count ++;
                }
            }
        }
    }

    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S divup_L(S a, T b){
  return (a+b-1)/b;
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
int C[500];
int S[500];
int F[500];
int main(){
  int i, k, t;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N-1);Lj4PdHRW++){
      rd(C[Lj4PdHRW]);
      rd(S[Lj4PdHRW]);
      rd(F[Lj4PdHRW]);
    }
  }
  for(i=0;i<(N);i++){
    t = 0;
    for(k=(i);k<(N-1);k++){
      t = (divup_L(t,F[k])) * F[k];
      chmax(t, S[k]);
      t += C[k];
    }
    wt_L(t);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// int N, C[500], S[500], F[500];
// {
//   int i, k, t;
//   rd(N,(C,S,F)(N-1));
//   rep(i,N){
//     t = 0;
//     rep(k,i,N-1){
//       t = (t /+ F[k]) * F[k];
//       t >?= S[k];
//       t += C[k];
//     }
//     wt(t);
//   }
// }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int dp[110][10010];
int main(){
    int n,w;
    cin>>n>>w;
    //int dp[n+10][w+10]={0};
    int V[n],W[n];
    rep(i,n) cin>>V[i]>>W[i];
    rep(i,n) rep(j,w+1){
        if(j-W[i]>=0){
            dp[i+1][j]=max(dp[i][j],dp[i][j-W[i]]+V[i]);
        }else dp[i+1][j]=dp[i][j];
    }
    /*
    rep(i,n+1){
        rep(j,w+1) cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    cout<<dp[n][w]<<endl;
    return 0;
}


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

string str;
long long n;

int main(){
    cin >> str >> n;
    int flag = 1;
    for(int i=0;i<n;i++) if(str[i] != '1') {flag = str[i]-'0';break;}
    if(flag == 1){puts("1");}
    else printf("%d\n",flag);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<deque>
#include<list>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	for(int i=1; i<10; i++){
		for(int j=1; j<10; j++){
			cout<<i<<"x"<<j<<"="<<i*j<<endl;
		}
	}
	return 0;
}



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

q1 = 1
q2 = N

step = q1 + q2 - 2

for i in range(N):
    x = i+1
    if x**2 > N:
        break
    if N % x == 0:
        q1_cand = x
        q2_cand = N / x
        step_cand = q1_cand + q2_cand - 2
        if step_cand < step:
            step = step_cand
print(str(int(step)))

Measured memory_bytes: 3060
def solve(x):
    to_the_fifth = [x**5 for x in range(150)]
    ttf_set = set(to_the_fifth)
    for i, item in enumerate(to_the_fifth):
        if abs(x-item) in ttf_set:
            # (1-33)**0.2 is a complex number for some reason
            # but -32**0.2 is -2
            second_number_hack = abs(item-x)**0.2
            second_number_hack *= -1 if item-x < 0 else 1
            return map(int, [item**0.2, second_number_hack])
    raise Exception("should've found it")


if __name__ == "__main__":
    print(" ".join(map(str, solve(int(input())))))

Measured memory_bytes: 9360
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    string S;
    cin>>S;
    ll L=S.size();
    ll mod=0;
    for(ll i=0;i<L;i++){
        mod+=S[i]-'0';
        mod%=9;
    }
    if(mod==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3720
N = int(input())
A = list(map(int,input().split()))

S = sum(A)
s = 0
for i in range(N):
    s += A[i]
    if s > S//2:
        p = i
        break
print(min(abs(s-(S-s)),abs(s-A[i]-(S-(s-A[i])))))

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1L<<62LL)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  vector<vector<int>> cnt(n, vector<int>(26, 0));

  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    for (int j = 0; j < s.size(); j++)
      cnt[i][s[j]-'a']++;
  }

  for (int i = 0; i < 26; i++) {
    int min_cnt = INF;
    for (int j = 0; j < n; j++) min_cnt = min(min_cnt, cnt[j][i]);
    for (int j = 0; j < min_cnt; j++) cout << (char)('a' + i);
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i,j,k,M,N;
string S,T;
map<char,char> S2T,T2S;
int main(void){
  cin>>S>>T;
  M=S.size();
  N=T.size();
  if(M!=N){
    cout<<"No"<<endl;
    return EXIT_SUCCESS;
  }
  for(i=0;i<M;i++){
    if((S2T[S[i]]&&S2T[S[i]]!=T[i])||
       (T2S[T[i]]&&T2S[T[i]]!=S[i])){
         cout<<"No"<<endl;
         return EXIT_SUCCESS;
    }
    S2T[S[i]]=T[i];
    T2S[T[i]]=S[i];
  }
  cout<<"Yes"<<endl;
  return EXIT_SUCCESS;
}


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

using namespace std;

int main () {
  
  int A, B;
  cin >> A >> B;

  bool ans;

  if (A + B > 16 || A < 1 || A > 8 || B < 1 || B > 8) {
    ans = false;
  } else {
    ans = true;
  }

  if (ans) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  int x, y;
  cin >> x >> y;
  cout << x + y / 2 << endl;
}



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

const int MAX = 2000000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll COM(int n, int k) {
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  int X, Y;
  cin >> X >> Y;
  vector<pair<int, int>> p;
  COMinit();
  if((2 * Y - X) % 3 != 0 || (2 * X - Y) % 3 != 0) { cout << 0; return 0; }
  ll a = (2 * Y - X) / 3;
  ll b = (2 * X - Y) / 3;
  ll answer = 0;
  
  answer += COM(a + b, a);

  cout << answer % 1000000007;

  
  return 0;
}

Measured memory_bytes: 47232
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		vi a(200);
		for(int i=0;i<n;i++){
			int x;
			cin>>x;
			a[x/m]++;
		}
		int t;
		for(int i=199;i>=0;i--) if(a[i]){
			t=i;
			break;
		}
		double res=0.01;
		int mx=0;
		for(int i=0;i<=t;i++) mx=max(mx,a[i]);
		for(int i=0;i<=t;i++){
			res+=(double)(t-i)/t*a[i]/mx;
//			cout<<(double)(t-i)/t<<' '<<a[i]<<endl;
		}
		cout<<syosu(9)<<res<<endl;
	}
}


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

using namespace std;

bool IsContainInvalidDigits(int n, vector<int > d)
{
    while(n)
    {
        int curr = n % 10;
        for(auto it: d)
        {
            if(it == curr)
                return true;
        }

        n /= 10;      
    }

    return false;
}

int main()
{
    int n, k;
    cin >> n >> k;

    vector<int > a(k);
    for(auto &it: a)
        cin >> it;

    int res = n;
    while(IsContainInvalidDigits(n, a))
    {
        res = ++n;
    }

    cout << res;
    return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  int H, W, A, B;
  cin >> H >> W >> A >> B;



  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if (i < B && j < A){
        cout << '0';
      }else if(B <= i && A <= j){
        cout << '0';
      }else{
        cout << '1';
      }
    }
    cout << endl;
  }
  

  

  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<cstdio>
#include<map>
#pragma warning(disable : 4996)
#define P pair<int,int>
using namespace std;

bool g[1000][1000]{};
int x[] = { -1,0,0,1 }, y[] = { 0,-1,1,0 };
map<int, P>j;
int a, b, c;
int meiro(int d) {
	queue<P> e;
	vector<vector<int>>f(a, vector<int>(b));
	for (int g = 0; g < a; g++) {
		for (int h = 0; h < b; h++) {
			f[g][h] = 1 << 29;
		}
	}
	e.push(j[d]);
	f[(j[d]).first][(j[d]).second] = 0;
	while(e.size()) {
		P p = e.front(); e.pop();
		if (p == j[d+1])break;
		for (int q = 0; q < 4; q++) {
			int l = p.first + x[q];
			int r = p.second + y[q];
			if (l >= 0 && l < a&&r >= 0 && r < b&&g[l][r] && f[l][r] == 1 << 29) {
				P w(l, r);
				e.push(w);
				f[l][r] = f[p.first][p.second] + 1;
			}
		}
	}
	return f[(j[d + 1]).first][(j[d + 1]).second];
}
int main() {
	scanf("%d%d%d", &a, &b, &c);
	for (int d = 0; d < a; d++) {
		for (int e = 0; e < b; e++) {
			char f;
			cin >> f;
			if (f == 'X')g[d][e] = false;
			else if (f == '.')g[d][e] = true;
			else if (f == 'S') {
				g[d][e] = true;
				P h(d, e);
				j[0] = h;
			}
			else {
				g[d][e] = true;
				P h(d, e);
				j[f - 48] = h;
			}
		}
	}
	int s = 0;
	for (int l = 0; l < c; l++) {
		s += meiro(l);
	}
	printf("%d\n", s);
}

Measured memory_bytes: 7852
#include <stdio.h>
int main(){
        int x1, x2, y1, y2, a, b;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        a=y1-y2;
        b=x2-x1;
        printf("%d %d %d %d" , x2+a, y2+b, x1+a, y1+b);
}


Measured memory_bytes: 128
a,b=map(int,input().split())
l1=[1,3,5,7,8,10,12]
l2=[4,6,9,11] 
if a==2 or b==2:
  print("No")
elif a in l1 and b in l1:
  print("Yes")
elif a in l2 and b in l2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9020
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as UV

a#b = abs$a-b

main = do
    [n,k] <- map read.words<$>getLine
    hr <- UV.unfoldr(B.readInt.B.dropWhile(<'!'))<$>B.getLine
    print $ f n k hr

inf = 10^18
f n k h = UV.last $ UV.foldl' proc (UV.singleton 0) $ UV.enumFromTo (1::Int) (n-1) where
    proc v0 dhi
        | dhi < k = UV.snoc v0 $ UV.minimum $ UV.zipWith m v0 h
        | otherwise = UV.tail $ UV.snoc v0 $ UV.minimum $ UV.zipWith m v0 $ UV.slice (dhi-k) k h
        where
            m sv sh = sv+sh# (h UV.! dhi)

Measured memory_bytes: 5116
#122_D
n=int(input())
mod=10**9+7

dp=[[[[0 for _ in range(4)]for _ in range(4)] for _ in range(4)] for _ in range(n+1)]
for k in range(4):
    for l in range(4):
        for m in range(4):
            flg=(k==0 and l==1 and m==2) or (k==0 and l==2 and m==1) or (k==2 and l==0 and m==1)
            if not flg:
                dp[3][k][l][m]=1
        

        
for i in range(4,n+1):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                for m in range(4):
                    flg=(j==0 and (k==2 or l==2) and m==1) or (k==0 and l==1 and m==2) or (k==0 and l==2 and m==1) or (k==2 and l==0 and m==1)
                    if not flg:
                        dp[i][k][l][m]+=dp[i-1][j][k][l]
ans=0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans+=dp[n][i][j][k]
print(ans%mod)

Measured memory_bytes: 3444
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

#define REP(idx, end) for(int idx = 0; idx < end; ++idx)
#define DBG(x) cerr << #x << ": " << x << "\n"

using namespace std;
typedef long long lint;
const int MOD = 1000000007;

int main() {

	cin.tie(0);

	int M, N;
	lint cnt = 1;

	cin >> N;
	vector<int> prime(N, 1);

	for (int j = 1; j <= N; j++){

		M = j;

		for (int i = 2; i <= N; i++) {

			while (M%i == 0) {
				prime[i - 1]++;
				M /= i;
			}
		}
	}

	REP(i, N) {
		cnt *= prime[i];
		cnt %= MOD;
		DBG(prime[i]);
	}
	cout << cnt;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  while (1) {
    int a, b;
    char op;
    cin >> a >> op >> b;

    if (op == '?') {
      break;
    } else if (op == '+') {
      cout << a + b << endl;
    } else if (op == '-') {
      cout << a - b << endl;
    } else if (op == '*') {
      cout << a * b << endl;
    } else if (op == '/') {
      cout << a / b << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3084
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>


#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;
 

int main(){
    int a,p; cin >> a >> p;
    cout << (3*a+p)/2 << endl;
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

vec ans;
void dfs(ll id,ll sum) {
  if(sum==0) {
    for(ll i=1;i<10;i++) {
      ll tsum=sum+i;
      ans.push_back(tsum);
      dfs(id-1,tsum);
    }
  }
  else {
    for(ll i=-1;i<2;i++) {
      ll tmp=i+sum%10;
      if(tmp<0||tmp>=10) continue;
      ll tsum=sum*10+tmp;
      ans.push_back(tsum);
      if(id) {
        dfs(id-1,tsum);
      }
    }
  }
}

int main() {
  ll k;
  cin >> k;
  dfs(10,0);
  sort(ans.begin(),ans.end());
  cout << ans[k-1] << endl;
}

Measured memory_bytes: 11580
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int x,y,z;
  cin>> x>>y;
  if((x==1)||(x==3)||(x==5)||(x==7)||(x==8)||(x==10)||(x==12)){
    x=1;
  }
  if((x==4)||(x==6)||(x==9)||(x==11)){
    x=4;
  }
  if((y==1)||(y==3)||(y==5)||(y==7)||(y==8)||(y==10)||(y==12)){
    y=1;
  }
  if((y==4)||(y==6)||(y==9)||(y==11)){
    y=4;
  }
  if(x==y){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  
}

           

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

   int n;
   cin >> n;
   vector<int> d(n);
   rep(i, 0, n) cin >> d[i];
   sort(all(d));
   int ans = d[n / 2] - d[n / 2 - 1];
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=105;
int a[MAXN];
int main()
{
	int n,k,ans=0;
	bool f=0;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) {
		if(k-a[i]>=0) {
			ans++;
			k-=a[i];
		}
		else {
			f=1;
			break;
		}
	}
	if(k!=0&&!f) ans--;
	printf("%d",max(ans,0));
}

Measured memory_bytes: 128
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N, K = map(int, input().split())

cnt = 0
for b in range(max(1, K), N+1):
    cnt += N-max(1, K)+1
    if b!=0:
        cnt -= K*(N//b)
        if b*(N//b)+(K-1) > N:
            cnt += b*(N//b)+(K-1) - N

print(cnt)



Measured memory_bytes: 69064
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
int n,m,r,dr[200][200],ds[200][200],inf=4*1e8;
int main(){
	while(true){
		cin>>n>>m;
		if(n==0) break;
		rep(i,n) rep(j,n) if(i!=j) dr[i][j]=inf,ds[i][j]=inf;
		rep(i,m){
			int x,y,t;
			char s;
			cin>>x>>y>>t>>s;
			x--,y--;
			if(s=='L'){
				dr[x][y]=min(dr[x][y],t);
				dr[y][x]=min(dr[y][x],t);
			}else{
				ds[x][y]=min(ds[x][y],t);
				ds[y][x]=min(ds[y][x],t);
			}
		}
		rep(i,n) rep(j,n) rep(k,n) dr[j][k]=min(dr[j][k],dr[j][i]+dr[i][k]);
		rep(i,n) rep(j,n) rep(k,n) ds[j][k]=min(ds[j][k],ds[j][i]+ds[i][k]);
		cin>>r;
		int ans[200],nans[200];
		rep(i,n) ans[i]=inf,nans[i]=inf;
		int v,p;
		cin>>p;
		p--;
		ans[p]=0;
		rep(i,r-1){
			cin >> v;
			v--;
			rep(j,n) rep(k,n){
				if(j==k) nans[k]=min(nans[k],ans[j]+dr[p][v]);
				else nans[k]=min(nans[k],ans[j]+dr[p][j]+ds[j][k]+dr[k][v]);
			}
			p=v;
			rep(j,n) ans[j]=nans[j],nans[j]=inf;
		}
		int aans=inf;
		rep(i,n) aans=min(aans,ans[i]);
		cout << aans << endl;
	}
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int n, k;
    cin >> n >> k;
    int ans = pow(n/k, 3);
    if(k % 2 == 0){
        ans += pow(n/k + (n % k >= k/2 ? 1 : 0), 3);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;




int main() {
    string s;
    cin >> s;
    string a = s;
    s.erase(unique(s.begin(),s.end()),s.end());
    string ans = "Yes";
    
    for(int i = 0;i < s.length();i++){
        int cnt = 0;
        for(int j = 0;j < a.length();j++){
            if(s[i] == a[j]){
                cnt++;
            }
        }
        if(cnt % 2 != 0){
            ans = "No";
            break;
        }
    }
    cout << ans;
}



Measured memory_bytes: 256
#include <stdio.h>


int main(void)
{
	int j,k,h;
	
	fscanf(stdin, "%d %d %d", &j,&k,&h);
	
	if (j < k && k < h) fputs("Yes", stdout);
	else fputs("No", stdout);
	
	
	fputc('\n', stdout);
	return 0;
}

Measured memory_bytes: 584
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace DiceInLine
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int diceAmount = int.Parse(input[0]);
            int chosenDice = int.Parse(input[1]);
 
            List<string> data = (Console.ReadLine().Split(' ').ToList());
            List<int> dicesValue = new List<int>();
 
            for (int i = 0; i < diceAmount; i++)
            {
                dicesValue.Add(int.Parse(data[i]));
            }
 
            double exceptedValue = 0.0;
            double[] output = new double[diceAmount];
            for (int i = 0; i < diceAmount; i++)
            {
                exceptedValue += (1.0 + dicesValue[i]) / 2;
                output[i] = exceptedValue;
            }
 
            double printValue = output[chosenDice - 1];            
            for (int i = 0; i + chosenDice < diceAmount; i++)
            {
                printValue = Math.Max(printValue, output[i + chosenDice] - output[i]);                
            }
            Console.WriteLine(printValue);            
        }
    }
}

Measured memory_bytes: 33372
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int k = sc.nextInt();

			int odd = 0;
			int even = 0;

			for (int i = 1; i <= k; i++) {
				if(i % 2 == 0) {
					odd++;
				} else {
					even++;
				}
			}


			System.out.println(odd * even);
		}
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int euclidean_gcd(int a,int b) {
  if(a < b) return euclidean_gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    int N;cin >> N;
    int64_t result=0;
    for(int a=1;a<=N;a++){
        for(int b=1;b<=N;b++){
            for(int c=1;c<=N;c++){
                result+=euclidean_gcd(a,euclidean_gcd(b,c));
            }
        }
    }
    cout << result<<endl;
}


Measured memory_bytes: 3636
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

#和がx以上になる組み合わせの総数
def pattern_num_ge_x(x):
    p=0
    for a in A:
        ng=-1
        ok=N
        while (ok-ng)>1:
            m=(ok+ng)//2
            if a+A[m]>=x:
                ok=m
            else:
                ng=m
        p+=N-ok
    return(p)

#pattern_num_ge_x(x)がM未満になる最小のxを探す(=r)
#lはM以上になる最大のx
l=-1
r=10**10+1
while r-l>1:
    m=(r+l)//2
    if pattern_num_ge_x(m)<M:
        r=m
    else:
        l=m
#print(l,r)
#for i in range(300):
#    print(i,pattern_num_ge_x(i),sep=',')

#和がr以上になる組み合わせの総和を求める(累積和を使用)
S=list(reversed(A))
for i in range(1,N):
    S[i]+=S[i-1]
#print(S)
ans=0
for a in A:
    ng=-1
    ok=N
    while (ok-ng)>1:
        m=(ok+ng)//2
        if a+A[m]>=r:
            ok=m
        else:
            ng=m
    ans+=a*(N-ok) + (S[N-ok-1] if N-ok-1>=0 else 0)
    M-=(N-ok)
    #print(a,ok,a*(N-ok),ans)

#回数のあまり分lを足す
ans+=l*M

print(ans)

Measured memory_bytes: 54668
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {

	while (1) {
		int n;
		cin >> n;
		if (n == 0) break;
		vector<int> k(n);
		for (int i = 0; i < n; i++) cin >> k[i];

		// そういうことね
		bool can = false;
		for (int i = 0; i < n; i++) {
			if (k[i] >= 2) {
				can = true;
				break;
			}
		}

		if (!can) {
			cout << "NA" << endl;
			continue;
		}

		// 1以上の個数 + 1
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (k[i] > 0) cnt++;
		}

		cout << cnt + 1 << endl;
	}
	return 0;
}


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int gcd(int x, int y) {
    if (x % y == 0) {
        return y;
    }

    else {
        return gcd(y, x % y);
    }
}

int main(){
    int X;
    cin>>X;
    int t = gcd(360,X);
    int ans = 360*X/t;
    ans/=X;
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
int main(){
	char s[105];
	char p[105];
	scanf("%s%s",s,p);
	//printf("%d",strlen(s));
	for(int i=0;i<strlen(s);i++){
		for(int j=0;s[(i+j)%strlen(s)]==p[j];j++){
			if(j+1 == strlen(p)){
				printf("Yes\n");
				i=120;
				break;
			}
		}
		if(i+1==strlen(s)){
			printf("No\n");
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 2096
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include<string.h>


void insertionSort(int R[], int n,int g,int *cnt) {
	int i, v, j;
	
	for (i = g; i < n; i ++) {					
		v = R[i];
		j = i - g;
		while (j >= 0 && R[j] > v) {				
			R[j + g] = R[j];
			j = j - g;
			(*cnt)++;	//()をつける！！
		}
		R[j + g] = v;
	}
}

void shellSort(int R[], int n) {
	int cnt = 0;
	int m = 0;
	int h = 0;
	int *G, i;
	
	G = (int*)malloc(sizeof(int)*2*n);
	while (cnt == 0) {
		h = 3 * h + 1;
		if (h > n){
			break; }
		G[m] = h;
		m++;
	}

	printf("%d\n", m);
	for (i = 0; i < m ; i++) {
		printf("%d ", G[m-i-1]);
		if (i == m - 1) {
			printf("\n");
		}
	}

	for (i = 0; i < m ;i++ ) {
		insertionSort(R, n, G[m-i-1],&cnt);
	}
	printf("%d\n",cnt);
}

int main(void){
	
	char nc[20],Rc[20];
	int n, *R,i;

	fgets(nc,sizeof(nc),stdin);
	n = atoi(nc);									//nの取得
	
	//Rc = (char *)malloc(sizeof(char)* (11*n));
	R = (int *)malloc(sizeof(int)* n);				//R,Rc配列を作成(文字列の配列は不安定なのでバツ）

	for (i = 0; i < n; i++) {
		fgets(Rc,sizeof(Rc),stdin);
		if (Rc == NULL) {
			printf("errorです");
		}
		else {
			R[i] = atoi(Rc);
		}
	}

	shellSort(R, n);

	for (i = 0; i < n; i++) {
		printf("%d\n", R[i]);
	}
	free(R);

	


	return 0;
}


Measured memory_bytes: 5464
#include <iostream>
#include <set>
using namespace std;
int main(){
	set<string> se;
	string s;int k;
	cin >> s >> k;
	for(int i=0;i<s.size();i++)
		for(int j=1;j+i<=min(i+5,(int)s.size());j++){
			se.insert(s.substr(i,j));
	}
	auto itr = se.begin();
	for(int i=0;i<k-1;i++)++itr;
	cout << *itr << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=998244353;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
  ll n,k;
  cin >> n >> k;
  vll a(n);
  rep(i,0,n) {
    cin >> a[i];
    --a[i];
  }
  vll f(n,0);
  f[0]=1;
  ll now=a[0];
  queue<ll> que;
  que.push(0);
  while(1){
   if(f[now]) break;
   que.push(now); 
   f[now]=1;
   now=a[now]; 
  }
  
 
  while(k>1&&que.front()!=now){
   que.pop(); 
   --k; 
  }
  k%=que.size();
  while(k>0){
   que.pop();
   --k; 
  }
  cout << que.front()+1 << endl;
  
}

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


Measured memory_bytes: 7884
#include <iostream>
using namespace std;
int main() {
    int n,c=0,i=0,a;
    cin >> n;
    a=n;
    for( i=0;n>0;i++) {
        c = n % 10;
        n /= 10;
    }
    if(i==3){
        cout<<'A'<<'B'<<'C'<<a;
    }else if(i==2)
        cout<<'A'<<'B'<<a;
    else
        cout<<'A'<<a;
}



Measured memory_bytes: 256
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define INF 1e9 + 1
#define _INF INT32_MIN
#define PQ priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	LL c;
	while (a != 0) {
		c = a;
		a = b % a;
		b = c;
	}
	return b;
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		printf("%d ", 2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			printf("%d ", i);
			n /= i;
		}
	}
	if (n > 2)printf("%d ", n);
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	double n, t, a;
	cin >> n >> t >> a;
	double idx = 0, curDiff = 1e9;
	for (int i = 0; i < n; i++)
	{
		double x;
		cin >> x;
		double cal = t - x*0.006;
		double dif = fabs(a - cal);
		if (curDiff>dif)
		{
			curDiff = dif;
			idx = i + 1;
		}
	}
	cout << idx << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int ta[]=new int[(2*n)+1];
			int ha[]=new int[(2*n)+1];
			for(int i=0;i<n;i++)
				ta[in.nextInt()]++;
			for(int i=1;i<=2*n;i++)
				if(ta[i]==0)
					ha[i]++;
			int max=-1;
			for(int i=1;i<=2*n;i++)
			{
				if(ta[i]==1){
					ta[i]=0;
					max=i;
					break;}
			}
			int turn=1;
			int t=n-1;
			int h=n;
			int reset=0;
			for(;;)
			{
				if(turn==1)
				{
					for(int i=1;i<=2*n;i++)
					{
						if(i>max&&ha[i]==1)
						{
							h--;
							max=i;
							ha[i]=0;
							reset=1;
							break;
						}
					}
					turn=0;
					if(reset==0)
						max=0;
				}
				else if(turn==0)
				{
					for(int i=1;i<=2*n;i++)
						if(i>max&&ta[i]==1)
						{
							t--;
							max=i;
							ta[i]=0;
							reset=0;
							break;
						}
					turn=1;
					if(reset==1)
						max=0;
				}
				if(h==0||t==0)
					break;
			}
			System.out.println(h);
			System.out.println(t);
		}
	}
}

Measured memory_bytes: 12000
from sys import stdin
from collections import defaultdict
from collections import deque

N,M = list(map(int,stdin.readline().split()))
Cs = [tuple(map(int,stdin.readline().split())) for _ in range(M)]
S,T = list(map(int,stdin.readline().split()))

INF = 10 ** 15
# visit = [False] * ( (N + 1) * 3 )
dist  = [-1] * ( (N) * 3 + 1 )
graph_connection = defaultdict(lambda :[])
graph_cost = defaultdict(lambda :defaultdict(lambda :INF))
#
# def dfs(v,dist_before):
#
#     dist[v] = dist_before + 1
#     next_vertexs = graph_connection[v]
#     for next_v  in next_vertexs :
#         if dist[next_v] == -1:
#             dfs(next_v,dist[v])
#     return 0
#

for cost in  Cs:
    a,b= cost
    for i in range(0,3):
        from_v = a + (i) * N
        to_v = b + (i + 1) % 3 * N
        graph_connection[from_v].append(to_v )

        # from_v = b + (i) * N
        # to_v = a + (i + 1) % 3 * N
        # graph_connection[from_v].append(to_v )

# dist[S] = 0


que = deque()
#(from_v,to_v)
dist[S] = 0
que.append(S)
while len(que) != 0:
    from_v = que.popleft()
    nexts = graph_connection[from_v]
    for next_v in nexts:
        if dist[next_v] == -1:
            dist[next_v] = dist[from_v] + 1
            que.append(next_v)

if dist[T] < 0:
    print(dist[T] )
else:
    print(dist[T]//3)


Measured memory_bytes: 93228
import math
n = int(input())
def yinzi(n):
    list_yinzi = []
    if n <= 2:
        return list_yinzi
    for i in range(2, int(math.sqrt(n)) + 1):
        """
        为什么循环范围定在平方根呢？：因为一个数的因子是成对的，a=b*c。也就是说：找到一个因子b，肯定会找到相对应的另外一个因子c（a/b）。所以我们的工作量减少了一半。
        又有：一个因子变大，另一个因子必然要变小。假设b永远是小的那个，c是大的那个，那么b的最大值就是a的平方根。也就是b=c=(根号a)的时候。所以循环范围定在[1 , a的平方根+1]，+1的原因是为了能够取到a的平方根避免遗漏。
        """
        #如果找到了一个因子，那么把其相对应的另一个因子一同加入到因子列表中
        if n % i == 0:
            list_yinzi.extend([i, n/i])

    #此处的set为了去重，因为会出现两个相同的平方根的情况。所以去掉重复
    #sorted重排序是因为，因子都是成对成对找出来的，也就是说一次找到的两个因子肯定会有一大一小。这样把所以因子找完放在一起，大小排序就乱了
    return sorted(set(list_yinzi))
res = []
if len(yinzi(n)) == 0:
    print(n-1)
else:
    for i in yinzi(n):
        res.append(i+n/i)
    print(int(min(res)-2))

Measured memory_bytes: 4040
using Yorukatsu050.Questions;
using Yorukatsu050.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu050.Questions
{
    /// <summary>
    /// https://atcoder.jp/contests/abc156/tasks/abc156_a
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var nr = inputStream.ReadIntArray();
            var n = nr[0];
            var rating = nr[1];

            if (n >= 10)
            {
                yield return rating;
            }
            else
            {
                yield return rating + 100 * (10 - n);
            }
        }
    }
}


namespace Yorukatsu050
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu050.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu050.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#N = int(input())
#S = str(input())

print (max(0, (min(B,D) - max(A,C))))

Measured memory_bytes: 38384