akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define read(x)	 freopen(x, "r", stdin);
#define write(x) freopen(x, "w", stdout);
// #define xihaad

int main()
 {
#ifdef xihaad
	read("input.txt");
	// write("output.txt");
#endif

long long a,b,c,d;
cin>>a>>b>>c>>d;
long long ar[4];
ar[0]=a*c;
ar[1]=b*c;
ar[2]=a*d;
ar[3]=b*d;
sort(ar,ar+4);
cout<<ar[3]<<endl;



   return 0;

}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define x first
#define y second
#define pb push_back
using namespace std;

ll n,distX[ 100010 ],ans,points[ 100010 ];
pair< ll , ll > p[ 100010 ];
vector< ll > arr[ 100010 ];
ll dsu[300010];
set< ll > labels,distY[ 100010 ];

ll getF( ll nd ){
    if( dsu[nd]==nd ) return nd;
    return dsu[ nd ] = getF( dsu[ nd ] );
}

void join(ll u,ll v){
    ll fu = getF( u ) , fv = getF( v );
    if( fu == fv ) return;
    dsu[ fu ] = fv;
    return;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for(ll i=0; i<n; i++) cin >> p[i].x >> p[i].y , arr[ p[i].x ].pb( p[i].y );

    for(ll i=1; i<=100000; i++) dsu[i]=i;
    for(ll i=1; i<=100000; i++){
        if( arr[i].size()>1 )
        for(ll j=0; j<arr[i].size()-1; j++) join( arr[i][j] , arr[i][j+1] );
    }


    for(ll i=1; i<=100000; i++){
        if( arr[i].empty() ) continue;
        distX[ getF( arr[i][0] ) ]++;
        labels.insert( getF( arr[i][0] ) );
        for(ll j=0; j<arr[i].size(); j++) distY[ getF( arr[i][0] ) ].insert( arr[i][j] ), points[ getF( arr[i][0] ) ]++;
    }

    for( auto l:labels ) ans+=distX[l]*distY[l].size()-points[l];
    cout << ans;

    return 0;
}


/*

15

1 1
1 6
2 2
2 4
3 2
3 6
10 1
10 4

17 3
17 5
17 9
14 5
14 7
22 3
22 5


Ans: 13

*/


Measured memory_bytes: 16768
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <cstring>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

std::string A, B;
int M;

int dp[501][501][10][3][2];

bool zigzag(const std::string &s){
    for(int i=0;i+2<s.size();i++){
        if(s[i+1]-s[i] > 0 && s[i+2]-s[i+1] < 0);
        else if(s[i+1]-s[i] < 0 && s[i+2]-s[i+1] > 0);
        else{return false;}
    }
    return true;
}

int rec(std::string &s, int d, int r, int prev_n, int updown, int nine){
    if(d == s.size()){return r == 0;}
    if(dp[d][r][prev_n][updown][nine] != -1){
        return dp[d][r][prev_n][updown][nine];
    }
    
    int n = s[d]-'0', res = 0;

    for(int i=0;i<=(nine?9:n);i++){
        // 増加しない
        if(updown == 0 && prev_n <= i)continue;
        // 減少しない
        if(updown == 1 && prev_n >= i)continue;
        // 一つ前が0でない または 0以外の先頭桁が決まっていて，次がその桁の数と同じ(増加も減少もしない)
        if(updown == 2 && prev_n && prev_n == i)continue;

        int dd;
        if(updown == 2){
            if(prev_n == 0){ // 0でいく
                dd = 2;
            }else if(prev_n > i){ // 減少する
                dd = 1;
            }else { // 増加する
                dd = 0;
            }
        } else dd = !updown; // 反転

        res = (res + rec(s, d+1, (r*10+i)%M, i, dd, nine|(i!=n))) % 10000;
    }
    
    return dp[d][r][prev_n][updown][nine] = res;
}

int main(){
    std::cin >> A >> B;
    std::cin >> M;

    int an, bn;

    memset(dp, -1, sizeof(dp));
    bn = rec(B, 0, 0, 0, 2, 0);

    memset(dp, -1, sizeof(dp));
    an = rec(A, 0, 0, 0, 2, 0);

    std::cout << (bn - an + 10000 + zigzag(A)) % 10000 << std::endl;
}

Measured memory_bytes: 60120
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Integer[] x = new Integer[m];
        Index[] diff = new Index[m-1];
        for(int i = 0; i < m; i++) {
            x[i] = sc.nextInt();
        }
        if(n >= m) {
            System.out.println(0);
            return;
        }
        Arrays.sort(x);
        for(int i = 0; i < m-1; i++) {
            diff[i] = new Index(i, x[i+1] - x[i]);
        }
        Arrays.sort(diff, (a, b) -> b.length - a.length);
        Index[] sorted = new Index[n-1];
        for(int i = 0; i < n-1; i++) {
            sorted[i] = diff[i];
        }
        Arrays.sort(sorted, (a, b) -> a.index - b.index);
        int count = 0;
        int current = 0;
        for(int i = 0; i < n-1; i++) {
            Index index = sorted[i];
            count += (x[index.index] - x[current]);
            current = index.index + 1;
        }
        count += (x[m-1] - x[current]);
        System.out.println(count);
    }
    private static class Index {
        int index;
        int length;
        Index(int index, int length) {
            this.index = index;
            this.length = length;
        }

    }
}



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

