akhauriyash/Code-Regression huggingface dataset:
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

//
const int MN = 100010;
struct dinic{
	struct edge{
		int to;ll cap;int rev;
		edge(int to,ll cap,int rev): to(to),cap(cap),rev(rev){}
	};

	vector<edge> G[MN];
	ll level[MN];
	int iter[MN];
	
	void init(int N){
		rep(i,N)G[i].clear();
	}
	
	void add_edge(int from,int to,ll cap){
		G[from].pb(edge(to,cap,sz(G[to])));
		G[to].pb(edge(from,0,sz(G[from])-1));
	}
	
	void bfs(int s){
		memset(level,-1,sizeof(level));
		queue<int> que;
		level[s]=0;
		que.push(s);
		while(!que.empty()){
			int v=que.front(); que.pop();
			rep(i,sz(G[v])){
				edge &e = G[v][i];
				if(e.cap>0 && level[e.to]<0){
					level[e.to] = level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	
	ll dfs(int v,int t,ll f){
		if(v==t)return f;
		for(int &i=iter[v]; i<sz(G[v]); i++){
			edge &e = G[v][i];
			if(e.cap>0 && level[v] < level[e.to]){
				ll d=dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	
	int max_flow(int s,int t){
		ll flow=0;
		for(;;){
			bfs(s);
			if(level[t]<0)return flow;
			memset(iter,0,sizeof(iter));
			int f;
			while((f=dfs(s,t,INF*INF))>0){
				flow+=f;
			}
		}
	}
};
//

int H,W,C,M,NW,NC,NM;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	dinic D;
	while(cin>>H>>W>>C>>M>>NW>>NC>>NM && H>=0){
		D.init(H + 2*(W+C) + M + 7);
		int s = H + 2*(W+C) + M;
		int t = s + 6;

		rep(i,H){
			D.add_edge(s,i,1);
		}

		int n,x;
		rep(i,W){
			cin>>n;
			rep(j,n){
				cin>>x;x--;
				D.add_edge(x,H+i,1); 
			}
		}
		rep(i,H){
			D.add_edge(i,s+1,1);
		}

		rep(i,W){
			D.add_edge(H+i,H+W+i,1);
		}
		D.add_edge(s+1,s+2,NW);

		rep(i,C){
			cin>>n;
			rep(j,n){
				cin>>x;x--;
				D.add_edge(H+W+x,H+2*W+i,1);
			}
		}
		rep(i,W){
			D.add_edge(H+W+i,s+3,1);
		}
		rep(i,C){
			D.add_edge(s+2,H+2*W+i,1);
		}

		rep(i,C){
			D.add_edge(H+2*W+i,H+2*W+C+i,1);
		}
		D.add_edge(s+3,s+4,NC);

		rep(i,M){
			cin>>n;
			rep(j,n){
				cin>>x;x--;
				D.add_edge(H+2*W+C+x,H+2*W+2*C+i,1);
			}
		}
		rep(i,C){
			D.add_edge(H+2*W+C+i,s+5,1);
		}
		rep(i,M){
			D.add_edge(s+4,H+2*W+2*C+i,1);
		}

		rep(i,M){
			D.add_edge(H+2*W+2*C+i,t,1);
		}
		D.add_edge(s+5,t,NM);

		cout<<D.max_flow(s,t)<<endl;
	}
}

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

const int Maxn = 1005, p = 1e9 + 7;
int n, m;
long long k;
string str[Maxn];
struct Matrix
{
	long long val[3][3];
	Matrix()
	{
		memset(val, 0, sizeof(val));
	}
	Matrix operator * (const Matrix &A) const
	{
		Matrix ans;
		for (int i = 1; i <= 2; i++)
			for (int j = 1; j <= 2; j++)
				for (int k = 1; k <= 2; k++)
					(ans.val[i][j] += val[i][k] * A.val[k][j]) %= p;
		return ans;
	}
} res;
Matrix fast_pow(Matrix x, long long y)
{
	Matrix ans, now = x;
	ans.val[1][1] = ans.val[2][2] = 1;
	while (y)
	{
		if (y & 1) ans = ans * now;
		now = now * now;
		y >>= 1;
	}
	return ans;
}
int main()
{
	scanf("%d%d%lld", &n, &m, &k);
	for (int i = 1; i <= n; i++)
		cin >> str[i];
	bool flag = false;
	for (int i = 1; i <= n; i++)
		if (str[i][0] == '#' && str[i][m - 1] == '#') res.val[2][2]++, flag = true;
	for (int i = 0; i < m; i++)
		if (str[1][i] == '#' && str[n][i] == '#')
		{
			res.val[2][2]++;
			if (flag)
			{
				puts("1");
				return 0;
			}
		}
	if (!flag)
	{
		for (int i = 1; i < n; i++)
			for (int j = 0; j < m; j++)
				if (str[i][j] == '#' && str[i + 1][j] == '#') res.val[1][2]++;
	}
	else
	{
		for (int i = 1; i <= n; i++)
			for (int j = 0; j < m - 1; j++)
				if (str[i][j] == '#' && str[i][j + 1] == '#') res.val[1][2]++;
	}
	for (int i = 1; i <= n; i++)
		for (int j = 0; j < m; j++)
			res.val[1][1] += str[i][j] == '#';
	if (!res.val[2][2])
		res.val[1][2] = 0;
	Matrix ans = fast_pow(res, k - 1);
	printf("%lld", (ans.val[1][1] - ans.val[1][2] + p) % p);
	return 0;
}

Measured memory_bytes: 5752
import java.util.Scanner;


public class Main {


	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		Long a = Long.parseLong(sc.next());
		Long b = Long.parseLong(sc.next());
		Long c = Long.parseLong(sc.next());
		Long d = Long.parseLong(sc.next());
		
		Long max = -1000000000000000000l;
		
		max = Math.max(max,a * c);
		max = Math.max(max,a * d);
		max = Math.max(max,b * c);
		max = Math.max(max,b * d);
		System.out.println(max);
	}
}


Measured memory_bytes: 26984
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}


int main(){
  ll n ,k; cin>> n>>k ;
  vector<ll> A(n) ; rep(i,n) cin>>A[i] ;
  sort(A.begin(),A.end()) ;
  ll ans= 0;
  rep(i,k){
    ans+=A[i] ;
  }
  cout<<ans<<endl ;
  return 0;
  }

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  cin >> a >> b;
  double p = (a + b) % 2;
  if(p == 1){
  	p / 2;
  }
  double x = (a + b) / 2 + p;
  if(1 - p == 1){
  	x = x - 1;
  }
  cout << x + 1 - p << endl;
}

Measured memory_bytes: 3772
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, less<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(int i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(int i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(int i=0;i<int(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(int)(b);++i)
#define rrep(i,n) for(int i=int(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define irep(i) for(int i=0;;++i)
#define all(n) begin(n),end(n)
inline auto gcd(auto A,auto B){return B?gcd(B,A%B):A;}
inline auto lcm(auto A,auto B){return A/gcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={-1,1,0,0,1,1,-1,-1};
const vector<lint> dy={0,0,-1,1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[](auto f,auto... args){return f(f,args...);};

int main(){
    lint n;
    cin>>n;
    vec c(n);
    rep(i,n)c[i]=i+1;
    vec a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    lint s=-1,t=-1;
    irep(i){
        if(s!=-1&&t!=-1)break;
        if(a==c)s=i;
        if(b==c)t=i;
        next_permutation(all(c));
    }
    cout<<abs(s-t)<<endl;
}


Measured memory_bytes: 256
// Problem : C - Lamps
// Contest : AtCoder - Tokio Marine & Nichido Fire Insurance Programming Contest 2020
// URL : https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long
#define N 200005

int n,k;
vi a;

void operation(){
    vi res(n);
    for(int i=0;i<n;i++){
        int l = max(0LL,i-a[i]);
        int r = min(n-1,i+a[i]);
        res[l]++;
        if(r+1 < n) res[r+1]--;
    }
    for(int i=1;i<n;i++) res[i] += res[i-1];
    a = res;
}

bool is_done(){
    int ret = true;
    for(int i=0;i<n;i++) ret &= (a[i] == n);
    return ret;
}

void solve(){
    cin>>n>>k;
    a.resize(n);
    for(int i=0;i<n;i++) cin>>a[i];
    while(k--){
        operation();
        if(is_done()) break;
    }
    for(int i : a) cout<<i<<" ";
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int t;
    //cin>>t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int b[n+1]{0};
    b[1]=a[n-1];
    b[2]=abs(a[n-2]-a[n-1]);
    b[3]=min((abs(a[n-3]-a[n-2])+b[2]),(abs(a[n-3]-a[n-1])));
    for(int i=4;i<=n;i++){
        b[i] = min((abs(a[n-i]-a[n-i+2])+b[i-2]),(abs(a[n-i]-a[n-i+1])+b[i-1]));
    }
    cout<<b[n]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
long long a[100010],b[50] = {},f[2][50];
int main(){
	long long i,j,n,k,x = 0,ans = 0;
	cin >> n >> k; k++;
	for(i=0;i<n;i++){
		long long c,res = 0;
		cin >> a[i];
		c = a[i];
		while(c>0){
			b[res] += c&1;
			c /= 2; res++;
		}
	}
	for(i=49;i>=0;i--){
		f[0][i] = b[i]*(1LL<<i);
		f[1][i] = (n - b[i])*(1LL<<i);
	}
	vector<int> v;
	while(k>0){
		v.push_back(k&1);
		k /= 2;
	}
	while(v.size()<41){
		v.push_back(0);
	}
	for(i=0;i<v.size();i++){
		if(!v[i]) continue;
		long long res = 0;
		for(j=0;j<i;j++){
			res += max(f[0][j],f[1][j]);
		}
		res += f[0][i];
		for(j=i+1;j<v.size();j++){
			res += f[v[j]][j];
		}
		ans = max(ans,res);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
n = int(input())

h = list(map(int, input().split()))

cnt = 0
ans = 0
low = 0
for i in range(n):
    if cnt < h[i]:
        cnt = h[i]
    elif cnt > h[i]:
        ans += cnt - low
        low = h[i]
        cnt = h[i]
    

ans += cnt - low
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}

lln modMul(lln  a, lln b,lln mod){
    lln ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
lln powerMod(lln a,lln b,lln mod){
	if(b==0)return 1LL%mod;
	lln x=powerMod( a,b/2,mod );
	x = ( x%mod * x%mod ) % mod;
	if( b%2==1 )x = ( x%mod * a%mod ) % mod;
	return x%mod;
}

int main()
{
    lln a;
    cin>>a;
    int maxi=1000000;
    for(lln i=1;i*i<=a;i++)
    {
        if(a%i==0)
        {
            lln x=a/i;
            int c=0,d=0;
            lln y=i;
            while(x>0)
            {
                x/=10LL;
                c++;
            }
            while(y>0)
            {
                y/=10;
                d++;
            }
            int p=max(c,d);
            maxi=min(p,maxi);
        }
    }
    cout<<maxi;
}



Measured memory_bytes: 3392
#include <stdio.h>


int main(void) {

	// 1_2-D Circle in a Rectangle
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

	if( (r<=x) && (x <= (w-r)) && (r<=y) && (y <= (h-r) )){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

        return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define maxN 105
#define maxR 15
using namespace std;
int dp[maxN][maxR],v[maxN],sol,n;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&v[i]);
    }
    /**
        dp[i][j]-ultimul i, rest j
    **/
    for(int i=1;i<=n;i++)
        dp[i][v[i]%10]=v[i];
    for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
            for(int rest=0;rest<10;rest++)
                if(dp[i][rest])
            dp[j][(v[j]+rest)%10]=max(dp[j][(v[j]+rest)%10],dp[i][rest]+v[j]);
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<10;j++)
    {
        sol=max(sol,dp[i][j]);
    }
    printf("%d\n",sol);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long,long>
#define all(a) a.begin(),a.end()
using namespace std;
int gcd(int a, int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}
signed main(){
    int n,m; string s,t;
    cin>>n>>m>>s>>t;
    int l=n*m/gcd(n,m);
    int a=l/n,b=l/m;
    int c=a*b/gcd(a,b);
    rep(i,l/c){
        if(s.at(i*c/a)!=t.at(i*c/b)){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<l<<endl;
}

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

using namespace std;

int main()
{
    int A[5], cnt = 10, answer = 0, tmp = 0;
    for (int i = 0; i < 5; i++)
    {
        cin >> A[i];
    }

    for (int i = 0; i < 5; i++)
    {
        if (cnt >= A[i] % 10 && (A[i] % 10) != 0)
        {
            cnt = A[i] % 10;
            tmp = i;
        }
    }

    for (int i = 0; (i < 5); i++)
    {
        if (i == tmp)
        {
            continue;
        }
        if ((A[i] % 10) != 0)
        {
            A[i] += 10 - (A[i] % 10);
        }

        answer += A[i];
    }
    cout << answer + A[tmp] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string n;
    bool sum=0,sum1=0;
    cin>>n;
    for(int i=0;i<n.length();i++)
    {
        if(n[i]=='C')sum=1;
        if(sum==1)
        {
            if(n[i]=='F')
            sum1=1;
        }
    }
    if(sum==1&&sum1==1)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    ll a[2];
    cin>>a[0]>>a[1];
    ll ans=a[0];
    for(int i=0;i<2;i++){
        ans^=(((a[i]+1)/2)&1)^(a[i]&1?0:a[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var K, S int
	fmt.Scan(&K, &S)

	ans := 0
	for x := 0; x <= K; x++ {
		for y := 0; y <= K; y++ {
			z := S - x - y
			if 0 <= z && z <= K {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

A, B = map(int, input().split())
print('unsafe' if A <= B else 'safe')




# def main():

# if __name__ == '__main__':
#     main()


Measured memory_bytes: 9580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        if (n == 3) {
            System.out.println("2 5 63");
            return;
        }


        final List<Integer> answers = new ArrayList<>();
        answers.add(2);
        answers.add(4);
        answers.add(3);
        answers.add(9);

        int index = 4;
        int two = 8;
        int three = 15;
        while (index < n / 2 * 2) {
            if (two < 30_000) {
                answers.add(two);
                two += 2;
                answers.add(two);
                two += 4;
                index += 2;
            } else if (three < 30_000) {
                answers.add(three);
                three += 6;
                answers.add(three);
                three += 6;
                index += 2;
            } else {
                break;
            }
        }

        int six = 6;
        while (index < n) {
            answers.add(six);
            six += 6;
            index++;
        }

        final String answer = answers.stream()
                .map(Object::toString)
                .collect(Collectors.joining(" "));
        System.out.println(answer);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

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


Measured memory_bytes: 28936
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int m;
	scanf("%d", &m);
	ll sum = 0;
	ll tot = 0;
	for (int i = 0; i < m; ++i) {
		int d;
		ll c;
		scanf("%d%lld", &d, &c);
		sum += d * c;
		tot += c;
	}
	ll ans = tot - 1 + (sum - 1) / 9;
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
n = int(input())
s = input()
a = [False for _ in range(1000)]
for j in range(1000):
  t = str(j).zfill(3)
  if(s.find(t[0:1]) > -1):
    s1 = s[s.find(t[0:1])+1:]
    if(s1.find(t[1:2]) > -1):
      s2 = s1[s1.find(t[1:2])+1:]
      if(s2.find(t[2:3]) > -1):
        a[j] = True
ans = 0
for i in range(1000):
  if(a[i]):
    ans += 1
print(ans)
    

Measured memory_bytes: 9304
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

public class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int arr[]=new int[n];
        for (int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        int cnt=0;
        for (int i=1;i<n-1;i++){
            if ((arr[i]>arr[i-1] && arr[i]<arr[i+1]) || (arr[i]<arr[i-1] && arr[i]>arr[i+1]) ){
                cnt++;
            }
        }
        System.out.println(cnt);

    }

}



Measured memory_bytes: 21844
A, B, C = map(int,input().split())

dict = {}
ans = 0
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    A, B, C = (B+C)/2,(C+A)/2,(A+B)/2
    ans += 1
    string = str(A) + "_" + str(B) + "_" + str(C)
    if string in dict:
        print(-1)
        exit()
    else:
        dict[string] = string

print(ans)

Measured memory_bytes: 3064
*S, = map(int, open(0).readline().strip())
N = len(S)
ok = 1
for i in range(N-1):
    if S[i] != S[-2-i]:
        ok = 0
        break
if not ok or S[0] != 1 or S[-1] != 0:
    print(-1)
    exit(0)

E = []
V = [i+1 for i in range(N//2) if S[i]]
p = 1
for v in V:
    for i in range(p, v):
        E.append("%d %d\n" % (i, v))
    p = v

E.append("%d %d\n" % (p, p+1))
p += 1
for i in range(p+1, N+1):
    E.append("%d %d\n" % (p, i))
open(1, 'w').writelines(E)

Measured memory_bytes: 14240
//B
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;

int main(){
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	string s;
	cin >> s;
	int cnt = 0;
	for (auto i : s) {
		cnt += (i - '0'); cnt %= 9;
	}
	if (cnt > 0) printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 3732
chars = (None, '.,!? ', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqrs', 'tuv', 'wxyz')
n = int(input())

while n:
    n -= 1
    s = input()
    number, counter = 0, 0
    for c in s:
        if c == '0':
            if number:
                charset = chars[number]
                print(charset[(counter - 1) % len(charset)], end='')
                number, counter = 0, 0
        elif counter:
            counter += 1
        else:
            number = int(c)
            counter = 1
    print()

Measured memory_bytes: 7580
#include<stdio.h>
int main()
{

    long int n,min,max,i,sum=0, a[100000];


    scanf("%ld",&n);
    for(i=0;i<n;i++)
    {
       scanf("%ld",&a[i]);
    }
 min=a[0];
   for(i=1;i<n;i++)
   {
       if(a[i]<min)
       {
          min=a[i];

       }
   }
    max=a[0];
        for(i=1;i<n;i++)
   {
        if(a[i]>max)
       {
          max=a[i];
       }
   }

    for(i=0;i<n;i++)
    {
        sum+=a[i];

    }
   printf("%ld %ld %ld\n",min,max,sum);


return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long int

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int N;
    cin>>N;
    vector<int> in;
    vector<int> num;
    for(int i = 0; i < N; i++){
        int n; cin>>n; in.push_back(n);
    }
    sort(in.begin(), in.end());
    for(int i = N-1; i > 0; i--){
        if(in[i] == in[i-1]){
            num.push_back(in[i]);
            i--;
        }
        if(num.size() == 2) break;
    }
    // for(auto itr = in.rbegin(); itr != in.rend(); itr++) {
    //     if(*itr == *(itr+1)){
    //         num.push_back(*itr);
    //         itr++;
    //         continue;
    //     }
    //     if(num.size() == 2) break;
    // }
    
    if(num.size() < 2) cout<<0<<endl;
    else{
        ll a = num[0];
        ll b = num[1];
        cout<<a*b<<endl;
    }
    return 0;
}

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

int main(){
  int n;
  scanf("%d", &n);
  double r = 0.0;
  for(int i=0; i<n; ++i){
    char buf[100];
    char tp[5];
    scanf("%s%s", buf, tp);
    if(tp[0] == 'J'){
      int y;
      sscanf(buf, "%d", &y);
      r += y;
    }else{
      double b;
      sscanf(buf, "%lf", &b);
      r += b*380000.0;
    }
  }
  printf("%lf", r);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void)
{
    int n, i, l[10], max, suml;
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &l[i]);
    }
    max=l[0];
    suml=l[0];
    for(i=1;i<n;i++){
        suml=l[i]+suml;
        if(max<l[i])
            max=l[i];
    }
    if(max<suml-max)
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        List<Pair> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int X = scan.nextInt();
            int L = scan.nextInt();
            list.add(new Pair(X, L));
        }
        list.sort(new PairComparator());
        int ans = 0;
        int right = Integer.MIN_VALUE;
        for (int i = 0; i < N; i++) {
            Pair p = list.get(i);
            if (right <= p.X - p.L) {
                ans += 1;
                right = p.RIGHT;
            }
        }
        System.out.println(ans);
    }
    class Pair{
        int RIGHT;
        int X;
        int L;
        Pair(int X, int L) {
            this.X = X;
            this.L = L;
            this.RIGHT = X + L;
        }
    }
    class PairComparator implements Comparator<Pair> {
        @Override
        public int compare(Pair o1, Pair o2) {
            if (o1.RIGHT != o2.RIGHT){
                return Integer.compare(o1.RIGHT, o2.RIGHT);
            }
            return Integer.compare(o1.L, o2.L);
        }
    }
}


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

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

signed main(void){
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int a = 0;
    rep(i, n) {
        if (s[i] == 'R') a++;
        else a--;
    }
    cout << (a > 0 ? "Yes" : "No") <<endl;
    return 0;
}


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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define dbg(x) std::cerr<<#x<<" = " << (x) << std::endl
#define pnl(x) std::cout << x << "\n"

typedef	std::vector<int>	vi;
typedef std::pair<int,int>	ii;
typedef std::vector<std::string>	vs;
typedef std::vector<ii>	vii;
typedef std::vector<long long>	vl;
typedef	long long ll;


const int	NB_D = 4;
const int	DY[] = {-1, 1, 0, 0};
const int	DX[] = {0, 0, -1, 1};

int		main(void)
{
	std::ios_base::sync_with_stdio(false);
	int	a, b;
	std::cin >> a >> b;

	pnl((a * b % 2 == 0 ? "Even" : "Odd"));
}



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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

pll A[305 * 305];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W, D;
    cin >> H >> W >> D;
    REP(i, H) {
        REP(j, W) {
            ll a;
            cin >> a;
            A[a - 1] = pll(i, j);
        }
    }
    vector<vector<ll>> S(D);
    REP(i, D) {
        S[i].push_back(0);
        for (ll j = 1; i + D * j < H * W; ++j) {
            ll x = i + D * j, y = i + D * (j - 1);
            S[i].push_back(S[i][j - 1] + abs(A[x].first - A[y].first) + abs(A[x].second - A[y].second));
        }
    }

    ll Q;
    cin >> Q;
    REP(i, Q) {
        ll l, r;
        cin >> l >> r;
        l--;
        r--;
        ll index = l % D;
        ll x = l / D;
        ll y = r / D;
        cout << S[index][y] - S[index][x] << endl;
    }
    return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;

vector<ll> dp;
vector<int> hidx;
vector<int> a;
int digit;

ll query(int q) {
  int idx = q + digit - 1;
  ll ret = dp[idx];
  while (idx) {
    if (idx % 2 == 0) {
      ret = max(ret, dp[idx - 1]);
    }
    idx = (idx - 1) / 2;
  }
  return ret;
}

void update(int q, ll v) {
  int idx = q + digit - 1;
  while (1) {
    dp[idx] = max(dp[idx], v);
    if (idx == 0) {
      break;
    }
    idx = (idx - 1) / 2;
  }
}

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  digit = 1;
  REP(i, 30) {
    if (n <= digit) {
      break;
    }
    digit <<= 1;
  }
  dp = vector<ll>((digit << 1) - 1, 0);
  hidx = vector<int>(n);
  a = vector<int>(n);
  REP(i, n) {
    int h;
    cin >> h;
    h--;
    hidx[h] = i;
  }
  REP(i, n) {
    cin >> a[i];
  }

  REP(i, n) {
    update(hidx[i], query(hidx[i]) + a[hidx[i]]);
  }
  cout << dp[0] << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 5888
#include <iostream>

using namespace std;

int main() {
    int n,x,ok=1;
    cin>>n;
    while(n--){
        cin>>x;
        if(x%2==0){
            if(!(x%3==0 || x%5==0)){
                ok=0;
                break;
            }
        }
    }
    if(ok==1)   cout<<"APPROVED";
    else        cout<<"DENIED";
    return 0;
}

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

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	vector<int> v(in());
	for (int &x: v)
		x = in();
	auto e = unique(v.begin(), v.end());
	for (auto i = v.begin(); i != e; i++) {
		if (i != v.begin())
			out(' ');
		out(*i);
	}
	outl();
}


Measured memory_bytes: 2632
#include<cstdio>
#include<map>
#include<vector>
#include<algorithm>


using namespace std;
using vi=vector<int>;


struct grp
{
	int p;
	int parent;
	vi g;
};


using vgrp=vector<grp>;


int parent_seek(vgrp&vg, int a)
{
	int pa, top;

	for(pa=a;vg[pa].parent!=pa;pa=vg[pa].parent)
		;

	top=pa;
	for(pa=a;pa!=top;pa=vg[pa].parent)
		vg[pa].parent=top;

	return top;
}


void combine(vgrp&vg, int a, int b)
{
	int pa, pb;
//return;
	pa=parent_seek(vg, a);
	pb=parent_seek(vg, b);

	if(vg[pa].g.size()<vg[pb].g.size())
	{
		swap(a, b);
		swap(pa, pb);
	}
	if(pa!=pb)
	{
		vg[pb].parent=pa;
		copy(vg[pb].g.begin(), vg[pb].g.end(), back_inserter(vg[pa].g));
		vg[pb].g.clear();
	}
}


int main(void)
{
	int n, m;

	while(scanf("%d%d", &n, &m)==2)
	{
		vgrp vg(n+1);

		for(int i=1;i<=n;i++)
		{
			int p;
			scanf("%d", &p);
			vg[p].p=i;
			vg[p].parent=p;
			vg[p].g.push_back(i);
		}

		for(int i=0;i<m;i++)
		{
			int x, y;
			scanf("%d%d", &x, &y);
			combine(vg, x, y);
		}

		for(int i=1;i<=n;i++)
		{
			parent_seek(vg, i);
		}

		int ans=0;
		for(int i=1;i<=n;i++)
		{
			for(auto&x:vg[i].g)
			{
				if(vg[x].parent==i) ans++;
			}
		}

		if(0)
		{
			for(int i=1;i<=n;i++)
			{
				printf("%2d[%2d] :", i, vg[i].parent);
				for(int j=0;j<vg[i].g.size();j++)
				{
					printf(" %d", vg[i].g[j]);
				}
				printf("\n");
			}
			printf("\n");
		}

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

	return 0;
}


Measured memory_bytes: 10232
#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

int solve(int way, vector<int>ls, int A, int B, int C) {
	int a = 0, b = 0, c = 0;
	int cost = 0;
	for (auto l : ls) {
		int tar = way & 3; way >>= 2;
		switch (tar) {
		case 0:if (a)cost += 10; a += l; break;
		case 1:if (b)cost += 10; b += l; break;
		case 2:if (c)cost += 10; c += l; break;
		case 3:break;
		}
	}
	if (!a || !b || !c)return INF;
	return abs(A - a) + abs(B - b) + abs(C - c) + cost;
}

int main()
{
	int N, A, B, C;
	cin >> N >> A >> B >> C;
	vector<int> l(N);
	REP(i, N)cin >> l[i];

	int res = INF;
	REP(i, 1 << (2 * N)) res = min(res, solve(i, l, A, B, C));
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    Runtime.getRuntime().addShutdownHook(new Thread(() -> out.close()));
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));

    int N = sc.nextInt();


    String s = String.valueOf(N);
    String[] strings = s.split("");

    int SN = Arrays.stream(strings).map(Integer::parseInt).reduce(0, ((integer, accumu) -> integer+accumu));

    String ans = "No";
    if (N%SN==0){
      ans = "Yes";
    }
    out.println(ans);
    out.close();
  }

  /*          
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 28628
#include <cstdio>
#include <cstring>
#define Inf 0x7f7f7f7f
int dist[100005];
int head[100005],arrive[200005],nxt[200005],tot;
void add_edge(int from,int to){
	arrive[++tot]=to;
	nxt[tot]=head[from];
	head[from]=tot;
}
int mx(int a,int b){
	return a>b?a:b;
}
int mn(int a,int b){
	return a<b?a:b;
}
int left[100005],right[100005];
int father[100005];
bool visit[100005];
bool get_ans;
int ab(int a){
	return a<0?-a:a;
}
void dfs(int root){
	if(!get_ans){
		return;
	}
	left[root]=-Inf;
	right[root]=Inf;
	if(visit[root]){
		left[root]=right[root]=dist[root];
	}
	for(int i=head[root];i;i=nxt[i]){
		if(arrive[i]==father[root]){
			continue;
		}
		father[arrive[i]]=root;
		dfs(arrive[i]);
		if(!get_ans){
			return;
		}
		if(left[arrive[i]]>-Inf/2){
			if(left[root]<-Inf/2){
				left[root]=left[arrive[i]]-1;
				right[root]=right[arrive[i]]+1;
			}
			else{
				if((ab(left[arrive[i]])&1)==(ab(left[root])&1)){
					get_ans=0;
					return;
				}
				left[root]=mx(left[root],left[arrive[i]]-1);
				right[root]=mn(right[root],right[arrive[i]]+1);
				if(left[root]>right[root]){
					get_ans=0;
					return;
				}
			}
		}
	}
}
void find_ans(int root){
	if(!visit[root]){
		dist[root]=left[root];
	}
	for(int i=head[root];i;i=nxt[i]){
		if(arrive[i]==father[root]){
			continue;
		}
		if(!visit[arrive[i]]){
			if(dist[root]-1>=left[arrive[i]]&&dist[root]-1<=right[arrive[i]]){
				dist[arrive[i]]=dist[root]-1;
				visit[arrive[i]]=1;
			}
			else{
				dist[arrive[i]]=dist[root]+1;
				visit[arrive[i]]=1;
			}
		}
		find_ans(arrive[i]);
	}
}
int main(){
	int n;
	scanf("%d",&n);
	int u,v;
	for(int i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		add_edge(u,v);
		add_edge(v,u);
	}
	int k;
	scanf("%d",&k);
	for(int i=1;i<=k;i++){
		scanf("%d%d",&u,&v);
		dist[u]=v;
		visit[u]=1;
	}
	get_ans=1;
	dfs(1);
	if(!get_ans){
		puts("No");
	}
	else{
		find_ans(1);
		puts("Yes");
		for(int i=1;i<=n;i++){
			printf("%d\n",dist[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 7552
#include <stdio.h>
#include <math.h>
int main(void){
    
    int n,max=1,i,j=1;

    scanf("%d",&n);
    
    for(i=2;i<=n;i++){
        if(i%(int)(pow(2,j))==0){
            max=i;
            j++;
        }
    }

    printf("%d\n",max);

    return 0;    
}


Measured memory_bytes: 2572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = (int)1e9+7;
const double PI = 3.14159265359;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	//ctrl + /cin>>t;
	t = 1;
	while(t--){
		int n,m;
		cin>>n>>m;
		ll sum = 0;
		vector<int> a(n+1);
		for(int i=1;i<=n;i++){
			cin>>a[i];
			sum += a[i];
		}
		int cnt = 0;
		for(int i=1;i<=n;i++){
			if(4*m*a[i]>=sum)
				cnt++;
		}
		if(cnt>=m) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}
































Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class BGoToJail {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int[] d1 = new int[n];
            int[] d2 = new int[n];
            for (int i = 0; i < n; i++) {
                d1[i] = Integer.parseInt(in.next());
                d2[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < n - 2; i++) {
                if (d1[i] == d2[i] && d1[i + 1] == d2[i + 1] && d1[i + 2] == d2[i + 2]) {
                    out.println("Yes");
                    return;
                }
            }
            out.println("No");
            return;

        }

    }
}



Measured memory_bytes: 35776
a,b,k = map(int,input().split())
for i in range(k):
  if i%2!=0:
    if b%2 != 0:
      b = b-1
    b = b/2
    a = b+a
  else:
    if a%2 != 0:
      a = a-1
    a = a/2
    b = b+a
print(round(a), round(b))

Measured memory_bytes: 3060
class Node
  attr_accessor :name, :child, :done, :cost
  def initialize(i)
    @name = i
    @child = {}
    @done = false
    @cost = 1.0 / 0.0
  end
end

v, e, r = gets.split.map(&:to_i)

node = Array.new(v){|i| Node.new(i)}
e.times{
  s, t, d = gets.split.map(&:to_i)
  node[s].child[t] = d
}

node[r].cost = 0

(v-1).times{|i|
  v.times{|j|
    node[j].child.each{|t,d|
      if node[t].cost > node[j].cost + d then
        node[t].cost = node[j].cost + d
      end
    }
  }
}

v.times{|j|
  node[j].child.each{|t,d|
    if node[j].cost + d < node[t].cost then
      puts "NEGATIVE CYCLE"
      exit
    end
  }
}

v.times{|j|
  node[j].cost = "INF" if node[j].cost == 1.0 / 0.0
  puts node[j].cost
}

Measured memory_bytes: 8900
def f;gets.split.map &:to_i;end
while(n,m=f)[0]>0
o=(u=(0..2).map{(i=f)[0]=0;i}).reverse.map &:dup
r=[o,u].map{|a,b,c|(0..m).find{|d|!(b[1]||a[1]&&c[1])||!(s,t=a[-1]>b[-1]?[b,a]:[a,b];s.push t.pop;a,c=c,a)}||1e8}.min
p r<1e8?r:-1
end

Measured memory_bytes: 6132
#include<iostream>
using namespace std;
int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    if (x == y && x != z)
        cout << z;
    else if (x == z && z != y)
        cout << y;
    else if (y == z && y != x)
        cout << x;
  
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	const int mod = 1e9 + 7;
	int n, k; cin >> n >> k;
	vi a(n); rep(i, n) cin >> a[i];
	ll ans = 0;
	rep(i, n) for(int j = i + 1; j < n; j++) if(a[i] > a[j]) ans++;
	
	int sml[2001] = {};
	rep(i, n) rep(j, n) if(a[i] > a[j]) sml[a[i]]++;
	rep(i, 2000) sml[i + 1] += sml[i];
	
	ans *= k;
	ans += sml[2000] % mod * (k * (k - 1ll) / 2 % mod) % mod;
	cout << ans % mod << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

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

    if (x < 600) cout << "8\n";
    else if (x < 800) cout << "7\n";
    else if (x < 1000) cout << "6\n";
    else if (x < 1200) cout << "5\n";
    else if (x < 1400) cout << "4\n";
    else if (x < 1600) cout << "3\n";
    else if (x < 1800) cout << "2\n";
    else cout << "1\n";

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

map<long long,int> mp;
vector<long long> prime_factorization(long long a){
    vector<long long> v;
    if(a==1) v.push_back(1);
    long long i=2,n=a;
    while(n>1){
        if(a<i*i){
            v.push_back(i);
            mp[n]++;
            return v;
        }
        if(n%i==0){
            n/=i;
            v.push_back(i);
            mp[i]++;
        }else{
            i++;
        }
    }
    return v;
}
int main(){
    long long n,p; cin>>n>>p;
    if(n==1){
        cout<<p<<endl;
        return 0;
    }
    vector<long long> v=prime_factorization(p);
    long long ans=1;
    for(auto i:mp){
        ans*=pow(i.first,i.second/n);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256