akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class HighwayExpressBus {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      while(true) {
        int c, n, m, s, d; cin >> c >> n >> m >> s >> d;
        s--; d--;
        if (c==0) return;

        vector<P> graph[(c+1)*n];
        int cost[(c+1)*n];
        rep(i, (c+1)*n) {
          cost[i] = INT_MAX/2;
        }

        while(m--) {
          int a, b, f; cin >> a >> b >> f;
          a--; b--;
          rep(i, c+1) {
            graph[a+i*n].emplace_back(b+i*n, f);
            graph[b+i*n].emplace_back(a+i*n, f);
          }
          rep(i, c) {
            graph[a+i*n].emplace_back(b+(i+1)*n, f/2);
            graph[b+i*n].emplace_back(a+(i+1)*n, f/2);
          }
        }

        priority_queue<P, vector<P>, greater<>> que;
        que.emplace(0, s);
        cost[s] = 0;
        while(!que.empty()) {
          auto p = que.top(); que.pop();
          if (p.first > cost[p.second]) continue;
          for(const auto& e: graph[p.second]) {
            if (cost[e.first] > p.first + e.second) {
              cost[e.first] = p.first + e.second;
              que.emplace(cost[e.first], e.first);
            }
          }
        }

        int ans = INT_MAX;
        rep(i, c+1) {
          chmin(ans, cost[d+n*i]);
        }
        cout << ans << endl;
      }

    }
};

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


Measured memory_bytes: 3320
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  ll n,k; cin>>n>>k; ll p[n],c[n];
  rep(i,n){
    cin>>p[i]; p[i]--;
  }
  rep(i,n){
    cin>>c[i];
  }
  ll period[n]; vector<ll> v[n];
  ll sum[n]={},ruis[n][n];
  rep(i,n){
    ll tmp=0,q=i,s=0;
    while(1){
      q=p[q];
      v[i].push_back(q);
      tmp++;
      s+=c[q];
      ruis[i][tmp-1]=s;
      if(q==i){
        period[i]=tmp;
        break;
      }
    }
    sum[i]=s;
  }
  ll ma=-INF,anst;
  rep(i,n){
    ll r=(k-1)%period[i]+1,q=(k-r)/period[i],maxi1=0,maxi2=ruis[i][0];
    for(int j=0;j<r;j++){
      maxi1=max(maxi1,ruis[i][j]);
    }
    for(int j=1;j<min(k,period[i]);j++){
      maxi2=max(maxi2,ruis[i][j]);
    }
    q!=0?(sum[i]>0?anst=q*sum[i]+max(maxi1,(ll)0):anst=maxi2):anst=maxi2;
    ma=max(ma,anst);
  }
  cout<<ma;
}

