akhauriyash/Code-Regression huggingface dataset:
class BIT():
    def __init__(self,n,mod):
        self.BIT=[0]*(n+1)
        self.num=n
        self.mod=mod

    def query(self,idx):
        res_sum = 0
        mod=self.mod
        while idx > 0:
            res_sum += self.BIT[idx]
            res_sum%=mod
            idx -= idx&(-idx)
        return res_sum

    #Ai += x O(logN)
    def update(self,idx,x):
        mod=self.mod
        while idx <= self.num:
            self.BIT[idx] += x
            self.BIT[idx]%=mod
            idx += idx&(-idx)
        return

import sys,bisect

input=sys.stdin.readline

mod=10**9+7
inv=pow(2,mod-2,mod)

N=int(input())
taka=[tuple(map(int,input().split())) for i in range(N)]
taka.sort()

V=[0]+[taka[i][1] for i in range(N)]+[10**15]
cummin=[V[i] for i in range(N+2)]
for i in range(N,-1,-1):
    cummin[i]=min(cummin[i],cummin[i+1])
cummax=[V[i] for i in range(N+2)]
for i in range(1,N+2):
    cummax[i]=max(cummax[i],cummax[i-1])

const=[]
for i in range(1,N+1):
    R=bisect.bisect_right(cummin,V[i])-1
    L=bisect.bisect_left(cummax,V[i])
    const.append((L,R))


Lconst=[(i,10**15) for i in range(N+1)]
for L,R in const:
    pL,pR=Lconst[L]
    Lconst[L]=(L,min(R,pR))

_const=[]
for i in range(1,N+1):
    L,R=Lconst[i]
    if R!=10**15:
        _const.append((L,R))

const=[]
for L,R in _const:
    while const and const[-1][1]>=R:
        const.pop()
    const.append((L,R))


M=len(const)
const=[(-10**15,0)]+const
Rconst=[const[i][1] for i in range(M+1)]
B=BIT(M,mod)
dp=[1]*(M+1)
for i in range(1,M+1):
    L,R=const[i]
    id=bisect.bisect_left(Rconst,L)
    res=(B.query(i-1)-B.query(id-1))%mod
    l,r=const[id]
    l=max(l,Rconst[id-1]+1)
    res+=dp[id-1]*(pow(2,r-L+1,mod)-1)*pow(2,L-l,mod)%mod
    res%=mod
    dp[i]=res
    if i!=M:
        nR=Rconst[i+1]
        add=dp[i]*(pow(2,nR-R,mod)-1)%mod
        add%=mod
        B.update(i,add)

cnt=0
data=[0]*(N+2)
for i in range(1,M+1):
    L,R=const[i]
    data[L]+=1
    data[R+1]+=-1
for i in range(1,N+2):
    data[i]+=data[i-1]
for i in range(1,N+1):
    if data[i]==0:
        cnt+=1
ans=pow(2,cnt,mod)*dp[M]
ans%=mod
print(ans)


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll n,m,l;
  cin>>n>>m>>l;
  vector<vector<ll>> dist(n,vector<ll>(n,INF));
  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    dist[a][b] = dist[b][a] = c;
  }
  rep(k,n)rep(i,n)rep(j,n){
    chmin(dist[i][j],dist[i][k]+dist[k][j]);
  }
  vector<vector<ll>> dist2(n,vector<ll>(n,INF));
  rep(i,n)rep(j,n)if(dist[i][j]<=l)dist2[i][j]=1;
  rep(k,n)rep(i,n)rep(j,n){
    chmin(dist2[i][j],dist2[i][k]+dist2[k][j]);
  }
  int q;
  cin>>q;
  vector<ll> ans(q);
  rep(i,q){
    int s,t;
    cin>>s>>t;
    s--;t--;
    if(dist2[s][t]==INF)ans[i]=-1;
    else ans[i]=dist2[s][t]-1;
  }
  for(auto x:ans)cout<<x<<endl;

}

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

int n,k;
int arr[105];
int memo[100005][2];

int dp(int x,int player){
	//printf("%d %d\n",x,player);
	if(x<0)return player;
	if(x==0)return 1^player;
	if(memo[x][player]!=-1)return memo[x][player];
	int ans=-1;
	for(int i=0;i<n;i++){
		int cur=dp(x-arr[i],1^player);
		if(cur==player)ans=player;
	}
	if(ans==-1)ans=1^player;
	return memo[x][player]=ans;
}

