akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl A;
  cout << SP(20) << (ceil)((long double)N / 2) / N << endl;
  ;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    string s;
    cin >> s;
    if((int)s.find("a")==-1 || (int)s.find("b")==-1 || (int)s.find("c")==-1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }


    return 0;
}


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

int main() {
    int n, x;
    cin >> n >> x;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a+n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int p = a[i];
        if (x < p) {
            cout << ans << endl;
            return 0;
        }
        ans += 1;
        x -= p;
    }
    if (x > 0)
        ans--;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>


class BigInt
{
	public:
	int c;
	int a[100];
	BigInt()
	{
		c=1;
		memset(a,0,sizeof(a));
	}
	BigInt(int x)
	{
		if(!x)
		{
			c=1;
			memset(a,0,sizeof(a));
			return;
		}
		c=0;
		memset(a,0,sizeof(a));
		while(x!=0)
		{
			a[c++]=x%10000;
			x/=10000;
		}
	}
	BigInt operator+(const BigInt &b)const
	{
		BigInt result;
		result.c=max(c,b.c);
		for(int i=0;i<result.c;i++)
		{
			result.a[i]+=a[i]+b.a[i];
			result.a[i+1]=result.a[i]/10000;
			result.a[i]%=10000;
		}
		if(result.a[result.c]>0)
		{
			result.c++;
		}
		return result;
	}
	BigInt operator*(const BigInt &b)const
	{
		BigInt result;
		result.c=c+b.c;
		for(int i=0;i<c;i++)
		for(int j=0;j<b.c;j++)
		{
			result.a[i+j]+=a[i]*b.a[j];
		}
		int d=0;
		for(int i=0;i<result.c;i++)
		{
			result.a[i]+=d;
			d=result.a[i]/10000;
			result.a[i]%=10000;
		}
		if(d)result.a[result.c++]=d;
		while(result.a[result.c-1]==0)result.c--;
		return result;
	}
	BigInt operator-(const BigInt &b)const
	{
		BigInt result;
		result.c=max(c,b.c);
		for(int i=0;i<result.c;i++)
		{
			result.a[i]+=a[i]-b.a[i];
			if(result.a[i]<0)result.a[i+1]--,result.a[i]+=10000;
		}
		while(result.a[result.c-1]==0)result.c--;
		return result;
	}
	void print()const
	{
		printf("%d",a[c-1]);
		for(int i=c-2;i>=0;i--)
		{
			printf("%04d",a[i]);
		}
	}
};

const int maxn=200005;
int n,k,cnt;
ll ans;
int a[maxn],b[maxn];
ll tree[maxn];
pair<ll,int> s[maxn];

void add(int pos,int val){
	while(pos<=cnt){
		tree[pos]+=(ll)val;
		pos+=(pos&-pos);
	}
}

ll sum(int pos){
	ll res=0;
	while(pos>0){
		res+=tree[pos];
		pos-=(pos&-pos); 
	}
	return res;
}

int main(){
	scanf("%d%d",&n,&k);
	rep(i,n)scanf("%d",&a[i]),a[i]-=k;
	rep(i,n){
		if(!i)s[i].fi=(ll)a[i];
		else s[i].fi=s[i-1].fi+(ll)a[i];
		s[i].se=i;
		if(s[i].fi<0)ans--;
	}
	sort(s,s+n);
	rep(i,n){
		if(!i||s[i].fi!=s[i-1].fi)b[s[i].se]=++cnt;
		else b[s[i].se]=cnt;
	}
	rep(i,n){
		add(b[i],1);
		ans+=sum(b[i]);
	}
	printf("%lld",ans);
	return 0;
}

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

ll gcd(ll a, ll b){
    while(b > 0){
        a %= b;
        swap(a, b);
    }
    return a;
}

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a / g * b;
}

int main(){
    ll a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    ll l = lcm(c, d);
    ll n1 = b / c + b / d - b / l;
    ll n2 = (a - 1) / c + (a - 1) / d - (a - 1) / l;
    printf("%lld\n", b - a + 1 - (n1 - n2));
}

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

char num[200001];

inline int comp(char me , char you){
    if(me == you)
        return 0;
    else
        return me > you ? 1 : -1;
}

