akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using PLL = pair<ll, ll>;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;

const ll mod = 998244353;

ll mod_pow(ll n, ll k) { return k ? (k & 1 ? n : 1) * mod_pow(n * n % mod, k / 2) % mod : 1; }

ll mod_inv(ll n) { return mod_pow(n, mod - 2); }

ll N;

void dfs(ll cur, ll pre, V<ll> &parents, const VV<ll> &edges) {
    parents[cur] = pre;
    for(ll nxt : edges[cur]) if(nxt != pre) dfs(nxt, cur, parents, edges);
}

void input(VV<ll> &edges) {
    for(ll i = 1; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
}

int main() {
    cin >> N;
    VV<ll> tedges(N), uedges(N);
    V<ll> tpar(N), upar(N);
    input(tedges);
    input(uedges);

    dfs(0, -1, tpar, tedges);
    dfs(0, -1, upar, uedges);

    ll inv2 = mod_inv(2);
    ll inv4 = inv2 * inv2 % mod;
    
    ll ans = 0;
    ans += uedges[0].size() * inv2 % mod;
    ans += (N - (1 + uedges[0].size())) * inv4 % mod;
    ans = ans % mod * inv2 % mod;

    for(ll i = 0; i < N; i++) {
        sort(uedges[i].begin(), uedges[i].end());
        auto tmp = move(uedges[i]);
        uedges[i].clear();
        for(ll e : tmp) if(e != upar[i]) uedges[i].push_back(e);
    }

    // // cerr << inv2 << ", " << inv4 << endl;
    // // cerr << ans << endl;

    for(ll i = 1; i < N; i++) {
        ll p = tpar[i];
        ll add_v = 0;
        ll oth = N - (uedges[i].size() + uedges[p].size());
        
        {
            ll a[] = { i, p };
            ll b[] = { 0, i, p };
            sort(b, b + 3);
            auto *ptr = unique(b, b + 3);
            ll upper = ptr - b;
            oth -= upper;  // root, i, p
            for(ll j = 0; j < 2; j++) for(ll k = 0; k < upper; k++) {
                auto &v = uedges[a[j]];
                auto ite = lower_bound(v.begin(), v.end(), b[k]);
                if(ite != v.end() && *ite == b[k]) oth++;
            }
        }

        //oth=count_nodes(i,p);
        // cerr << i << ", " << p << ", " << oth << endl;

        // p
        if(upar[p] == i || p == 0) add_v += 1;
        else add_v += inv2;
        
        // root
        if(p) add_v += inv2;

        // cerr << add_v << endl;

        // i's children
        add_v += (uedges[i].size() - (upar[p] == i)) * inv2 % mod;
        
        // cerr << uedges[i].size() << ", " << add_v << endl;

        // oth
        add_v += oth * inv4 % mod;
        
        // cerr << add_v << endl;

        add_v = add_v % mod * inv4 % mod;  // i
        // // cerr << add_v << endl;
        (ans += add_v) %= mod;
    }

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



Measured memory_bytes: 39780
#include <iostream>

using namespace std;

int main() {
    long long x;

    cin >> x;

    if (x % 11 >= 1 && x % 11 <= 6) {
        cout << x / 11 * 2 + 1 << endl;
    } else {
        cout << (x + 10) / 11 * 2 << endl;
    }
}


Measured memory_bytes: 256
class Pointer
  def initialize(t, x, y)
	@t = t
  	@x = x
	@y = y
  end
  attr :t, :x, :y
end

def getDistans(from, to)
	return (from.x - to.x).abs + (from.y - to.y).abs
end
def checkDistans(distans, time)
	raise "err distans:%d time:%d" % [distans, time] if distans > time
	raise "err distans/2:%d time/2:%d" % [distans % 2, time % 2] if distans % 2 != time % 2
end

n = gets.to_i
from = Pointer.new(0,0,0)

begin
n.times{
	t,x,y = gets.split.map(&:to_i)
	to = Pointer.new(t,x,y)
	
	distans = getDistans(from, to)
	checkDistans(distans, to.t - from.t)
	
	from = to
}
	puts "Yes"
rescue => e
	# puts e
	puts "No"
end


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

#define rep(i, n) for(int i = 0; i < n; i++)
using ll = long long;

using namespace std;

double sqr(double n){
    return n * n;
}

double dist(double x1, double x2, double y1, double y2)
{
    return sqrt(sqr(x1 - x2) + sqr(y1 - y2));
}

int main()
{
    int n; cin >> n;
    double x[n], y[n]; rep(i, n) cin >> x[i] >> y[i];
    vector<int> v(n); rep(i ,n) v[i] = i;
    double sum = 0.0;
    int conb = 1; for(int i = 2; i <= n; i++) conb *= i;

    do{
        for(int i = 0; i < n - 1; i++)
        sum += dist(x[v[i]], x[v[i + 1]], y[v[i]], y[v[i + 1]]);
    }while(next_permutation(v.begin(), v.end()));

    cout << setprecision(10) << sum / conb << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

const int MAX_V = 101010;

struct edge { int to, cap, rev; };

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from, int to, int cap) {
	G[from].emplace_back(edge{ to,cap,(int)G[to].size() });
	G[to].emplace_back(edge{ from,0,(int)G[from].size() - 1 });
}

void bfs(int s) {
	REP(i, MAX_V)level[i] = -1;
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while(!que.empty()) {
		int v = que.front();
		que.pop();
		REP(i, G[v].size()) {
			edge &e= G[v][i];
			if (e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v, int t, int 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]) {
			int 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;
}

int max_flow(int s, int t){
	int flow = 0;
	for (;;) {
		bfs(s);
		if (level[t] < 0)return flow;
		REP(i, MAX_V)iter[i] = 0;
		int f;
		while ((f = dfs(s, t, INF)) > 0) {
			flow += f;
		}
	}
}


int n, m;
int main() {
	cin >> n >> m;
	REP(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		add_edge(a, b, c);
	}
	cout << max_flow(0, n - 1) << endl;
}


Measured memory_bytes: 6344
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
using namespace std;


int main(){

    string s;

    cin >> s;

    int res = 1000000000;

    for(int i = 0; i < s.length()-2; i++)
    {
        int a = abs(stoi(s.substr(i,3)) - 753);
        if (a < res) {
            res = a;
        }
        
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define uLL unsigned long long

using namespace std;
const int N=500+10,mod=1e9+7;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}
int fpow(int a,int b){int an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;}return an;}
int ginv(int a){return fpow(a,mod-2);}
int n,m,a[N],f[2][N][N],pw[N][N],c[N][N],fac[N],iac[N];

int main()
{
    m=rd(),n=rd();
    while(m--) ++a[rd()];
    for(int i=0;i<=n;++i)
    {
	pw[i][0]=1;
	for(int j=1;j<=N-5;++j) pw[i][j]=1ll*pw[i][j-1]*i%mod;
    }
    for(int i=0;i<=n;++i)
    {
	c[i][0]=1;
	for(int j=1;j<=i;++j) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
    }
    fac[0]=1;
    for(int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;
    iac[n]=ginv(fac[n]);
    for(int i=n;i;--i) iac[i-1]=1ll*iac[i]*i%mod;
    int nw=1,la=0;
    f[la][0][0]=1;
    for(int i=n;i;--i)
    {
	for(int j=0;j<=n;++j)
	    for(int k=j;k<=n;++k)
	    {
		if(!f[la][j][k]) continue;
		for(int l=0;k+i*l<=n;++l)
		    ad(f[nw][j+l][k+i*l],1ll*f[la][j][k]*iac[l]%mod*pw[k+i*l-(j+l)*(i-1)][a[i]]%mod);
		f[la][j][k]=0;
	    }
	nw^=1,la^=1;
    }
    int ans=0;
    for(int j=0;j<=n;++j)
	for(int k=j;k<=n;++k)
	{
	    int dx=1ll*f[la][j][k]*c[n-k+1][j]%mod*fac[j]%mod;
	    ad(ans,((n-k)&1)?mod-dx:dx);
	}
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3712
from sys import stdin

sN, sQ = stdin.readline().split()
N, Q = int(sN), int(sQ)
# print(N,Q)
S = stdin.readline().rstrip()
data = [stdin.readline().split() for itr in range(Q)]
# print(data)

grid = [None] * N
# print(grid)
count = 0
for num in range(N):
    if num == 0:
        grid[num] = count
        continue
    if S[num] == 'C' and S[num-1] == 'A':
        count += 1
        grid[num] = count
        continue
    grid[num] = count

# print(grid)

for itr in range(Q):
    l = int(data[itr][0]) - 1
    r = int(data[itr][1]) - 1
    # print(grid[r],grid[l])
    print(grid[r]-grid[l])

Measured memory_bytes: 35540
#include <stdio.h>

int main(void)
{
	char st[200001];
	int i, n, cnt[200000];
	scanf("%d%*c%s%*c", &n, st);

	int s = 0;
	for(i=0;i<n;i++) {
		if(st[i] == '#') s++;
		cnt[i] = s;
	}
	s = 0;
	for(i=n-1;i>=0;i--) {
		if(st[i] == '.') s++;
		cnt[i] += s;
	}

	int min = 200000;
	for(i=0;i<n;i++) {
		if(min > cnt[i]) min = cnt[i];
	}
	printf("%d", min-1);
	
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <string>
#include <cassert>
using namespace std;

#define N 4
#define N2 16
#define LIMIT 100

static const int dx[4] = {0,-1,0,1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle {int f[N2], space, MD; };

Puzzle state;
int limit;
int path[LIMIT];

int getALLMD(Puzzle pz){
  int sum = 0;
  for(int i=0; i< N2; i++){
    if(pz.f[i] == N2) continue;
    sum += MDT[i][pz.f[i]-1];
  }
  return sum;
}

bool isSolved(){
  for(int i=0; i<N2; i++) if(state.f[i] != i+1) return false;
  return true;
}

bool dfs(int depth, int prev){
  if(state.MD == 0)return true;
  if(depth + state.MD > limit) return false;
  int sx = state.space / N;
  int sy = state.space % N;
  Puzzle tmp;

  for(int r=0; r<N; r++){
    int tx=sx+dx[r];
    int ty = sy+dy[r];
    if(tx<0 || ty<0 || tx>=N || ty>=N) continue;
    if(max(prev, r)-min(prev, r) == 2) continue;
    tmp = state;

    state.MD -= MDT[tx*N+ty][state.f[tx*N+ty]-1];
      state.MD += MDT[sx*N+sy][state.f[tx*N+ty]-1];
      swap( state.f[tx*N+ty], state.f[sx*N+sy] );
      state.space = tx*N+ty;
      if(dfs(depth +1, r)){path[depth]=r; return true; }
      state=tmp;
  }
  return false;
}

string iterative_deepening(Puzzle in){
  in.MD = getALLMD(in);
  
  for(limit = in.MD; limit<=limit; limit++){
    state=in;
    if(dfs(0, 100)){
      string ans = "";
      for(int i=0; i<limit; i++) ans += dir[path[i]];
      return ans;
    }
  }
  
  return "unsolvable";
}

int main(){
  for(int i=0; i<N2; i++)
    for(int j=0; j<N2; j++)
      MDT[i][j] =abs(i/N-j/N)+abs(i%N-j%N);
  
  Puzzle in;
  for(int i=0; i<N2; i++){
    cin >> in.f[i];
    if(in.f[i]==0){
      in.f[i]=N2;
      in.space =i;
    }
  }
  string ans=iterative_deepening(in);
  cout << ans.size() <<endl;
  return 0;
}



Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int a[2][105];
int n,ans;
void dfs(int x,int y,int sum)
{
	if(x<0 || x>=2 || y<0 || y>=n)
		return ;
	//printf("%d %d\n",x,y);
	if(x==1 && y==n-1)
	{
		ans=max(ans,sum+a[x][y]);
		return ;
	}
	dfs(x,y+1,sum+a[x][y]);
	dfs(x+1,y,sum+a[x][y]);
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<2;i++)
		for(int j=0;j<n;j++)
			scanf("%d",&a[i][j]);
		dfs(0,0,0);
		printf("%d\n",ans);
    return 0;
}


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

int main() {
  int N,K,sum=0;
  cin >> N >> K;

  vector<int> num(60);

  for(int i=0;i<N;i++) {
    cin >> num.at(i);
  }
  sort(num.rbegin(),num.rend());
  //reverse(num.begin(),num.end());
  for(int j=0;j<K;j++) {
    sum+=num.at(j);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int d(ll h, ll w){
    ll min1 = MAXINF;
    REP(i,h-2){
        ll a = (i+1)*w;
        ll b = h*w-a*2;
        if(b<0) break;
        min1 = min(min1, abs(a-b));
    }

    ll min2 = MAXINF;
    REP(i,h-1){
        ll a = (i+1)*w;
        ll b,c;
        ll d = w/2;
        if(w&1){
            b = (h-i-1) * d;
            c = (h-i-1) * (d + 1);
        }else{
            b = c = (h-i-1) * d;
        }
        min2 = min(min2, max({a,b,c})-min({a,b,c}));
    }
    return int(min(min1, min2));
}

int main(void)
{
    int H,W;
    cin >> H >> W;
    pr(min(d(H,W), d(W, H)));
}

Measured memory_bytes: 256
i,j,x;main(n){for(scanf("%d",&n);n--;printf("%d\n",j)){scanf("%d%d",&i,&j);if(i<6)for(;i-j;i+=i<j?1:-1)printf("%d ",i);if(i>5)for(x=-1;i-j;x=i?x:1)printf("%d ",i),i+=i<6?x:i>8?-4:1;}}

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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

ll niz[100010];
ll pref1[100010];
ll pref2[100010];

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

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

    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> niz[i];

    pref1[0] = niz[0];
    for(int i = 1; i < n; i++) pref1[i] = nzd(pref1[i-1], niz[i]);

    pref2[n-1] = niz[n-1];
    for(int i = n-2; i >= 0; i--) pref2[i] = nzd(pref2[i+1], niz[i]);

    ll best = 0;
    best = pref2[1];
    if(pref1[n-2] > best) best = pref1[n-2];
    for(int i = 1; i < n-1; i++)
    {
        ll p = nzd(pref1[i-1], pref2[i+1]);
        if(p > best) best = p;
    }
    cout << best;


    return 0;
}


Measured memory_bytes: 2560
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
x=a[-1]
ans=[x,0]
for i in a:
    if x>i and abs(x//2-i)<abs(x//2-ans[1]):
        ans[1]=i
    if x>i and x%2 and abs((x+1)//2-i)<abs((x+1)//2-ans[1]):
        ans[1]=i

print(ans[0],ans[1])


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

bool gridsearch(vector<vector<int>> m, int row, int col){
    bool flag = false;

    if (m.at(row).at(col+1) == 1) flag = true;
    if (m.at(row).at(col-1) == 1) flag = true;
    if (m.at(row+1).at(col) == 1) flag = true;
    if (m.at(row-1).at(col) == 1) flag = true;

    return flag;
}

int main(){
    int h,w;
    cin >> h >> w;
	vector<vector<int> > F(h+2, vector<int>(w+2));

    char c;
    for (int i = 1; i <= h; i++){
        for (int j = 1; j <= w; j++){
            cin >> c;
            if (c == '#') ++F.at(i).at(j);
        }
    }

    bool can = true;
    for (int i = 1; i <= h; i++){
        for (int j = 1; j <= w; j++){
            if (F.at(i).at(j) == 1){
                if(!gridsearch(F, i, j)) {
                    can = false;
                    break;
                }
            }
        }
    }

    if (can) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
#include "stdio.h"
int main(){
    int A,B;
    int ret;
    scanf("%d %d",&A,&B);
    ret = 0;
    if (A > B){
        ret = A;
        A--;
    }else{
        ret = B;
        B--;
    }
    if (A > B){
        ret += A;
    }else{
        ret += B;
    }
    printf("%d\n",ret);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define pb push_back
#define mp make_pair
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
    const uint32 Buffsize=1<<15,Output=1<<24;
    static char Ch[Buffsize],*S=Ch,*T=Ch;
    inline char getc()
	{
		return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
	}
    static char Out[Output],*nowps=Out;
    
    inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

    template<typename T>inline void read(T&x)
	{
		x=0;static char ch;T f=1;
		for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
		for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
		x*=f;
	}

	template<typename T>inline void write(T x,char ch='\n')
	{
		if(!x)*nowps++='0';
		if(x<0)*nowps++='-',x=-x;
		static uint32 sta[111],tp;
		for(tp=0;x;x/=10)sta[++tp]=x%10;
		for(;tp;*nowps++=sta[tp--]^48);
		*nowps++=ch;
	}
}
using namespace IO;

inline void file()
{
#ifndef ONLINE_JUDGE
	FILE*WA=freopen("water.in","r",stdin);
	FILE*TER=freopen("water.out","w",stdout);
#endif
}

const int MAXN=2e5+7;

static int n;

static char s[MAXN];

inline void init()
{
	scanf("%s",s+1);
	n=strlen(s+1);
}

static int cn;

static ll ans;

inline void solve()
{
	Rep(i,1,n)if(s[i]=='B')++cn;
	else ans+=cn;
	cout<<ans<<endl;
}

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N, M;
const int INF = 1e9;
int S = 1e9;
vector<vector<int>> G;
stack<int> ans;

void search(int s) {
  vector<int> d(N, INF), prev(N, -1);
  queue<int> q;
  q.push(s);

  d[s] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();

    for (int v : G[u]) {
      if (v == s) {
        if (S > d[u]) {
          S = d[u];
          ans = stack<int>();
          while (u != -1) {
            ans.push(u);
            u = prev[u];
          }
          return;
        }
      }
      if (d[v] > d[u] + 1) {
        prev[v] = u;
        d[v] = d[u] + 1;
        q.push(v);
      }
    }
  }
}

int main() {
  cin >> N >> M;
  G.resize(N);
  rep(i, M) {
    int A, B;
    cin >> A >> B;
    A--, B--;
    G[A].push_back(B);
  }

  rep(i, N) search(i);

  if (ans.size() == 0) {
    cout << -1 << endl;
    return 0;
  }

  cout << ans.size() << endl;
  while (!ans.empty()) {
    cout << (ans.top() + 1) << endl;
    ans.pop();
  }

  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
import collections
c=collections.Counter(a)
s=0
for cc in c:
  s+=c[cc]*(c[cc]-1)//2
for aa in a:
  sa=c[aa]*(c[aa]-1)//2-(c[aa]-1)*(c[aa]-2)//2
  print(s-sa)


Measured memory_bytes: 32188
#include <iostream>
#include <cfenv>
#include <algorithm>
#include <cmath>

#define rep(i,n) for(int (i)=0;(i)<(n); ++(i))
using namespace std;

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

    float ans = 0;
    if(fmod(n,2) == 1){
        ans = floor(n/2) + 1;
    }else{
        ans = n/2;
    }

    cout << (ans/n) << endl;
}

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

#define dump(a) cerr << #a << " " << a << endl
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using vi = vector<int>;

int main(){
  int n, m;
  while(cin >> n >> m, n){
    map<int, int> ans;
    rep(i,n){
      int d, v; cin >> d >> v;
      ans[d] = max(ans[d], v);
    }
    int num = 0;
    for(auto p : ans) num += p.second;
    cout << num << endl;
  }
}



Measured memory_bytes: 3084
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b,c,d,e; cin >> a >> b >> c >> d >> e;
    int ans = ( (a+9)/10 + (b+9)/10 + (c+9)/10 + (d+9)/10 +(e+9)/10 ) * 10;
    int m = 0;
    if(a%10!=0)chmax(m,10-a%10);
    if(b%10!=0)chmax(m,10-b%10);
    if(c%10!=0)chmax(m,10-c%10);
    if(d%10!=0)chmax(m,10-d%10);
    if(e%10!=0)chmax(m,10-e%10);
    out(ans-m);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(int argc, const char * argv[]) {
    int n = 0;
    int count = 0;
    vector<int> vec;
    cin >> n;
    int x = 0;
   // int i = 0;
    for (int j = 0; j< n*2 ; j++) {
        cin>>x;
        vec.push_back(x);

    }
    
    sort(vec.begin(),vec.end());
    for (int i = 0; i < n*2 ; i = i+2 ) {
        if(vec[i] >= vec[i+1])  count += vec[i+1];
        else count += vec[i];
    }
    cout<<count<<endl;
   // return count;
    
    
    // insert code here...
   // std::cout << "Hello, World!\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for (int i=n;^i;i--)
#define ALL(v) v.begin(),v.end()
// #define int ll 
#define eps 1e-9
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
typedef long long ll;

inline bool isprime(int temp){
	int i=3;
	if (temp==2) return true;
	if (!(temp&1)) return false;
	while(i<=sqrt(temp)){
		if (!(temp%i))
			return false;	
		i += 2;
	}
	return true;
}

int main(void){
	int n,count=0;
	cin >> n;
	rep(i,n){
		int temp;
		cin >> temp;
		count += isprime(temp);
	}
	cout << count << endl;
}

Measured memory_bytes: 3056
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define ll long long

using namespace std;

vector<int> conv(int a){
  if(a < 5){
    return {-2,a-2};
  }
  if(a > 14){
    return {2,a-17};
  }
  if(a < 10){
    if(a == 7){
      return {0,-2};
    }
    return {-1,a-7};
  }
  if(a == 12){
    return {0,2};
  }
  return {1,a - 12};
}

int main(void){
  int high,wide;
  cin >> high >> wide;
  int magihi,magiwi;
  int disthi,distwi;
  cin >> magihi >> magiwi;
  cin >> disthi >> distwi;
  vector<vector<int>> maze(high+2,vector<int>(wide+2,-1));
  for(int i = 0;i < high;i ++){
    string st;
    cin >> st;
    for(int j = 0;j < wide;j ++){
      if(st[j] == '.'){
        maze[i+1][j+1] = 100000000;
      }else{
        maze[i+1][1+j] = -1;
      }
    }
  }
  bool cont = true;
  int s = 0;
  int o = 0;
  maze[magihi][magiwi] = 0;
  vector<vector<int>> prev = {{magihi,magiwi}};
  vector<vector<int>> warprev = {{magihi,magiwi}};
  while(cont == true){
    if(maze[disthi][distwi] != 100000000){
      cout << maze[disthi][distwi] << endl;
      return 0;
    }
    if(prev.size() > s){
      vector<int> serch = prev[s];
      s ++;
      if(maze[serch[0]+1][serch[1]] > maze[serch[0]][serch[1]]){
        warprev.push_back({serch[0]+1,serch[1]});
        prev.push_back({serch[0]+1,serch[1]});
        maze[serch[0]+1][serch[1]]= maze[serch[0]][serch[1]];
      }

      if(maze[serch[0]-1][serch[1]] > maze[serch[0]][serch[1]]){
        warprev.push_back({serch[0]-1,serch[1]});
        prev.push_back({serch[0]-1,serch[1]});
        maze[serch[0]-1][serch[1]]= maze[serch[0]][serch[1]];
      }

      if(maze[serch[0]][serch[1]+1] > maze[serch[0]][serch[1]]){
        warprev.push_back({serch[0],serch[1]+1});
        prev.push_back({serch[0],serch[1]+1});
        maze[serch[0]][serch[1]+1] = maze[serch[0]][serch[1]];

      }

      if(maze[serch[0]][serch[1]-1] > maze[serch[0]][serch[1]]){
        warprev.push_back({serch[0],serch[1]-1});
        prev.push_back({serch[0],serch[1]-1});
        maze[serch[0]][serch[1]-1] = maze[serch[0]][serch[1]];
      }
    }else{
      vector<int> serch = warprev[o];
      o ++;
      for(int j = 0;j < 20;j ++){
        vector<int> plus = conv(j);
        if(0 < serch[0] + plus[0] and serch[0] + plus[0] < high+1 and serch[1] + plus[1] > 0 and serch[1] + plus[1] <= wide){
          if(maze[serch[0]+plus[0]][serch[1]+plus[1]]> maze[serch[0]][serch[1]]+1){
            maze[serch[0]+plus[0]][serch[1]+plus[1]] = maze[serch[0]][serch[1]]+1;
warprev.push_back({serch[0]+plus[0],serch[1]+plus[1]});
prev.push_back({serch[0]+plus[0],serch[1]+plus[1]});
          }
        }
      }
    }
    if(prev.size() <= s and warprev.size() <= o){
      cont = false;
    }
  }
                                                            
                                                         

  int ans = maze[disthi][distwi];
                                                            if(ans == 100000000){
    ans = -1;
  }
                                                            cout<< ans << endl;
                                                            return 0;
}

Measured memory_bytes: 52440
h, w = map(int, input().split())
grid = [None]*h
cnt = [[0 for _ in range(w+1)] for __ in range(h+1)]
for i in range(h):
    grid[i] = list(input())
for i in range(h):
    done = [0]*w
    for j in range(w):
        if grid[i][j] == "#": continue
        if done[j] == 1: continue
        l = 0
        while j+l < w:
            if grid[i][j+l] == "#": break
            l += 1
        for k in range(l):
            cnt[i][j+k] += l
            done[j+k] = 1
for j in range(w):
    done = [0]*h
    for i in range(h):
        if grid[i][j] == "#": continue
        if done[i] == 1: continue
        l = 0
        while i+l < h:
            if grid[i+l][j] == "#": break
            l += 1
        for k in range(l):
            cnt[i+k][j] += l
            done[i+k] = 1
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, cnt[i][j]-1)
print(ans)


Measured memory_bytes: 221704
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>

using namespace std;

int N;
int v[10];
int edge[10][10];
int ans;

int dfs(int crt){
    v[crt] = 1;
    int flag = 1;
    for (int i = 1; i <= N; i++){
        if (!v[i]) flag = 0;
    }
    if (flag) ans++;
    
    for (int i = 1; i <= N; i++){
        if (edge[crt][i] == 1 && v[i] != 1){
            dfs(i);
        }
    }
    v[crt] = 0;
    return 0;
}

int main(){
    cin.tie(0);
    
    int M; cin >> N >> M;
    for (int i = 0; i < M; i++){
        int a, b; cin >> a >> b;
        edge[a][b] = 1;
        edge[b][a] = 1;
    }
    
    dfs(1);
    cout << ans << endl;
}

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

int main()
{
    int n;
    cin>>n;
    int k,x;
    cin>>k>>x;
    int arr[n+5];
    for(int i=1;i<=n;i++)cin>>arr[i];

    int sum=0;

    for(int i=1;i<=n;i++)
    {
        int p=arr[i];
        for(int j=1;j<=k;j+=p)
        {
            sum++;
        }
    }
    cout<<sum+x<<endl;

}


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

#define LL long long

const int maxN = 2e5 + 10;

int n, m;
LL ans;
char s[maxN + 1];

int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) m += s[i] - '0';

	for(int i = 1; i <= m; i++) ans += (i + 1) / 2;
	
	int sum = 0;
	for(int i = 1, j; i <= n; i = j)
		if(s[i] == '0') sum ++, j = i + 1;
		else
		{
			j = i + 1;
			while(s[j] == '1' && j <= n) j ++;
			int len = j - i;
			ans += 1ll * (n - m) * (len >> 1);
			if(len & 1)
			{
				if(i & 1) ans += (sum + 1) / 2;
				else ans += sum / 2;
				ans += n - m - sum;
			}
		}
	
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4020
#include <bits/stdc++.h>
#define maxi 300005
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define ll long long
#define si(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif
#define gc getchar
#define REP(i,j,n)               for( i=j;i<n;i++)
#define PER(i,j,n)               for( i=n-1;i>=j;i--)
ll mpow(ll a, ll n,ll mod){
	ll ret=1;ll b=a;
	while(n) {
		if(n&1)
			ret=(ret*b)%mod;
		b=(b*b)%mod;
		n>>=1;
	}
	return (ll)ret;
}
inline void read(int &x){
	x=0;
	register char c=gc();
	for(;c<'0' || c>'9';c=gc());
	for(;c>='0' && c<='9';c=gc())
		x=(x<<3)+(x<<1)+(c-'0');
}
inline void write(int x){
	register char buffor[35];
	register int i=0;
	do{
		buffor[i++]=(x%10)+'0';
		x/=10;
	} while(x);
	i--;
	while(i>=0) putchar(buffor[i--]);
	putchar('\n');
}
inline int in() { int x; read(x); return x; }
void solve();
int dbg=1;
using namespace std;
int main(){
	int t=1;
	//read(t);
	for(int i=0;i<t;i++){
		//printf("Case #%d:\n",i);
		solve();
	}
	return 0;
}
void solve() {
	double a,b,x,i,j,k;
	cin>>a>>b>>x;
	if(x>a*a*b/2)
		cout<<setprecision(11)<<atan(2*(a*a*b-x)/(a*a*a))*180/M_PI<<endl;
	else
		cout<<setprecision(11)<<90-atan(2*x/(a*b*b))*180/M_PI<<endl;
}



Measured memory_bytes: 256
N = gets.to_i
puts N.times.map{ gets.split }.map{|name,score| [name, score.to_i] }.map.with_index{|a,i| [a,i+1].flatten}.sort{|a,b| (a[0] <=> b[0]).nonzero? || (b[1] <=> a[1]) }.map{|a,b,c| c}



Measured memory_bytes: 1788
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a < b){
			System.out.println("a < b");
		}else if(a > b){
			System.out.println("a > b");
		}else if(a == b){
			System.out.println("a == b");
		}
	}

}

Measured memory_bytes: 26048
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n, d;
	int[][] w;

	void run(){
		n=sc.nextInt();
		d=sc.nextInt();
		w=new int[d-1][n];
		for(int j=0; j<d-1; j++){
			for(int i=0; i<n; i++){
				w[j][i]=sc.nextInt()-1;
			}
		}
		solve();
	}

	void solve(){
		int[] a=new int[n], b=new int[n];
		boolean ok=true;
		for(int n0a=0; n0a<=n/2; n0a++){
			for(int n0b=0; n0b<=n/2; n0b++){
				int n1a=n/2-n0a, n1b=n/2-n0b;
				fill(a, 1);
				for(int i=0; i<n0a; i++){
					a[i]=0;
				}
				for(int i=0; i<n0b; i++){
					a[i+n/2]=0;
				}
				// debug("1", a);
				if(false)
					for(int j=0; j<d-1; j++){
						for(int i=0; i<n; i++){
							// b[w[j][i]]=a[i];
							b[i]=a[w[j][i]];
						}
						System.arraycopy(b, 0, a, 0, n);
						sort(a, 0, n/2);
						sort(a, n/2, n);
					}
				for(int j=d-2; j>=0; j--){
					for(int i=0; i<n; i++){
						b[i]=a[w[j][i]];
					}
					System.arraycopy(b, 0, a, 0, n);
					sort(a, 0, n/2);
					sort(a, n/2, n);
				}
				// debug("2", a);
				for(int i=0; i<n-1; i++){
					ok&=a[i]<=a[i+1];
				}
			}
		}
		println(ok?"Yes":"No");
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)
#define dwn(i,n) for(int i = n; i >= 0; i--)
#define dwn2(i,start,end) for(ll i = start; i >= end; i--)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 0x3f3f3f;
const ll Mode = 1e9 + 7;

vector<ll> G[N];
ll numb[N];
ll father[N];
int main(){
	ll n,m;
	cin>>n>>m;
	rep(i,n-1){
		ll x,y;
		cin>>x>>y;
		G[x].push_back(y);
		father[y] = x;
	}
	rep(i,m){
		ll x,y;
		cin>>x>>y;
		numb[x] += y;
	}
	ll sum = 0;
	rep2(i,1,n+1){
		numb[i] += numb[father[i]];
		cout<<numb[i]<<" ";
	}
	cout<<endl;
	
	return 0;
}








Measured memory_bytes: 23808
#include "stdio.h"

int main(void){
  int x,y,z,i;
  scanf("%d", &x);
  int a[x];
  for(i = 0; i < x; i++){
    if(i != (x-2)){
      scanf("%d ", &a[i]);
    }else{
      scanf("%d\n", &a[i]);
    }
  }
  for(i = 0; i < x; i++){
    if(i == (x-1)){
      printf("%d\n", a[0]);
    }else{
      printf("%d ", a[x-i-1]);
    }
  }
}



Measured memory_bytes: 2032
#include <iostream>
#include <vector>
#include <queue>

template <class T>
using MaxHeap = std::priority_queue<T>;

using lint = long long;

void solve() {
    int n;
    std::cin >> n;

    std::vector<lint> xs(n), ys(n);
    for (auto& x : xs) std::cin >> x;
    for (auto& y : ys) std::cin >> y;

    MaxHeap<std::pair<lint, int>> heap;
    for (int i = 0; i < n; ++i) {
        if (xs[i] < ys[i]) heap.emplace(ys[i], i);
    }

    lint cnt = 0;
    while (!heap.empty()) {
        int i = heap.top().second;
        heap.pop();

        int l = (i + n - 1) % n,
            r = (i + 1) % n;
        lint s = ys[l] + ys[r];
        lint d = ys[i] - xs[i];

        if (d % s == 0) {
            cnt += d / s;
            ys[i] = xs[i];
        } else {
            cnt += ys[i] / s;
            ys[i] %= s;
            if (s > d || ys[i] < xs[i]) {
                std::cout << -1 << std::endl;
                return;
            }
            heap.emplace(ys[i], i);
        }
    }

    std::cout << cnt << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 9456
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    int a, b;
    cin >> a >> b;
    if(a <= 9 && b <= 9) cout << a * b << endl;
    else cout << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 3668
n=int(input())
if n==0:
	print(0)
	exit()
x=""
while n!=0:
	y=n%(-2)
	if y==-1:
		y+=2
		x+=str(y)
		n=n//(-2)+1
	else:
		x+=str(y)
		n//=(-2)
print(x[::-1])


Measured memory_bytes: 3060
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //input
        Scanner sc = new Scanner(System.in);
        //int n = sc.nextInt();
        long x = sc.nextLong();

        long n = x/100;
        long n2 = x-(n*100);

//        System.out.println(n);
//        System.out.println(n2);

        if (5*n < n2) System.out.println(0);
        else System.out.println(1);

        sc.close();
    }

    public class Pair<F,S>
    {
        private final F first;
        private final S second;

        Pair(F first,S second)
        {
            this.first = first;
            this.second = second;
        }

        public void print() { System.out.println("("+this.first+","+this.second+")"); }

        //get
        public F first() {return this.first;}
        public S second() {return this.second;}

        @Override
        public boolean equals(Object object)
        {
            if (object instanceof Pair)
            {
                Pair pair = (Pair)object;
                return this.first==pair.first && this.second==pair.second;
            }else
            {
                return false;
            }
        }

        @Override
        public int hashCode()
        {
            return Objects.hash(first,second);
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;

#define rep(i,n) for(ull (i)=0;(i)<(n);++(i))

int main(){
    ll n,k,sum=0;
    cin >> n >> k;
    rep(i,n){
        ll tmp;
        cin >> tmp;
        if(k <= tmp){++sum;}
    }
    cout << sum << endl;
}

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

using namespace std;

int main(){
	long long int n, m, s, t;
	cin >> n >> m >> s >> t;
	s--; t--;
	vector<vector<pair<long long int, pair<long long int, long long int>>>>D(n, vector<pair<long long int, pair<long long int, long long int>>>());
	for( size_t i = 0; i < m; i++ ){
		long long int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		D[u].push_back(make_pair(v, make_pair(a, b)));
		D[v].push_back(make_pair(u, make_pair(a, b)));
	}
	vector<long long int>path1(n, 1LL << 60), path2(n, 1LL << 60);
	path1[s] = 0;
	path2[t] = 0;
	priority_queue<pair<long long int, long long int>, vector<pair<long long int, long long int>>, greater<pair<long long int, long long int>>>que1, que2;
	que1.push(make_pair(0, s));
	que2.push(make_pair(0, t));
	while( que1.size() ){
		auto now = que1.top(); que1.pop();
		for( auto x : D[now.second] ){
			if( path1[x.first] > now.first + x.second.first ){
				path1[x.first] = now.first + x.second.first;
				que1.push(make_pair(path1[x.first], x.first));
			}
		}
	}

	while( que2.size() ){
		auto now = que2.top(); que2.pop();
		for( auto x : D[now.second] ){
			if( path2[x.first] > now.first+ x.second.second ){
				path2[x.first] = now.first + x.second.second;
				que2.push(make_pair(path2[x.first], x.first));
			}
		}
	}

	vector<pair<long long int, long long int>>memo(n);
	for( size_t i = 0; i < n; i++ ){
		memo[i] = make_pair(path1[i] + path2[i], i);
	}

	sort(memo.begin(), memo.end());
	int idx = 0;
	for( size_t i = 0; i < n; i++ ){
		while( memo[idx].second < i ){
			idx++;
		}
		cout << 1000000000000000LL - memo[idx].first << endl;
	}
}


Measured memory_bytes: 14968
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int q;
    cin >> q;

    multiset<ll, greater<ll>> stl;
    multiset<ll> str;
    ll bsum = 0, ans = 0;
    while (q--) {
        ll a, b, c;
        cin >> c;
        if (c == 1) {
            cin >> a >> b;
            bsum += b;

            if (stl.size() == 0) {
                stl.insert(a);
                continue;
            }

            ll lmx = *stl.begin();
            if (a < lmx) stl.insert(a);
            else str.insert(a);
            ans += abs(lmx - a);

            int lsz = stl.size(), rsz = str.size();
            if (lsz == rsz + 2) {
                str.insert(lmx);
                stl.erase(stl.begin());
            } else if (lsz + 1 == rsz) {
                stl.insert(*str.begin());
                str.erase(str.begin());
                ans -= *stl.begin() - lmx;
            }
        } else {
            cout << *stl.begin() << ' ' << ans + bsum << '\n';
        }
    }

    return 0;
}

Measured memory_bytes: 9600
from collections import Counter
from operator import itemgetter

s = input()
t = input()

pairs = set(zip(s, t))
sc = Counter(map(itemgetter(0), pairs))
tc = Counter(map(itemgetter(1), pairs))

if any(count >= 2 for count in sc.values()) or \
        any(count >= 2 for count in tc.values()):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 4144
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

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

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

int main()
{
  ll x,a[30],ans;
  cin >> x;
  rep(i,12)a[i]=x%POW(10,i+3)/POW(10,i);
  ans=INF;
  rep(i,12)ans=min(ans,abs(a[i]-753));
  printf("%lld",ans);
}


Measured memory_bytes: 256
# Wrote in Mar 7, 2020 21:26 by reetok
require 'time'
require 'prime'
require 'bigdecimal'
def inp(type=:to_i,spst=" ")
  return eval("gets.chomp.split(#{spst}).map(&:#{type})")
end
def inpf() return self.inp(:to_f," ") end
def inps() return self.inp(:to_s," ") end
def r_up(a, b) (a/b).ceil end
def r_down(a, b) (a/b).floor end
def sum(a) a.inject(:+) end
def big(a,b) return (a>b)? a:b end
def small(a,b) return (a<b)? a:b end
def minp(n,datatype=".to_i")
  t = []
  n.times do
    t.push(eval("gets.chomp#{datatype}"))
  end
  return t
end
def yes() puts "Yes" end
def no() puts "No" end
def ynju(bool,yes="Yes",no="No") puts (bool ? yes : no) end
class Integer
  def divisor_list
    devisors = [1]
    2.upto(self/2) do |i|
      devisors << i if self%i == 0
    end
    devisors << self
    return devisors.uniq.sort
  end
end
class Array
  def upper(a) #aより上
    self.sort.select{|n|n>=a}
  end
  def downer(a) #aより下
    self.sort.select{|n|n<=a}
  end
end
#---------------

s = gets.chomp
if s=="AAA"||s=="BBB"
  no
else
  yes
end

Measured memory_bytes: 2680