Measured memory_bytes: 414256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	long long sum = 0;
	for(int i = 1; i <= n; i++){
		if((i % 3) && (i % 5)){
			sum += i;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
int n;
int m;

double cnt[6];
int main() {
	cin >> n >> m;
	double cr = 1;
	for (int j = 1; j <= m; j++) {
		cr *= 1.0 / 2.0;
	}
	for (int j = 0; j < (1 << m); j++) {
		int cc = 0;
		for (int k = 0; k < m; k++) {
			if ((j >> k) & 1) {
				cc++;
			}
		}
				cnt[cc] += 1.0 / (double)(1<<m);
		
	}
	double ans = 0;
	for (int j = 0; j <= m; j++) {
		double tim = 1900 * m;
		tim += 100 * (n-m);
		tim *= cnt[j];
		tim /= cr;
		ans += tim;
	}
	int k = ans;
	printf("%d\n", k);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
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; }
//ミョ(-ω- ?)
int main() {
    int w,h,n;
    cin >> w >> h >> n;
    int s = 0,t=0;
    rep(i,n){
        int x,y,a;
        cin >> x >> y >> a;
        if(a == 1){
            s = max(x,s);
        }else if(a == 2){
            w = min(x,w);
        }else if(a == 3){
            t = max(y,t);
        }else if(a == 4){
            h = min(y,h);
        }
    }
    if(w-s > 0 && h-t > 0){
        cout << (w-s)*(h-t) << endl;
    }else{
        cout << 0 << endl;  
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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


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

    int a, b;
    cin >> a >> b;
    int total = 0;
    if(b < 10){
        total = a * 10 + b;
    }else if(b < 100){
        total = a * 100 + b;
    }else{
        total = a * 1000 + b;
    }

    // total が平方数か判定
    bool is_sqr = false;
    for(int i = 1; i <= (sqrt(total) + 1); i++){
        if(total % i == 0 && total / i == i) is_sqr = true;
    }

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



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

int N,M;
pair<int,int> AB[100001];
int daycount[100001];
priority_queue<int> bqueue;

int main(){
    cin>>N>>M;
    rep(i,N){
        cin>>AB[i].first>>AB[i].second;
        daycount[AB[i].first]++;
    }
    sort(AB,AB+N);

    int index=0;
    int ans=0;
    for(int i=1;i<=M;i++){
        for(int j=index;j<index+daycount[i];j++){
            bqueue.push(AB[j].second);
        }
        index+=daycount[i];
        if(!bqueue.empty()){
            ans+=bqueue.top();
            bqueue.pop();
        }
    }

    cout<<ans<<endl;
}

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

int main() {
  long N,K;
  cin>>N>>K;
  vector<int> a(N);

  for(int i=0;i<N;i++){
    cin>>a[i];
    a[i]--;
  }
  long now=0;
  vector<int> v(N);
  while(K>0){
    now = a[now];
    K--;
  //  cout<<now+1<<endl;
    if(v[now]==1) {
      v[now]++;
      break;
    }
    else v[now]++;

  }
  //cout<<"K"<<K<<endl;
  long loop=0;
  while(K>0){
    now = a[now];
    K--;
    loop++;
  //  cout<<now+1<<endl;
    if(v[now]==2) {
      v[now]++;
      break;
    }
    else v[now]++;

  }
  //cout<<"K"<<K<<endl;
  //cout<<loop<<endl;
  if(loop>0) K %=loop;
  while(K>0){
    now=a[now];
    K--;
//  cout<<now+1<<endl;
  }
  cout<<now+1<<endl;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}
int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}
ll powermod(ll x, ll y, ll p)  
{  
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;  
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}
 
int main()
{
    ll l,r,d,c=0;
    cin>>l>>r>>d;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
        c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3672
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 
#define int ll
using namespace std;

const int N = 3e5 + 5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const long double eps = 1e-9 ;

using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int adj[705][705];
int vis[705] = {} ;
vector<int> g[705];
int cnt[3];
int n , m ;
void dfs(int u , int col){
  cnt[col]++;
  vis[u] = col;
  trav(v , g[u]){
    if(vis[v] && vis[v] != vis[u]) continue ;
    if(!vis[v]) dfs(v , 3 - col);
    else{
      cout << -1;
      exit(0);
    }
  }
}



void solve()
{
  cin >> n >> m ;
  rep(i , m){
    int x , y;
    cin >> x >> y;
    --x , --y ;
    adj[x][y] = adj[y][x] = 1;
  }
  rep(i , n){
    repA(j , i + 1 , -1 + n){
       if(!adj[i][j]){
          g[i].pb(j);
          g[j].pb(i);
       }
    }
  }
  vector<int> v;
  rep(i , n){
    if(!vis[i]){
      rep(j , 3)cnt[j] = 0;
      dfs(i , 1);
      v.pb(abs(cnt[1] - cnt[2]));
    }
  }
  // need to use diff[i] or -diff[i] to minimize total abs sum
  const int M = 705; 
  vector<bool> dp(M*2, false) , newdp(M*2 , false);
  dp[M + 0] = true ;
  
  trav(diff , v){
    rep(i , M * 2) newdp[i] = false; 
    rep(i , M * 2){
      if(!dp[i]) continue ;
      if(i - diff >= 0) newdp[i - diff] = (newdp[i-diff] | dp[i]);
      if(i + diff < 2 * M) newdp[i + diff] = (newdp[i + diff] | dp[i]);
    }
    swap(dp , newdp);
  }
  rep(i , M){
    if(dp[M - i] || dp[M + i]){
      // k - (n - k) = i 
      //
      // 2k = n + i
      int k = (n + i) / 2;
      int ans = k * (k - 1) / 2 + (n - k) * (n - k - 1) / 2 ;
      cout << ans ; 
      break ; 
    }
  }
}
     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}


Measured memory_bytes: 9016
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

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

	ll N;
	cin >> N;

	vl P(N);

	rep(i, N) {
		cin >> P[i];
	}

	ll count = 0;

	range(i, 1, N - 1) {
		ll mx = max({ P[i - 1], P[i], P[i + 1] });
		ll mn = min({ P[i - 1], P[i], P[i + 1] });

		if (P[i] != mn && P[i] != mx)count++;
	}


	cout << count << endl;

	return 0;
}



Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define MAX_N (1<<18)
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;





template<class T>
class RMQ_segment{
private:
  int n;
  T dat[2*MAX_N-1];
public:
  void init(int n_){
    n = 1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;i++)dat[i] = 0;
  }

  void update(int k,T a){
    k += n-1;
    dat[k] = a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = max(dat[k*2+1],dat[k*2+2]);
    }
  }

  T query(int a,int b,int k,int l,int r){
    if(r<=a || b<=l)return 0;
    else if(a<=l && r<=b)return dat[k];
    
      T vl = query(a,b,k*2+1,l,(l+r)/2);
      T vr = query(a,b,k*2+2,(l+r)/2,r);
      return max(vl,vr);
    
  }

  T _query(int a,int b){//nの範囲でミスしないように極力こっちを利用
    return query(a,b,0,0,n);
  }

};


 int x[1000010];
 RMQ_segment<ll> rmq;