int main(){
    scanf("%s" , num);
    int l = strlen(num) , ans = 0;
    for(int i = 0 ; i < l ; i++)
        ans += comp(i & 1 ? 'p' : 'g' , num[i]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <functional>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(std::min<int>(l_, r_)), r(r_) {}
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): r(std::max<int>(l_, r_) - 1), l(l_ - 1) {}
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (int &x: A) {
    std::cin >> x;
  }
  std::sort(A.begin(), A.end());
  for (int i: range(0, A.size() - 1)) {
    if (A[i] == A[i + 1]) {
      std::cout << "NO\n";
      return 0;
    }
  }
  std::cout << "YES\n";
  return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            boolean[][] island = new boolean[12][12];
            int[][] map = new int[12][12];
            for (int i = 0; i < 12; i++) {
                Arrays.fill(map[i], 999);
                String str = sc.next();
                for (int j = 0; j < 12; j++) {
                    island[i][j] = str.toCharArray()[j] == '1';
                }
            }
            int count = 0;
            for (int i = 0; i < 12; i++) {
                for (int j = 0; j < 12; j++) {
                    if (island[i][j]) {
                        if (i - 1 >= 0 && island[i - 1][j]) {
                            map[i][j] = Math.min(map[i][j], map[i - 1][j]);
                        } else if (j - 1 >= 0 && island[i][j - 1]) {
                            map[i][j] = Math.min(map[i][j], map[i][j - 1]);
                        } else if (j + 1 < 12 && island[i][j + 1]) {
                            for (int k = j; k < 11; k++) {
                                if (i - 1 >= 0 && island[i][k] && island[i][k + 1] && island[i - 1][k + 1]) {
                                    map[i][j] = map[i - 1][k + 1];
                                    count--;
                                    break;
                                }
                            }
                            map[i][j] = count++;
                        } else {
                            map[i][j] = count++;
                        }
                    }
                }
            }
            System.out.println(count);
//                        for(int i=0;i<12;i++) {
//                            for(int j=0;j<12;j++) {
//                                System.out.print(map[i][j]!=999?map[i][j]:" ");
//                            }
//                            System.out.println();
//                        }
        }
    }
}



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

#define M 1000005
#define MOD 1000000007
#define PI 3.14159265358979323846
#define ep emplace_back
#define mk make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> PII;
typedef pair<lli,lli> PLL;

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

	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
		
	int a,b,h,m;
	cin>>a>>b>>h>>m;

	double h_angle = (h*60+m)*(0.5);
	double m_angle = (m*6)%360;
	double diff_angle = abs(h_angle-m_angle);
	double side = (a*a) + (b*b) - (2*a*b*cos(diff_angle * PI/180));
	double ans = (double)sqrt(side);

	cout<<fixed<<setprecision(20)<<ans<<"\n";	
}

Measured memory_bytes: 4160
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

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

const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;