int main(){
 int N;
 string S;
 cin >> N;
 cin >> S;
  
  //a番目のアルファベットを@で表す。
 
 for (int i = 0; i < S.size(); i++){
     S.at(i) += N;
     if(S.at(i) > 'Z') S.at(i) -= 26;
 }
  
  cout << S << endl;
 
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;  // or pb_ds;

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#ifndef DEBUG
#define endl "\n"
#endif
#define fff ff
#define sss ss.ff
#define ttt ss.ss
#define INF (1 << 30)
#define LLF (1ll << 60)
#define PRIME (1000000007)
#define FASTIO std::ios::sync_with_stdio(false)
#ifdef DEBUG
#define debug(x) cerr << #x << " = " << x << endl
#else
#define debug(x)
#endif
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define FILE_INPUT                  \
  freopen("input.txt", "r", stdin); \
  freopen("output.txt", "w", stdout)

#define all(x) x.begin(), x.end()

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<string> vs;

template <typename T, typename B = null_type>
using oset =
    tree<T, B, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order / order_of_key

const ld eps = 1e-12;

/*-----------------END TEMPLATE-----------------*/

bool test(ll n, ll k) {
  while (n >= k) {
    if (n % k == 0)
      n /= k;
    else
      n = n % k;
  }
  return n == 1;
}

int(((((((((((((((main)))))))))))))))() {
  FASTIO;
  ll n;
  cin >> n;
  set<ll> ans;
  ans.emplace(n);
  ans.emplace(n - 1);
  for (ll i = 2; i * i <= n; i++) {
    ll equivalent = n / i;
    if (test(n, i)) {
      ans.emplace(i);
    }
    if (test(n, equivalent)) {
      ans.emplace(equivalent);
    }
  }
  ll res = ans.size();
  if (ans.count(1)) res--;
  cout << res << endl;
}

/*

K = 3, N = 6



*/

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

long N, K;
vector<long> A, visited;

int main(void) {

    cin >> N >> K;
    A.resize(N+1); visited.resize(N+1, false);
    for (long i = 1; i <= N; i++) cin >> A[i];


    long x = 1;
    long s = 0, t = 0;
    while (!visited[x]) {
        visited[x] = true;
        x = A[x];
        s++;
    }


    long y = x;
    do {
        y = A[y];
        t++;
    }
    while (x != y);


    long u = 0;
    if (K <= s) {
        u = K;
    }
    else {
        u = s + (K - s) % t;
    }


    long ans = 1;
    for (long i = 0; i < u; i++) ans = A[ans];


    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 6408
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
    string s;
    getline(cin, s);
    for (int i=0; i<(int)s.size(); ) {
        if (s.substr(i, 5) == "apple") {
            cout << "peach";
            i += 5;
        } else if (s.substr(i, 5) == "peach") {
            cout << "apple";
            i += 5;
        } else {
            cout << s[i];
            i ++;
        }
    }
    cout << endl;
    return 0;
}

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

using namespace std;

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

  int n, m, r;
  cin >> n >> m >> r;
  vector<int> targets(r);
  for (auto &e : targets) {
    cin >> e;
  }

  vector<vector<uint64_t>> path(n + 1, vector<uint64_t>(n + 1, 1e10));
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    path[a][b] = c;
    path[b][a] = c;
  }

  for (int k = 1; k <= n; ++k) {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) {
        path[i][j] = min(path[i][j], path[i][k] + path[k][j]);
      }
    }
  }

  sort(targets.begin(), targets.end());
  uint64_t ans = 1e10;
  do {
    uint64_t cost = 0;
    for (int i = 0; i < r - 1; ++i) {
      cost += path[targets[i]][targets[i + 1]];
    }
    ans = min(ans, cost);
  } while (next_permutation(targets.begin(), targets.end()));

  cout << ans << "\n";
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<P,P>P2;

int dp[111][111][1<<5];
int n,m,e,s,t,r;

vector<P>v[100000];