int main(){
  int n;
  cin >> n;
 
  rmq.init(n+1);
 
  rep(i,n)cin >> x[i];
  ll mex=0;
  ll sum=0;

  for(int i=0;i<n;i++){
    sum+=x[i];
    ll premex = rmq._query(0,x[i])+x[i];
    rmq.update(x[i],premex);
    mex = max(mex,premex);
   
  }  
  
  cout << sum-mex << endl;

return 0;
}

Measured memory_bytes: 7292
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
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;
}

// 無限大の値
const ll INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

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

    rep(i,N){
        cin >> h[i];
    }

    rep(i,100010){
        dp[i] = INF;
    }

    dp[0] = 0;

    for(int i=1;i<N;i++){
        chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1){
            chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
        }
    }


    // 解を得て出力
    cout << dp[N-1] << endl;
}

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

string s;
int k, cnt;
set <string> sub;

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> s >> k;
	for(int i = 0; i < s.length(); ++i) {
		for(int j = min(k, (int)s.length()-i); j > 0; --j) {
			sub.insert(s.substr(i, j));
		}
	}
	cnt = 0;
	for(auto it:sub) {
		if (cnt == k-1) {
			cout << it;
			break;
		}
		++cnt;
		// cout << '#' << ' ' << cnt << '\n';
		// cout << it << '\n';
	}
}

Measured memory_bytes: 4800
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#define INF 1000000000000000000LL
#define MAX_N 120000
#define MAX_M 320000
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
struct edge{
	int t;
	ll dist;
	edge(){}
	edge(int tt,ll dd){
		t=tt;
		dist=dd;
	}
};

int n,m;
ll x,h[MAX_N];
vector<edge> G[MAX_N];
ll dp[MAX_N];

ll dijk(){
	for(int i=0;i<MAX_N;i++){
		dp[i]=INF;
	}
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,0));
	dp[0]=0;
	while(que.size()){
		P p=que.top();
		que.pop();
		ll cost=p.first;
		int v=p.second;
		if(cost>dp[v])continue;
		if(v==n-1){
			if(cost>x)return cost+h[n-1];
			else return cost+h[n-1]-(x-cost);
		}
		for(int i=0;i<G[v].size();i++){
			edge e=G[v][i];
			ll ncost=cost+e.dist;
			ll ph=max(x-cost,0LL);
			if(ph-e.dist<0LL)ncost+=e.dist-ph;
			if(ph-e.dist>h[e.t])ncost+=ph-e.dist-h[e.t];
			if(ncost<dp[e.t]){
				dp[e.t]=ncost;
				que.push(P(ncost,e.t));
			}
		}
	}
	return -1;
}