template<class T> bool ckmin(T& a, const T& b) {
    return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template <typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template <typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template <class X, class Y>
std::ostream & operator << (std::ostream & os, std::pair <X, Y> const& p) {
    return os << p.first << " " << p.second;
}

template <class Ch, class Tr, class Container>
std::basic_ostream <Ch, Tr> & operator << (std::basic_ostream <Ch, Tr>& os, Container const& x) {
    bool first = true;
    for(auto& y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BVaried {
public:
	void solve(std::istream& in, std::ostream& out) {
        string str;
        in >> str;
        set<char> S(all(str));
        bool res = sz(S) == sz(str);
        out << (res ? "yes" : "no") << '\n';
	}

	void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
	BVaried solver;
    solver.setup();
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3660
N, K = (int(i) for i in input().split())
ans = 0
if K == 0:
    ans = N ** 2
else:
    for i in range(K + 1, N + 1):
        a = i - K
        ans += a * (N // i)
        b = N % i - (K - 1)
        ans += max(0, b)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

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

static const double PI = 3.141592653589793;
double h, a, x;

double getMaxWater(double degree) {
    double d = PI / 180 * degree;
    double t = tan(d);
    double p1 = t * h;
    double s1 = h * p1 * 0.5;
    if (p1 > a) {
        double p3 = p1 - a;
        double p4 = p3 / t;
        double s2 = p3 * p4 * 0.5;
        s1 -= s2;
    }
    return s1 * a;
}

int main() {
    scanf("%lf %lf %lf", &a, &h, &x);
    double left = 0, right = 90;
    while (abs(right - left) > 0.00000001) {
        double mid = (left + right) / 2;
        double c = getMaxWater(mid);
        if (c > x) {
            right = mid;
        } else {
            left = mid;
        }
    }
    printf("%.9lf\n", 90.0 - left);
    return 0;
}



Measured memory_bytes: 384
// Abhishek Chaturvedi- abhishekchaturvedi10oct //

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define endl            "\n"
#define inf             2e18+1
#define ninf            -2e18+1
#define mod             1000000007
#define eps             1e-9
#define ff              first
#define ss              second
#define int             long long 
#define ld              long double
#define str             string 
#define pb              emplace_back
#define mp              make_pair
#define vi              vector<int>
#define si              set<int>
#define pii             pair<int,int>
#define psi             pair<str,int>
#define mii             map<int,int>
#define msi             map<str,int>
#define maxheap         priority_queue<int>
#define minheap         priority_queue<int,vi,greater<int>>
#define sz(x)           (int)x.size()
#define all(x)          x.begin(),x.end()
#define allr(x)         x.rbegin(),x.rend()
#define gcd(x,y)        __gcd(x, y)
#define arrsz(x)        sizeof(x)/sizeof(x[0])
#define sp(x,y)         fixed<<setprecision(y)<<x
#define tc(x)           int x; cin>>x; while(x--)
#define loopf(i,x,y)    for(int i=x;i<=y;i++)
#define loopb(i,x,y)    for(int i=x;i>=y;i--)
#define in(x,n)         int x[n];loopf(i,0,n-1) cin>>x[i];
#define out(x)          for(auto i:x) cout<<i<<" "; cout<<endl;
#define init(x,n,y)     int x[n];loopf(i,0,n-1) x[i]=y;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool isPowerOfTwo(int x){
   return x&&(!(x&(x-1)));
}

int takemod(int x){ 
    return (x%mod + mod) % mod; 
}

int lcm(int x,int y) {
    return (x/gcd(x,y)) * y;
}

int fpow(int base,int power,int MOD) {
    int result = 1;
    base=base%MOD;
    while(power){
        if(power&1) 
            result = (result*base) % MOD;
        base = (base*base) % MOD;
        power = power>>1;
    }
    return result;
}

int modinv(int x){return fpow(x,mod-2,mod);}

void fastIO(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

// void solve(){  
// }

// int dp[100005]; bool visited[100005]; vector<vector<int>> graph(100005);

// void dfs(int par){
//     if(!visited[par]){
//         visited[par]=true;
//         for(auto i:graph[par]){
//             dp[i]=max(dp[i],dp[par]+1);
//             dfs(i);
//         }
//     }
//     return;
// }

int32_t main(){
    
    fastIO();
    int n; cin>>n; vector<ld> dp(n+1); dp[0]=1; 
    loopf(toss,0,n-1){
        ld prob; cin>>prob;
        loopb(i,toss+1,0){
            if(i-1>-1) dp[i]=dp[i]*(1-prob)+dp[i-1]*prob;
            else dp[i]*=(1-prob);
        }
    }
    ld ans=0;
    loopf(j,n/2+1,n){
        ans+=dp[j];
    }
    cout<<sp(ans,10);
    //tc(t){();

     //   solve    //}

    return 0;
}

Measured memory_bytes: 384
from collections import deque
dxdy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
h, w = map(int, input().split())
s = [input() for _ in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        d = [[-1] * w for _ in range(h)]
        q = deque([(i, j)])
        d[i][j] = 0
        while q:
            y, x = q.popleft()
            for dx, dy in dxdy:
                if 0 <= x + dx < w and 0 <= y + dy < h and s[y + dy][x + dx] == '.' and d[y + dy][x + dx] == -1:
                    q.append((y + dy, x + dx))
                    d[y + dy][x + dx] = d[y][x] + 1
        for row in d:
            ans = max(ans, max(row))
print(ans)

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


int main() {

	string s;
	cin >> s;

	REP(i, s.size()) {
		cout << 'x';
	}
	cout << endl;

}

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

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

    int cnt1 = 0, cnt2 = 0, cnt3 =0;
    rep(i, n) {
        int p;
        cin >> p;
        if(p <= a) {
            cnt1++;
        }
        else if(p <= b) {
            cnt2++;
        }
        else {
            cnt3++;
        }
    }

    int ans = min({cnt1, cnt2, cnt3});

    cout << ans << endl;
    return 0;
}

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

// check if visited, pair< distance, sign >
// map<int, pair<int, int>> dist;
map<int, vector<pair<int, int>>> adj;

// void dfs(int s, int f = 0) {
// 	if (s != 1 && visited[s].second > 0)
// 		return;
// 	visited[s] = f;
// 	for (auto x : adj[s]) {
// 		if (x == f) continue;
// 		dfs(x, s);
// 	}
// }

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

	int n, m;
	cin >> n >> m;
	// vector<int> a(m), b(m);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back({b, 1});
		adj[b].push_back({a, 1});
	}

	// distance, from node
	vector<pair<int, int>> dist(n + 1, {INT_MAX, 0});

	priority_queue<
		pair<int, int>, 
		vector<pair<int, int>>, 
		greater<pair<int, int>>> pq;

	// distance, node
	pq.push({0, 1});
	dist[1] = {0, 0};

	while (!pq.empty()) {
		auto u = pq.top().second;
		pq.pop();

		for (auto it : adj[u]) {
			auto node = it.first;
			auto weight = it.second;

			// auto d = dist[node];
			if (dist[node].first > dist[u].first + weight) {
				dist[node] = {dist[u].first + weight, u};
				pq.push({dist[node].first, node});
			}
		}
	}


	bool ok = true;
	for (int i = 2; i <= n; i++) {
		if (dist[i].second == 0) ok = false;
	}

	cout << (ok ? "Yes\n" : "No\n");
	if (ok) {
		for (int i = 2; i <= n; i++)
			cout << dist[i].second << endl;
	}
}

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

using namespace std;
using LL = long long;

constexpr int MAXN = 2e5 + 5;

int n, to[MAXN], in[MAXN], step1[MAXN], step2[MAXN], vis[MAXN];
LL k, len1, len2;

void toposort() {
    queue<int> q;
    for (int i = 1; i <= n; i++)
        if (!in[i]) q.push(i);
    while (!q.empty()) {
        int cur = q.front();
        q.pop();
        if(!(--in[to[cur]])) q.push(to[cur]);
    }
}

void getLen(int cur) {
    //cout << cur << endl;
    if (vis[cur]) return;
    vis[cur] = 1;
    if (in[cur]) {
        step2[++len2] = to[cur], in[cur]--;
        getLen(to[cur]);
    }
    else step1[++len1] = to[cur], getLen(to[cur]);
}

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> to[i], in[to[i]]++;
    toposort(), getLen(1);
    if (k <= len1) cout << step1[k] << endl;
    else {
        k = (k - len1) % len2 ? (k - len1) % len2 : len2;
        cout << step2[k] << endl;
    }
    return 0;
}

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

using namespace std;

bool is_palindrome(string S) {
	return equal(S.begin(), S.begin() + S.length() / 2, S.rbegin());
}

string B(string& S) {
	int N = S.length();
	bool palindrome = is_palindrome(S);
	palindrome &= is_palindrome(string(S.begin(), S.begin() + (N - 1) / 2));
	palindrome &= is_palindrome(string(S.begin() + (N + 3) / 2 - 1, S.end()));
	return palindrome ? "Yes" : "No";
}

int main() {
	string S;
	cin >> S;
	cout << B(S);
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};
use std::collections::BTreeMap;

fn main() {
    let mut tree = BTreeMap::new();
    for &k in [1,-1].iter() {
        let n = read_i64();
        for _i in 0..n {
            let ss = read_line();
            if tree.contains_key(&ss) {
                if let Some(x) = tree.get_mut(&ss) {
                    *x += k;
                }
            }
            else {
                tree.insert(ss,k);
            }
        }
    }
    let res = tree.values().max().unwrap();
    println!("{}", max(&0,res));
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    let mut ret :i64 = 0;
    for c in ss.chars() {
        if ! ('0' <= c && c <= '9') { break; }
        let t = c.to_digit(10).unwrap() as i64;
        ret = ret * 10 + t;
    }
    return ret;
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let ss = read_line();
    let mut res = Vec::new();
    let mut edited = false;
    let mut x:i64 = 0;
    for c in ss.chars() {
        if !('0' <= c && c <= '9') {
            if edited {
                edited = false;
                res.push(x);
                x = 0;
            }
        }
        else {
            let t = c.to_digit(10).unwrap() as i64;
            x = x * 10 + t;
            edited = true;
        }
    }
    if edited {
        res.push(x);
    }
    return res;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
ll dp[1011][1011]={{0}};
char a[1011][1011]={{0}};
int n,m;
ll cal(int i, int j){
if((i==n-1)&&(j==m-1))return 1;
if(i>n-1||j>m-1)return 0;
if(a[i][j]=='#')return 0;
if(dp[i][j]!=-1)return dp[i][j];
ll total=(cal(i+1,j)%mod+cal(i,j+1)%mod)%mod;
return dp[i][j]=total;
}
int main(){
cin>>n>>m;
memset(dp,-1,sizeof dp);
for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        cin>>a[i][j];
    }
}
cout<<cal(0,0)<<'\n';
return 0;
}


Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<long long int>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vb vector<bool>
#define vvl vector<vector<ll> >
#define vvi vector<vector<int> >
#define pl pair<ll,ll>
#define pb push_back
#define PI 3.14159265
#define mod 998244353
#define pb push_back
#define mp make_pair
#define fri(s,n) for(int i=s;i<n;i++)
#define frj(s,n) for(int j=s;j<n;j++)
#define T(i) int i=1;cin>>i;while(i--)
#define vsi vector<set<int> >
#define pii pair<int,int>
#define inf 1e9
#define vpii vector<pair<int,int> >


ll power(ll a,ll b){
    if(b==0)
        return 1;
    if(b&1)
        return a*power(a,b-1);
    ll temp=power(a,b/2);
    return temp*temp;
    }
bool mycompare(ll a,ll b){
    return a>b;
    }
double dp[301][301][301];
double trials(int x,int y,int z,int n){
    if(x<0 || y<0 || z<0)
        return 0.0;
    if(x==0 && y==0 && z==0)
        return 0.0;
    //cout<<x<<" "<<y<<" "<<z<<"\n";
    if(dp[x][y][z]>-0.1)
        return dp[x][y][z];
    return dp[x][y][z]=(n+x*trials(x-1,y,z,n)+y*trials(x+1,y-1,z,n)+z*trials(x,y+1,z-1,n))/(x+y+z);
    }
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    fast;
    int n;
    cin>>n;
    int x=0,y=0,z=0;
    fri(0,n){
        int temp;
        cin>>temp;
        if(temp==1)
            x++;
        else if(temp==2)
            y++;
        else
            z++;
        }
    memset(dp,-1.0,sizeof dp);
    //vector<vector<vector<double> > > dp(x+1,vector<vector<double> >(y+1,vector<double>(z+1,-1.0)));
    cout<<setprecision(15)<<trials(x,y,z,n);


}


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