signed main(){
  r(i,111)r(j,1<<5)r(k,111)dp[i][k][j]=1e9;
  cin>>n>>m>>e>>s>>t>>r;

  r(i,m){
    int a,b;
    cin>>a>>b;
    v[a].push_back(P(b,-1));
    v[b].push_back(P(a,-1));
  }

  map<int,int>M;
  int state=0;

  r(i,e){
    int a,b,c;
    cin>>a>>b>>c;
    v[a].push_back(P(b,i));
    v[b].push_back(P(a,i));

    M[c] = i;
    if(c==s)state|=(1<<i);
  }

  priority_queue<P2,vector<P2>,greater<P2> > q;

  q.push(P2(P(0,s),P(r,state))); /// warning

  dp[s][r][state]=0;

  while(!q.empty()){
    P2 PP=q.top();q.pop();

    int now=PP.first.second;
    int cost=PP.first.first;
    int R = PP.second.first;
    int S = PP.second.second;

    // cout<<cost<<' '<<now<<' '<<R<<' '<<S<<endl;

    if(dp[now][R][S] < cost)continue;

    // cout<<cost<<' '<<now<<' '<<R<<' '<<S<<endl;

    if(R){
      r(i,v[now].size()){
	int nex = v[now][i].first;
	int flag = v[now][i].second;

	int f=flag%100;
	int nR=R-1;

	int nS = S;
	if(M.count(nex))nS= (nS|(1<<M[nex]));

	if(flag == -1){

	  if(dp[nex][nR][nS] <= cost+1)continue;
	  dp[nex][nR][nS] = cost+1;
	  q.push(P2(P(cost+1,nex),P(nR,nS)));
	}
	else{
	  if(!(S&(1<<f)))continue;

	  if(dp[nex][nR][nS] <= cost+1)continue;
	  dp[nex][nR][nS] = cost+1;
	  q.push(P2(P(cost+1,nex),P(nR,nS)));
	}
      }
    }

    if(dp[s][r][S] <= cost+1)continue;
    dp[s][r][S] = cost+1;
    q.push(P2(P(cost+1,s),P(r,S)));
  }


  int ans= 1e9;

  r(i,101)r(j,(1<<5)){
    ans=min(ans,dp[t][i][j]);
  }

  if(ans==1e9)cout<<-1<<endl;
  else cout<<ans<<endl;

  
  
  
}





Measured memory_bytes: 7096
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 200003, M = N << 1;

int n, k;
int a[N], b[N];
char s[N];

int main()
{
    scanf("%s", s + 1);
    if (s[2] == 'R') s[2] = 'B';
    else s[2] = 'R';
    cout << s + 1 << endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n,k;

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

  cin>>n>>k;
  ll cnt=(n+1)/2;
  if(cnt>=k)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
h,w,k = map(int,input().split())
s = [list(map(int, input())) for i in range(h)]
ans = h+w-2
for i in range(2**(h-1)):
    index = [0] * h
    rowcuts = 0
    for j in range(h-1):
        if 1 & (i >> j) == 1:
            rowcuts += 1
        index[j + 1] = rowcuts
    chocos = [0] * (rowcuts + 1)
    coulmncuts = 0
    valid = True
    for j in range(w):
        for l in range(h):
            chocos[index[l]] += s[l][j]
        if max(chocos) > k:
            coulmncuts += 1
            chocos = [0] * (rowcuts + 1)
            for l in range(h):
                chocos[index[l]] += s[l][j]
            if max(chocos) > k:
                valid = False
        if not valid:
            break
    if valid:
        ans = min(ans, rowcuts + coulmncuts)

print(ans)

Measured memory_bytes: 74316
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    // 入力
    Init();
    ll n, l;
    cin >> n >> l;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    // 各結び目iについて、a[i]+a[i-1]>=lとなる結び目があるかチェック
    bool ok = false;
    ll okIdx = -1;
    for(ll i=1; i<n; i++){
        // 条件を満たす結び目がある場合
        if(a[i]+a[i-1] >= l){
            ok = true, okIdx = i;
            break;
        }
    }
    
    // 条件を満たす結び目がある場合は、その結び目を残すように左右から解いていくことで達成可能
    if(ok){
        cout << "Possible" << endl;
        // 先頭から解いていく
        for(ll i=1; i<okIdx; i++) cout << i << endl;
        // 末尾から解いていく
        for(ll i=n-1; i>okIdx; i--) cout << i << endl;
        // 最後にl以上を満たしている結び目を解く
        cout << okIdx << endl;
    }
    // 条件を満たす結び目が無い場合は、達成不可能
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 3996
heights = []
for i in range(10):
    heights.append(int(input()))

for i in range(10):
    for j in range(i,10):
        if (heights[j] > heights[i]):
            w = heights[i]
            heights[i] = heights[j]
            heights[j] = w

for i in range(3):
    print(heights[i])

Measured memory_bytes: 7556
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	int ans = 0;
	if (N < 10) cout << N << endl;
	else if (N >= 10 && N <= 99) cout << 9 << endl;
	else if (N >= 100 && N <= 999) cout << 9 + N - 100 + 1 << endl;
	else if (N >= 1000 && N <= 9999) cout << 909 << endl;
	else if (N >= 10000 && N <= 99999) cout << 909 + N - 10000 + 1;
	else cout << 90909 << endl;
}


Measured memory_bytes: 256
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;

void solve()
{
	int i, j, p = 0;
	cin >> m >> n;
	si st;

	vpi v;
	for (i = 0; i < N; i++)
		a[i] = 1e9;

	for (i = 0; i < n; i++)
	{
		int x; string c;
		cin >> x >> c;

		if (c == "AC")
		{
			st.insert(x);
			a[x] = min(a[x], i);
		}
		else
		{
			v.pb({x, i});
		}
	}

	for (auto x : v)
	{
		if (a[x.F] != 1e9 && a[x.F] > x.S)
			p++;
	}

	cout << sz(st) << " " << p;

}

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


	cout << setprecision(9) << fixed;
	clock_t z = clock();
	solve();
	cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}

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