int main(void){
	scanf("%d%d%lld",&n,&m,&x);
	for(int i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	for(int i=0;i<m;i++){
		int a,b;
		ll d;
		scanf("%d%d%lld",&a,&b,&d);
		a--;
		b--;
		if(h[a]>=d)G[a].push_back(edge(b,d));
		if(h[b]>=d)G[b].push_back(edge(a,d));
	}
	printf("%lld\n",dijk());
	return 0;
}

Measured memory_bytes: 22044
#include <bits/stdc++.h>
    
#define int long long
    
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
    
using namespace std;
    
int dy[4]={1, -1, 0, 0};
int dx[4]={0, 0, 1, -1};

int32_t main(){
    vector<vector<int> > v(3, vector<int>(3));
    int sum=0;
    REP(i, 3){
        REP(j, 3){
            cin >> v[i][j];
            sum+=v[i][j];
        }
    }

    if((v[0][0]+v[1][1]+v[2][2])*3==sum) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
h, w = map(int,input().split())
arr = [list(input()) for i in range(h)]
tmp = []
for i in arr:
    if "#" in i:
        tmp.append(i)
ans = [[] for i in range(len(tmp))]
for i in range(w):
    count = 0
    for j in range(len(tmp)):
        if tmp[j][i] == ".":
            count += 1
    if count < len(tmp):
        for j in range(len(ans)):
            ans[j].append(tmp[j][i])

for i in ans:
    for j in range(len(ans[0])):
        print(i[j], end="")
    print()

Measured memory_bytes: 4596
#include <iostream>
#include <algorithm>
using namespace std;
const int PRIME_MAX = 1299710;
bool isPrime[PRIME_MAX];
int main () {
	fill(isPrime, isPrime + PRIME_MAX, true);
	isPrime[0] = isPrime[1] = false;
	for (int i = 2; i * i <= PRIME_MAX; i++) {
		if (isPrime[i]) {
			for (int j = i << 1; j < PRIME_MAX; j += i) {
				isPrime[j] = false;
			}
		}
	}
	int k;
	while (cin >> k, k) {
		int lo, hi;
		lo = hi = k;
		while (!isPrime[lo]) lo--;
		while (!isPrime[hi]) hi++;
		cout << hi - lo << endl;
	}
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    // dp[N][k]: N日目にk（0:A, 1:B, 2:C）を選んだときのN日までの幸福度の総和の最大値
    long long dp[100001][3];

    int a[100001], b[100001], c[100001]; // 幸福度

    int N;
    cin >> N;

    for (int i = 1; i <= N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    dp[1][0] = a[1];
    dp[1][1] = b[1];
    dp[1][2] = c[1];

    // ループごとにdp[i][k]を計算
    for (int i = 2; i <= N; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }

    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
    return 0;
}

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

signed main(){
    int N;cin>>N;
    int d=sqrt(N);
    cout<<d*d<<endl;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        ArrayList<Long> A = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            A.add(sc.nextLong());
        }

        for (int i = 1; i < N; i++) {
            A.set(0, gcd(A.get(0), A.get(i)));
        }

        System.out.println(A.get(0));
    }

    private static long gcd(long x, long y) {
        if (x > y) {
            long tmp = x;
            x = y;
            y = tmp;
        }
        while (true) {
            long rem = x % y;
            if (rem == 0) {
                return y;
            }
            x = y;
            y = rem;
        }
    }
}


Measured memory_bytes: 62292
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 2e5 + 6;//, mod = 1e9 + 7;
int n, m, k, ans = 1<<30;
set<pi> blocked;
set<int> fy[maxn];
bool can(pi t) {
	if(t.first>n) return false;
	if(t.second>m) return false;
	return 1^blocked.count(t);
}
int get(int x, int y) {
	auto it = fy[y].lower_bound(x);
	if(it==fy[y].end()) return 1<<30;
	return *it - 1;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m >> k;
	for(int x, y, i = 0; i < k; i++) {
		cin >> x >> y;
		blocked.insert(pi(x, y));
		fy[y].insert(x);
	}
	int cx = 1, cy = 1, play = 1;
        ans = get(1, 1);
	while(true) {
		play = 0;
		if(can(pi(cx+1, cy))) {
			play = 1;
			cx++;
		}
		if(!play) break;
		if(can(pi(cx, cy+1))) {
			cy++;
			ans = min(ans, get(cx, cy));
		}
	}
	cout << min(ans, cx);
}



Measured memory_bytes: 31488
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.p = [e for e in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def same(self, u, v):
        return self.find_set(u) == self.find_set(v)

    def unite(self, u, v):
        u = self.find_set(u)
        v = self.find_set(v)

        if u == v:
            return

        if self.rank[u] > self.rank[v]:
            self.p[v] = u
            self.size[u] += self.size[v]
        else:
            self.p[u] = v
            self.size[v] += self.size[u]
            if self.rank[u] == self.rank[v]:
                self.rank[v] += 1

    def find_set(self, u):
        if u != self.p[u]:
            self.p[u] = self.find_set(self.p[u])

        return self.p[u]

    def update_p(self):
        for u in range(self.n):
            self.find_set(u)

    def get_size(self, u):
        return self.size[self.find_set(u)]


uf = UnionFind(n)

sm = n * (n - 1) // 2
ans = [sm]
for a, b in ab[-1:0:-1]:
    a -= 1
    b -= 1
    if not uf.same(a, b):
        sm -= uf.get_size(a) * uf.get_size(b)
        uf.unite(a, b)
    ans.append(sm)

print(*ans[::-1], sep="\n")


Measured memory_bytes: 38164
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    cin>>N>>M;
    vec x(N);
    rep(i,N) cin>>x[i];
    vec num(M,0);
    mat same(M, vec(0));
    sort(ALL(x));
    ll last = 0, temp = 0;
    rep(i,N){
        ++num[x[i]%M];
        if(x[i] == last) {
            temp = (temp == 0 ? 2 : temp + 1);
        }else{
            if(temp != 0) same[x[i-1]%M].push_back(temp);
            temp = 0;
        }
        last = x[i];
    }
    if(temp != 0) same[x[N-1]%M].push_back(temp);
    ll ans = 0;
    rep(i,M/2 + 1){
        ll I = i, J = (M - i)%M;
        if(I != J) {
            if (num[I] < num[J]) swap(I, J);
            ll sa = 0;
            for(ll a : same[I]) sa += a/2;
            ans += num[J] + min(sa, (num[I] - num[J])/2);
        }else{
            ans += num[I]/2;
        }
        //cout<<I<<' '<<num[I]<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
use std::io::*;
use std::str::FromStr;

/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let n: i64 = read();
    let mut m: i64 = read();
    let mut sum: i64 = 0;
    if n*2 >=m{
	println!("{}",m/2);
	return;
    }else{
	sum += n;
	m -= 2*n;
    }
    sum += m/4;
    println!("{}",sum);
}


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

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    int num = r*100 + g*10 + b;
    if (num & 0x3) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
    return 0;
}

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


int main(){
    long H,W,N;
    cin >> H >> W >> N;

    long ans[10];
    for(int i=0; i<10; i++) ans[i] = 0;
    ans[0] = (H-2)*(W-2);
    map<string,int> m;

    for(int t=0; t<N; t++){
        long a, b;
        cin >> a >> b;
        for(int i = -1; i < 2; i++){
            for(int j=-1; j<2; j++){
                if (a+i < 2 || b+j < 2 || a+i > H-1 || b+j > W-1) continue;
                string s = to_string(a+i) + "-" + to_string(b+j);
                m[s] = m[s] + 1;
                ans[m[s]] += 1;
                ans[m[s]-1] -= 1;
            }
        }
    }


    for(int i=0; i<10; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define NMAX 200005
using namespace std;
typedef long long ll;
ll a, b;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie();
}
int main()
{
    fast();
    cin>>a>>b;
    cout<<max(max(a+b,a*b),a-b);
    return 0;
}


Measured memory_bytes: 256
using System;

namespace v0_0005
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            while (!string.IsNullOrEmpty(line = Console.ReadLine()))
            {
                var ab = line.Split(' ');
                var a = int.Parse(ab[0]);
                var b = int.Parse(ab[1]);
                int LCM = 1;
                int GCD = 1;

                int divVal;
                while ((divVal = GetDivisor(a, b)) != -1)
                {
                    a /= divVal;
                    b /= divVal;
                    GCD *= divVal;
                }
                LCM = GCD * a * b;

                Console.WriteLine("{0} {1}", GCD, LCM);
            }
        }

        static int GetDivisor(int a, int b)
        {
            for (int i = 2; i <= Math.Min(a, b); i++)
            {
                if ((a % i == 0) && (b % i == 0))
                {
                    return i;
                }
            }
            return -1;
        }
    }
}

