akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define N 100010
using namespace std;
int n,m,pp[N];
int g[N],sz[N];
void init(){
    for(int i=1;i<=n;i++){
        g[i] = i;sz[i]=1;
    }
}
int find(int p){
    if(g[p]==p) return p;
    else return g[p] = find(g[p]);
}
void uni(int p,int q){
    p=find(p);q=find(q);
    if(rand()&1) g[p]=q,sz[q]+=sz[p];
    else g[q]=p,sz[p]+=sz[q];;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>pp[i];
    init();
    for(int i=0;i<m;i++){
        int x,y;cin>>x>>y;
        uni(x,y);
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(find(i)==find(pp[i])) cnt++;
    }
    cout<<cnt<<'\n';
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
map<int,int> a;
set<int> s;

int main(){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x] = i;
  }
  ll ans = 0;
  s.insert(-1);
  s.insert(n);
  for (int i = 1; i <= n; i++) {
    int pos = a[i];
    auto it = s.lower_bound(pos);
    int r = *it;
    it--;
    int l = *it;
    s.insert(pos);
    ans += (ll)i * (r - pos) * (pos - l);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  ll n,d;
  cin >> n >> d;
  vector<ll> x(n);
  vector<ll> y(n);
  rep (i,n) cin >> x[i] >> y[i];
  ll res = 0;
  rep (i,n) {
    double a = sqrt(x[i]*x[i]+y[i]*y[i]);
    if (a <= d) res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 6360
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 4001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

// MOD確認

int main(){
    ll N;
    cin >> N;
    set<string> st;
    rep(i,N){
        string S;
        cin >> S;
        st.insert(S);
    }
    cout << st.size() << endl;
}


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

const int MAX = 30;
int dp[MAX + 1];

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

	dp[0] = 1;
	for (int i = 0; i <= MAX - 1; i++) {
		for (int j = 1; j <= 3; j++) {
			if (i + j <= MAX)
				dp[i + j] += dp[i];
		}
	}

	int n;
	while (cin >> n , n) {
		cout << ((dp[n] + 9) / 10 + 364) / 365 << endl;
	}
}

Measured memory_bytes: 1192
import java.util.Scanner;

public class Main {

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

	int c=a*b;
	if(c%2==0){
		System.out.println("Even");
	}else{
		System.out.println("Odd");
	}

	}}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    vector<LL> v(N);
    REP(i, N) {
        cin >> v[i];
    }
    sort(ALL(v));
    LL n = *(v.end() - 1);
    LL r = *v.begin();
    REP(i, N - 1) {
        if(r < min(v[i], n - v[i])) {
            r = v[i];
        }
    }
    cout << n << " " << r << endl;
    return 0;
}