using namespace std;
typedef long long int ll;
int main()
{
	ll N,i,j,k,d;
	ll a[2];
	ll m[32];
	ll M[32];
	for (i=0; i<32; i++)
	{
		m[i]=1000000000;
		M[i]=-1000000000;
	}
	scanf("%lld",&N);
	d = 2;
	for (i=0; i<N; i++)
	{
		for (j=0; j<d; j++)
			cin >> a[j];//,fix();
		for (j=0; j<1<<(d-1); j++)
		{
			int x=a[0];
			for (k=0; k<d-1; k++)
				if (j&(1<<k))
					x+=a[k+1];
				else
					x-=a[k+1];
			if (m[j]>x)
				m[j]=x;
			if (M[j]<x)
				M[j]=x;
		}
	}
	ll ans=0;
	for (i=0; i<1<<(d-1); i++)
		if (ans<M[i]-m[i])
			ans=M[i]-m[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3808
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))

ans = 0
for i, v in enumerate(a):
    x -= v
    if i == n - 1:
        if x == 0:
            ans += 1
        break
    else:
        if x >= 0:
            ans += 1
            continue
        else:
            break

print(ans)


Measured memory_bytes: 61832
s = [int(x) for x in input()]

t = set()
def calc(p):
    total = 0
    tmp = 0
    for i in range(l):
        tmp = tmp * 10 + s[i]
        if p & (2**i):
            total += tmp
            tmp = 0
    return total + tmp