int main() {
	int a[32] = {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};
	int k;
	cin >> k;
	//cin >> k;
	cout << a[k - 1];
	return 0;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
X, Y = C, D

while True:
  if X > Y:
    t = Y
    Y = X % Y
    X = t
  else:
    Y = Y % X
  if Y == 0:
    break;

a = (A - 1) - (A - 1)//C - (A - 1)//D + (A - 1)//(C*D//X)
b = B - B//C - B//D + B//(C*D//X)

print(b - a)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
PII arr[MAXN];
int main(){
    //~ freopen("file.in", "r", stdin);
    int n,k,cnt=0;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		if(a>k)
			continue;
		arr[++cnt]=mp(a,b);	
	}int mask=0;
	ll ans=0,res=0;
	for(int i=29;i>=0;i--){
		if(k>>i&1){res=0;
			for(int j=1;j<=cnt;j++)
				if(((arr[j].ff>>i)|(mask>>i))==mask>>i)
					res+=arr[j].ss;	
			umax(ans,res);
			mask|=(1<<i);
		}
	}res=0;
	for(int j=1;j<=cnt;j++)
		if((mask|arr[j].ff)==mask)
			res+=arr[j].ss;
	printf("%lld\n",max(ans,res));		
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define M_PI 3.14159265358979323846
template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
	while (*sdbg != ',')cerr << *sdbg++; cerr << '=' << h << ','; _dbg(sdbg + 1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
	os << "["; for (auto& vv : V) os << vv << ","; os << "]";
	return os;
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
	return os << "(" << P.st << "," << P.nd << ")";
}


#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

int32_t main(int32_t argc, char ** argv) {
	ios_base::sync_with_stdio(0);
	string s;
	cin >> s;
	if (s.substr(0, 4) == "YAKI") {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K;
  cin>>K;
  vector<int> vec={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};
  cout<<vec.at(K-1)<<endl;
  return 0;
}

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

int main(){
  string temp;
  int rday = 0;
  int sidx = 0;
  cin >> temp;
  for(int i=0;i<3;i++){
    if(temp[i] == 'R'){
     rday++; 
    }else{
      sidx = i;
    }
    if(rday == 2){
      if(sidx == 1){
        rday = rday - 1;
      }
    }
  }
  cout << rday << endl;
}

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

int main(){
  int n,c[4]={},p[9]={},q[9]={},k,cnt=0;
  bool fl=0;
  cin >> n;
  for(int i=0;i<262144;i++){
    fl=0;
    c[0]=0;
    c[1]=0;
    c[2]=0;
    c[3]=0;
    k=i;
    for(int j=0;j<9;j++){
      p[j]=k%4;
      if(p[j]==0){c[0]++;q[j]=0;}
      else if(p[j]==1){c[1]++;p[j]=3;q[j]=3;}
      else if(p[j]==2){c[2]++;p[j]=5;q[j]=5;}
      else{c[3]++;p[j]=7;q[j]=7;}
      k/=4;
    }
    if(c[1]*c[2]*c[3]==0) continue;
    sort(q,q+9);
    for(int j=0;j<9;j++){
      if(p[j]==0&&q[j]!=0) fl=1;
    }
    if(fl) continue;
    if(n>=p[8]+10*p[7]+100*p[6]+1000*p[5]+10000*p[4]+100000*p[3]+1000000*p[2]+10000000*p[1]+100000000*p[0]+1000000000*p[9]) cnt++;
  }
  cout<<cnt;
}

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

const int maxn = 100005, P = 1000000007;
int n, m, x[maxn], y[maxn], q[maxn], k, c, f[maxn], t[maxn];
struct point { int a, b; } p[maxn];
bool operator==(const point &a, const point &b) { return a.a == b.a && a.b == b.b; }
bool operator<(const point &a, const point &b) { return a.a < b.a || (a.a == b.a && a.b > b.b); }

int query(int x) { int s = 0; for (; x; x -= x & -x) s = (s + t[x]) % P; return s; }
void update(int x, int y) { for (; x <= k; x += x & -x) t[x] = (t[x] + y) % P; }

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) scanf("%d", x + i);
	for (int i = 1; i <= m; i++) scanf("%d", y + i);
	for (int i = 1; i <= n; i++)
	{
		if (x[i] <= y[1] || x[i] >= y[m]) continue;
		int j = lower_bound(y + 1, y + 1 + m, x[i]) - y;
		if (y[j] == x[i]) continue;
		p[++c] = {x[i] - y[j - 1], y[j] - x[i]};
	}
	sort(p + 1, p + 1 + c);
	c = unique(p + 1, p + 1 + c) - p - 1;
	for (int i = 1; i <= c; i++) q[++k] = p[i].b;
	sort(q + 1, q + 1 + k);
	k = unique(q + 1, q + 1 + k) - q - 1;
	int ans = 0;
	for (int i = 1; i <= c; i++)
	{
		p[i].b = lower_bound(q + 1, q + 1 + k, p[i].b) - q;
		f[i] = (1 + query(p[i].b - 1)) % P;
		ans = (ans + f[i]) % P;
		update(p[i].b, f[i]);
	}
	printf("%d\n", (ans + 1) % P);
	return 0;
}