Measured memory_bytes: 1024
/**
 *    author:  tourist
 *    created: 29.12.2019 22:13:37       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = (long long) 1e18;
  for (int p = 0; p < 2; p++) {
    long long cur = 0;
    long long s = 0;
    for (int i = 0; i < n; i++) {
      s += a[i];
      if (i % 2 == p) {
        if (s < 1) {
          cur += 1 - s;
          s = 1;
        }
      } else {
        if (s > -1) {
          cur += s - -1;
          s = -1;
        }
      }
    }
    ans = min(ans, cur);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());
            
            int[] a = new int[N];
            for(int i = 0;i < N; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }

            var j = 1;
            var count = 0;
            while(j != 2)
            {
                j = a[j-1];
                count++;
                if (count == N)
                {
                    count = -1;
                    break;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 15172
use std::io::*;

fn main() {
    let mut n = read_v();
    n.sort();
    println!("{}", n[0] + n[1]);
}

fn read_v() -> Vec<u32> {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.split_whitespace()
        .map(|c| c.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

int main()
{
	int n;
	cin >> n;
	vector<long double> hoge;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		hoge.push_back(tmp);
	}
	sort(hoge.begin(), hoge.end());
	reverse(hoge.begin(), hoge.end());
	while (hoge.size() > 1)
	{
		long double ll = hoge.back();
		hoge.pop_back();
		long double ll2 = hoge.back();
		hoge.pop_back();
		hoge.erase(hoge.end(), hoge.end());
		hoge.push_back((ll + ll2) / 2);
	}
	cout << hoge[0];
}


Measured memory_bytes: 31488
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5+100)
from collections import *

class FordFulkerson:
    def __init__(self, N, edges):
        self.N = N
        self.G = defaultdict(lambda : defaultdict(int))
        
        for s, t, cap in edges:
            self.G[s][t] = cap
        
    def dfs(self, v, t, f):
        if v==t:
            return f
        
        self.used[v] = True
        
        for nv, cap in self.G[v].items():
            if not self.used[nv] and self.G[v][nv]>0:
                d = self.dfs(nv, t, min(f, self.G[v][nv]))
                
                if d>0:
                    self.G[v][nv] -= d
                    self.G[nv][v] += d
                    
                    return d
        
        return 0
    
    def max_flow(self, s, t):
        flow = 0
        
        while True:
            self.used = [False]*self.N
            f = self.dfs(s, t, 10**18)
        
            if f==0:
                return flow
        
            flow += f

V, E = map(int, input().split())
edges = [tuple(map(int, input().split())) for _ in range(E)]
ff = FordFulkerson(V, edges)
print(ff.max_flow(0, V-1))


Measured memory_bytes: 6252
#include<bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

typedef long long   ll;
typedef long double ld;
const int N  = 5e5+10;
const int M  = 20;
const ll mod = 1e9+7;
const ll inf = 1e18;
 
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb              push_back
#define mp              make_pair
#define ub              upper_bound                 // first element >  val(itr)
#define lb              lower_bound                 // first element >= val(itr) 
#define all(x)          (x).begin(),(x).end()
#define reset(a,x)      memset(a,x,sizeof(a))       // x can be 0 or -1
#define leadzero(a)     __builtin_clz(a)            // count leading zeroes
#define trailzero(a)    __builtin_ctz(a)            // count trailing zeroes
#define bitcount(a)     __builtin_popcount(a)       // count set bits
#define iceil(n,x)      ((n)+(x)-1)/(x)
#define test            int t; cin>>t; while(t--)
#define forn(i,a,e)     for(ll i = a; i < e; i++)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;    }
ll powm(ll base,ll exp){ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
ll add(ll a,ll b)  { return (a%mod+b%mod)%mod;        }
ll sub(ll a, ll b) { return (a%mod+mod-b%mod)%mod;    }
ll mult(ll a,ll b) { return ((a%mod)*(b%mod))%mod;    }
ll choose2(ll n)   { ll ans=(n*(n-1))/2; return ans;  }
ll dist2(ll x1,ll y1,ll x2,ll y2){ ll ans=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1); return ans;}
ll a,b,c,d;

ll solve(ll n)
{ 
  ll ans=0;
  ans+=(n/c);
  ans+=(n/d);
  ll L=(c*d)/(gcd(c,d));
  ans-=(n/L);
  return n-ans;
}

int main()
{
    fast
    ll ans=0;
    cin>>a>>b>>c>>d;
    
    ans=solve(b)-solve(a-1);
    cout<<ans; 


    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static Scanner sc = new Scanner(System.in);
	
	int[][] map = new int[8][8];
	
	void blust(int x, int y) {
		map[x][y] = 0;
		int i = 1;
		while (x + i < 8 && i <= 3) {
			if (map[x+i][y] == 1)
				blust(x+i, y);
			i++;
		}
		
		i = 1;
		while (x - i >= 0 && i <= 3) {
			if (map[x-i][y] == 1)
				blust(x-i, y);
			i++;
		}
		
		i = 1;
		while (y + i < 8 && i <= 3) {
			if (map[x][y+i] == 1)
				blust(x, y+i);
			i++;
		}
		
		i = 1;
		while (y - i >= 0 && i <= 3) {
			if (map[x][y-i] == 1)
				blust(x, y-i);
			i++;
		}
	}
	
	void run() {
		int n , x, y;
		n = Integer.parseInt(sc.nextLine());
		
		String s;
		for (int k = 1; k <= n; k++) {
			sc.nextLine();
			for (int i = 0; i < 8; i++) {
				s = sc.nextLine();
				for (int j = 0; j < 8; j++) {
					map[j][i] = Integer.parseInt(s.substring(j, j+1));
				}
			}
			x = Integer.parseInt(sc.nextLine());
			y = Integer.parseInt(sc.nextLine());
			blust(x-1, y-1);
			
			System.out.printf("Data %d:\n", k);
			for (int i = 0; i < 8; i++) {
				for (int j = 0; j < 8; j++) {
					System.out.print(map[j][i]);
				}
				System.out.println();
			}
		}
		
		
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}

Measured memory_bytes: 17372
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define double long double
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}



signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<": ";
    int n;
    cin>>n;
    int ans=(2*power(9,n))%mod-power(8,n);//+2*power(9,n-1);
    ans%=mod;
    ans=power(10,n)-ans;
    ans%=mod;
    ans+=mod;
    ans%=mod;
    cout<<ans<<endl;
}


return 0;
}





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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000010
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >


ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<bool>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);

ll block;
struct query{
    ll l, r, ind, res;
};

bool compare(query a, query b)
{
    if(a.l / block != b.l / block)
        return a.l / block < b.l / block;
    return a.r < b.r;
}

bool compare1(query a, query b)
{
    return a.ind < b.ind;
}

void solve()
{
	ll n, q;
	cin>>n>>q;
	vl a(n);
	block = sqrt(n);
	vector<query> qry(q);
	for(ll i = 0; i < n; i++) cin>>a[i];
	for(ll i = 0; i < q; i++)
	{
	    ll a, b;
	    cin>>a>>b;
	    a--;
	    b--;
	    qry[i].l = a;
	    qry[i].r = b;
	    qry[i].ind = i;
	    qry[i].res = 0;
	}
	
	sort(all(qry), compare);
	vl freq(MAX, 0);
	ll cl = 0, cr = 0, dist = 0;
	for(ll i = 0; i < q; i++)
	{
	    ll L = qry[i].l, R = qry[i].r;
	    
	    while(cl < L)
	    {
	        freq[a[cl]]--;
	        if(freq[a[cl]] == 0)
	            dist--;
	        cl++;
	    }
	    while(cl > L)
	    {
	        freq[a[cl - 1]]++;
	        if(freq[a[cl - 1]] == 1)
	            dist++;
	        cl--;
	    }
	    while(cr <= R)
	    {
	        freq[a[cr]]++;
	        if(freq[a[cr]] == 1)
	            dist++;
	        cr++;
	    }
	    while(cr > R + 1)
	    {
	        freq[a[cr - 1]]--;
	        if(freq[a[cr - 1]] == 0)
	            dist--;
	        cr--;
	    }
	    qry[i].res = dist;
	}
	sort(all(qry), compare1);
	for(ll i = 0; i < q; i++)
	    cout<<qry[i].res<<"\n";
	    
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin>>t;
	while(t--)
	{
		solve();		
	}
	return 0;
}

ll mulmod(ll a, ll b)
{
	ll res = 0; 
	a = a % MOD;
	while(b > 0)
	{
		if (b % 2 == 1)
			res = (res + a) % MOD;
 
		a = (a * 2) % MOD; 
		b /= 2;
	} 
	return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
	ll res = 1;
	while(n > 0)
	{
		if(n % 2 != 0)
		{
			res = (res * a) % MOD;
		}
		n /= 2;
		a = (a * a) % MOD;
	}
	return res;
}

void getprime(vector<bool>&prime)
{
	prime[0] = false;
	prime[1] = false;
	
	for(ll i = 2; i * i <= MAX; i++)
	{
		if(prime[i])
		{
			for(ll j = i*i; j <= MAX; j += i)
				prime[j] = false;
		}
	}
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
	fact[0] = 1;
	ifact[0] = 1;
	
	for(ll i = 1; i <= MAX; i++)
	{
		fact[i] = (fact[i-1] * i)%MOD;
		ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
	}
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
	ll res;
	res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
	return res;
}

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

int main(){
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=y/2;++i){
        if(4*x-2*i==y){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 3128
/*
  Contest 084
  A - New Year
  Rakesh Kumar --> 17/09/2020
 */