l = len(s)
total = 0
for i in range(2**(l-1)):
    total += calc(i)
print(total)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,m,t;
char a[1005][1005];
queue<pair<int,int> > q;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='#')
				q.push(make_pair(i,j));
		}
	while(!q.empty())
	{
		int len=q.size();
		t++;
		for(int i=1;i<=len;i++)
		{
			pair<int,int> p=q.front();
			q.pop();
			int x=p.first,y=p.second;
			for(int d=0;d<4;d++)
			{
				int xx=x+dx[d],yy=y+dy[d];
				if(a[xx][yy]=='.')
					q.push(make_pair(xx,yy));
				a[xx][yy]='#';
			}
		}
	}
	cout<<t-1;
	return 0;
}

Measured memory_bytes: 9360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    x -= 2 * z;
    int ans = 0;
    while(1){
        x -= y;
        if(x >= 0){
            ans++;
            x -= z;
        }else{
            cout << ans << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("03")
#include <bits/stdc++.h>
typedef long long ll;
const int inf=INT_MAX;
using namespace std;
int n,ans,x,y;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n;
    for(int i=0;i<n;i++) {cin>>x>>y; ans+=(y-x);}
    cout<<ans+n<<endl;
    return 0;
}


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


int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);

    int n, m; std::cin >> n >> m;

    std::vector<std::vector<std::pair<int, int>>> edge(n);
    for(int i = 0; i < m; ++i){
        int u, v, val; std::cin >> u >> v >> val; --u; --v;
        edge[u].emplace_back(v, val); edge[v].emplace_back(u, val);
    }
    std::vector<std::pair<bool, int>> dp(n);
    for(int i = 0; i < n; ++i) dp[i].second = std::numeric_limits<int>::min();

    int lwr = 1, upr = std::numeric_limits<int>::max();
    
    std::stack<int, std::vector<int>> Stk; 
    constexpr int root = 0; 
    Stk.push(root); dp[root].first = true; dp[root].second = 0;

    while(not Stk.empty()){
        const int v = Stk.top(); Stk.pop();
        for(const auto [nv, val] : edge[v]) {
            const int value = val - dp[v].second;
            if(dp[v].first){
                if(dp[nv].second == std::numeric_limits<int>::min()){
                    dp[nv].first  = false;
                    dp[nv].second = value;
                    if(upr > value - 1) upr = value - 1;
                    Stk.push(nv);
                }
                else {
                    if(dp[nv].first){
                        const int t = value - dp[nv].second;
                        if(t % 2 == 0){
                            const int tt = t / 2;
                            if(lwr < tt) lwr = tt; if(upr > tt) upr = tt;
                        }
                        else{ upr = 0; goto END_LABEL; }
                    }
                    else {
                        if(dp[nv].second != value){ upr = -1; goto END_LABEL; }
                    }
                }
            }
            else {
                if(dp[nv].second == std::numeric_limits<int>::min()) {
                    dp[nv].first  = true;
                    dp[nv].second = value;
                    if(lwr < 1 - value) lwr = 1 - value;
                    Stk.push(nv);
                }
                else {
                    if(dp[nv].first){
                        if(dp[nv].second != value){ upr = 0; goto END_LABEL; }
                    }
                    else{
                        const int t = dp[nv].second - value;
                        if(t % 2 == 0){
                            const int tt = t / 2;
                            if(lwr < tt) lwr = tt; if(upr > tt) upr = tt;
                        }
                        else{ upr = 0; goto END_LABEL; }
                    }
                }
            }
        }
        if(lwr > upr) goto END_LABEL;
    }
    END_LABEL:
    if(upr <= 0 or lwr > upr) std::cout << "0\n"; else std::cout << (upr - lwr + 1) << '\n';        
    return 0;
}