Measured memory_bytes: 8948
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 200005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A[NMAX],B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = 0;

void solve(){
  // main algorithm
  for (int i = 1; i < N; ++i)
  {
    ans += min(M, A[i] - A[i-1]);
  }
  ans += M;
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N >> M;
  for (int i = 0; i < N; ++i)
  {
    scanf("%lld", &A[i]);
  }
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  
  
  int sum = 0;
  for (int i = 0; i < 1000; i++){
    int k = 0;
    for( int j = 0; j < n; j++){
      int c = (i/(std::pow(10,k)));
      c = c % 10;
      if(c == s[j] - '0' ){
        k++;
      }
      if(k == 3){
        sum ++;
        break;
      }
    }
    
  }
  cout << sum << endl;
}

Measured memory_bytes: 384
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

void show_field(string field) {
	REP(i, 4) {
		REP(j, 8) {
			cout << field[16 * i + 2 * j] << field[16 * i + 2 * j + 1] << " ";
		}
		cout << endl;
	}
}

int main() {
	string goal;
	REP(i, 4) {
		REP(j, 8) {
			if (j != 7) {
				goal.push_back('1' + i);
				goal.push_back('1' + j);
			}
			else {
				goal.push_back('0');
				goal.push_back('0');
			}
		}
	}

	int n;
	cin >> n;

	REP(hoge, n) {
		vvi field(4, vi(8));
		REP(i, 4) {
			FOR(j, 1, 7) {
				int num;
				cin >> num;
				if (num % 10 == 1) {
					field[num / 10 - 1][0] = num;
				}
				else {
					field[i][j] = num;
				}
			}
		}
		string start;
		REP(i, 4) {
			REP(j, 8) {
				if (field[i][j] == 0) {
					start.push_back('0');
					start.push_back('0');
				}
				else {
					start.push_back('0' + field[i][j] / 10);
					start.push_back('0' + field[i][j] % 10);
				}
			}
		}

		map<string, int> memo;
		queue<string> Q;
		Q.push(start);
		memo[start] = 0;
		bool finished = false;
		while (!Q.empty()) {
			string s = Q.front();
			Q.pop();

			if (s == goal) {
				finished = true;
				break;
			}

			vi change_pos;
			vs change_str;
			REP(i, 32) {
				if (s[2 * i] == '0') {
					if (s[2 * i - 1] != '7') {
						string str = s.substr(2 * (i - 1), 2);
						str[1]++;
						change_pos.push_back(i);
						change_str.push_back(str);
					}
				}
			}

			int size = change_pos.size();
			REP(i, size) {
				string str = change_str[i];
				REP(j, 32) {
					if (s[2 * j] == str[0] && s[2 * j + 1] == str[1])  {
						int pos = change_pos[i];
						string ns = s;
						ns[2 * pos] = str[0];
						ns[2 * pos + 1] = str[1];
						ns[2 * j] = '0';
						ns[2 * j + 1] = '0';
						if (memo[ns] == 0) {
							memo[ns] = memo[s] + 1;
							Q.push(ns);
						}
					}
				}
			}
		}

		if (finished) {
			cout << memo[goal] << endl;
		}
		else {
			cout << -1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 12516
#include <bits/stdc++.h>
using namespace std;
long long INF = 10000000000;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  for (int i = 0; i < N; i++){
    cin >> P[i];
    P[i]--;
  }
  vector<int> C(N);
  for (int i = 0; i < N; i++){
    cin >> C[i];
  }
  if (K <= N){
    long long ans = -INF;
    for (int i = 0; i < N; i++){
      long long p = i;
      long long s = 0;
      for (int j = 0; j < K; j++){
        p = P[p];
        s += C[p];
        ans = max(ans, s);
      }
    }
    cout << ans << endl;
  } else {
    vector<vector<int>> next(31, vector<int>(N));
    for (int i = 0; i < N; i++){
      next[0][i] = P[i];
    }
    for (int i = 1; i < 31; i++){
      for (int j = 0; j < N; j++){
        next[i][j] = next[i - 1][next[i - 1][j]];
      }
    }
    vector<vector<long long>> sum(31, vector<long long>(N));
    for (int i = 0; i < N; i++){
      sum[0][i] = C[P[i]];
    }
    for (int i = 1; i < 31; i++){
      for (int j = 0; j < N; j++){
        sum[i][j] = sum[i - 1][j] + sum[i - 1][next[i - 1][j]];
      }
    }
    long long ans = 0;
    for (int i = 0; i < N; i++){
      long long p = i;
      long long s = 0;
      for (int j = 0; j < N; j++){
        p = P[p];
        s += C[p];
        ans = max(ans, s);
      }
      p = i;
      s = 0;
      for (int j = 0; j < 31; j++){
        if ((K - N) >> j & 1){
          s += sum[j][p];
          p = next[j][p];
        }
      }
      ans = max(ans, s);
      for (int j = 0; j < N; j++){
        p = P[p];
        s += C[p];
        ans = max(ans, s);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 5104
from itertools import accumulate

n,k = map(int, input().split())
a = list(map(int, input().split()))
b = [max(0,i) for i in a]
cumsum_a = [0] + list(accumulate(a))
cumsum_b = [0] + list(accumulate(b))
ans = 0
for i in range(n-k+1):
  tmp = max(0,cumsum_a[i+k]-cumsum_a[i]) + cumsum_b[i] + cumsum_b[n] - cumsum_b[i+k]
  ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 18496
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}

uint32_t nextpint(void){
	uint_fast32_t x=0;
	while(1){
		uint_fast8_t c=getchar();
		if('0'<=c && c<='9'){
			x=x*10+c-'0';
		}else{
			break;
		}
	}
	return x;
}

int main(void){
	int n = nextpint();
	if(n == 1){
		puts("Hello World");
	}else{
		int a = nextpint();
		int b = nextpint();
		printf("%d\n", a+b);
	}
}


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

int main() {
    int N;
    cin >> N;
    string s,t;
    cin >> s >> t;

    int ct=N;
    while(ct<=N){
        if(s.substr(s.size()-ct,ct)==t.substr(0,ct)){
            break;
        }
        else {
            ct--;
            
        }
    }
    cout << 2*N-ct << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;


class Main {

    public static void main(String[] args) {
        FastReader f = new FastReader();
        int h = ii(f), w = ii(f);
        int n = ii(f);
        printn((int)Math.ceil((float)n/(max(h, w))));
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static int ii(FastReader fr) {
        return fr.nextInt();
    }

    static long il(FastReader fr) {
        return fr.nextLong();
    }

    static double id(FastReader fr) {
        return fr.nextDouble();
    }

    static void printArray(Object[] arr) {
        for (Object x : arr)
            print(x, " ");
        printn("");
    }

    static void print(Object s, String sep) {
        System.out.print(s + sep);
    }

    static void printn(Object s) {
        System.out.println(s);
    }

    static long[] inputArrL(int n, FastReader fr) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
            arr[i] = fr.nextLong();
        return arr;
    }

    static int[] inputArr(int n, FastReader fr) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
            arr[i] = fr.nextInt();
        return arr;
    }

    static int max(int... args) {
        int max = Integer.MIN_VALUE;
        for (int x : args) {
            max = Math.max(x, max);
        }
        return max;
    }

    static int min(int... args) {
        int min = Integer.MAX_VALUE;
        for (int x : args) {
            min = Math.min(x, min);
        }
        return min;
    }

    static long max(long... args) {
        long max = Integer.MIN_VALUE;
        for (long x : args) {
            max = Math.max(x, max);
        }
        return max;
    }

    static long min(long... args) {
        long min = Integer.MAX_VALUE;
        for (long x : args) {
            min = Math.min(x, min);
        }
        return min;
    }

    static int lenDigit(int d) {
        if (d == 0)
            return 1;
        int l = 0;
        while (d != 0) {
            l++;
            d /= 10;
        }
        return l;
    }

}



Measured memory_bytes: 21332
// RAM RAM
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55
const int MOD=1000000007;
using namespace std;

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

    int num[]={2,3,4,5,6,7,8,9,10,11,12,13,1};


    int a,b;cin>>a>>b;
    int ind1,ind2;

    for(int i=0;i<13;i++){
    	if(a==num[i]){
    		ind1=i;
    		break;
    	}
    }

for(int i=0;i<13;i++){
    	if(b==num[i]){
    		ind2=i;
    		break;
    	}
    }

    if(ind1>ind2){
    	cout<<"Alice"<<endl;
    }else if(ind1<ind2){
    	cout<<"Bob"<<endl;
    }else{
    	cout<<"Draw"<<endl;
    }


	return 0;
}

Measured memory_bytes: 256
import numpy as np
from scipy.sparse import *

U = 10**5
N = int(input())
XY = np.array([input().split() for _ in range(N)], dtype=np.int32)

graph = csr_matrix((np.ones(N,dtype=np.bool), (XY[:,0], U + XY[:,1])), (2*U+1, 2*U+1))
_, component = csgraph.connected_components(graph)

X_cnt = np.bincount(component[:U+1], minlength = 2*U+2)
Y_cnt = np.bincount(component[U+1:], minlength = 2*U+2)
pts_cnt = np.bincount(component[XY[:,0]], minlength = 2*U+2)
answer = (X_cnt * Y_cnt - pts_cnt).sum()
print(answer)


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

int main(void)
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        double xa, ya, ra, xb, yb, rb;
        cin >> xa >> ya >> ra >> xb >> yb >> rb;
        double d = sqrt(pow((xa-xb),2.0) + pow((ya-yb),2.0));
        if (d + ra < rb)
            cout << -2;
        else if(d + rb < ra)
            cout << 2;
        else if (d <= ra + rb)
            cout << 1;
        else
            cout << 0;
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3188
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()

    ret = 0
    for i in range(1, N+1):
        cnt = 0
        for j in range(1, i+1):
            if j % 2 != 0 and i % j == 0:
                cnt += 1
        if cnt == 8:
            ret += 1
    print(ret)


if __name__ == '__main__':
    main()


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> ans(n);
    for (int i = 0; i < n; i++) {
        ans[i] = 0;
    }

    for (int i = n-1; i >= 0; i--) {
        int frag = 0;
        for (int j = 1; j*(i+1) <= n; j++) {
            frag += ans[(i+1)*j-1];
        }
        //cout << frag << endl;
        if (frag%2 != a[i]) {
            ans[i] = 1;
        }
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        if (ans[i] == 1) {
            count++;
        }
    }
    cout << count << endl;
    for (int i = 0; i < n; i++) {
        if (ans[i] == 1) {
            cout << i+1 << endl;
        }
    }
}


Measured memory_bytes: 2432
from sys import stdin
import numpy as np

h,w= [int(x) for x in stdin.readline().rstrip().split()]

li = [["" for i in range(w)]for j in range(h)]

for i in range(h):
    s = stdin.readline().rstrip()
    for j in range(w):
        li[i][j] = s[j]

li = np.asarray([s for s in li if s != ['.']*w]).T.tolist()
li = np.asarray([s for s in li if s != ['.']*len(li[0])]).T.tolist()

for i in li:
    s = ""
    for j in range(len(li[0])):
        s += i[j]
    print(s)

Measured memory_bytes: 12512
#include <bits/stdc++.h>
using namespace std ;
#define An setprecision(16) 
int main(){
    int L,R,d;
    cin >> L >> R >> d;
    int a = (L-1)/d;
    int b = R/d;
    int ans = b-a;
    cout << ans << endl;
}

Measured memory_bytes: 3600
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	x := make([]int, n)
	for i, _ := range x {
		fmt.Scan(&x[i])
	}

	ans := 1000000000000
	for i := 1; i <= 100; i++ {
		temp := 0
		for _, v := range x {
			temp += (i - v) * (i - v)
		}
		ans = min(temp, ans)
	}
	fmt.Println(ans)

}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

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

LL cao(LL h,LL w) {
  LL maxs,mins,s1,s2,s3,a,b,ans = h * w,c;
  if (w & 1) a = w / 2 + 1,b = w - a;
  else a = b = w / 2;
  for (LL i = 1; i < h; ++i) {
    s1 = a * i,s2 = b * i,s3 = h * w - s1 - s2;
    maxs = max({s1,s2,s3});
    mins = min({s1,s2,s3});
    ans = min(maxs - mins,ans);
  }
  a = b = c = w / 3;
  ans = min(ans,h);
  return ans;
}
int main() {
  LL h,w,ans;
  scanf("%lld%lld",&h,&w);
  ans = h * w;
  if (h % 3 == 0 || w % 3 == 0) printf("0\n");
  else {
    ans = cao(h,w);
    ans = min(ans,cao(w,h));
    printf("%lld\n",ans);
  }
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int kosu(int n){
  int ans=0;
  for (int i=1;i<n+1;i++){
    if (n%i==0){
      ans+=1;
    }
  }
  return ans;
}
int main(){
  int n;
  cin>>n;
  int ans=0;
  for (int i=1; i<=n;i++){
    if (i%2==1 && kosu(i)==8){
      ans+=1;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5,mod=1e9+7;
ll n,a[N],mx=0,mn=N;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        mx=max(mx,a[i]);
        mn=min(mn,a[i]);
    }
    if(mx>mn+1)return cout<<"No" , 0;

    if(mx==mn){
        if(mn==n-1 || mn*2<=n)cout<<"Yes";
        else cout<<"No";
    }
    else{
        ll cnt=0;for(ll i=0;i<n;i++)cnt+=(a[i]==mn);
        if(cnt<mx && 2*(mx-cnt)<=n-cnt)cout<<"Yes";
        else cout<<"No";
    }
}

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

ll d[MAX];

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

  int n;
  cin >> n;

  for (int i = 1; i <= MAX; ++i) for (int j = 1; j*i <= MAX; ++j) ++d[j*i];

  ll ans = 0;
  for (ll i = 1; i <= n; ++i) ans += d[i] * i;
  
  cout << ans << '\n';

  return (0);
}


Measured memory_bytes: 81772