#include <bits/stdc++.h>

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

    int m = 0;
    std::cin >> m;
    std::cout << 48 - m << std::endl;

    return 0;
}


Measured memory_bytes: 3548
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

string s;

int solve() {
    int zero_one = 0;
    int one_zero = 0;
    for (int i = 0; i < s.length(); ++i) {
        if ((i % 2 == 0) && (s[i] != '0')) {
            zero_one++;
        } else if ((i % 2 == 1) && (s[i] != '1')) {
            zero_one++;
        }

        if ((i % 2 == 0) && (s[i] != '1')) {
            one_zero++;
        } else if ((i % 2 == 1) && (s[i] != '0')) {
            one_zero++;
        }
    }
    return (zero_one < one_zero) ? zero_one : one_zero;
}

int main(void) {
    cin >> s;
    int ans = solve();
    cout << ans << endl;
}


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

int main(void) {
	int a[4][3][10] = {0};
	int n, b, f, r, v, i, j, k;
	cin >> n;
	while (n--) {
		cin >> b >> f >> r >> v;
		a[b-1][f-1][r-1] += v;
	}
	for (i = 0; i < 4; i++) {
		if (i)
			cout << "####################" << endl;
		for (j = 0; j < 3; j++) {
			for (k = 0; k < 10; k++) {
				cout << ' ' << a[i][j][k];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef pair<int,ll> Pil;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 466666;
int n;ll a[N],b[N],c[N],d[N],qz[N];Pil sta[N];int top;
void shift(ll *a, int p){
	static ll b[N];rep(i,1,n)b[i]=a[i];int len=0;p=p+1<=n?p+1:1;
	while(len<n){
		a[++len]=b[p];p=p+1<=n?p+1:1;
	}
}
Pil operator-(Pil a,Pil b){return mp(a.fi-b.fi,a.se-b.se);}
ll Cross(Pil a,Pil b){return a.fi*b.se-a.se*b.fi;}
int main() {
	read(n);
	rep(i,1,n)read(a[i]);
	rep(i,1,n)read(b[i]);
	int p=max_element(a+1,a+n+1)-a;
	shift(a,p);shift(b,p);
	a[0]=a[n];
	rep(i,1,n)qz[i]=qz[i-1]+2*b[i];
	rep(i,1,n)d[i]=d[i-1]-qz[i-1];
	rep(i,0,n)c[i]=d[i]+a[i];
//	rep(i,0,n)printf("%d:%lld %lld %lld %lld\n",i,a[i],b[i],c[i],d[i]);
	rep(i,0,n){
		auto x=mp(i,c[i]);
		while(top>1&&Cross(x-sta[top-1],sta[top]-sta[top-1])<=0)top--;
		sta[++top]=x;
	}
	double res=0;p=1;
//	rep(i,1,top)printf("%d %lld\n",sta[i].fi,sta[i].se);
	rep(i,0,n-1){
		while(p+1<=top&&sta[p+1].fi<i)p++;
		res+=sta[p].se+1.0*(sta[p+1].se-sta[p].se)/(sta[p+1].fi-sta[p].fi)*(i-sta[p].fi)-d[i];
	//	printf("%d:%lf\n",i,sta[p].se+1.0*(sta[p+1].se-sta[p].se)/(sta[p+1].fi-sta[p].fi)*(i-sta[p].fi));
	}
	res/=n;
	printf("%.11lf\n",res);
	return 0;
}


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

int main(){

//入力
int K, S;
cin >> K >> S;
//答えの変数
int ans = 0;

/*
//総当たり
	for(int X = 0; X <= K; X++){
		if(X <= S){
			for(int Y = 0; Y <= K; Y++){
				if(X + Y <= S){
				for(int Z = 0; Z <= K; Z++){
					if(X + Y + Z == S){
					ans++;	
				}
			}
			} 	
		}
		}
	}
*/

//X + Y + Z = S >> Z = S - Y - X

	for(int X = 0; X <= K ; X++){
		for(int Y = 0; Y <= K ; Y++){
				int Z = S - Y - X;
				if(0 <= Z and Z <= K){
					ans++;
				}
	}
}

cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double

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

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

signed main(){
  string s;cin>>s;string ss[7] = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
  rep(i,7){
    if(s == ss[i]){
      if(i != 6)cout << 7-i-1 << endl;
      else cout << 7 << endl;
      return 0;
    }
  }
} 


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	
	int n, i, j, s, t, u, min;
	int x[100], y[100], z[100][100];
	
	scanf("%d", &n);
	
	for( i = 0; i < n; i++) {
		x[i] = 0;
		y[i] = 1000000;
		for( j = 0; j < n; j++) {
			z[i][j] = -1;
		}
	}
	
	for( i = 0; i < n; i++) {
		scanf("%d %d", &s, &t);
		for( j = 0; j < t; j++) {
			scanf("%d", &u);
			scanf("%d", &z[s][u]);
		}
	}
	y[0] = 0;
	
	while(1) {
		min = 1000000;
		for( i = 0; i < n; i++) {
			if( x[i] != 1 && y[i] < min) {
				min = y[i];
				s = i;
			}
		}
		
		if( min == 1000000) {
			break;
		}
		
		for( i = 0; i < n; i++) {
			if(z[s][i] != -1 && x[i] != 1 && y[s] + z[s][i] < y[i]) {
				y[i] = y[s] + z[s][i];
			}
		}
		x[s] = 1;
	}
	
	for( i = 0; i < n; i++) {
		printf("%d %d\n", i, y[i]);
	}
	
	return 0; 
}
		

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

#define xx first
#define yy second

const int N = 301;

int n, f[4];
bool memo[N][N][N];
double p, ev[N][N][N];

double dp(int x, int y, int z) {
    int w = x + y + z;
    if (!w) return 0;
    if (memo[x][y][z])
        return ev[x][y][z];
    w = n - w;

    double ans = 0.0;
    double px = x * p;
    double py = y * p;
    double pz = z * p;
    if (x) ans += px * (1.0 + dp(x - 1, y, z));
    if (y) ans += py * (1.0 + dp(x + 1, y - 1, z));
    if (z) ans += pz * (1.0 + dp(x, y + 1, z - 1));

    double pw = w * p;
    double bt = 1.0 / (1.0 - pw);
    ans *= bt;
    ans += pw * bt;

    memo[x][y][z] = 1;
    return ev[x][y][z] = ans;
}

void solve() {
    cin >> n;
    fill(f, f + 4, 0);
    for (int i = 0, a; i < n; i++)
        cin >> a, f[a]++;
    for (int i = 0; i <= f[1] ; i++)
        for (int j = 0; j <= f[2]; j++) {
            fill(ev[i][j], ev[i][j] + f[3] + 1, 0.0);
            fill(memo[i][j], memo[i][j] + f[3] + 1, 0);
        }
    p = 1.0 * n;
    p = 1.0 / p;
    cout << dp(f[1], f[2], f[3]) << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << setprecision(15);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 125696
#include<stdio.h>
#include<string.h>
int main()
{
    int i, d, N, count=0;
    scanf("%d", &N);
    for(i=1;i<=3; i++)
    {
        d= N%10;
        N= N/10;
        if(d==7)
        {
            count+=1;
        }
    }
    if(count>=1)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

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

typedef long long ll;
typedef long double ld;

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

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll N, A, B;

    cin >> N >> A >> B;

    cout << min(A * N, B) << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        ary.Sort();

        int pos = ary.Count / 2;
        return ary[pos] - ary[pos-1];
    }

    static List<int> ToIntArray(string strs, int n) {
        var ret = new List<int>(n);
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret.Add(int.Parse(spl[i]));
        return ret;
    }
}


Measured memory_bytes: 18784
//
//  main.cpp
//  ac
//
//  Created by 胡天翼 on 2017/2/21.
//  Copyright © 2017年 胡天翼. All rights reserved.
//

#include <iostream>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#define read freopen("in.txt","r",stdin)
#define maxlongint 2147483647
typedef  long long LL;
typedef  unsigned long long ULL;
#pragma comment(linker, "/STACK:102400000,102400000")
#define fori for(int i=1;i<=n;i++)
#define forj for(int j=1;j<=m;j++)
#define fork for(int k=1;k<=n;k++)
#define FOR(i,n) for(int i=1;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define DREP(i,a,b) for(int i=a;i>=b;i--)
#define DOWN(i,n) for(int i=n;i>=1;i--)
#define enter cout<<endl;
#define in push_back
#define out pop_back
#define sqr(x) ((x)*(x))
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define offcin ios::sync_with_stdio(false)
#define s(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define sd(x,y) scanf("%d%d",&x,&y)
#define sch(s) scanf("%s",s)
#define fillfalse(v) memset(v,false,sizeof(v))
#define filltrue(v) memset(v,true,sizeof(v))
#define f0(a)    memset(a,0,sizeof(a))
#define Fillplus(a)    memset(a,-1,sizeof(a))
#define lowbit(x) x&(-x)
using namespace std;
const int maxn = 1e5+5;
const int N=1e6+5;
const int mod=1e9+7;
int i,x,y,z,n,m,k,t,l,r,mid,cc,ans,tmp,cnt;
string s;
int a[maxn];
int main()
{
    cin>>n;
    fori s(a[i]);
    sort(a+1,a+n+1);
    LL sum=0;
    x=1;
    FOR(i,n-1)
    {
        sum+=(LL) a[i];
        if (sum*2<a[i+1]) x=i+1;
    }
    cout<<n-x+1<<endl;
}

Measured memory_bytes: 640
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define MAX(a,b) (a>b?a:b)
using namespace std;

int main(){
  long int N, A[100001];
  long int allcount=0;
  long int ans;
  cin >> N;
  long int tmp;
  rep(i,N) A[i]=0;
  rep(i,N){
    cin >> tmp;
    if(A[tmp]!=0) allcount++;
    A[tmp]++;
  }
  long int max=0;
  rep(i,N) max = MAX(max, A[i]);
  max--;

  ans = N - 2*(allcount/2 + allcount%2);
  cout << ans << endl;
}


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

int N, Q;
vector<int> edges[200005];
vector<int> add_v[200005];
bool visited[200005];
int counter[200005];

void dfs(int p, int v) {
  if(visited[p]) return;
  visited[p] = true;
  int next_add=v;
  rep(i, add_v[p].size()) {
    next_add+=add_v[p][i];
  }
  counter[p] += next_add;
  for(int i=0; i<edges[p].size(); i++) {
    dfs(edges[p][i], next_add);
  }
}

int main() {
  int a, b, p, x;
  cin >> N >> Q;
  rep(i, N-1) {
    scanf("%d %d", &a, &b);
    a--; b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  rep(i, Q) {
    scanf("%d %d", &p, &x);
    p--;
    add_v[p].push_back(x);
  }
  dfs(0, 0);
  rep(i, N) {
    printf("%d ", counter[i]);
  }
  printf("\n");
  return 0;
}



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

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> a(M);
    for (int i=0; i<M; i++) cin >> a[i].first >> a[i].second;
    
    for (int x=0; x<1000; x++) {
        int keta = 1;
        int nx = x/10;
        vector<int> d(1, x%10);

        while (nx) {
            keta++;
            d.push_back(nx%10);
            nx /= 10;
        }

        reverse(d.begin(), d.end());

        if (keta != N) continue;

        bool ok = true;

        for (int i=0; i<M; i++) {
            if (d[a[i].first-1] != a[i].second) ok = false;
        }

        if (ok) {
            cout << x << endl;
            return 0;
        }

    }
    
    cout << -1 << endl;

    return 0;
}



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

int main() {
 int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d) cout<<"Left"<<endl;
  else if(a+b==c+d) cout<<"Balanced"<<endl;
  else cout<<"Right"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2e5+5;
const int inf=0x3f3f3f3f;
char s[N];
int minn[1<<26],pos[N],pre[N],dp[N],n;

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;++i)
	{
		int f=s[i]-'a';
		pre[i]=pre[i-1]^(1<<f);
		dp[i]=dp[i-1]+1;
			if(minn[pre[i]]==0&&pre[i]!=0)	minn[pre[i]]=inf;
		dp[i]=min(dp[i],minn[pre[i]]+1);
		for(int j=0;j<26;++j)
		{
			int k=pre[i]^(1<<j);
				if(minn[k]==0&&k!=0)	minn[k]=inf;
			dp[i]=min(dp[i],minn[k]+1);
		}
		minn[pre[i]]=min(dp[i],minn[pre[i]]);
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 264320
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)

int n, m, c[100001], cl[2];
vector<int> g[100001];

bool go(int v = 1, int cc = 1){
	if (c[v]){
		if (c[v] != cc)return true;
		return false;
	}
	c[v] = cc;
	++cl[cc - 1];
	cc ^= 3;
	f(i, 0, g[v].size())if (go(g[v][i], cc))return true;
	return false;
}

int main(){
	scanf("%d%d", &n, &m);
	f(i, 0, m){
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	if (go())printf("%lld\n", ((ll)n * (n - 1) >> 1) - m);
	else printf("%lld\n", (ll)cl[0] * cl[1] - m);
}

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



int main() {
  
  long long N;
  scanf("%lld", &N);

  vector<int> v;
  
  while(N>0){
    N--;
    v.push_back(N%26);
    N/=26;
  };

  for(int i=v.size()-1;i>=0;i--){
    printf("%c", 'a'+v[i]);
  }
  printf("\n");

  return 0;
}




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

#define INF (1<<30)

int main(){
	int D,G;	cin>>D>>G;
	vector<int> p(D+1), c(D+1);
	for(int i=1;i<=D;i++){
		cin>>p[i]>>c[i];
	}

	int ans=INF;
	for(int mask=0; mask<(1<<D); mask++){
		int score=0;
		int num=0;
		int needPos=0;

		for(int i=0;i<D;i++){
			if( mask>>i&1){
				score+=(100*(i+1)*p[i+1])+c[i+1];
				num+=p[i+1];
			}else{
				needPos=i+1;
			}
		}

		if(score<G){
			int s1=100*needPos;
			int needNum = ( (G-score)+s1-1 )/s1;
			// あと必要な点数(G-score)を、s1で割る(切り上げ) -> s1点の問題の必要個数

			if(needNum>=p[needPos]){
				continue;
			}

			num+=needNum;
		}

		ans=min(ans,num);
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        scanner.close();
        int sLength = S.length();

        String a = S.substring(0, (sLength-1)/2);
        String b = S.substring((sLength+3)/2 - 1 ,sLength);

        if(a.equals(b)) { 
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using ll = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

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

  const int INF=1e8;
  int n;
  cin>>n;
  vector<int> A(n,0);
  for(int i=1;i<n;i++){cin>>A[i];}
  vector<vector<pair<int,int>>> edge(n);
  for(int i=1;i<n;i++){
    int u,v,p;
    cin>>u>>v>>p;
    edge[u].emplace_back(v,p);
    edge[v].emplace_back(u,p);
  }
  vector<ll> dp(n,0);
  function<void(int,int)> dfs=[&](int v,int p){
    for(auto &u:edge[v]){
      if(u.first==p){continue;}
      dfs(u.first,v);
      dp[v]+=min(dp[u.first],(ll)u.second);
    }
    if(A[v]>0){dp[v]=INF;}
  };
  dfs(0,-1);
  cout<<dp[0]<<endl;
  
  
  return 0;
}



Measured memory_bytes: 3248
def f(a, b):
    return len(str(max(a, b)))
def main():
    n = int(input())
    ans = 100
    for i in range(1, int(n ** 0.5 + 0.5) + 1):
        if n % i == 0:
            ans = min(ans, f(i, n // i))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

vector<int64> gen_vSum(const vector<int>& vA){
    const int N = vA.size();
    vector<int64> vSum(N); vSum[0]=vA[0];
    for(int i=1; i<N; ++i){ vSum[i] = vSum[i-1]+vA[i]; }
    return vSum;
}

int64 min(int64 i1, int64 i2, int64 i3, int64 i4){
    if(i2<i1){ i1=i2; }
    if(i4<i3){ i3=i4; }
    if(i3<i1){ i1=i3; }
    return i1;
}
int64 max(int64 i1, int64 i2, int64 i3, int64 i4){
    if(i2>i1){ i1=i2; }
    if(i4>i3){ i3=i4; }
    if(i3>i1){ i1=i3; }
    return i1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    uint N; cin >> N;
    vector<int> vA(N); for(uint i=0; i<N; ++i){ cin>>vA[i]; }
    vector<int64> vSum = gen_vSum(vA);
    
    int64 ans_min=INT64_MAX;
    uint li=0;
    uint ri=2;
    for(uint c=1; c<N-2; ++c){ // c: center
        
        int64 minPQ = INT64_MAX;
        for(; li<c; ++li){
            int64 P = vSum[li];
            int64 Q = vSum[c] - vSum[li];
            int64 diff = abs(P-Q);
            if(diff<minPQ){ minPQ = diff; continue; }
            break;
        }
        --li;
        
        int64 minRS = INT64_MAX;
        if(ri<=c){ ri=c+1; }
        for(; ri<N; ++ri){
            int64 R = vSum[ri] - vSum[c];
            int64 S = vSum[N-1] - vSum[ri];
            int64 diff = abs(R-S);
            if(diff<minRS){ minRS = diff; continue; }
            break;
        }
        --ri;
        
        int64 P = vSum[li];
        int64 Q = vSum[c] - vSum[li];
        int64 R = vSum[ri] - vSum[c];
        int64 S = vSum[N-1] - vSum[ri];
        int64 minVal = min(P, Q, R, S);
        int64 maxVal = max(P, Q, R, S);
        if(maxVal-minVal<ans_min){
            ans_min = maxVal-minVal;
        }
    }
    cout << ans_min << endl;
    
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>


bool f(pair<string, P> x, pair<string, P> y){
    if (x.first == y.first){
        return x.second.first > y.second.first;
    }else{
        return x.first < y.first;
    }
}

int main(){
    int n;
    cin >> n;
    pair<string, P> p[n];
    rep(i, n) {
        cin >>  p[i].first >> p[i].second.first;
        p[i].second.second = i + 1;
    }
    sort(p, p + n, f);
    rep(i, n){
        cout << p[i].second.second << endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <cinttypes>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll INF = 1e18 + 10;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int ans = 0;

  int st = max(a, c);
  int en = min(b, d);
  ans = en - st;
  if (ans < 0) {
    ans = 0;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
long long n;
long long v[6];
long long ceil2(long long a,long long b)
{
    return (a+b-1)/b;
}
int main()
{
    cin>>n;
    for(int i=1;i<=5;i++)
        cin>>v[i];
    sort(v+1,v+6);
    cout<<ceil2(n,v[1])+4;
    return 0;
}


Measured memory_bytes: 256
//Kaori Miyazono, did I reach you ?
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;              

int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int h, w;
	cin >> h >> w;
	int n = h;
	string s[h];
	for(int i = 0; i < h; i++) cin >> s[i];
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if ( s[i][j] == '#' ) continue;
			int tot = 0;
			if ( i < n - 1 ) if ( s[i + 1][j] == '#' ) tot++;
			if ( i > 0 ) if ( s[i - 1][j] == '#' ) tot++;
			if ( j < w - 1 ) if ( s[i][j + 1] == '#' ) tot++;
			if ( j > 0 ) if ( s[i][j - 1] == '#' ) tot++;
			if ( i < n - 1 && j < w - 1 ) if ( s[i + 1][j + 1] == '#' ) tot++;
			if ( i < n - 1 && j > 0 ) if ( s[i + 1][j - 1] == '#' ) tot++;
			if ( i > 0 && j < w - 1 ) if ( s[i - 1][j + 1] == '#' ) tot++;
			if ( i > 0 && j > 0 ) if ( s[i - 1][j - 1] == '#' ) tot++;
			s[i][j] = '0' + tot;
		}
	}
	for(int i = 0; i < h; i++) cout << s[i] << endl;
	return 0;	
}    

Measured memory_bytes: 256
import sys
n = int(input())

for i in range(3, n + 1):
	x = i
	if x % 3 == 0 or x % 10 == 3:
		sys.stdout.write(' ')
		sys.stdout.write(str(i))
	else:
		while x != 0:
			x = int(x / 10)
			if x % 10 == 3:
				sys.stdout.write(' ')
				sys.stdout.write(str(i))
				break
print()




Measured memory_bytes: 5876
#include <cmath>
#include <iostream>
#include <iomanip>

int main()
{
  double r;
  std::cin >> r;
  std::cout << std::fixed << std::setprecision(6);
  std::cout << M_PI * r * r << " "  << 2 * M_PI * r << std::endl;
  return 0;
}

Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
char s[333];
int n,suf0[333],suf1[333],arr[333],mx[333][333],num[333][333][333],ans;
bool dp[333][333][333];
void upd(int &x,int y)
{
	if (x<y) x=y;
}
void add(int &x,int y)
{
	x+=y;
	if (x>=mod) x-=mod;
}
int main()
{
	scanf("%s",s);n=strlen(s);
	for (int i=1;i<=n;i++) arr[i]=s[i-1]-'0';
	for (int i=n;i>=1;i--)
	{
		suf0[i]=suf0[i+1]+(arr[i]==0);
		suf1[i]=suf1[i+1]+(arr[i]==1);
	} 
	dp[0][0][1]=1;
	for (int k=1;k<=n+1;k++)
	{
		for (int i=n;i>=0;i--)
		{
			for (int j=n;j>=0;j--)
			{
				if (!dp[i][j][k]) continue;
				if (arr[k]==1 || arr[k+1]==1) dp[i][j+1][k+2]=1;
				if (arr[k]==0 || arr[k+1]==0) dp[i+1][j][k+2]=1;
				dp[i][j][k+1]=1;
				if (arr[k]==1 && i) dp[i-1][j+1][k+1]=1;
				if (arr[k]==0 && j) dp[i+1][j-1][k+1]=1;
				if (i) dp[i-1][j][k]=1;
				if (j) dp[i][j-1][k]=1;
			}
		}
	}
	memset(mx,-1,sizeof(mx));
	for (int i=0;i<=n;i++)
	{
		for (int j=0;j<=n;j++)
		{
			for (int k=1;k<=n+1;k++)
			{
				if (dp[i][j][k])
				{
					upd(mx[i+suf0[k]][j+suf1[k]],k);
				}
			}
		}
	}
	num[0][0][n]=1;
	for (int i=0;i<=n;i++)
	{
		for (int j=0;j<=n;j++)
		{
			add(num[i+1][j][0],num[i][j][0]);
			add(num[i][j+1][0],num[i][j][0]);
			for (int k=1;k<=n;k++)
			{
				if (arr[k])
				{
					add(num[i+1][j][k],num[i][j][k]);
					add(num[i][j+1][k-1],num[i][j][k]);
				}
				else
				{
					add(num[i+1][j][k-1],num[i][j][k]);
					add(num[i][j+1][k],num[i][j][k]);
				}
			}
		}
	}
	for (int i=0;i<=n;i++)
	{
		for (int j=0;j<=n;j++)
		{
			if (!i && !j) continue;
			for (int k=0;k<=n;k++)
			{
				if (k<mx[i][j]) 
				{
					if (num[i][j][k]) 
					{
						add(ans,num[i][j][k]);
					}
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128384
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    
    if(a > b){
        printf("a > b\n");
    }
    else if(a < b){
        printf("a < b\n");
    }
    else{
        printf("a == b\n");
    }
    
    return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
using Int = long long unsigned int;
typedef pair<int,int> P;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    int a,b,c; cin>>a>>b>>c;
    cout<<max(0,c-a+b)<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if(a < b)swap(a,b);
  long long int r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  return b;
}
int main(){
  long long int n;
  cin >>n;
  long long int a[n],b[n+1],c[n+1],x=0;
  for(long long int i=0;i<n;i++)cin >>a[i];
  b[0]=0;
  c[0]=0;
  b[1]=a[0];
  c[1]=a[n-1];
  for(long long int i=1;i<n-1;i++){
    b[i+1]=gcd(b[i],a[i]);
  }
  for(long long int i=1;i<n-1;i++){
    c[i+1]=gcd(c[i],a[n-1-i]);
  }
  long long int ans=0;
  for(long long int i=0;i<n;i++){
    long long int temp=0;
    if(i==0)temp=c[n-1];
    else if(i==n-1)temp=b[n-1];
    else temp=gcd(b[i],c[n-1-i]);
    //cout<<temp;
    ans=max(ans,temp);
  }
  cout << ans <<endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		
		String S = sc.nextLine();
		
		char alpha = 'a';
		
		for(int i =0; i < 26; i++){
			if(S.indexOf(String.valueOf(alpha)) == -1){
				System.out.println(alpha);
				return;
			}
			else{
				alpha++;
			}
		}
		System.out.println("None");
	}

}

Measured memory_bytes: 25036
n = int(input())
s = input()
r, g, b = [], [], []
for i in range(n):
    if s[i] == 'R':
        r.append(i)
    elif s[i] == 'G':
        g.append(i)
    else:
        b.append(i)
lr, lg, lb = len(r), len(g), len(b)
ans = lr * lg * lb

for i in r:
    for j in g:
        a = 2 * j - i
        c = 2 * i - j
        if 0 <= a and a <= n-1 and s[a] == 'B':
            ans -= 1
        if 0 <= c and c <= n-1 and s[c] == 'B':
            ans -= 1
        if (i + j) % 2 == 0 and s[(i + j) // 2] == 'B':
            ans -= 1
print(ans)

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
using lint = long long int ;
using Pii = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define _GLIBCXX_DEBUG
 
constexpr int MOD = 1000000007;
const int INF = 1 << 30;
 
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }


// 各操作を行う関数を実装する
 
// AとBに共通して含まれる要素からなる集合を返す
int main(){
lint N,D;
  cin >>N>>D;
  int count=0;
vector<lint> a(N);
  vector<lint> b(N);
 rep(i,N){
       cin >> a[i]>>b[i];
 }
  rep(i,N){

    long long int c = a[i]*a[i]+b[i]*b[i];
    if(c<=D*D){
      count ++;
    }
  }
  cout << count;
}

Measured memory_bytes: 6356
#pragma GCC optimize("O2")
// luogu-judger-enable-o2
#include <bits/stdc++.h>
using namespace std;
const int maxn = 500010;
const int maxm = 500010;
typedef long long ll;
template<class T>
inline void read(T &a)
{
    T s = 0, w = 1;
    char c = getchar();
    while(c < '0' || c > '9')
    {
        if(c == '-') w = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9')
    {
        s = (s << 1) + (s << 3) + (c  ^ 48);
        c = getchar();
    }
    a = s*w;
}
int n,m,Block_Size;
int Block[maxn];
struct Que{
     int l, r, Id;
};
inline int cmp(const Que &a,const Que &b)
{
    return (Block[a.l] < Block[b.l]) || (Block[a.l] == Block[b.l] && a.r < b.r);
}
Que q[maxm];
int Answer[maxm];
int col[maxn];
int sum[maxn],Sum;
inline void Update(int a, int otp)
{
	if (otp == 1 && sum[col[a]] == 0) Sum++;
	if (otp == -1 && sum[col[a]] == 1) Sum--;
    sum[col[a]] += otp;
}
int main()
{

    read(n); read(m);
    Block_Size = (int)sqrt(n);
    for (int i = 1; i <= n; i++)
    {
        read(col[i]);
        Block[i] = i / Block_Size + 1;
    }
    for (int i = 1; i <= m; i++)
    {
        read(q[i].l), read(q[i].r);
        q[i].Id = i;
    }
    sort(q + 1, q + 1 + m,cmp);
    int l(1), r(0);
    for (int i = 1; i <= m; i++)
    {
        while(l < q[i].l)
            Update(l++,-1);
        while(l > q[i].l)
            Update(--l,1);
        while(r < q[i].r)
            Update(++r,1);
        while(r > q[i].r)
            Update(r--,-1);
        Answer[q[i].Id] = Sum;
    }
    for (int i = 1; i <= m; i++)
    {
		printf("%d\n", Answer[i]);
    }
    return 0;
}



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

using namespace std;

int main(){
	long long N;
	scanf("%lld", &N);
	long long m = 1, ans = 0; 
	while (N != 1){
		N = N / 2;
		ans += m;
		m *= 2;
	}
	printf("%lld\n", ans + m);
}

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

int main()
{
	int array[1000];
	int n;
	
	while (scanf("%d", &n), n){
		for (int i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		
		int q;
		scanf("%d", &q);
		
		int l = 0;
		int r = n - 1;
		int cnt = 0;
		while (1){
			int m = (l + r) / 2;
			
			cnt++;
			
			if (q == array[m]){
				break;
			}
			
			else if (l == r){
				break;
			}
			
			else if (q < array[m]){
				r = m - 1;
				if (r < l){
					break;
				}
			}
			
			else if (q > array[m]){
				l = m + 1;
				if (l > r){
					break;
				}
			}
		}
		
		printf("%d\n", cnt);
	}
	
	return 0;
}

Measured memory_bytes: 1032
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	X = LI()
	X.sort()
	X = np.array(X)
	X2 = X ** 2
	m0 = np.sum(X) // N
	m1 = m0+1
	print(min(np.sum(X2) - 2*m0*np.sum(X) + N*m0**2, np.sum(X2) - 2*m1*np.sum(X) + N*m1**2))

if __name__ == '__main__':
	main()

Measured memory_bytes: 12224
#include<bits/stdc++.h>
using namespace std;
struct disjoint_set{
  long parent[1<<17];
  long rank[1<<17];
  disjoint_set(long n){
    for(long i=1;i<=n;i++){
      parent[i]=i;
      rank[i]=0;
    }
  }
  long find(long x){
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
  }
  bool unite(long x,long y){
    x=find(x);
    y=find(y);
    if(x==y)return false;
    if(rank[x]<rank[y])parent[x]=y;
    else{
      parent[y]=x;
      if(rank[x]==rank[y])rank[x]++;
    }
    return true;
  }
  bool is_same(long x,long y){return find(x)==find(y);}
};
long N,M,X,Y,Z,ans;
int main(){
  cin>>N>>M;
  disjoint_set ds(N);
  while(M--){
    cin>>X>>Y>>Z;
    ds.unite(X,Y);
  }
  for(int i=1;i<=N;i++)if(i==ds.find(i))ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792