akhauriyash/Code-Regression huggingface dataset:
import itertools
import math

n = int(input())

xy = [list(map(int, input().split())) for _ in range(n)]

l = range(n)

d_list =[]

for v in itertools.permutations(l):
    d = 0
    for i in range(n-1):
        f = v[i]
        t = v[i+1]
        d += math.sqrt((xy[t][0] - xy[f][0]) ** 2 + (xy[t][1] - xy[f][1]) ** 2)
    d_list.append(d)

print(sum(d_list) / math.factorial(n))

Measured memory_bytes: 75840
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int deta[11];

	for (int i = 0; i < 10; i++){
		cin >> deta[i];
	}

	sort (deta, deta + 10);

	for (int i = 9; i >= 7; i--){
		cout << deta[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3124
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>

int main(void) {
	double x1, x2;
	double y1, y2;
	double distance = 0;
	double x = 0, y = 0;

	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

	if (x1 < x2) {
		x = x2 - x1;
	}
	else if(x1 >= x2) {
		x = x1 - x2;
	}

	if (y1 < y2) {
		y = y2 - y1;
	}
	else if(y1 >= y2) {
		y = y1 - y2;
	}

	distance = (x*x) + (y*y);
	distance = sqrt(distance);

	printf("%f\n", distance);
	return 0;
}


Measured memory_bytes: 2108
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#include<unordered_set>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 0x2aaaaaaa; // 715,827,882
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first
#define sc  second


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

	set<int> s;
	rep(i, k) {
		if(a+i<=b) s.insert(a + i);
	}
	rep(i, k) {
		if (b-i >= a) s.insert(b - i);
	}
	for (int a : s) cout << a << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    int n,d,X;std::cin>>n>>d>>X;
    for(int i=0;i<n;i++){
        int x;std::cin>>x;
        X+=(d+x-1)/x;
    };
    std::cout<<X<<std::endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int digitsNumber(int num)
{
    int digits = 0;
    while (num > 0){
        num /= 10;
        digits++;
    }

    return digits;
}

int main()
{

    int given;  cin >> given;
    int test = 0, answer = 0;

    for (int i = 0; i <= given; i++){
        if (digitsNumber(test) % 2 != 0){\
            answer++;
        }
        test++;
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuffer sb1 = null;
		StringBuffer sb2 = new StringBuffer();
		String cards;
		while (!(cards = input.readLine()).equals("-")) {
			sb1 = new StringBuffer(cards);
			int shuffle = Integer.parseInt(input.readLine());
			int i = 0;

			while (i != shuffle) {
				i++;
				int n = Integer.parseInt(input.readLine());
				String str = sb1.substring(0, n);
				sb1.delete(0, n);
				sb1.append(str);
			}
			sb2.append(sb1 + "\n");
		}
		System.out.print(sb2);

	}

}

Measured memory_bytes: 17076
#include<iostream>
#include<vector>
#include<map>
#include<numeric>
#define ll long long
#define PI 3.14159265359

using namespace std;

int main() {
  int n,m;
  cin >> n >> m;
  long long ans=0;
  for(int i=0;i<m;++i){
    int a;
    cin >> a;
    ans += a;  
  }

  if(n >= ans){
    cout << n-ans << endl;
  }else{
    cout << -1 << endl;
  }
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> V(N),C(N);
	for(int i = 0; i < N ; i++)cin >> V[i];
	for(int i = 0; i < N ; i++) cin >> C[i];
	
	int ans = 0;
	for(int i =0;i<N;i++){
		int k = V[i] - C[i];
		if(k > 0) ans +=k;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cerr << #x << " = " << x << "\n";
#define debug_v(x) cerr << #x << " ="; for(auto it : x) {cerr << " [" <<  it << "]";} cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
const double PI = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18 + 100;
void add_self(int& a, int b){
	a += b;
	if(a >= mod){
		a -= mod;
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(20);
	int H, W;
	cin >> H >> W;
	vector<vector<char>> grid(H, vector<char>(W));
	for(int i = 0;i < H;++i){
		for(int j = 0;j < W;++j){
			cin >> grid[i][j];
		}
	}
	vector<vector<int>> dp(H, vector<int>(W));
	dp[0][0] = 1;
	for(int i = 0;i < H;++i){
		for(int j = 0;j < W;++j){
			if(grid[i][j] == '#'){
				continue;
			}
			if(i - 1 >= 0){
				add_self(dp[i][j], dp[i - 1][j]);
			}
			if(j - 1 >= 0){
				add_self(dp[i][j], dp[i][j - 1]);
			}
		}
	}
	cout << dp[H - 1][W - 1] << '\n';
	return 0;
}


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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int x;
    cin>>x;
    if(x==1)cout<<0;
    else cout<<1;
    return 0;
}

Measured memory_bytes: 3636
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, K, S = map(int, read().split())

if S != 1:
    ans = [S - 1] * N
else:
    ans = [S + 1] * N
for i in range(K):
    ans[i] = S

print(*ans)


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

int main() {
  int n;
  int cal=0;
  int sum_a=0,sum_b=0;
  cin >> n;
  vector<int> a(n);
  
  for(int i=0; i<n; i++) cin >> a.at(i);
  for(int i=0; i<n-1; i++){
    for(int j=n-1; j>i; j--){
      if(a.at(j)>a.at(j-1)){
        cal=a.at(j);
        a.at(j)=a.at(j-1);
        a.at(j-1)=cal;
      }
    }
  }
  
  for(int i=0; i<n; i++){
    if(i%2==0) sum_a+=a.at(i);
    else sum_b+=a.at(i);
  }
  
  cout << sum_a-sum_b << endl;
  
}




Measured memory_bytes: 256
#include <cstdio>

inline int readin(){
	int x=0,c;
	for (;(c=getchar())<'0'||c>'9';);
	for (;c>='0'&&c<='9';c=getchar()) x=x*10+c-48;
	return x;
}

int f[100005];
int h[100005];

int abs(int x){return x>0?x:-x;}

int min(int x,int y){return x>y?y:x;}

int main(){
	int n=readin();
	for (int i=1;i<=n;i++) h[i]=readin();
	h[0]=h[1];
	for (int i=2;i<=n;i++) f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
	printf("%d\n",f[n]);
}

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

int main(){
    int N, K;
    cin >> N >> K;
    double Pn = 1/(double)N;
    vector<double> p(N,Pn);
    int dice[N];
    for (int i = 0; i < N; i++)
    {
        dice[i] = i+1;
    }
    for (int i = 0; i < N; i++)
    {
        while(dice[i] < K){
            dice[i]*=2;
            p[i]/=2;
        }
    }
    double ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += p[i];
    }
    printf("%.12f",ans);
}

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

const int N = 1e5 + 5;

map<char,char> dna;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    dna['A'] = 'T';
    dna['T'] = 'A';
    dna['G'] = 'C';
    dna['C'] = 'G';
    char c;
    cin>>c;
    cout<<dna[c]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N);
    rep(i, N)cin >> A[i];
    vector<ll> B(M);
    rep(i, M)cin >> B[i];
    vector<ll> cumA(N+1,0);
    vector<ll> cumB(M+1,0);
    rep(i,N)cumA[i+1] = cumA[i] + A[i];
    rep(i,M)cumB[i+1] = cumB[i] + B[i];
    //X冊読むとしたときにK分以内にできるか(O(N+M));
    auto check = [&](ll X){
        ll minn = INFLL;
        rep(i,N+1){
            ll j = X - i;
            if(j > M)continue;
            if(j < 0)continue;
            chmin(minn, cumA[i] + cumB[j]);
        }
        return minn <= K;
    };
    ll ok = 0;
    ll ng = N+M+1;
    while(ng - ok > 1){
        ll mid = (ok + ng) >> 1;
        if(check(mid))ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,k;
	double sum=0.0;
	cin >> n >> k;
	for(ll i=1;i<=n;i++){
		ll cnt=0;
		ll now=i;
		while(now<k){
			cnt++;
			now*=2;
		}
		sum+=pow(0.5,cnt);
	}
	cout << DOUBLE << sum/n << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  	int n;
  	cin >> n;
  	ll a[n];

  	ll M = 0;
  	int num;
  	for(int i=0;i<n;i++){
  		cin >> a[i];
  		if(a[i]>=M){
  			num = i;
  			M = a[i];
  		}
  	}

  	
	ll error = 10000000000;
	int num2;
	for(int i=0;i<n;i++){
		if(min(abs(a[i]-M/2), abs(a[i]-(M+1)/2)) <=error){
			num2 = i;
			error = min(abs(a[i]-M/2), abs(a[i]-(M+1)/2));
		}
	}
	cout << a[num] << " " << a[num2] <<endl;

  	


    
  	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)

#define INF INT_MAX / 2 - 1
#define PI 2*acos(0.0)
#define ll long long

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

int main() {
	int n, w;
	cin >> n >> w;
	struct { int v, w; } item[100];
	REP(i, n)
		cin >> item[i].v >> item[i].w;
	int dp[101][10001] = {};
	REP(i, n)
	FOR(j, 1, w+1)
		if (j < item[i].w)
			dp[i+1][j] = dp[i][j];
		else
			dp[i+1][j] = max(dp[i][j], dp[i+1][j-item[i].w] + item[i].v);
	cout << dp[n][w] << endl;
	return 0;
}

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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

const int maxn = 2e5 + 100;

ll a[maxn];

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

ll lcm(ll a, ll b)
{
  return a * (b / __gcd(a,b));
}

char f(char c)
{
  if(c == 'r')
    return 'p';
  else if(c == 'p')
    return 's';
  else
    return 'r';
}

int main()
{

  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  int j = 1;
  for(int i = 0 ; i < n ; i++)
  {
    int a;
    cin >> a;
    if(a == j)
      j++;
  }

  cout << ( j == 1 ? -1 : (n - j + 1)) << endl;
  return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using li = unsigned long long int;
using namespace std;

int main() {
    fastIO;
    string s;
    cin >> s;
    bool word[26]{false};
    for (auto ch : s) {
        if (word[ch - 'a'] == true) {
            cout << "no";
            return 0;
        }
        word[ch - 'a'] = true;
    }
    cout << "yes";
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <map>
#include <algorithm>
using namespace std;
struct data{
    int x,y;
    bool operator==(const data&r)const{
        return x==r.x&&y==r.y;
    }
    bool operator<(const data&r)const{
        if(x==r.x)return y<r.y;
        return x<r.x;
    }
}a[100010];
map<data,int> m;
map<data,int> chk;
long long ans[10];
int x[]={-1,-1,0,1,1,1,0,-1,0},y[]={0,1,1,1,0,-1,-1,-1,0};
int main(){
    int i,j,k,n,w,h,r,c,p;
    scanf("%d%d%d",&h,&w,&n);
    for(i=1;i<=n;++i)scanf("%d%d",&a[i].x,&a[i].y);
    sort(a+1,a+n+1);
    for(i=1;i<=n;++i){
        for(j=0;j<9;++j){
            r=a[i].x+x[j],c=a[i].y+y[j];
            if(r>1&&r<h&&c>1&&c<w&&!chk[{r,c}]){
                chk[{r,c}]=1;
                int s=0;
                for(k=0;k<9;++k){
                    data t={r+x[k],c+y[k]};
                    p=lower_bound(a+1,a+n+1,t)-a;
                    if(a[p]==t)++s;
                }
                ++ans[s];
            }
        }
    }
    long long sum=0;
    for(i=1;i<10;++i)sum+=ans[i];
    ans[0]=(long long)(h-2)*(w-2)-sum;
    for(i=0;i<10;++i)printf("%lld\n",ans[i]);
    return 0;
}


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

using namespace std;

int main () {
    int N;
    cin >> N;
    float A;
    float ans;
    for (int i = 0; i < N; i++) {
        cin >> A;
        ans += 1 / A;
    }
    cout << 1 / ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int h, w;
    while (true) {
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) cout << '#';
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



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


const LL mod = 998244353;

LL modpow(LL a, LL b){
    if(b == 0) return 1;
    LL k = modpow(a, b/2);
    k = k * k % mod;
    if(b&1) k = k * a % mod;
    return k;
}

LL memoinv[600000];
LL modinverse(LL a){
    if(memoinv[a]) return memoinv[a];
    return memoinv[a] = modpow(a, mod-2);
}

LL binom[600000];

int main() {
    LL N, K;
    cin >> N >> K;
    if(N > K){
        cout << 0 << endl;
        return 0;
    }
    
    binom[0] = 1;
    for(int i=1; i<=K; i++){
        binom[i] = binom[i-1] * (K-i+1) % mod * modinverse(i) % mod;
    }
    
    LL ans = 0;
    LL B = 0;
    while(2 * B <= K){
        if(2*B <= K-N) ans = (ans + binom[B]) % mod;
        else if(2*B < K){
            ans = (ans + binom[B]) % mod;
            LL d = 2*B - K + N;
            LL r = 0;
            if(d-1 <= K) r = binom[d-1];
            //~ cerr << d-1 << ' ' << binom[d-1] << endl;
            ans = (ans + mod - r) % mod;
        }else if(2*B == K){
            LL r = binom[B];
            r = (r * (K-B)) % mod;
            r = (r * modinverse(K)) % mod;
            ans = (ans + r) % mod;
            
            r = binom[N-2];
            r = (r * (K-N+2)) % mod;
            r = (r * modinverse(K)) % mod;
            ans = (ans + mod - r) % mod;
        }
        //~ cerr << "B = " << B << ";  " << ans << endl;
        B++;
    }
    cout << ans << '\n';
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int32 a, b;
	cin >> a >> b;

	cout << (a%b&1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
#define pb push_back
#define FLOW int
//using FLOW = int;
namespace flow{
    constexpr FLOW INF = 1e7;
    struct edge{
        FLOW flow;
        int to,rev;
    };
    typedef vector<edge> E;
    typedef vector<E> Graph;
    void addedge(Graph&g,int from,int to,FLOW f){
        int x=g[from].size();
        int y=g[to].size();
        g[from].pb(edge{f,to,y});
        g[to].pb(edge{(FLOW)0,from,x});
    }

    vector<int> bfs(Graph& G,int s){
        int N = G.size();
        queue<int> que;
        vector<int> dist(N,-1);
        dist[s] = 0;
        que.push(s);
        for(;!que.empty();que.pop()){
            auto v=que.front();
            for(auto& e : G[v])
                if(e.flow>0&&dist[e.to]==-1){
                    dist[e.to] = dist[v] + 1;
                que.push(e.to);
                }
        }
        return dist;
    }
}
FLOW maxflow(flow::Graph& G,int s,int t){
    using namespace flow;
    FLOW res=0;
    int N = G.size();
    while(true){
        auto dist = bfs(G,s);
        if(dist[t] < 0)break;
        vector<unsigned> iter(N,0);
        std::function<FLOW(int,FLOW)> dfs=[&](int v,FLOW f){
            if(v==s)return f;
            for(auto &i = iter[v]; i < G[v].size(); i++){
                edge &e = G[v][i];
                edge &re = G[e.to][e.rev];
                if(re.flow>0 && dist[v] >dist[e.to]){
                    FLOW d=dfs(e.to,min(f,re.flow));
                    if(d>0){e.flow+=d;re.flow-=d;return d;}
                }
            }
            return (FLOW)0;
        };
        FLOW f;
        while((f=dfs(t,INF))> 0)res+=f;
    }
    return res;
}

int N,M;
int A[1001];
int B[1001];
int main(){
	int N,M;
	cin>>N>>M;
	string s;
	cin>>s;
	REP(i,N){
		cin>>A[i];
	}
	flow::Graph g(N+10);
	REP(i,M){
		int a,b,c;
		cin>>a>>b>>c;
		int d=min(a,b);
		int e=max(a,b);
		flow::addedge(g,d,e,c);
	}
	
	REP(i,N){
		if(s[i]=='L'){
			flow::addedge(g,0,i+1,0);
			flow::addedge(g,i+1,N+1,A[i]);
		}else{
			flow::addedge(g,0,i+1,A[i]);
			flow::addedge(g,i+1,N+1,0);
		}
	}
	cout<<maxflow(g,0,N+1)<<endl;
}


Measured memory_bytes: 3320
#include<stdio.h>
#include<stdbool.h>
#define N 8
#define NFR -1
#define FR 1


int row[N], col[N], dpos[2*N-1], dneg[2*N-1];
bool S[N][N];

void initialize(){
  int i;
  for( i = 0 ; i < N ; i++){
    row[i] = FR;
    col[i] = FR;
  }
  for( i = 0 ; i < 2*N-1 ; i++){
    dpos[i] = FR;
    dneg[i] = FR;
  }
}

void print(){
  int i, j;
  for( i = 0 ; i < N ; i++){
    for( j = 0 ; j < N ; j++){
      if( S[i][j] ){
        if( row[i] != j) return;
      }
    }
  }

  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N ; j++ ){
      if(row[i] != j)
      printf(".");
      else printf("Q");
    }
    printf("\n");
  }
}

void qeen(int i){
  int j;
  if( i == N ){
    print();
    return;
  }

  for( j = 0 ; j < N ; j++ ){
    // {i, j }がクイーンの攻撃範囲にあるか調査
    if( col[j] == NFR || dpos[i+j] == NFR || dneg[i-j+(N-1)] == NFR) continue;
    //{i, j}がクイーンの攻撃範囲に入っていなければクイーンの配置
    row[i] = j;
    col[j] = NFR;
    dpos[i+j] = NFR;
    dneg[i-j+(N-1)] = NFR;
    //　次の行
    qeen(i+1);
    row[i] = FR;
    col[j] = FR;
    dpos[i+j] = FR;
    dneg[i-j+(N-1)] = FR;
  }
}

int main(){
  int i, j, k, r, c;

  initialize();

  for( i = 0 ; i < N ; i++){
    for( j = 0 ; j < N ; j++){
      S[i][j] = false;
    }
  }

  scanf("%d", &k);
  for( i = 0 ; i < k ; i++){
    scanf("%d%d", &r, &c);
    S[r][c] = true;
  }
  qeen(0);

  return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

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

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

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

	if (b < 10)
	{
		a *= 10;
	}
	else if (b < 100)
	{
		a *= 100;
	}
	else
	{
		a *= 1000;
	}

	int n = a + b;
	string s = "No";
	REP(i, 1005)
	{
		if (n == i*i)
		{
			s = "Yes";
			break;
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
local s = io.read()
local num = tonumber(s)
local outstr = ""

local _map = {
	["AC"] = 0,
	["WA"] = 0,
	["TLE"] = 0,
	["RE"] = 0
}
local t = {
	"AC",
	"WA",
	"TLE",
	"RE"
}
for i=1,num do
	s = io.read()
	if _map[s] then
		_map[s] = _map[s] + 1
	end
end

-- for k,v in pairs(_map) do
-- 	outstr = outstr .. k .. " x " .. v .. "\n"
-- end
for k,v in pairs(t) do
	outstr = outstr .. v .. " x " .. _map[v] .. "\n"
end
print(outstr)

Measured memory_bytes: 2700
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

int main()
{
	cin >> n >> m;
	if (n % 3 == 0 || m % 3 == 0 || (n + m) % 3 == 0) {
		cout << "Possible" << endl;
	} else {
		cout << "Impossible" << endl;
	}

}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    array = [[] for _ in range(n+1)]
    temp = []
    for _ in range(m):
        a, b = map(int, input().split())
        array[a].append(b)
        array[b].append(a)
        temp.append([a, b])
    result = 0
    from collections import deque
    while len(temp) > 0:
        a, b = temp.pop()
        array[a].remove(b)
        array[b].remove(a)
        d = deque([1])
        pop = d.popleft
        append = d.append
        flag = [True] * (n + 1)
        while len(d) > 0:
            now = pop()
            for to in array[now]:
                if flag[to]:
                    append(to)
                    flag[to] = False
        for f in flag[1:]:
            if f:
                result += 1
                break
        array[a].append(b)
        array[b].append(a)
    print(result)
main()

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> grid(H, vector<char> (W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> grid.at(i).at(j);
    }
  }
  vector<vector<int>> dp(H, vector<int> (W));
  dp.at(0).at(0) = 1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (grid.at(i).at(j) == '.' && j != W - 1) {
        dp.at(i).at(j + 1) += dp.at(i).at(j);
        dp.at(i).at(j + 1) %= 1000000007;
      }
      if (grid.at(i).at(j) == '.' && i != H - 1) {
        dp.at(i + 1).at(j) += dp.at(i).at(j);
        dp.at(i + 1).at(j) %= 1000000007;
      }
    }
  }
  cout << dp.at(H - 1).at(W - 1) << endl;
  return 0;
}

Measured memory_bytes: 8540
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
    let mut buff = String::new();
    stdin().read_line(&mut buff).unwrap();
    let mut itr = buff.split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let mut buff = String::new();
    stdin().read_line(&mut buff).unwrap();
    let mut itr = buff.split_whitespace();
    let r: i32 = itr.next().unwrap().parse().unwrap();
    let s: i32 = itr.next().unwrap().parse().unwrap();
    let p: i32 = itr.next().unwrap().parse().unwrap();
    let mut buff = String::new();
    stdin().read_line(&mut buff).unwrap();
    let mut itr = buff.split_whitespace();
    let t: String = itr.next().unwrap().parse().unwrap();
    // let mut t2 = t.chars();
    let t2 = t.chars().collect::<Vec<char>>();

    let mut vec = vec!['\0'; k];
    let mut res = 0;
    for i in 0..n {
        let index = i % k;
        let aitenote = t2[i];
        if vec[index] == aitenote {
            vec[index] = '\0';
        } else {
            match aitenote {
                'r' => { res += p; vec[index] = 'r'; }
                's' => { res += r; vec[index] = 's'; }
                'p' => { res += s; vec[index] = 'p'; }
                _ => { /* unreachable code */ }
            }
        }
    }


    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let ans = format!("{}", res);
    writeln!(out, "{}", ans).unwrap();
}

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

int main() {
    int N, Z, W; cin >> N >> Z >> W;
    vector<int> a(N); for (auto &x : a) cin >> x;
    if (N == 1) cout << abs(W - a[0]) << endl;
    else cout << max(abs(W - a[N-1]), abs(a[N-2] - a[N-1])) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
   

int main()
 {
 	long long int n,i,k,j,ans,s=0;
 	cin>>k;
 	for(i=1;i<=k;i++)
 		{
 			for(j=1;j<=k;j++)
 			{
 				for(n=1;n<=k;n++)
 					{
					 
 					ans=gcd(i,j);
 					s+=gcd(ans,n);
 				}
			 }
		 }
 	cout<<s<<endl;
 }
 	

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
 
  for(int i=0 ; i<N ; i++)
    cin >> a.at(i);
 
  int n = 0;
 
  for(int j=0 ; n<N ; n++){
    if(a.at(j) == 2){
      n++;
      break;
    }
    else
      j = a.at(j) - 1;    
  }
 
  if(n == N)
    cout << -1 << endl;
  else
    cout << n << endl;  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    string s;
    cin >> s;
    (s == "AAA" || s == "BBB") ? cno : cyes;

    
    
    
    

    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using cd = complex<ld>;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  ll res = 0;
  for (int i = n - 1; i >= 0; i--) {
    a[i] += res;
    a[i] %= b[i];
    res += a[i] == 0 ? 0 : b[i] - a[i];
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 4784
#include<iostream>
using namespace std;
 
int main(){
	int x,y;
  	cin >> x >> y;
   int a;
  a=y-x*2;
  if(a<0)
    cout << "No" << endl;
  else if(a%2==0 && (a/2)<=x)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
using namespace std;
using ll = long long;
int main()
{
	ll a, b, c, d;
	cin >> a;
	cin >> b;
	cin >> c;
	if (a+b==c||a+c==b||b+c==a)
	{
		cout << "Yes" << endl;
	}
	else
	{
	cout << "No" << endl;

	}

	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



i64 a,b;
void solve(){
	cin >> a >> b;
	if(b-a >= 2019) cout << 0 << endl;
	else{
		i64 ans = INF;
		for(i64 i = a; i < b; i++){
			for(i64 j = a+1; j <= b; j++){
				chmin(ans, i*j % 2019);
			}
		}
		cout << ans << endl;
	}
}

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

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

string s;
vector<int> G[100010];
int d[100010];
int ver = 0;
int idx = 0;

void add(int now, int par){
    int num = 0;
    if(par != -1) G[par].push_back(now);
    while(1){
        if(s[idx] == '['){
            ver++;
            idx++;
            add(ver, now);
        }else if(isdigit(s[idx])){
            num = num * 10 + s[idx] - '0';
            idx++;
        }else if(s[idx] == ']'){
            if(num != 0){
                d[now] = (num + 1) / 2;
            }
            idx++;
            break;
        }
    }
}

int dfs(int now, int pre){
    if(d[now] != 0) return d[now];
    int res = 0;
    vector<int> cd;
    rep(i, 0, G[now].size()){
        int nxt = G[now][i];
        int tmp = dfs(nxt, now);
        cd.push_back(tmp);
    }
    sort(cd.begin(), cd.end());
    rep(i, 0, (cd.size() + 1) / 2){
        res += cd[i];
    }
    return d[now] = res;
}

int main() {
    int tc;
    cin >> tc;
    rep(ij, 0, tc){
        cin >> s;
        rep(i, 0, 100010) G[i].clear();
        memset(d, 0, sizeof(d));
        ver = 0; idx = 1;
        add(0, -1);
        int ans = dfs(0, -1);
        cout << ans << endl;
    }
}


Measured memory_bytes: 6012
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<stack> 
#define LL long long
#define M 401000
using namespace std;
const int p=1e30;
int n,m,r,w[M],cnt,to[M],next[M],head[M],deep[M],fa[M],siz[M],son[M],top[M],id[M],wt[M],zz;
struct node{
	int l,r;
	LL tag,sum;
}t[M*4];
struct edge{
	int to,next;
}e[M];
void add(int a,int b)
{
	cnt++;
	e[cnt].to=b;
	e[cnt].next=head[a];
	head[a]=cnt;
}
void build(int x,int y,int now)
{
	t[now].tag=0;
	t[now].l=x;
	t[now].r=y;
	if (x==y)
	{
		t[now].sum=wt[x];
	}
	else
	{
		int mid=(x+y)>>1;
		build(x,mid,now*2);
		build(mid+1,y,now*2+1);
		t[now].sum+=(t[now*2].sum+t[now*2+1].sum);
	}
	t[now].sum%=p;
	return;
}
void spread(int u)
{
	t[u*2].sum+=(t[u*2].r-t[u*2].l+1)*t[u].tag;
	t[u*2].sum%=p;
	t[u*2+1].sum+=(t[u*2+1].r-t[u*2+1].l+1)*t[u].tag;
	t[u*2+1].sum%=p;
	t[u*2].tag+=t[u].tag;
	t[u*2].tag%=p; 
	t[u*2+1].tag+=t[u].tag;
	t[u*2+1].tag%=p;
	t[u].tag=0;
	return;
}
void change1(int now,int x,int y,int v)
{
	if (x>y)
	{
		return;
	}
	if (t[now].l>=x&&t[now].r<=y)
	{
		t[now].sum+=(t[now].r-t[now].l+1)*v;
		t[now].sum%=p;
		t[now].tag+=v;
		t[now].tag%=p;
		return;
	}
	spread(now);
	int mid=(t[now].l+t[now].r)>>1;
	if (x<=mid)
		change1(now*2,x,y,v);
	if (y>mid)
		change1(now*2+1,x,y,v);
	t[now].sum=(t[now*2].sum+t[now*2+1].sum)%p;
	return;
}
int sumup(int x,int y,int now)
{
	if (x>y)
	{
		return 0;
	}
    if(x<=t[now].l && y>=t[now].r) return t[now].sum%p;
    spread(now);
    int mid=(t[now].l+t[now].r)>>1;
    int ans=0;
    if(x<=mid) ans=(ans+sumup(x,y,now*2))%p;
    if(y>mid) ans=(ans+sumup(x,y,now*2+1))%p;
    return ans%p;
}
void dfs1(int x,int f,int depth)
{
	deep[x]=depth;
	fa[x]=f;
	siz[x]=1;
	int maxson=-1;
	for (int i=head[x];i;i=e[i].next)
	{
		int y=e[i].to;
		if (y==f)
		{
			continue;
		}
		dfs1(y,x,depth+1);
		siz[x]=siz[x]+siz[y];
		if (siz[y]>maxson)
		{
			maxson=siz[y];
			son[x]=y;
		}
	}
}
void dfs2(int x,int topf)
{
	zz++;
	id[x]=zz;
	wt[zz]=w[x];
	top[x]=topf;
	if (!son[x])
	{
		return;
	}
	dfs2(son[x],topf);
	for (int i=head[x];i;i=e[i].next)
	{
		int y=e[i].to;
		if (y==fa[x]||y==son[x])
		{
			continue;
		} 
		dfs2(y,y);
	}
}
LL qrange (int x,int y)
{
	LL ans=0;
	while (top[x]!=top[y])
	{
		if (deep[top[x]]<deep[top[y]])
		{
			swap(x,y);
		}
		ans+=sumup(id[top[x]],id[x],1);
		ans%=p;
		x=fa[top[x]];
	}
	if (deep[x]>deep[y])
	{
		swap(x,y);
	}
	ans+=sumup(id[x],id[y],1);
	ans%=p;
	return ans;
}
void upd2(int x,int z)
{
	change1(1,id[x],id[x]+siz[x]-1,z);
}
int main()
{
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n-1;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		add(a,b);
		add(b,a);
	}
	dfs1(1,0,1);
	dfs2(1,1);
	build(1,zz,1);
	for (int i=1;i<=m;i++)
	{
		int x,z;
		scanf("%d %d",&x,&z);
		upd2(x,z);
	}
	for (int i=1;i<=n;i++)
	{
		printf("%d ",qrange(i,i));
	}
	return 0;
}

Measured memory_bytes: 50816
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
string s;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>s;
    for(auto isi:s){
        cout<<'x';
    }
    cout<<endl;
}

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

int main() {
    int N;
    std::string s;

    std::cin >> N >> s;
    if (N % 2 != 0) {
        std::printf("No\n");
        return 0;
    }

    int i = 0, j = N / 2;
    while (i < N / 2) {
        if (s[i] != s[j]) {
            std::printf("No\n");
            return 0;
        }

        ++i;
        ++j;
    } 

    std::printf("Yes\n");

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using ll = long long;
using namespace std;
int main() {
    int n; ll a, b, c, d; scanf("%d%lld%lld%lld%lld", &n, &a, &b, &c, &d);
    bool found = false;
    repeat (k, n) {
        ll r1 = d * k;
        ll l1 = c * k;
        ll r2 = - c * (n - 1 - k);
        ll l2 = - d * (n - 1 - k);
        ll r = r1 + r2;
        ll l = l1 + l2;
        if (l <= abs(b - a) and abs(b - a) <= r) {
            found = true;
        }
    }
    printf("%s\n", found ? "YES" : "NO");
    return 0;
}


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

int main(int argc, char *argv[])
{
  int n;
  std::vector<int> b;
  std::cin >> n;
  for (int i = 0; i < n - 1; i++)
  {
    int b_i;
    std::cin >> b_i;
    b.push_back(b_i);
  }
  long long sum(b[0]);
  for (int i = 1; i < n - 1; i++)
  {
    sum += std::min(b[i - 1], b[i]);
  }
  sum += b[n - 2];
  std::cout << sum << std::endl;
  return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<pair<long, long>> AB(N);
	for (pair<long, long>& i : AB) cin >> i.first >> i.second;
	sort(AB.begin(), AB.end(), [](pair<long, long>& a, pair<long, long>& b) { return b.first + b.second < a.first + a.second; });
	long ans = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2) ans -= AB[i].second;
		else ans += AB[i].first;
	}
	cout << ans;
}

Measured memory_bytes: 1792
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 1e6 + 6, mod = (int) 1e9 + 7;
int dp[N];
int pw(int a, int b) { return b != 0? pw(a * 1ll * a % mod, b >> 1) * 1ll * (b & 1? a: 1) % mod: 1; }
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> d;
    for (int i = 1; i * i <= n; ++i)
        if (n % i == 0) {
            d.push_back(i);
            if (i * i != n)
                d.push_back(n / i);
        }
    sort(d.begin(), d.end());
    long long res = 0;
    for (int j = 0; j < (int) d.size(); ++j) {
        int x = d[j];
        int g = (x / 2) + (x % 2);
        dp[j] = pw(k, g);
        for (int l = 0; l < j; ++l) if (x % d[l] == 0) {
            dp[j] = (dp[j] - dp[l] + mod) % mod;
        }
        res = (res + dp[j] * 1ll * (x & 1? x: g)) % mod;
    }
    cout << res << endl;
}



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

int main()
{
  string s;
  int K;

  cin >> s >> K;

  set<string> str;

  int len = s.length();
  for( int i = 0; i < len; i++ ) {
    for( int w = 0; i + w < len; w++ ) {
      string t = s.substr( i, w + 1 );
      str.insert( t );
      if( t.length() > K ) {
        break;
      }
    }
  }

  int cnt = 0;
  for( auto itr = str.begin(); itr != str.end(); itr++ ) {
    if( cnt == K - 1 ) {
      cout << *itr << endl;
    }
    cnt += 1;
  }

  return 0;
}


Measured memory_bytes: 1536
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll k;
    cin>>k;
    ll oper=0;
    while(b<=a)
    {
        b*=2;
        oper++;
    }
    while(c<=b)
    {
        c*=2;
        oper++;
    }
    if(oper<=k)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>p(n);
	for(auto&i:p)cin>>i;
	int ans=0;
	for(int i=0;i<n;++i){
		if(p.at(i)==i+1)++ans,++i;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 640
s = input().rstrip()
t = input().rstrip()
count = 0
min_count = 10000
for i in range(len(s) - len(t) + 1):
    s_selected = s[i:i + len(t)]
    #print(s_selected)
    count = 0
    for j in range(len(t)):
        if t[j] != s_selected[j]:
            count += 1
    #print(count)
    if count < min_count:
        min_count = count
print(min_count)


Measured memory_bytes: 8968
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

void calc(const vector<vector<int> >& G, vector<int>& D) {
    queue<int> Q;
    D[1] = 0;
    Q.push(1);
    while (!Q.empty()) {
        int i = Q.front();
        Q.pop();
        for (int j = 1; j < G[i].size(); j++) {
            if (G[i][j] && D[j] == -1) {
                D[j] = D[i] + 1;
                Q.push(j);
            }
        }
    }
}

int main(){
    int n;
    cin >> n;
    vector<vector<int> > G(n + 1, vector<int>(n + 1, 0));
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            G[u][v] = 1;
        }
    }
    vector<int> D(n + 1, -1);
    calc(G, D);

    for (int i = 1; i <= n; i++) {
        cout << i << " " << D[i] << endl;
    }

    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;


int main() {

    ll ans = 0;
    
    ll N; cin >> N;
    map<string, ll> S;

    for(ll i = 0; i < N; i++){
        string k; cin >> k;
        S[k]++;
    }
    
    ll M; cin >> M;
    map<string, ll> T;
    for(ll i = 0; i < M; i++){
        string k; cin >> k;
        T[k]++;
    }

    //確認
    auto begin = S.begin(), end = S.end();
    for (auto iter = begin; iter != end; iter++) {
        ll tmp = iter -> second - T[iter -> first];
        ans = max(tmp, ans);
    }    

    cout << ans << endl;

}

Measured memory_bytes: 256