int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)scanf("%d",&arr[i]);
	memset(memo,-1,sizeof(memo));
	if(dp(k,0)==0)printf("First");
	else printf("Second");
}


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

int main() { 
  long  n;
  cin>>n;
  string ans="";
  while(n!=0){
    if(n%2==0){
      ans ="0"+ans;
    }
    else{
      ans ="1"+ans;
      n--;
    }
    n/=(-2);
  }
  if(ans==""){
    cout << "0";
  }
  else{
    cout << ans;
  }
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
  double pi = 3.1415926535;
  int r;
  cin >> r;

  cout << setprecision(6) << 2 * pi * r << endl;

  return 0;
}


Measured memory_bytes: 3784
#include <iostream>
using namespace std;
inline int max(int x, int y)
{
	
return ((x>y)?x:y);
}
int main()
{
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	int A=a*b;
	int B=c*d;
	cout<<max(A, B);
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,x,y,w,h,N;
  cin >> n;
  rep(u,n){
    cin >> x >> y >> w >> h >> N;
    ++w,++h;
    ll ans = 0,a,b;
    rep(i,N){
      cin >> a >> b;
      if(value(a - x,b - y,w,h)){
        ++ans;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define int long long
typedef pair<int, int> P;
typedef pair<int, P> Pi;

struct Edge {
  int to, cost;
};

int N, M, L, K, A, H;
vector<Edge> G[101];
bool is_freeze[101];

int dij() {
  priority_queue<Pi, vector<Pi>, greater<Pi> > Q;
  bool used[101][101] = {{0}};
  Q.push(Pi(0, P(M, A)));
  while ( !Q.empty() ) {
    Pi p = Q.top(); Q.pop();
    int c = p.first, m = p.second.first, v = p.second.second;

    if ( v == H ) {
      return c;
    }

    if ( used[v][m] ) continue;
    used[v][m] = true;    

    if ( is_freeze[v] ) {
      if ( m < 0 ) Q.push(Pi(c-m, P(0, v)));      
      else if ( m+1 <= M ) Q.push(Pi(c+1, P(m+1, v)));      
    }
    
    for ( Edge e: G[v] ) {
      int to = e.to, cost = e.cost;
      int nm = m-cost;
      if ( nm >= 0 ) Q.push(Pi(c+cost, P(nm, to)));
    }    
  }

  return -1;
}

signed main() {
  while ( cin >> N >> M >> L >> K >> A >> H, N ) {    
    fill_n(is_freeze, 101, 0);
    for ( int i = 0; i < N; i++ ) G[i].clear();    
    for ( int i = 0; i < L; i++ ) {
      int a;
      cin >> a;
      is_freeze[a] = true;
    }
    
    for ( int i = 0; i < K; i++ ) {
      int a, b, c;
      cin >> a >> b >> c;
      G[a].push_back(Edge{b, c});
      G[b].push_back(Edge{a, c});
    }  

    int ans = dij();
    if ( ans == -1 ) cout << "Help!" << endl;
    else cout << ans << endl;
  }
  
  return 0;
}



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

a_list.sort()
a_list.reverse()

x = 0
y = 0
n = 0

for a in a_list:
  if n % 2 == 0:
    x = x + a
    n = n +1
  else:
    y = y + a
    n = n +1

sabun = x - y

print(sabun)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;

int main() {
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		int c, d, e, f,g;
		cin >> c >> d >> e >> f>>g;
		int s = 0;
		for (int h = 0; h < g; h++) {
			int i, j;
			scanf("%d%d", &i, &j);
			if (i >= c&&i <= c + e&&j >= d&&j <= d + f)s++;
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 3132
#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>;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  int result = 0;
  for (int i = 1; i <= n - 2; i++) {
    if (p[i] != min({p[i - 1], p[i], p[i + 1]}) && p[i] != max({p[i - 1], p[i], p[i + 1]})) {
      result++;
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N,K;
    cin >> N >> K;
    if(K>(N-1)*(N-2)/2)cout << -1;
    else{
        int M=N-1+(N-1)*(N-2)/2-K;
        cout << M << endl;
        rep(i,N-1){
            cout << 1 << ' ' << i+2 << endl;
        }
        int cnt=(N-1)*(N-2)/2-K;
        for(int i=2;i<N+1 && cnt>0;i++){
            for(int j=i+1;j<N+1 && cnt>0;j++){
                cout << i << ' ' << j << endl;
                cnt--;
            }
        }


    }
    


}

/*



 */



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

int v[100002];

int main(){
  int n;
  cin >> n;
  rep(i,n){
    int tmp;
    cin >> tmp;
    v[tmp]++;
  }
  int ans = 0;
  for (int i=1;i < 100000-1;i++){
    ans = max(ans,v[i]+v[i-1]+v[i+1]);
  }
  cout << ans << endl;

  
  return 0;
}

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


struct unionFind {
    vector<int> parent;
    unionFind(int n): parent(n) {
        for (int i = 0; i < n; i++) parent[i] = i;
    };

    int root(int x) {
        if (parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) parent[y] = x;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    long long n, a, b;
    cin >> n >> a >> b;

    long long d = n / (a + b);
    long long r = n % (a + b);
    cout << d * a + min(r, a) << endl;





    return 0;
}



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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<vector<int> > ivve;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define setp       setprecision
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define spc(x)     cout<<fixed<<setp(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
void solve()
{
    ll t,n=0,m,a,b,c,d,e=0,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;
    
    cin>>a>>b;
    x=a-2*b;
    if(x<=0) cout<<0<<endl;
    else cout<<x<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
#include<bits/stdc++.h>
#include<vector>
#include<queue>

#define             ll                      long long
#define             si(a)                   scanf("%d",&a)
#define             sii(a,b)                scanf("%d%d",&a,&b)
#define             siii(a,b,c)             scanf("%d%d%d",&a,&b,&c)
#define             pii                     pair<int,int>
#define             pb(a)                   push_back(a)
#define             fr(i,n)                 for(int i=0;i<n;i++)
#define             bl                      printf("\n")
#define             pi                      acos(0.0)
#define             inf                     1000000
#define             sz                      100

using namespace std;

int main(){

    int n,i;
    sii(n,i);
    printf("%d\n",(n-i)+1);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return [f = std::forward<F>(f)](auto&&... args) {
    return f(f, std::forward<decltype(args)>(args)...);
  };
}
template<typename T>
static inline T fin() { T t; cin >> t; return std::move(t); }

int main() {
  i64 a, b;
  cin >> a >> b;
  cout << max({ a + b , a - b, a * b }) << endl;
}


Measured memory_bytes: 256
#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<ll, ll> P;

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    int n; cin >> n;
    for(int i = 1; i <= n; i++){
        int res = 0;
        for(int x = 1; x*x <= i ; x++){
            for(int y = x; y*y <= i; y++){
                for(int z = y; z*z <= i; z++){
                    if(x*x + y*y + z*z + x*y + y*z + z*x == i){
                        if(x == y && y == z){
                            res++;
                        }else if(x != y && y != z && x != z){
                            res += 6;
                        }else{
                            res += 3;
                        }
                    }
                }
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>

using namespace std;
typedef long long ll;

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


    ll ans=0;
    ll anss =0;
    ll count=0;
    ll i,j;
  
    ll K;
    vector<ll> a;

    ll Q,N;
    string S;
    cin>>N>>K>>S;
    ll flag=0;
    ll t1=0;
    ll t2=0;
    if(S[0]-'0'==0){
        a.push_back(-1);
        a.push_back(-1);
        t1++;
    }
    for(i=0;i<S.length();i++){
            if(S[i]-'0'==1){
            if(flag==0){
                a.push_back(i);
                flag=1;
            }
        }else if(S[i]-'0'==0){
            if(flag==1){
                flag=0;
                a.push_back(i-1);
            }
        }

        if(i==S.length()-1){
            if(S[i]-'0'==1){
                a.push_back(i);
            }else{
                a.push_back(i+1);
                a.push_back(i+1);
                t2++;
            }
        }
    }
    ll maxx=0;
    ll temp;
    ll aaa=0;
    ll f=0;
  
    if(a.size()/2-1<=K){
        //maxx=N;
        cout<< N << endl;
        return 0;
    }else{
        for(i=0;i<a.size()/2-1-K+1;i++){
            temp=a[2*i+1+2*K]-a[0+2*i]+1;
            //cout<<a[2*i+1+2*K]<<a[0+2*i]<<endl;
            // if(i==a.size()/2-1-K+1 -1 && t2==1 ){
            //     if(temp<maxx){
            //         aaa++;
            //     }
            // }
            // if(i!=0 && t1==1 ){
            //     if(temp>maxx){
            //         aaa++;
            //     }
            // }
            if(i!=0 && i!=a.size()/2-1-K && maxx<temp){
                f=1;

            }
            if( i==a.size()/2-1-K && maxx<temp){
                f=2;
            }
            maxx=max(maxx,temp);
            
        }
    }
    if(f==0){
        aaa=t2;
    }else if(f==1){
        aaa=t1+t2;
    }else if(f==2){
        aaa=t1;
    }
  
    //cout<<maxx<<aaa<<endl;
ll kotae;
kotae=maxx-t1 - t2 + aaa;
//cout<< maxx<<aaa << endl;
//cout<< a.size() << endl;
        cout<< kotae << endl;

 
}

Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <queue>
#include <limits>
using namespace std;
template <typename T, bool directed>
class Johnson
{
public:
  int n;
  struct Edge
  {
    int dst;
    T cost;
    Edge(int dst, T cost) : dst(dst), cost(cost) {}
  };
  vector<T> h;
  vector<vector<T>> dist;
  vector<vector<Edge>> graph;

  Johnson(int n) : n(n), graph(n) {}
  void add_edge(int src, int dst, T cost)
  {
    graph[src].emplace_back(dst, cost);
    if (!directed)
      graph[dst].emplace_back(src, cost);
  }
  bool build()
  {
    if (!bellman_ford())
      return false;
    dist.assign(n, vector<T>(n, numeric_limits<T>::max() / 2));
    // n回ダイクストラ
    for (int s = 0; s < n; ++s)
      dijkstra(s);
    return true;
  }
  inline T get(int s, int t) const { return dist[s][t]; }

private:
  bool bellman_ford()
  {
    // ベルマンフォードによりポテンシャルを導入
    h.assign(n, 0);
    for (int i = 0; i < n; ++i)
      for (int v = 0; v < n; ++v)
        for (Edge e : graph[v])
          if (h[e.dst] > h[v] + e.cost)
          {
            h[e.dst] = h[v] + e.cost;
            if (i == n - 1)
              return false;
          }
    return true;
  }
  
  void dijkstra(int s)
  {
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> pq;
    dist[s][s] = 0;
    pq.emplace(0, s);
    while (!pq.empty())
    {
      T c = pq.top().first;
      int v = pq.top().second;
      pq.pop();
      for (Edge e : graph[v])
        if (dist[s][e.dst] > dist[s][v] + e.cost)
        {
          dist[s][e.dst] = dist[s][v] + e.cost;
          pq.emplace(dist[s][e.dst], e.dst);
        }
    }
    for (int i = 0; i < n; ++i)
      dist[s][i] += h[i] - h[s];
  }
};

int main()
{
  int H, W, c, A;
  cin >> H >> W;
  Johnson<int, true> js(10);
  for (int i = 0; i <= 9; ++i)
  {
    for (int j = 0; j <= 9; ++j)
    {
      cin >> c;
      js.add_edge(i, j, c);
    }
  }
  js.build();

  int ans = 0;
  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      cin >> A;
      if (A == -1)
        continue;
      ans += js.get(A, 1);
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
	int H,W,h,w;

	while(1){
		cin >> H >> W;
		
		if(H==0 && W==0)break;
		
		for(w=1 ; w<=W ; w++){
			cout << "#";
		}
		
		cout << endl;
		
		for(h=3 ; h<=H ; h++){
			cout << "#";
			for(w=3 ; w<=W ; w++){
				cout << ".";
			}
			cout << "#\n";
		}
		
		for(w=1 ; w<=W ; w++){
			cout << "#";
		}
		cout << endl << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1152
//Pantyhose(black) + glasses = infinity

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

int main() {
	#ifdef GLASSES_GIRL
		freopen(FILE_NAME".inp", "r", stdin);
		freopen(FILE_NAME".out", "w", stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int n, k;
	cin >> n >> k;
	if (n/2+n%2>=k)
		cout << "YES";
	else
		cout << "NO";
}

Measured memory_bytes: 256
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
m = 10**8
index = -1
for i in range(N):
    tmp = T - H[i]*0.006
    if(abs(A-tmp) < m):
        m = abs(A-tmp)
        index = i
print(index+1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.weight", "r", stdin );

	int w;
	while (scanf ("%d", &w ) != EOF ){
		vector<int> res; res.clear();
		for (int i = 1; i <= 512; i<<=1 ){
			 if (w & i ) res.push_back (i );
		} // end for
		rep (i, res.size() ){
			cout << res[i] << (i != res.size() - 1 ? ' ' : '\n' );
		} // end rep
	} // end while

	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
long long ara[101],sum[101];

int main()
{
   long long a,b,c,i,pos=0,n,t,cur;
   cin>>a>>b>>c;
   if(b*c>=a)
    cout<<"Yes"<<"\n";
   else
    cout<<"No"<<"\n";

   
return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>


int main()
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);

    if( r<=x && x<=W-r && r<=y && y<=H-r){
        printf("Yes");
    }else{
        printf("No");
    }
    
    printf("\n");
    return 0;
    
}




Measured memory_bytes: 2144
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
int main() {
	int a, b; cin >> a >> b;
	int c = a + b;
	if (c % 2 == 0)cout << c / 2 << endl;
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}

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

#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef long double ld;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

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



vector<int> app(1000010,0);
vector<bool> is_prime(1000010,true);

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n;
    cin>>n;
    vector<int> a(n);
    vector<bool> isNOTcoprime(n,false);

    rep(i,n){
        int ai;
        cin>>ai;
        a[i] = ai;
        app[ai]++;
    }

    ll g = gcd(a[0],a[1]);
    //db(g);ln;
    rep1(i,2,n){
        g = gcd(g,a[i]);
        //db(g);ln;
    }

    if(g != 1){
        cout<<"not coprime"<<endl;
        return 0;
    }

    //sort(all(a));
    bool p_cop = true;


    vector<int> prime;
    rep1(i,2,1000001){
        if(is_prime[i]){
            prime.emplace_back(i);

            int p = i*2;
            while(p <= 1000000){is_prime[p]=false;p+=i;}
        }
    }

    
    for(int pi : prime){
        int cnt = 0;
        int p = pi;
        
        while(p <= 1000001){
            if(app[p] != 0)++cnt;
            p += pi;
        }

        //db2(pi,cnt);ln;

        if(cnt >= 2)p_cop=false;
        if(!p_cop)break;
    }

    if(p_cop){
        cout<<"pairwise coprime"<<endl;
    }else{
        cout<<"setwise coprime"<<endl;
    }

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 11916
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	double ans=0,t,m,sum=0;cin>>n>>k;
	double x[n+1];x[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>m;sum+=(m+1)/2;x[i]=sum;
	}
	for(int i=k;i<=n;i++)
	{
		t=x[i]-x[i-k];
		ans=max(ans,t);
	}
	printf("%.10lf\n",ans);
}

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

int main() {
  int n;
  cin >> n;
  for ( int i=6; i>=0; i-- ) {
    if ( (1<<i)<=n ) {
      cout << (1<<i) << '\n';
      break;
    }
  }
  return 0;
}

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

using namespace std;

vector<int> ans;

int main(){
	while(1){
		int e;
		cin >> e;
		if(e == 0) break;
		int m = 1e9;
		for(int i = 0;i < e;i++){
			if(i*i*i > e) break;
			int iii = i*i*i;
			for(int j = 0;j <= e - iii;j++){
				if(j*j > e - iii) break;
				int jj = j*j;
				int k = e - jj - iii;
				m = min(m,i+j+k);
			}
		}
		ans.push_back(m);
	}
	for(int i = 0;i < ans.size();i++)cout << ans[i] << endl;
	
	return 0;
}

Measured memory_bytes: 3192
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

// int main() {
//   int n;
//   string s;
//   cin >> n >> s;
//   rep(i,s.size()) {
//     int x = s[i] - 'A';
//     x = (x + n) % 26;
//     cout << (char)(x + 'A');
//   }
//   cout << endl;
// }

int main() {
  int n;
  cin >> n;
  cout << n*n << endl;
}


Measured memory_bytes: 3188
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.HashMap;

class Main
{
    public static String getId(Integer p, Integer x) {
        return String.format("%06d", p) + String.format("%06d", x);
    }
    
    public static void main(String args[])
    {
        class Io {
            public BufferedReader br;
            public StringBuilder stb;

            public Io() {
                InputStreamReader ir = new InputStreamReader(System.in);
                this.br = new BufferedReader(ir);
                this.stb = new StringBuilder();
            }
            
            public ArrayList<Integer> inputInts() {
                String[] inputParts = {""};
        
                try { 
                    inputParts = br.readLine().split(" ");
                }
                catch (IOException e) {
                    System.out.println("Error " + e.getMessage());
                }

                int n = inputParts.length;
                ArrayList<Integer> ints = new ArrayList<>();
                for (int i = 0; i < n; i++) {
                    ints.add(Integer.valueOf(inputParts[i]));
                }
                return ints;
            }

            public void appendToAnswer(String s) {
                stb.append(s).append("\n");
            }

            public void printAnswer() {
                System.out.print(stb.toString());
            }
        }

        Io io = new Io();
        ArrayList<Integer> ints = io.inputInts();
        Integer N = ints.get(0), M = ints.get(1);
        HashMap<Integer, ArrayList<Integer>> prefs = new HashMap<>();
        HashMap<Integer, ArrayList<Integer>> cities = new HashMap<>();

        for (Integer i = 1; i <= N; i++) {
            prefs.put(i, new ArrayList<>());
        }

        for (Integer i = 1; i <= M; i++) {
            ints = io.inputInts();
            Integer p = ints.get(0), y = ints.get(1);
            prefs.get(p).add(i);
            ArrayList<Integer> attrs = new ArrayList<>(3);
            attrs.add(p);
            attrs.add(y);
            cities.put(i, attrs);
        }

        for (Integer i = 1; i <= N; i++) {
            if (prefs.get(i).size() > 1) {
                prefs.get(i).sort((Integer city_a, Integer city_b) -> cities.get(city_a).get(1) - cities.get(city_b).get(1));
            }
        }

        for (Integer i = 1; i <= N; i++) {
            Integer size = prefs.get(i).size();
            for (Integer j = 0; j < size; j++) {
                cities.get(prefs.get(i).get(j)).add(j + 1);
            }
        }

        for (Integer i = 1; i <= M; i++) {
            ArrayList<Integer> city = cities.get(i);
            io.appendToAnswer(getId(city.get(0), city.get(2)));
        }
        io.printAnswer();
    }
}


Measured memory_bytes: 184812
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 27192
#include<stdio.h>
#include<stdlib.h>

long long int ex(long long int x,long long int y){
long long int a,b,tmp=1;
if(x<y){
tmp = x;
x = y;
y = tmp;
}
a=x;
b=y;
while(tmp!=0){
tmp=x%y;
x=y;
y=tmp;
} 
return (a/x)*b;
}

int main(void){
long long int* a;
int i,N;
scanf("%d",&N);
a =(long long int*)malloc(N*sizeof(long long int));
for(i=0;i<N;i++){
scanf("%lld",&a[i]);
}
if(N>=2){
long long int ty,tmp=ex(a[0],a[1]);
for(i=2;i<N;i++){
ty = ex(tmp,a[i]);
tmp = ty;
}
printf("%lld",tmp);
}else{
printf("%lld",a[0]);
}
    return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


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

    vector<int> c; 
    int now=1; //今見ている数
    int cnt=0; //nowがいくつ並んでいるか
    rep(i,n){
        if(s[i] == (char)(now + '0')) cnt++;
        else{
            c.push_back(cnt);
            now=1-now; //0と1を切り替えるときの計算
            cnt = 1; //新しいのをカウントし始める
        }
    }
    c.push_back(cnt);
    //1で始まって2で終わるようにしたいので終端が0だったら適当に1つ足す
    if(c.size()%2==0) c.push_back(0);

    int m=c.size();
    vector<int> S(m+1); //sが累積和のベクトル
    rep(i,m) S[i+1] = S[i] + c[i];

    int ans=0;
    //1-0-1...の1から始めるので偶数番目だけを見る
    for(int i=0; i<m; i+=2){
        int left=i;
        int right=min(i+2*k+1,m);
        chmax(ans,S[right]-S[left]);
    }
    cout << ans << endl;





}

Measured memory_bytes: 4108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]||s[1]==s[2]&&s[2]==s[3])
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;


int main() {
    // freopen("in.txt", "r", stdin);
    long long n, k;
    scanf("%lld %lld", &n, &k);
    long long v = __gcd(n, k);
    n /= v;
    k /= v;
    long long ans = 1 + (n - 1) + 1 + (2 * (n - 2));
    printf("%lld\n", ans * v);
}

Measured memory_bytes: 256
#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 pb push_back
#define mp make_pair
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int H,W;cin>>H>>W;
    int ans=min(H,W);
    vector<int>vec(3);
    if(H%3!=0&&W%3!=0){
        for(int i=1;i<=H/2;i++){
            vec[0]=i*W;
            if(W%2==0)vec[1]=vec[2]=(H-i)*W/2;
            else{
                vec[1]=(H-i)*(W/2);
                vec[2]=(H-i)*(W/2+1);
            }
            sort(vec.rbegin(),vec.rend());
            ans=min(ans,vec[0]-vec[2]);
        }
        for(int i=1;i<=W/2;i++){
            vec[0]=H*i;
            if(H%2==0)vec[1]=vec[2]=(W-i)*H/2;
            else{
                vec[1]=(W-i)*(H/2);
                vec[2]=(W-i)*(H/2+1);
            }
            sort(vec.rbegin(),vec.rend());
            ans=min(ans,vec[0]-vec[2]);
        }
    }
  	else ans=0;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    while(1):
        N = int(input())
        if N == 0:
            break
        p = [10,10]
        g = set()
        for _ in range(N):
            g.add(tuple([int(n) for n in input().split()]))
        M = int(input())
        if tuple(p) in g:
            g.remove(p)
        for _ in range(M):
            d, l = input().split()
            l = int(l)
            if d == "N":
                b = [0,1]
            elif d == "E":
                b = [1,0]
            elif d == "S":
                b = [0,-1]
            else:
                b = [-1, 0]
            while(l > 0):
                p[0] += b[0]
                p[1] += b[1]
                if tuple(p) in g:
                    g.remove(tuple(p))
                l -= 1
        # print(g)
        print("Yes" if len(g) == 0 else "No")
if __name__ == "__main__":
    main()


Measured memory_bytes: 5660
#include <bits/stdc++.h>
using namespace std;
typedef long long Int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    Int x, y; cin >> x >> y;
    int ans = 0;
    while ( x <= y) {
        x = (Int)2 * x;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//Vivek
#include <bits/stdc++.h>
 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long 
#define mod 1000000007
#define llt int test;cin>>test;while(test--)
#define pb push_back
#define setto(n) cout << fixed<< setprecision(n)
#define fi first
#define se second
#define sz(i) int(i.size())
#define all(v) v.begin(),v.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define len(s) s.length()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define INF LONG_MAX
#define random() ((ll)rand() << 32 | rand())
 
using namespace std; 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}
template<class T> void smax(T& a, T val) {if (a < val) a = val;}
template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int MAX = 100010;
 
map<char, int> freq;
// int visited[]
int main(){
	boost;
	string s;
	cin>>s;
	for (auto c: s)
		freq[c]++;
 
	set<char> others;
	for (int i = 0; i <26 ; ++i)
	{
		char c = (char)(97+i);
		if(freq[c] == 0)
			others.insert(c);
	}
	if(sz(s) != 26){
		cout<<s<<*others.begin();
		return 0;
	}
	int ls = len(s), pos = -1;
	char c;
	others.clear();
	for (int i = 0; i <26 ; ++i)
		others.insert(char(97+i));
	int total = 1;
	for (int i = ls-2; i >=0 and total; --i)
	{	
		others.erase(s[i+1]);
		if(s[i] == 'z')continue;
		for (int j = 1;  ; ++j)
		{
			c = (char)(s[i]+j);
			if(others.find(c) == others.end()){
				pos = i;
				total = 0;
				break;
			}
			if(c=='z')break;
		}
	}
 	
 	if(pos == -1)cout<<-1;
 	else{
		for (int i = 0; i <pos ; ++i)
			cout<<s[i];
		cout<<c;
 	}
	return 0;
}
 

Measured memory_bytes: 256
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


N = int(input())
A = list(map(int,input().split()))


for a in A:
    if a == 0:
        print("0")
        sys.exit()

num = 1
for a in A:
    num *= a
    if num > 1000000000000000000:
        print(-1)
        sys.exit()

print(num)


Measured memory_bytes: 33428
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;

int main(){
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	if(n <= k) cout << n * x << endl;
	else cout << k * x + (n - k) * y << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<map>
#include<string>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

typedef pair<double,pair<int,int> > pp;

#define MAX (10000000)

int main(){
  int n;
  while(scanf("%d",&n), n){
    int ct[10][10];
    int m = 0;
    REP(i,10) REP(j,10) ct[i][j] = (i==j?0:MAX);
    REP(i,n){
      int a,b,c;
      scanf("%d%d%d",&a,&b,&c);
      m = max(m, a); m = max(m, b);
      ct[a][b] = ct[b][a] = min(ct[a][b], c);
    }
    m++;

    REP(k,m) REP(i,m) REP(j,m)
      ct[i][j] = min(ct[i][j], ct[i][k]+ct[k][j]);

    int ans = -1;
    int d = INT_MAX;
    REP(i,m){
      int sum = 0;
      REP(j,m) sum+=ct[i][j];
      if(sum < d){
	ans = i;
	d = sum;
      }
    }

    printf("%d %d\n", ans, d);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
const int MAX = 1000000;
const int MOD = 1000000007;
 
int main(){
  string a;
  cin >> a;
  if(a[a.size()-1]=='s'){
    a += 'e';
    a += 's';
  }else{
    a += 's';
  }
  cout << a << endl;
}

Measured memory_bytes: 3600
from sys import stdin


def main():
    lines = stdin.readlines()
    N = int(lines[0].split()[0])
    Dk = lines[1].split()
    for i in range(N, 10 * N):
        for D in Dk:
            if D in str(i):
                break
        else:
            print(i)
            break
    return


main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return (rand()<<16|rand())%x;
}
const int N=200005,mod=1000000007;
vector<int> v[N];
int c[N],w[N],father[N],q[N],vis[N],x,y,n;
inline int getfather(int x){
	return father[x]==x?x:father[x]=getfather(father[x]);
}
map<int,int> M[N];
inline int ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
inline bool cmp(int a,int b){
	return w[a]<w[b];
}
void ins (int a,int b){
	//cout<<a<<" "<<b<<" "<<w[a]<<" "<<w[b]<<endl;
	int t1=getfather(a),t2=getfather(b);
	if(t1!=t2)father[t2]=t1;
}
void check(int a,int b){
	if(c[a]!=c[b]&&w[a]+w[b]<=y)ins(b,a);
	if(c[a]==c[b]&&w[a]+w[b]<=x)ins(b,a);
}
int main(){
	n=read(); x=read(); y=read();
	for(int i=1;i<=n;i++){
		c[i]=read(); w[i]=read(); v[c[i]].push_back(i); father[i]=q[i]=i;
	}
	for(int i=1;i<=n;i++)if(v[i].size()){
		sort(v[i].begin(),v[i].end(),cmp); vis[v[i][0]]=1;
		for(unsigned j=1;j<v[i].size();j++)if(w[v[i][j]]+w[v[i][0]]<=x)ins(v[i][0],v[i][j]);
	}
	sort(&q[1],&q[n+1],cmp); int jb=0;
	for(int i=2;i<=n;i++){
		if(!jb&&c[q[i]]!=c[q[1]])jb=q[i];
	}//else cout<<w[i]<<" "<<i<<" "<<father[i]<<endl;
	for(int i=1;i<=n;i++){
		check(i,jb); check(i,q[1]);
	}
	for(int i=1;i<=n;i++)M[getfather(i)][c[i]]++;
	ll ans=1;
	for(int i=1;i<=n;i++)if(getfather(i)==i){
		int sum=0;
		for(map<int,int>::iterator it=M[i].begin();it!=M[i].end();it++){
			sum+=it->second; for(int j=1;j<=it->second;j++)ans=ans*ksm(j,mod-2)%mod;
		}
		//cout<<i<<" "<<sum<<" "<<ans<<endl;
		for(int j=1;j<=sum;j++)ans=ans*j%mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 31872
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
 

int main() 
{    
    int A,B,C;
    cin >> A >> B >> C;
    int res;
    if(B >= A * C)res = C;
    else res = B/A;

    cout << res << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int Min = INF;
    int w[n + 1], b[n + 1];
    w[0] = b[0] = 0;

    rep(i, n) {
        if (s[i] == '.') {
            w[i + 1] = w[i] + 1;
            b[i + 1] = b[i];
        } else {
            w[i + 1] = w[i];
            b[i + 1] = b[i] + 1;
        }
    }

    rep(i, n + 1) {
        Min = min(Min, b[i] + w[n] - w[i]);
    }
    cout << Min << endl;
    return 0;
}



Measured memory_bytes: 2196
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(list[K-1])


Measured memory_bytes: 2940
$debug = false
flag = ARGV.shift
if flag == "-d"
  $debug = true
end

def dputs str
  p str if $debug
end

def max(n, m)
  if n > m
    return n
  else
    return m
  end
end

def min(n, m)
  if n < m
    return n
  else
    return m
  end
end

def gets_all_int
  return gets.chomp.split.map{|v| v.to_i}
end

## start
N = gets.to_i
S = gets.strip
ABC="ABC"

cnt = 0
0.upto(S.length - ABC.length) do |i|
  if S[i,3] == ABC
    cnt += 1
  end
end
puts cnt

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;

int main(){

  int n,k;
  
  cin >> n >> k;
  
  int ans = 0;
  rep(i,n){
    int h;
    cin >> h;
    if(h >= k)ans++;
  }
  
  cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256