Measured memory_bytes: 2688
s=input()
n=len(s)
t=s.lower()
if s[0]=='A' and s.count('C')==1 and s[1]!='C' and s[n-1]!='C':
  cnt=0
  for i in range(n):
    if s[i]!=t[i]:
      cnt+=1
  if cnt==2:
    print('AC')
    exit()
print('WA')

Measured memory_bytes: 9092
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main() {
  int N;
  cin >> N;
  std::vector<int> v(N);
  std::vector<int> count(N);
  REP(i,N){
    cin >> v.at(i);
  }
  REP(i,N){
    while(v.at(i)%2 == 0){
      v.at(i) /= 2;
      count.at(i)++;
    }
  }
  int min = 100000000;
  REP(i,N){
    if(min > count.at(i)){
      min = count.at(i);
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#pragma region alias
#define inf LONG_MAX
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repr(i,n) for(int i=(int)(n-1);i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define sz(v) ((int)(v).size())
#define rz resize
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vec vector
using vi=vec<int>;
using vs=vec<string>;
using ii=pair<int,int>;
#pragma endregion

// define variables here
int n;
void solve(){
  // write code here
  cin>>n;
  string s=to_string(n);
  for(char c:s){
    if(c=='7'){
      cout<<"Yes"<<endl;
      return;
    }
  }
  cout<<"No"<<endl;
}

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

Measured memory_bytes: 3680
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    double a[n],ave=0,s=0;
    for(int i=0;i<n;i++){
      cin>>a[i];
      ave+=a[i];
    }ave/=(double)n;
    for(int i=0;i<n;i++)s+=pow(a[i]-ave,2);
    s/=(double)n;
    s=sqrt(s);
    printf("%.10f\n",s);
  }
}

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

/**
 * X-Ray Screening System
 *  URL:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2002
 *
 * @author Igari Kazuya
 *
 */
public class Main {
	private static ArrayList<Integer> usemapint;

	public static void addList(int num){
		for(int i=0;i<usemapint.size();i++){
			if(usemapint.get(i) == num){
				return ;
			}
		}
		usemapint.add(num);
	}

	public static boolean check(int[][] map, int num){
		int startX = map[0].length;
		int endX = -1;
		int startY = map.length;
		int endY = -1;
		for(int y=0;y<map.length;y++){
			for(int x=0; x < map[0].length ;x++){
				if(map[y][x] == num){
					if(x < startX){
						startX = x;
					}
					if(endX < x){
						endX = x;
					}
					if(y < startY){
						startY = y;
					}
					if(endY < y){
						endY = y;
					}
				}
			}
		}

		for(int y=startY;y<=endY;y++){
			for(int x=startX;x<=endX;x++){
				if(map[y][x] != num && map[y][x] != -1){
					return false;
				}
			}
		}

		for(int y=startY;y<=endY;y++){
			for(int x=startX;x<=endX;x++){
				map[y][x] = -1;
			}
		}

		return true;
	}

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

		int loop;
		loop = sc.nextInt();

		for(int i=0;i<loop;i++){
			int h,w;
			h = sc.nextInt();
			w = sc.nextInt();
			int[][] map = new int[h][w];
			usemapint = new ArrayList<Integer>();
			boolean flag = true;

			for(int y=0;y<h;y++){
				String buf;
				buf = sc.nextLine();
				if(buf.equals("")){
					buf = sc.nextLine();
				}
				for(int x=0;x<w;x++){
					if(buf.charAt(x) == '.'){
						map[y][x] = 0;
					}else{
						map[y][x] = buf.charAt(x) - ('A' - 1);
						addList(map[y][x]);
					}
				}
			}

			while(flag){
				flag = false;
				for(int j=0; j<usemapint.size();j++){
					if(check(map,usemapint.get(j))){
						flag = true;
						usemapint.remove(j);
						break;
					}
				}
			}

			if(usemapint.isEmpty()){
				System.out.println("SAFE");
			}else{
				System.out.println("SUSPICIOUS");
			}
		}
	}
}

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

using namespace std;

const long long MOD = 1000000007;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}


