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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 999'999'999
#define MAX_DIGIT 9
#define N_BIT 4
i64 dp[MAX_DIGIT + 1][2][2][1 << N_BIT]; // [決定した桁数][未満フラグ][0しかでてないか][735フラグ]

int main() {
    string N; cin >> N;
    i64 L = N.length();

    REP(i, 2) REP(j, 2) REP(k, 1 << N_BIT) {
        dp[0][i][j][k] = 0;
    }
    dp[0][0][1][0] = 1;

    auto flag = [&](i64 d) {
        if      (d == 7) return (1 << 3);
        else if (d == 5) return (1 << 2);
        else if (d == 3) return (1 << 1);
        else             return (1 << 0);
    };

    REP(l, L) {
        i64 D = N[l] - '0';
        REP(smaller, 2) {
            REP(only_zero, 2) {
                REP(bit, 1 << N_BIT) {
                    for (i64 d = 0; d < (smaller ? 10 : D + 1); d++) {
                        if (only_zero && d == 0) {
                            dp[l + 1][smaller || d < D][1][bit] += dp[l][smaller][only_zero][bit];
                        } else {
                            dp[l + 1][smaller || d < D][0][bit | flag(d)] += dp[l][smaller][only_zero][bit];
                        }
                    }
                }
            }
        }
    }

    cout << dp[L][0][0][14] + dp[L][1][0][14] << endl;

    return 0;
}

Measured memory_bytes: 256
<?php                          
fscanf(STDIN, "%s %s", $S, $T);
fscanf(STDIN, "%d %d", $a, $b);
fscanf(STDIN, "%s", $U);       
                               
                               
if ($S == $U)$a--;             
if ($T == $U)$b--;             
                               
echo "$a $b";                  
?>                             

Measured memory_bytes: 3828
// #define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int64 n, x, m;
  cin >> n >> x >> m;
  vector<int> visit(m, -1);
  vector<int> a;
  int offset, len = 0;
  for (int i = 0; i < n; ++i) {
    if (visit[x] >= 0) {
      int j = visit[x];
      len = i - j;
      offset = j;
      break;
    }
    a.push_back(x);
    visit[x] = i;
    x = x * x % m;
  }
  trace(a);
  trace(offset, len);
  int64 ret = 0;
  if (len == 0) {
    for (auto& x : a) ret += x;
  } else {
    for (int i = 0; i < offset; ++i) ret += a[i];
    n -= offset;
    int64 q = n / len, r = n % len;
    int64 sum = 0;
    for (int i = 0; i < len; ++i) sum += a[offset + i];
    int64 rsum = 0;
    for (int i = 0; i < r; ++i) rsum += a[offset + i];
    ret += sum * q + rsum;
  }
  cout << ret << '\n';
  return 0;
}


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