Measured memory_bytes: 11148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  // 2root(ab) < (c - a - b)

  ll a, b, c; cin >> a >> b >> c;
  if (c - a - b <= 0) {
    cout << "No" << endl;
    return 0;
  }
  if (4 * a * b < (c - a - b) * (c - a - b)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;
int deco[1000];

int st[30][100000];
ll dp[52][2510];
const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int B[30];
int t[100010];
struct edge {
	int t;
	ll cost;
	edge(int _t,ll _cost) : t(_t)
							, cost(_cost){
	}
};
int table[15][15];
ll h;

bool use[15];
int ct[15];
bool memo[15][15][15];
string format(int val){
	ostringstream sout;
	sout << std::setfill('0') << setw(2) << val;
	return sout.str();
}
int ng[3];
bool check(int nm) {
	if (ng[0] == nm || ng[2] == nm || ng[1] == nm) return false;
	return true;
}
int f(int v) {
	if (v % 2 == 0) {
		return v / 2;
	}else return 3 * v + 1;
}
int k[105];

void Solve() {

	int n;
	cin >> n;
	int h[105];
	for (size_t i = 0; i < n; i++)
	{
		cin >> h[i];
	}

	int res = 0;
	
	for (int r = 0;r <= 105;r++)
	{
		bool ch = false;
		for (size_t i = 0; i < n; i++)
		{
			if (h[i] > r && (i == 0 || h[i - 1] <= r)) {
				res++;
			}
		}
	}
	cout << res << endl;
}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
class Main {
  public static void main(String[] args){
    Scanner input = new Scanner(System.in);
    int n;

    while (true){
      n = input.nextInt();
      if (n == 0) break;
      if (n % 1111 == 0){
        System.out.println("NA");
        continue;
      }
      int ct = 0;
      while (n != 6174){
        int l, s;
        int[] num = new int[4];
        for (int i = 0; i < 4; i++){
          num[i] = n % 10;
          n /= 10;
        }
        Arrays.sort(num);
        l = s = 0;
        for(int i = 0; i < 4; i++){
          s = s * 10 + num[i];
          l = l * 10 + num[3 - i];
        }
        n = l - s;
        ct++;
      }
      System.out.println(ct);
    }
  }
}

Measured memory_bytes: 48616
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
char s[11];
long long p[11];
int h[11];
int main()
{
	int l,k;
	long long ans=0;
	scanf("%s",s+1);
	l=strlen(s+1);
	p[0]=1;
	for(int i=1;i<=9;i++)
		p[i]=p[i-1]*10;
	h[0]=h[1]=1;
	for(int i=2;i<=10;i++)
		h[i]=h[i-1]*2;
	for(int i=1;i<=l;i++)
	{
		k=s[i]-'0';
		for(int j=l-i;j>=0;j--)
			ans+=p[j]*h[l-i-j]*h[i]*k;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n] ,b[n] , c[n];
  int dp[n][3];
  for(int i = 0 ; i <n ; i++){
    cin >> a[i] >> b[i] >> c[i] ;
  }
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for(int i = 1 ; i <n ; i++){
    dp[i][0] = a[i] + max(dp[i-1][1] , dp[i-1][2]);
    dp[i][1] = b[i] + max(dp[i-1][0] , dp[i-1][2]);
    dp[i][2] = c[i] + max(dp[i-1][0] , dp[i-1][1]);
  }
  cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl ;
  return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MaxN = 300, MaxM = 300 * 300;
int n, tot, all, g[MaxN + 5][MaxN + 5];
int pre[MaxM + 5], last[MaxN + 5], other[MaxM + 5];
LL cost[MaxM + 5], dis[MaxN + 5];
int seq[MaxM + 5];
bool Inseq[MaxN + 5];
struct EDGE {
	int u, v, w;
}edge[MaxM + 5];

void Build(int x, int y, int w)
{
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
	cost[all] = w;
}

void Init()
{
	tot = 0;
	all = -1; memset(last, -1, sizeof(last));
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) {
			scanf("%d", &g[i][j]);
			if (j > i) {
				edge[++tot].u = i;
				edge[tot].v = j;
				edge[tot].w = g[i][j];
			}
		}
}

void spfa(int s)
{
	memset(Inseq, 0, sizeof(Inseq));
	for (int i = 1; i <= n; i++) dis[i] = 1LL << 50;
	dis[s] = 0; Inseq[s] = true; 
	int head = 1, tail = 0; seq[++tail] = s;
	while (head <= tail) {
		int now = seq[head];
		int ed = last[now], dr;
		while (ed != -1) {
			dr = other[ed];
			if (dis[now] + cost[ed] < dis[dr]) {
				dis[dr] = dis[now] + cost[ed];
				if (!Inseq[dr]) {
					Inseq[dr] = true;
					seq[++tail] = dr;
				}
			}
			ed = pre[ed];
		}
		head++;
		Inseq[now] = false;
	}
}

bool cmp(EDGE A, EDGE B) {return A.w < B.w;}
void Solve()
{
	sort(edge + 1, edge + tot + 1, cmp);
	LL ans = 0; bool flag = false;
	for (int i = 1; i <= tot; i++) {
		int u = edge[i].u, v = edge[i].v, len = edge[i].w;
		spfa(u);
		if (dis[v] > len) Build(u, v, len), Build(v, u, len), ans = ans + len;
		else if (dis[v] < len) flag = true;
	}
	if (flag) printf("-1\n"); else printf("%lld\n", ans);
}

int main()
{
	while (~scanf("%d", &n)) {
		Init();		
		Solve();
	}		
	return 0;
}

Measured memory_bytes: 1152
using System;
class Program
{
    static void Main(string[] args)
    {
        bool i = false;
        int n, k, q, j;
        int[] m, x = new int[4], y = new int[4], p = new int[] { 10, 50, 100, 500 };

        while (true)
        {
            n = int.Parse(Console.ReadLine());
            if (n==0) { break; }
            if (!i) { i = !i; } else { Console.WriteLine(); }
            k = 0;
            m = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            for (j = 3; j >= 0; j--)
            {
                k += m[j] * p[j];
            }
            q = k - n;
            for (j = 3; j >= 0; j--)
            {
                x[j] = q / p[j]; q -= x[j] * p[j];
                y[j] = Math.Max(0, m[j] - x[j]);
            }

            for (j = 0; j < 4; j++)
            {
                if (y[j]!=0) { Console.WriteLine("{0} {1}", p[j], y[j]); }
            }
        }
    }
}


Measured memory_bytes: 9284
#include<iostream>
#include<algorithm>
#include<map>
#define bgn first
#define end second
using namespace std;
typedef pair<long long, long long> Range;



long long myMod(long long v, long long mod) {
    if (v < 0) {
        return (mod - llabs(v) % mod) % mod;
    } else {
        return v % mod;
    }
}


long long N, X, D;

void read() {
    cin >> N >> X >> D;
}


void work() {
    if (D == 0) {
        cout << (X == 0 ? 1 : N + 1) << endl;
        return;
    }
    
    if (D < 0) {
        X *= -1;
        D *= -1;
    }

    
    long long ans = 1;

    long long curMinV = N * X + N * (N - 1) / 2 * D;
    long long curMaxV = N * X + N * (N - 1) / 2 * D;
    long long subtMinD = X + (N - 1) * D;
    long long subtMaxD = X;
    
    long long toPush = N * X + N * (N - 1) / 2 * D;
    map<long long, Range> mod2range;
    mod2range[myMod(toPush, D)] = Range(toPush, toPush);
    
    for (int i = 0; i < N; ++i) {
        curMinV -= subtMinD;
        curMaxV -= subtMaxD;
        
        long long minV = min(curMinV, curMaxV);
        long long maxV = max(curMinV, curMaxV);
        
        if (mod2range.count(myMod(minV, D)) && max(minV, mod2range[myMod(minV, D)].bgn) <= min(maxV, mod2range[myMod(minV, D)].end)) {
            Range range = mod2range[myMod(curMinV, D)];
            ans += (maxV - minV) / D + 1;
            ans -= (min(maxV, range.end) - max(minV, range.bgn)) / D + 1;
        } else {
            ans += (maxV - minV) / D + 1;
        }
        mod2range[myMod(minV, D)] = Range(minV, maxV);

        subtMinD -= D;
        subtMaxD += D;
    }

    cout << ans << endl;
}


int main() {
    for (int i = 0; i < 1; ++i) {
        read();
        work();
    }
    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    int n,k;cin>>n>>k;
    vector<int>V(n),Count;
    rep(i,n)cin>>V[i];
    sort(V.begin(),V.end());
    V.push_back(-1);
    int count=0;
    rep(i,n){
        count++;
        if(V[i]!=V[i+1]){
           Count.push_back(count);count=0;
        }
    }
    sort(Count.begin(),Count.end());
    int s=Count.size();
    if(s<=k)cout<<0<<endl;
    else{
        int m=s-k;
        int ans=0;
        rep(i,m)ans+=Count[i];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 2800
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define pq          priority_queue
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define vll         vector<pll>
#define f           first
#define s           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323
ll v[100005],k,n;
//ll dp[100005];
ll c1(ll a, ll b)
{
    if(a%b==0) return (a/b)-1;
    else return (a/b);
}
bool check(ll m)
{   ll s=0;
    for(int i=1;i<n;i++)
        s+=c1(v[i]-v[i-1],m);
    return s<=k;
}
bool ispalindrome(string s2)
{
    ll n=s2.size();
    ll l=0,h=n-1;
    while(h>=l)
        if(s2[l++]!=s2[h--]) return 0;
    return 1;
}
void solve()
{
 ll t,b,m;
 string s1;
 cin>>s1;
 n=sz(s1);
 m=(n-1)/2;
 string s2="",s3="";
 for(int i=0;i<m;i++) s2+=s1[i];
    for(int i=(n+3)/2 -1;i<n;i++) s3+=s1[i];
        if(ispalindrome(s2) && ispalindrome(s3) && ispalindrome(s1)) cout<<"Yes";
        else cout<<"No";

}   

int main()
{
    speed_up
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Mod = 998244353;
const ll inf = (1ll << 61);
const int MX = 1e6 + 9;
ll n,a,b;
int main(){
    cin>>n>>a>>b;
    ll x = abs(a-b);
    if(x%2==0)cout<<x/2<<endl;
    else{
        cout<<min((n-b+n-a+1)/2,(a+b-1)/2)<<endl;
    }
}


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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;
    int x, y, X, Y, t, T;
    x = y = t = 0;
    for(int i = 0; i < N; i++) {
        cin >> T >> X >> Y;
        if(abs(T - t) < abs(X - x) + abs(Y - y) || abs(X + x + Y + y + T + t)%2) {
            cout << "No" << endl;
            return 0;
        }
        t = T, x = X, y = Y;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3592
import sys
from itertools import *
n=104730;a=list(range(n));a[:2]=0,0
for i in range(2,323):a[i*2::i]=[0]*len(a[i*2::i])
p=list(compress(range(n),a))
for e in sys.stdin:
 if'0\n'!=e:print(sum(p[:int(e)]))


Measured memory_bytes: 10460
N = int(input())
x, u = [0]*N, ['0']*N
for i in range(N):
    tmp_x, tmp_u = map(str, input().split())
    x[i], u[i] = float(tmp_x), tmp_u
cor = zip(x,u)

answer = 0
for i,j in cor:
    if j == 'JPY':
        answer += i
    else:
        answer += i*380000.0
print(answer)


Measured memory_bytes: 3060
N, M, K = map(int, input().split())
MOD = 998244353

# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, N+2):
    factorial.append(factorial[-1] * i % MOD)
    inverse.append(pow(factorial[-1], MOD - 2, MOD))

# 組み合わせ計算
def nCr(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % MOD

ans = 0
for k in range(K + 1):
    ans += M * nCr(N - 1, k) * pow(M - 1, N - 1 - k, MOD) % MOD
    ans %= MOD

print(ans % MOD)


Measured memory_bytes: 24856
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19
constexpr static double EPS = 1e-10;

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

    unordered_map<string, ll> numsMap;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        numsMap[s] = numsMap[s] + 1;
    }

    ll ans = 0;
    for (auto value : numsMap) {
        ll num = value.second;
        ans += (num * (num - 1)) / 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 7328
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	nums := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&nums[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(nums)))

	var alice, bob int
	for i := 0; i < len(nums); i++ {
		if i%2 == 0 {
			alice += nums[i]
		} else {
			bob += nums[i]
		}
	}
	fmt.Println(alice - bob)
}


Measured memory_bytes: 512