int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    // work backwards

    string a;

    cin >> a;

    if(a.size() < 5){
        cout << "NO";
        return 0;
    }

    for(int i = a.size() - 5; i >= 0;){

        if(a[i] == 'd' && a[i + 1] == 'r' && a[i + 2] == 'e' && a[i + 3] == 'a' && a[i + 4] == 'm'){
            i -= 5;
            continue;
        }

        if(a[i] == 'e' && a[i + 1] == 'r' && a[i + 2] == 'a' && a[i + 3] == 's' && a[i + 4] == 'e'){
            i -= 5;
            continue;
        }

        --i;

        if(i < 0){
            cout << "NO";
            return 0;
        }

        if(a[i] == 'e' && a[i + 1] == 'r' && a[i + 2] == 'a' && a[i + 3] == 's' && a[i + 4] == 'e' && a[i + 5] == 'r'){
            i -= 5;
            continue;
        }

        --i;

        if(i < 0){
            cout << "NO";
            return 0;
        }

        if(a[i] == 'd' && a[i + 1] == 'r' && a[i + 2] == 'e' && a[i + 3] == 'a' && a[i + 4] == 'm' && a[i + 5] == 'e' && a[i + 6] == 'r'){
            i -= 5;
            continue;
        }

        cout << "NO";
        return 0;

    }

    cout << "YES";

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll dp[101][2];
int main(){
	int l, k; cin >> l >> k;
	dp[0][0] = 0; dp[0][1] = 1;
	ll out = 0;
	rep(i, l) {
		dp[i + 1][0] += dp[i][1];
		dp[i + 1][1] += dp[i][0];
		if (i + k <= l) {
			dp[i + k][0] += dp[i][1];
		}
	}
	rep(i, l + 1) {
		out += dp[i][0];
	}
	cout << out << endl;
	return 0;
}


Measured memory_bytes: 3096
N,L=map(int,input().split())
A=[]
B=[]
for i in range(1,N+1):
    A.append(L+i-1)
for j in range(1,N+1):
    B.append(abs(L+j-1))
idx=B.index(min(B))
print(sum(A)-A[idx])

Measured memory_bytes: 3060
x = int(input())
if(x<600):
  print(8)
elif(x<800):
  print(7)
elif(x<1000):
  print(6)
elif(x<1200):
  print(5)
elif(x<1400):
  print(4)
elif(x<1600):
  print(3)
elif(x<1800):
  print(2)
elif(x<2000):
  print(1)

Measured memory_bytes: 9180
#include<iostream>
#include<string.h>
#include<queue>

using namespace std;

typedef pair<int, int>P;
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
int m, n, N;
char mat[1002][1002];
int d[1002][1002];
int ans;

int bfs(int sx, int sy, int goal){
    memset(d, -1, sizeof(d));
    queue<P>que;
    que.push(P(sx, sy));
    d[sx][sy] = 0;

    while(que.size()){
        P p = que.front();
        que.pop();
        int x = p.first, y = p.second;
        if(mat[x][y] == goal){
            //cout<<x<<" "<<y<<" "<<d[x][y]<<endl;
            return d[x][y];
        }

        for(int i = 0; i < 4; ++i){
            int gx = x + dx[i], gy = y + dy[i];
            if(0 <= gx && gx < m && 0 <= gy && gy < n
               && mat[gx][gy] != 'X' && d[gx][gy] == -1){
                   que.push(P(gx, gy));
                   d[gx][gy] = d[x][y] + 1;
            }
        }
    }
}

void solve(){
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < n; ++j){
            cin>>mat[i][j];
        }
    }

    ans = 0;
    char start = 'S';
    for(int k = 0; k < N; ++k){
        char goal = '1' + k;
        for(int i = 0; i < m; ++i){
            for(int j = 0; j < n; ++j){
                if(mat[i][j] == start){

                    //cout<<bfs(i, j, goal)<<endl;
                    ans += bfs(i, j, goal);
                }
            }
        }
        start = goal;
    }
    cout<<ans<<endl;
}

int main(){
    while(cin>>m>>n>>N && m > 0 && n > 0){
        solve();
    }
    return 0;
}



Measured memory_bytes: 8060
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    if(a >= b && a >= c){
        if(a == b + c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }else if(b >= a && b >= c){
        if(b == a + c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }else{
        if(c == a + b){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }


    


    
    


    
	}
}

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

int tc, A, B, C, D, T, H1, H2;
int x, y;

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin >> A >> B >> C >> D >> T;
  H1 = A * 60 + B;
  H2 = C * 60 + D - T;
  cout << H2 - H1 << "\n";
}

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