int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n,m,x;
  cin>>n>>m>>x;
  int c=0;
  int d=0;
  int a[105];
  for(int i=0;i<m;i++){

    cin>>a[i];
  if(a[i]>x){
    c++;
  }else{
    d++;
  }

}

  if(c>=d){
    cout<<d;
  }else{
    cout<<c;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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 rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    ll money=0;
    ll mini=INF;
    mini=min(A+B,2*C);
    if(X<Y){
        money+=X*mini;
        if(B>2*C){
            money+=2*C*(Y-X);
            cout << money << endl;
            return 0;
        }
        else{
            money+=B*(Y-X);
            cout << money << endl;
            return 0;
        }
    }
    else if(Y<X){
        money+=mini*Y;
        if(A>2*C){
            money+=2*C*(X-Y);
            cout << money << endl;
            return 0;
        }
        else{
            money+=A*(X-Y);
            cout << money << endl;
            return 0;
        }
    }
    else{
        money+=mini*X;
        cout << money << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999LL
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>


LL N, K, ans = 1;

int main() {
	cin >> N >> K;
	cout << N - K + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int maxn = 2e6 + 10;
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const ull base = 131;
const ull mod1 = 1e9 + 9;
const ull mod2 = 1610612741;

inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}


int n;
int a[maxn];

int main()
{
    scanf("%d", &n);
    n *= 2;
    for (int i = 1; i <= n; ++i)
        scanf("%d", a+i);
    sort(a+1, a+n+1);
    int sum = 0;
    for (int i = 1; i <= n; i+=2)
        sum += a[i];
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

    vector<int> x;
    for(int i=0; i < 3; i++) {
        int tmp;
        cin >> tmp;
        x.push_back(tmp);
    }
    sort(x.begin(), x.end());
    int ans = x.at(0) + x.at(1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HossamDoma
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {


            int n = in.nextInt();
            int m = in.nextInt();

            long ans = 0;
            int mod = ((int) 1e9) + 7;

            if (Math.abs(n - m) > 1) {
                ans = 0;
                out.println(ans);
                return;
            }


            ans = n;

            int tmp = n - 1;
            int tmp2 = m;

            for (int i = 1; i < (n + m); ++i) {

                if (i % 2 == 1)
                    ans = (ans * tmp2--) % mod;

                else
                    ans = (ans * tmp--) % mod;
            }

            tmp = n;
            tmp2 = m - 1;

            long ans2 = m;

            for (int i = 1; i < (n + m); ++i) {

                if (i % 2 == 1)
                    ans2 = (ans2 * tmp--) % mod;

                else
                    ans2 = (ans2 * tmp2--) % mod;
            }


            out.println((ans + ans2) % mod);


        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

constexpr int INF = 1e8;
constexpr int MOD = 1e9+7;

int a[10][10000];
int cnt[10000];
int r, c;

int dfs(int x) {
    int i;
    if (x == r) {
        int ret = 0;
        REP (i,c) ret += max(cnt[i],r-cnt[i]);
        return ret;
    }
    int ret = 0;
    REP (i,c) if (a[x][i]) cnt[i]++;
    ret = max(ret,dfs(x+1));
    REP (i,c) {
        if (a[x][i]) cnt[i]--;
        else cnt[i]++;
    }
    ret = max(ret,dfs(x+1));
    REP (i,c) if (!a[x][i]) cnt[i]--;
    return ret;
}

int main(void) {
    int i, j;
    while (true) {
        scanf("%d%d",&r,&c);
        if (r == 0 && c == 0) break;
        REP (i,r) REP (j,c) scanf("%d",&a[i][j]);

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

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

int main(){
  int N,l,max;
  cin >> N;
  max = 0;
  long S = 0;
  for(int i=0; i<N; i++){
    cin >> l;
    if(max>l){
      S +=(max-l);
    }
    else{
      max = l;
    }
  }
  cout << S <<endl;
}

Measured memory_bytes: 3564
#include<iostream>
using namespace std;
int search(int,int);
bool down=false;
int max=0;int n;
int a[3][101]={0};
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[1][i];
	for(int i=1;i<=n;i++)cin>>a[2][i];
	cout<<search(1,1);
	return 0;
}
int search(int x,int y)
{
	if(y==n)
	{
		if(x==2)return a[2][n];
		else return a[1][n]+a[2][n];
	}
	else
	{
		if(not down)
		{
			int j=a[x][y]+search(x,y+1);
			down=true;
			int k=a[x][y]+search(x+1,y);
			down=false;
			if(j>k) return j;
			else return k;
		}
		else return a[x][y]+search(x,y+1);
	}
}

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

int main(){ 

	int n,r,i,j,p,k,c,a=0; 

	int data[1000],buff[1000],answer[1000]; 

	while(1){ 

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


		if( (n==0) && (r==0) ) break; 

		for(i=n;i>0;i--){ 
		data[n-i]=i;	
		} 

		for(j=0;j<r;j++){ 

 
 		scanf("%d",&p);
 		scanf("%d",&c);
 

		p--; 
		c=p+c-1;


			for(i=p,k=0;i<=c;i++,k++){ 
			buff[k] = data[i]; 
			} 


		i = 0; 
			while(i < p){ 
			buff[k] = data[i]; 
			k++; 
			i++; 
			} 


		i=c+1; 
			while(i < n){ 
buff[k] = data[i]; 
k++;	
i++; 
} 


for(i=0;i<n;i++){ 
data[i] = buff[i]; 
} 
} 

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




return 0; 
}



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

struct ST{
    int x,y;
};


void solve(){
    int h,w;
    cin >> h >> w;

    vector<vector<char> > ch(h , vector<char>(w));

    int black = 0;

    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            cin >> ch[i][j];
            black += (ch[i][j] == '#');
        }
    }

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

    queue<ST> q;

    const int II = 1000000000;

    vector<vector<int> > dist(h , vector<int>(w , II));

    bool ans = false;

    vector<vector<int> > count(h,vector<int>(w,0));

    q.push(ST{0,0});

    dist[0][0] = 1;
    count[0][0] = 1;

    while(!q.empty()){
        int vx = q.front().x;
        int vy = q.front().y;

        q.pop();

        for(int i = 0; i < 4; ++i){
            int nx = vx + dx[i];
            int ny = vy + dy[i];

            if(nx == w - 1 && ny == h - 1){
                ans = true;
            }

            if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;

            if(ch[ny][nx] == '#') continue;

            if(count[ny][nx] < 5){
                dist[ny][nx] = min(dist[vy][vx] + 1,dist[ny][nx]);
                q.push(ST{nx,ny});
                count[ny][nx]++;
            }

        }
    }

    if(ans){
        //cout << dist[h - 1][w - 1] << endl;
        cout << h * w - dist[h - 1][w - 1] - black << endl;
    }else{
        cout << -1 << endl;
    }



    return ;
}

int main(){
    solve();

    return 0;
}

Measured memory_bytes: 256
//--- pB ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	private void run_case() {
		int n = reader.ni();
		int k = reader.ni();
		Set<Integer> vis = new HashSet<>();
		for (int i=0; i<k; i++) {
			int d = reader.ni();
			for (; d-->0;) {
				vis.add(reader.ni());
			}
		}
		int ans = 0;
		for (int i=1; i<=n; i++) {
			if (!vis.contains(i)) ans ++;
		}
		out.println(ans);
		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 34452
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<50
#define fst first
#define sec second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  int a,b,h;
  cin >>a >> b >> h;
  
  cout << (a+b)*h/2 << endl;

  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
X = sorted([int(a) for a in input().split()])
Y = []
for i in range(M-1):
    Y.append(X[i+1]-X[i])

Y = sorted(Y)
if N >= M:
    print(0)
else:
    print(sum(Y[:M-N]))

Measured memory_bytes: 13840
def sub(maxs, mins):
    for i in range(len(maxs)):
        if maxs[i] != mins[i]:
            if i == len(maxs)-1:
                return int(maxs[i]) - int(mins[i])
            if i == len(maxs)-2:
                return int(maxs[i:i+2]) - int(mins[i:i+2])
            return 10
    return 0

def checkEqual(S):
    ans = 8
    for k in range(1, len(S)):
        if len(S)%k != 0: continue
        mins = maxs = S[0:k]
        for s in range(0, len(S), k):
            maxs = max(maxs, S[s:s+k])
            mins = min(mins, S[s:s+k])
        ans = min(ans, sub(maxs, mins))

    return ans

def check12(S):
    maxv = 0
    minv = 10
    p = 0
    while p < len(S):
        v = int(S[p])
        if  S[p] == '1' and p+1 < len(S):
            v = 10 + int(S[p+1])
            p += 1
        maxv = max(maxv, v)
        minv = min(minv, v)
        p += 1
    return maxv - minv

S = input()
print(min(checkEqual(S), check12(S)))
                                                                                                                        


Measured memory_bytes: 5856
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;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 x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int X = read(), A = read();
    printf("%d\n", X < A ? 0 : 10);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
#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 k;
  cin >> k;
  vector<ll> a;
  for (int i = 1; i <= 9; ++i) a.push_back(i);
  while (1) {
    if (k <= a.size()) {
      cout << a[k-1] << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(old, a);
    for (ll x : old) {
      for (int i = -1; i <= 1; ++i) {
        int d = x%10 + i;
        if (d < 0 || d > 9) continue;
        ll nx = x*10 + d;
        a.push_back(nx);
      }
    }
  }
  return 0;
}

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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'

int dp[(int)1e5 + 5][4];

vector<int> adj[(int)1e5 + 7];

int mod(int n) {
    return n % ((int)1e9 + 7);
}

int f(int u, int p, int pp) {

    int &ret = dp[u][p];
    if(ret != -1)
        return ret;


    ret = 1;
    for(int v: adj[u]) {
        if(v == pp)
            continue;
        ret *= f(v, 0, u);
        ret = mod(ret);
    }

    int black = (p == 0);
    for(int v: adj[u]) {
        if(v == pp)
            continue;
        black *= f(v, 1, u);
        black = mod(black);
    }


    ret += black;
    ret = mod(ret);

    return ret;
}

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

  memset(dp, -1, sizeof dp);

  int n;

  cin >> n;

  for(int i = 1; i < n; i++) {
    int u, v;

    cin >> u >> v;

    adj[u].pb(v);
    adj[v].pb(u);
  }

  cout << f(1, 0, -1) << endl;

}

Measured memory_bytes: 15872
//AC済 バチャ用再提出
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n;
    long long a[200100];
    long long start = 1;
    long long end = 1;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    long long sum = a[1];
    long long checker = a[1];
    long long ans = 1;
    while(end < n){
        end++;
        sum += a[end];
        checker = checker xor a[end];
        while(checker != sum){
            sum -= a[start];
            checker = checker xor a[start];
            start++;
        }
        ans += (end - start + 1);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int n,a,now=0;
    cin>>n>>a;
    now=n%500;
    if(a>=now){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i <= n; i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

using namespace std;

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

/////////////////////////////////////////////////

string S;
int N;

void input()
{
    cin >> N >> S;
}

void solve()
{
    rep(i, S.length())
    {
        if(S[i] + N <= 'Z')
            S[i] += N;
        else
            S[i] += N - 'Z' + 'A' -1;
    }
    cout << S << endl;
}

/////////////////////////////////////////////////

int main()
{
    input();
    solve();
    return 0;
}

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

const int N = 3010;

double a[N];
double f[N][N];

int main() {
	int n; cin >> n;
	for(int i = 1 ; i <= n ; i++) {
		cin >> a[i];
	}
	f[0][0] = 1;
	for(int i = 1 ; i <= n ; i++) {
		for(int j = 0 ; j <= i ; j++) {

			f[i][j] = (f[i - 1][j] * (1 - a[i])) + ((j > 0 ? f[i - 1][j - 1] : 0) * a[i]);
		}
	}
	double ans = 0;
	for(int i = n / 2 + 1 ; i <= n ; i++) {
		ans += f[n][i];
	}
	printf("%.10lf", ans);
}


Measured memory_bytes: 69120
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

days = {"SUN":7,"MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}
def main():
    s = input()
    print(days[s])


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n, x = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')] + [0]

c = 0
for i in range(1, len(a)):
    if a[i-1] + a[i] > x:
        tmp = a[i]
        a[i] = x - a[i-1]
        c += tmp - a[i]

for i in range(1, len(a))[::-1]:
    if a[i-1] + a[i] > x:
        tmp = a[i]
        a[i] = x - a[i-1]
        c += tmp - a[i]

print(c)

Measured memory_bytes: 14544
lis = list(map(int,input().split()))

max_num = str(max(lis))
lis.pop(lis.index(int(max_num)))

if lis[0] > lis[1]:
    result = int(max_num + str(lis[0])) + lis[1]
else:
    result = int(max_num + str(lis[1])) + lis[0]

print(result)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>

#define u unsigned
#define s short
#define ll long long
#define REP(i, a, b) for (auto i = (a); i < (b); i++)
#define REPR(i, a, b) for (auto i = (a-1); i >= (b); i--)

using namespace std;

int main()
{
    int H, W, K; cin >> H >> W >> K;
    vector<string> c;

    REP(i, 0, H)
    {
        string temp; cin >> temp;
        c.push_back(temp);
    }

    // REP(i, 0, H)
    //     cout << c[i] << "\n";

    int result = 0;

    for (int maskR = 0; maskR < (1 << H); maskR++)
    {
        for (int maskC = 0; maskC < (1 << W); maskC++)
        {
            int black = 0;

            for (int i = 0; i < H; i++)
                for (int j = 0; j < W; j ++)
                    if ((((maskR >> i) & 1) == 0) and (((maskC >> j) & 1) == 0) and (c[i][j] == '#'))
                        black++;

            if (black == K)
                result++;
        }
    }

    cout << result << "\n";
}

Measured memory_bytes: 3576
#include<iostream>
#include<utility>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
int main(){
    int n;cin>>n;
    vector<P> v;
    int x,y;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        v.push_back(P(x,y));
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        cout<<v[i].first<<' '<<v[i].second<<endl;
    }
    return 0;
}


Measured memory_bytes: 3880
/// IN THE NAME OF METAL
#include <bits/stdc++.h>

using namespace std;

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

#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second

ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
ll W, Z, n, A[MAXN];

int main() {
    scanf("%lld%lld%lld", &n, &Z, &W);
    for (ll i = 1; i <= n; i++) scanf("%lld", &A[i]);
    if (n == 1) return !printf("%lld\n", abs(A[n] - W));
    printf("%lld\n", max(abs(A[n] - A[n - 1]), abs(W - A[n])));    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iostream>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;

//typedef long long int i64; // 9e18
typedef long long int i64; // 9e18

typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

//const double PI = 3.141592653589793238463;
//const int MAXN = 1000500;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;
const i64 INF = 1e18;
i64 mod = 1e9 + 7;


i64 T, n, m, k;
//vector <vector<i64>> a;
//vector <i64> b;
//vector <i64> dp;

vector <vector<i64>> dp;


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

    //cin >> T;
    T = 1;

    for (i64 tt = 0; tt < T; ++tt) {

        cin >> n;

        if (n == 1) {
            cout << 0 << endl;
        }
        else {
            cout << 1 << endl;
        }



    }
    return 0;
}

Measured memory_bytes: 3152
import sys

def input():
    return sys.stdin.readline()[:-1]

N = int(input())

alphabet = "zabcdefghijklmnopqrstuvwxy"
#alpha = [chr(ord('a') + i) for i in range(26)]

name = ""

for i in range(10000):
    if N <= 26:
        q = N // 26
        mod = N % 26
        if mod == 0:
            q -= 1
        name = alphabet[mod] + name
        break
    else:
        q = N // 26
        mod = N % 26
        if mod == 0:
            q -= 1
        name = alphabet[mod] + name
        N = q


    #print(q, mod)


print(name)


Measured memory_bytes: 61928
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t / 2;
    } else {
        return modpow(m, n - 1) * m;
    }
}

int main() {
    long long n, min = 1e6, b = 0, ans = 1;
    cin >> n;
    vector<int>as(n);
    for (int i = 0; i < n; i++){
        cin >> as[i];
    }
    min = as[0];
    for (int i = 1; i < n; i++){
        if (as[i] < min){
            ans++;
            min = as[i];
        }
    }
    cout << ans << endl;
}

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

int main() {
  string s;
  cin >> s;
  int hazime = 0, owari = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      hazime = i;
      break;
    }
  }
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == 'Z') {
      owari = i;
      break;
    }
  }
  cout << owari - hazime + 1;
}