int main() {
    int n, k;
    string s;
    string a;
    cin >> n >> s >> k;
    a[0] = s[k-1];

    for(int i = 0; i < n; i++){
        if(a[0] != s[i]){
            s[i] = '*';
        }
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

# Sunny, Cloudy, Rainy

s = input().strip()

if s == "Sunny":
    print("Cloudy")
elif s == "Cloudy":
    print("Rainy")

else:
    print("Sunny")

Measured memory_bytes: 38256
def f(n):
    if (n+1) % 4 == 0:
        return 0
    if (n+1) % 4 == 1:
        return n
    if (n+1) % 4 == 2:
        return 1
    if (n+1) % 4 == 3:
        return n +1
a, b = map(int, input().split())

print(f(a-1) ^ f(b))

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
#define FAILURE 0
#define SUCCESS 1

int isprime(int);

int main(void){

  int n,num,i,flag=0;

  scanf("%d\n",&n);

  for(i = 0; i < n; i++){
    scanf("%d",&num);
    if(isprime(num) == 1){
      flag++;
    }
  }

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


int isprime(int x){

  int i=3;

  if(x == 2) return SUCCESS;
  else if(x < 2 || x%2 == 0) return FAILURE;

  while( i <= sqrt((double)x)){
    if(x % i == 0) return FAILURE;
    i += 2;
  }
  return SUCCESS;
}



Measured memory_bytes: 2140
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    int res = 0;
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    while ( n-- )
    {
      int x, y, h, w;

      scanf ( "%d%d%d%d", &x, &y, &h, &w );

      if      ( x + y + h <= 60  && w <= 2  ) res += 600;
      else if ( x + y + h <= 80  && w <= 5  ) res += 800;
      else if ( x + y + h <= 100 && w <= 10 ) res += 1000;
      else if ( x + y + h <= 120 && w <= 15 ) res += 1200;
      else if ( x + y + h <= 140 && w <= 20 ) res += 1400;
      else if ( x + y + h <= 160 && w <= 25 ) res += 1600;
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

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

using namespace std;

#define ll					long long
#define vi					vector<int>
#define vii					vector<vi>
#define ALL(s)			(s).begin(),(s).end()
#define pii					pair<int, int>
#define pll					pair<ll, ll>
#define si					set<int>
#define mp					make_pair
#define F						first
#define S						second
#define pb					push_back
#define tc(t)				int t; cin >> t; while(t--)
#define _						ios_base::sync_with_stdio(false); cin.tie(NULL); 
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;


int main() {_
	ll n; 	cin >> n;
	ll a;	cin >> a;
	ll b;	cin >> b;
	ll ans = 0;
	if(a == 0)
		cout << "0\n";
	else {
		ll x = n/(a+b);
		ans += x*a;
		n %= (a+b);
		//cout << n << "\n";
		ans += min(n,a);
		cout << ans << "\n";
	}
	
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int N;
    string s;
    cin >> N >> s;
    ll kind[26] = {0};
    rep(i, N) kind[s[i]-'a']++;

    ll ans = 1;
    rep(i, 26){
        ans *= kind[i]+1;
        ans %= MOD;
    }

    cout << ans-1 << endl;

    return 0;
}

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

int gcd(int a, int b) {
	if (b == 0)return a;
	return (gcd(b, a%b));
}
int lcm(int a, int b) {
	return a*b / gcd(max(a, b), min(a, b));
}
int main() {
	int a[11];
	a[0] = 1;
	int b;
	scanf("%d", &b);
	int s = 1;
	for (int c = 0; c < b; c++) {
		int d;
		scanf("%d", &d);
		s = lcm(s, d);
	}
	printf("%d\n", s);
}

Measured memory_bytes: 3176
n=int(input())
ne=[[] for _ in range(n+1)]
for _ in range(n):
    u,k,*v=map(int,input().split())
    ne[u]=v
dis=[-1]*(n+1)
dis[1]=0
q=[1]
while q:
    p=q.pop(0)
    for e in ne[p]:
        if dis[e]==-1:
            dis[e]=dis[p]+1
            q.append(e)
for i in range(1,n+1):
    print(i,dis[i])


Measured memory_bytes: 5628
#include <stdio.h>

int main(void){

  int a,b;
  scanf("%d %d", &a, &b);
  int count = 0;
  for (int i = a; i <= b; i++) {
    if (i/10000 == i%10 && (i/1000)%10 == (i%100)/10) {
      count++;
    }
  }
  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 128
using System;

class test
{
	static void Main()
	{
		string[] s = getArgs(Console.ReadLine());

		Console.WriteLine(getAnswer(int.Parse(s[0]), int.Parse(s[1]), int.Parse(s[2])));
	}
	private static object getAnswer(int dayly, int weekly, int maxCoin)
	{
		int leftCoin, coinPerWeek, weekCnt;
		int dayCnt = 0;
		
		coinPerWeek = dayly * 7 + weekly;
		weekCnt = maxCoin / coinPerWeek;
		leftCoin = maxCoin - weekCnt * coinPerWeek;
		if(leftCoin > 0)
		{
		    dayCnt = leftCoin / dayly;
		}
		if(leftCoin - dayCnt * dayly > 0)
		{
		    dayCnt++;
		}
		if(dayCnt > 7)
		{
		    dayCnt = 7;
		}
	    
	    return weekCnt * 7 + dayCnt;
	}
	private static string[] getArgs(string line)
	{
		return line.Split(' ');
	}
}


Measured memory_bytes: 17996
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const ll mod = 1e9 + 7 ;
const ll inf =
 1e9 + 5 ;
 //1e18L + 5;
const ll nax = 2e5 + 5;
void min_self(ll&a , ll b){a=min(a,b);}
void max_self(ll&a , ll b){a=max(a,b);}
void add_self(ll&a , ll b){a=(a+b)%mod;}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll n ; cin>> n ;
vector<ll>h(n) , a(n);
for(ll i = 0 ; i<n ; i++)cin>>h[i];
for(ll i = 0 ; i<n ; i++)cin>>a[i];
ll base  =1 ;
while(base<=n)base*=2;
vector<ll>t(2*base) ; 
for(ll i = 0 ; i<n ; i++){

	ll l = base  , r = base +  h[i] - 1 ;

	ll best = 0 ; 
	while(l<=r){
		if(l&1)max_self(best , t[l++]);
		if(!(r&1))max_self(best , t[r--]);
		l/=2;
		r/=2;
	}

	t[base + h[i]] = best  + a[i];

	ll x = base + h[i];
	while(x>0){
		max_self(t[x] , t[base+h[i]]);
		x/=2;
	}

}

cout<<t[1];




	
}

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

int main() {
	string a, b;
	cin >> a >> b;

	if (a == "H") {
		if (b == "H") {
			cout << "H";
		}else {
			cout << "D";
		}
	}else{
		if (b == "H") {
			cout << "D";
		}else {
			cout << "H";
		}
	}

	return 0;
}

Measured memory_bytes: 256
N, X, Y = map(int, input().split())
ans = [0] * (N - 1)
X, Y = X - 1, Y - 1
Z = Y - X - 1

for i in range(N):
  if i <= X:
    for j in range(i + 1, Y):
      p = min(j - i - 1, abs(i - X) + Y - j)
      ans[p] += 1
    for l in range(Y, N):
      ans[l - i - Z - 1] += 1
      
  elif (X < i) and (i < Y - 1):
    for j in range(i + 1, N):
      p = min(j - i - 1, abs(i - X) + abs(Y - j))
      ans[p] += 1  
      
  else:#Y <= i
    for j in range(i + 1, N):
      ans[j - i - 1] += 1
  #print(ans)
for i in range(N - 1):
  print(ans[i])

Measured memory_bytes: 3444
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, k; cin >> n >> k;
	int r, s, p; cin >> r >> s >> p;
	string t; cin >> t;
	vector<vector<int>> dp(n,vector<int>(3));
	rep(i, k)
	{
		if (t[i] == 's')dp[i][0] = r;
		if (t[i] == 'p')dp[i][1] = s;
		if (t[i] == 'r')dp[i][2] = p;
		for (int j = i + k; j < n; j += k)
		{
			rep(x, 3)
			{
				if (x == 0)
				{
					dp[j][0] = max(dp[j - k][1], dp[j - k][2]);
					if (t[j] == 's')dp[j][0] += r;
				}
				else if (x == 1)
				{
					dp[j][1] = max(dp[j - k][0], dp[j - k][2]);
					if (t[j] == 'p')dp[j][1] += s;
				}
				else
				{
					dp[j][2] = max(dp[j - k][0], dp[j - k][1]);
					if (t[j] == 'r')dp[j][2] += p;
				}
			}
		}
	}
	int res = 0;
	for (int i = n - 1; i > n - k - 1; --i)
	{
		res += max({ dp[i][0],dp[i][1],dp[i][2] });
	}
	cout << res << endl;
}

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

int main(){
  string s;cin>>s;
  int a=0,b=0;
  for(int i=0;i<s.size();i++)
  {
    if(i%2==0)
    {
      if(s.at(i)!='0')
        a++;
    }
    else
    {
      if(s.at(i)!='1')
        a++;
    }
  }
     for(int i=0;i<s.size();i++)
  {
    if(i%2==0)
    {
      if(s.at(i)!='1')
        b++;
    }
    else
    {
      if(s.at(i)!='0')
        b++;
    }
     }
  int ans=min(a,b);
  cout<<ans;
}
      
        
      

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

int g[15][15];

int main() {
  int n;
  cin >> n;
  rep(i, n) rep(j, n) g[i][j] = -1;
  rep(i, n) {
    int m;
    cin >> m;
    rep(j, m) {
      int a, x;
      cin >> a >> x;
      --a;
      g[i][a] = x;
    }
  }

  int ans = 0;
  rep(i, 1 << n) {
    bool ok = true;
    rep(j, n) {
      if (i >> j & 1) {
        rep(k, n) {
          if (g[j][k] == -1) continue;
          if (g[j][k] != (i >> k & 1)) ok = false;
        }
      }
    }
    if (ok) ans = max(ans, (int)bitset<32>(i).count());
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    int i,x;
    cin >> i;
    for(int j = 1;j < i + 1;j++){
        x = j;
        if(j % 3 == 0){
            cout << " " << j;
        
        }
        else {while(x != 0){
            
            if(x%10 == 3){
                
                cout << " " << j;
                break;
            }
            x/=10;
        }
        }
        
    }
    cout << endl;
}


Measured memory_bytes: 3084
#include<cstdio>
#include<vector>
using namespace std;

const int A = 1e9 + 7;
int n;
char s[2][53];
vector<bool> v;

int main() {
    scanf("%d", &n);
    scanf("%s", s[0]);
    scanf("%s", s[1]);
    for (int i = 0; i < n; i++) {
        if (s[0][i] != s[1][i]) {
            v.push_back(true);
            i++;
        }
        else v.push_back(false);
    }
    
    int ans;
    if (v.front()) ans = 6;
    else ans = 3;
    for (int i = 1, s = v.size(); i < s; i++) {
        if (!v[i - 1]) ans = static_cast<long>(ans) * 2 % A;
        else if (v[i]) ans = static_cast<long>(ans) * 3 % A;
    }

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



Measured memory_bytes: 256