Measured memory_bytes: 3720
#include<iostream>
using namespace std;
int main()
{
	int N, M;
	cin >> N >> M;
	if ((N >= 1 && N <= 100) && (M >= 0 && M <= N))
	{
		if (M==N)
			cout <<"Yes"<< endl;
		else
			cout <<"No"<< endl;
	}
	else
		cout << "Wrong inputs" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9012337203685477580
using ll = long long;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    ll ans = LLINF;
    cin >> N >> K;
    vector<int> x(N),y(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i];
    }
    for (int x1 = 0; x1 < N; x1++)
    {
        for (int x2 = 0; x2 < N; x2++)
        {
            if (x[x1] < x[x2]) {
                for (int y1 = 0; y1 < N; y1++)
                {
                    for (int y2 = 0; y2 < N; y2++)
                    {
                        if (y[y1] < y[y2]) {
                            int cnt = 0;
                            for (int k = 0; k < N; k++)
                            {
                                if (x[x1] <= x[k] && x[k] <= x[x2] &&
                                    y[y1] <= y[k] && y[k] <= y[y2]) {
                                    cnt++;
                                }
                            }
                            if (K <= cnt) {
                                ans = min(ans, (ll)(x[x2] - x[x1])*(y[y2] - y[y1]));
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i);
h_arr = gets.chomp.split(" ").map(&:to_i);
good_arr = []
1.step(n, 1) do |i|
  good_arr[i] = true
end
1.step(m, 1) do |i|
  a, b = gets.chomp.split(" ").map(&:to_i);
  if h_arr[a - 1] < h_arr[b - 1]
    good_arr[a] = false
  elsif h_arr[a - 1] > h_arr[b - 1]
    good_arr[b] = false
  else
    good_arr[a] = false
    good_arr[b] = false
  end
end

puts good_arr.select{|e| e == true}.count


Measured memory_bytes: 23508
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define int ll
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

// 辺を表す構造体 {行先、容量、逆辺}
struct edge { int to; ll cap; int rev; };
#define V 1010
vector< vector<edge> > G(V, vector<edge>()); //グラフの隣接リスト表現
vl level(V); //sからの距離
vi iter(V); //どこまで調べ終わったか

			//fromからtoへ向かう容量capの辺をグラフに追加する
void add_edge(int from, int to, ll cap) {
	edge a;
	a.to = to; a.cap = cap; a.rev = G[to].size();
	G[from].push_back(a);
	a.to = from; a.cap = 0; a.rev = G[from].size() - 1;
	G[to].push_back(a);
}

//sからの最短距離をBFSで計算する
void bfs(int s) {
	fill(level.begin(), level.end(), -1);
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while (!que.empty()) {
		int v = que.front(); que.pop();
		for (int i = 0; i < G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

//増加パスをDFSで探す
ll dfs(int v, int t, ll f) {
	if (v == t) return f;
	for (int &i = iter[v]; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (e.cap > 0 && level[v] < level[e.to]) {
			ll d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

//sからtへの最大流を調べる
ll max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		bfs(s);
		if (level[t] < 0) return flow;
		fill(iter.begin(), iter.end(), 0);
		int f;
		while ((f = dfs(s, t, inf)) > 0) {
			flow += f;
		}
	}
}

signed main() {
	int n, i, j;
	cin >> n;
	vl a(n);
	ll sum = 0;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		sum += max(a[i], 0LL);
	}
	for (i = 1; i <= n; i++) {
		for (j = 2; i*j <= n; j++) {
			add_edge(i, i*j, INF);
		}
	}
	for (i = 0; i < n; i++) {
		if (a[i] < 0) {
			add_edge(0, i + 1, -a[i]);
		}
		else {
			add_edge(i + 1, n + 1, a[i]);
		}
	}
	cout << sum - max_flow(0, n + 1) << endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n,l,ans=1e9; cin>>n>>l;
	int S[n], sum=0;
	for(int i=0; i<n; i++){
		S[i] = l+i+1-1;
		sum+=S[i];
	}
	for(int i=0; i<n; i++){
		int x = abs(sum - (sum-S[i]));
		ans = min(ans, x);
	}
	if(sum>=0)cout<<sum-ans<<endl;
	else cout<<sum+ans<<endl;
}


Measured memory_bytes: 3636
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy
from functools import reduce

def main():

    n = int(input())
    lists = list(map(int, input().split()))
    lists.sort(reverse=True)
    ans = 0
    count = n-1
    for i in range(n):
        if i == 0:
            ans += lists[i]
            count -= 1
        else:
            for j in range(2):
                if count > 0:
                    ans += lists[i]
                    count -= 1
        

    print(ans)

        

if __name__ == "__main__":
    main()

Measured memory_bytes: 32128
#include <iostream>
#include <vector>

int main(){
  int a,b,n;
  while(std::cin >> a >> b){
    if(a == 0 && b == 0){ break; }
    std::cin >> n;
    std::vector<std::vector<int> > road(a,std::vector<int>(b, 1));
        
    for(int i = 0; i < n; ++i){
      int x,y;
      std::cin >> x >> y;
      //工事中を0で表す
      road[x-1][y-1] = 0;
    }
    
    for(int i = 0; i < a; ++i){
      for(int j = 0; j < b; ++j){
        //工事中と開始点を除く
        if(road[i][j] != 0 && !(i == 0 && j == 0)){
          if(i == 0){
            //前の点が工事中
            if(road[i][j-1] == 0)
              road[i][j] = 0;
            else
              road[i][j] = road[i][j-1];
          }
          else if(j == 0){
            //前の点が工事中
            if(road[i-1][j] == 0)
              road[i][j] = 0;
            else
              road[i][j] = road[i-1][j];
          }
          else{
            road[i][j] = road[i-1][j] + road[i][j-1];
          }          
        }
      }      
    }
    std::cout << road[a-1][b-1] << std::endl;
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> card(n);
  vector<ll> rui(n);
  for(int i=0; i<n; ++i){
    cin >> card[i];
    if(i) rui[i] = rui[i-1] + card[i];
    else rui[0] = card[0];
  }
  ll ans = abs(rui[n-1] - rui[0]*2);
  for(int i=1; i<n-1; ++i){
    ans = min(ans, abs(rui[n-1] - rui[i]*2));
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int h1,h2,m1,m2,result,k;
    cin>>h1>>m1>>h2>>m2>>k;
    result=max(0ll,h2*60+m2-(h1*60+m1)-k);
    cout<<result;
    return 0;
}


Measured memory_bytes: 3648
// clang-format off
#include <bits/stdc++.h>

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b)-1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep(i, n) for(int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T>& p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T>& vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
constexpr ll MOD = 1000000007;

constexpr int MAX = 100000;
bool checked[MAX];
vector<pii> edge[MAX];
deque<int> path;
void bfs(int s)
{
    checked[s] = true;
    path.pb(s+1);
    for(const auto& e: edge[s]){
        const int to = e.fst;
        if(not checked[to]){
            bfs(to);
            break;
        }
    }
}

void rbfs(int s)
{
    checked[s] = true;
    for(const auto& e: edge[s]){
        const int to = e.fst;
        if(not checked[to]){
            path.push_front(to+1);
            rbfs(to);
            break;
        }
    }
}

int main()
{
    int N, M;
    cin >> N >> M;
    rep(i, M){
        int A, B;
        cin >> A >> B;
        A--,B--;
        edge[A].pb(mp(B, i+1));
        edge[B].pb(mp(A, i+1));
    }

    int mini = M+1;
    int mini_v = 0;
    rep(i, N){
        if(edge[i].size() < mini){
            mini = edge[i].size();
            mini_v = i;
        }
    }
    bfs(mini_v);
    rbfs(mini_v);
    cout << path.size() << endl;
    rep(i, path.size()){
        if(i > 0){
            cout << " ";
        }
        cout << path[i];
        
    }
    cout << endl;
    return 0;
}


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

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

ll f(ll n) {
  return n*(n+1)/2;
}

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
      ll r = n/i;
      ans += f(r)*i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl


int main(){
	li n;
	cin>>n;
		string ss;
		getline(cin,ss);
	rin{
		string s;
		getline(cin,s);
		rep(j,sz(s)-6){
			if(s.substr(j,7)=="Hoshino"){
				s[j+6]='a';
				j+=5;
			}
		}
		cout<<s<<endl;
	}

	return 0;
}

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

int main()
{
	long long n;
	cin >> n;
	long long arr[n+1];

	for(int i = 1; i <= n; i++){
		cin >> arr[i];
	}

	for(int i = 1; i <= n; i++){
		if(arr[i] != i){
			swap(arr[i], arr[arr[i]]);
			break;
		}
	}

	for(int i = 1; i <= n; i++){
		if(arr[i] != i){
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int N = 100005 ;
using namespace std ;

int n, m, a[N], b[N] ;

bool cmp(int x, int y) {
	return (x & 1) > (y & 1) ;
}

int main() {
	scanf("%d%d", &n, &m) ;
	rep(i, 1, m) {
		scanf("%d", &a[i]) ;
	}
	sort(a + 1, a + m + 1, cmp) ;
	if (m > 2 && (a[3] & 1)) {
		printf("Impossible\n") ;
		return 0 ;
	}
	if (m == 1) {
		rep(i, 1, m) printf("%d ", a[i]) ;
		if (n == 1) printf("\n%d\n%d\n", 1, 1) ; else
			printf("\n%d\n%d %d\n", 2, 1, n - 1) ;
		return 0 ;
	}
	if (m > 1) swap(a[2], a[m]) ;
	rep(i, 1, m) printf("%d ", a[i]) ;
	rep(i, 1, m) b[i] = a[i] ;
	-- b[1], ++ b[m] ;
	if (!b[1]) {
		rep(i, 1, m - 1) b[i] = b[i + 1] ;
		-- m ;
	}
	printf("\n%d\n", m) ;
	rep(i, 1, m) printf("%d ", b[i]) ;
	return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,W,w,v,ans;
map<int,int>wv;
int main(){
 scanf("%d%d",&n,&W);
 wv[0]=0;
 while(n--){
  scanf("%d%d",&w,&v);
  for(auto it=--wv.end();;--it){
   if(it->first+w<=W)wv[it->first+w]=max(wv[it->first+w],it->second+v);
   if(it==wv.begin())break;
  }
 }
 for(auto&x:wv)ans=max(ans,x.second);
 printf("%d\n",ans);
}


Measured memory_bytes: 384