akhauriyash/Code-Regression huggingface dataset:
n,q = map(int,input().split())

edges = [[] for i in range(n)]

d = [0] * n

for i in range(n-1):
    aa,ba = map(int,input().split())
    edges[aa-1].append(ba-1)
    edges[ba-1].append(aa-1)

for i in range(q):
    pa,xa = map(int,input().split())
    d[pa-1] += xa

visited = [0 for i in range(n)]

#print(edges)
#print(d)

def dfs(v):
    q=[v]
    visited = [0] * n
    while q:
        v=q.pop()
        hoga = d[v]
        visited[v] = 1
        for i in edges[v]:
            if not visited[i]:
                d[i] += hoga
                q.append(i)
        #print(visited,d)
    return d

print(*dfs(0))

Measured memory_bytes: 55804
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin>>s;
  for(int i=0;i<26;i++){
    bool judge=true;
    for(int j=0;j<s.size();j++){
      if(i+'a'==s.at(j)) judge=false;
    }
    if(judge){
      char X='a'+i;
      cout<<X<<endl;
      break;
    }
    if(i==25) cout<<"None"<<endl;
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define MOD                1000000007
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define REP(i,l,r)         for(int i=l;i<r;i++)
#define RER(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
#define test()             int x;cin >> x;while(x--){solve();}
#define test2()            int x;cin >> x;for(int i=1;i<=x;i++){cout << "Case #" << i << " : ";solve();}
#define watch(x)           cout << (#x) << " is " << (x) << endl
using namespace std;


/* Mathematical Functions */
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);

const int inf = (int)1e17;
const int N = (int)3e5+5;

int32_t main(){

	
	FASTIO;
	int n;
	cin >> n;
	vector<int>a(n+1),b(n+1);
	REP(i,1,n+1){
		int x;
		cin >> x;
		a[i] = i+x;
		b[i] = i-x;
	}
	map<int,int>cnt;
	int ans = 0;
	REP(i,1,n+1){
		ans += cnt[b[i]];
		cnt[a[i]]++;
	}
	cout << ans << endl;
    return 0;

}
int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}
 
int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}
 
int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}
 
bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}

Measured memory_bytes: 28928
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main() {
    int N;
    cin>>N;
    int A[N],B[N];
    REP(i,N){
        cin>>A[i];
        B[i]=A[i];
    }
    sort(A,A+N);
    REP(i,N){
        if(B[i]==A[N-1]){
            cout<<A[N-2]<<endl;
        }else{
            cout<<A[N-1]<<endl;
        }
    }
}

Measured memory_bytes: 3200
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @n,@a,@b = gets.to_s.split.map{ |v| v.to_i }
  end

  def solve
    (b-a).even?
  end

  def show(ans)
    puts ans ? "Alice" : "Borys"
  end
end

Problem.new.instance_eval do
  show(solve)
end

Measured memory_bytes: 14372
#include<iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX+1];

void maxHeapify(int i){
    int l, r, largest;
    l = 2*i;
    r = 2*i+1;

    // 左の子、自分、右の子で値が最大のノードを選ぶ
    if(l<=H && A[l]>A[i]) largest = l;
    else largest = i;
    if(r<=H && A[r]>A[largest]) largest = r;

    if(largest != i){
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int main(int argc, char const *argv[])
{
    cin >> H;

    for(int i=1; i<=H; i++) cin >> A[i];

    for(int i=H/2; i>=1; i--) maxHeapify(i);

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

    return 0;
}



Measured memory_bytes: 5012
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,l; cin>>n>>l;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    int idx = INF;
    rep(i,n-1) {
        if (a[i]+a[i+1] >= l) {
            idx = i;
            break;
        }
    }

    if (idx==INF) {
        cout << "Impossible" << '\n';
        return 0;
    }

    vector<int> ans;
    for (int i = idx+1; i < n; ++i) {
        ans.push_back(i);
    }
    for (int i = idx; i > 0; --i) {
        ans.push_back(i);
    }

    reverse(ans.begin(), ans.end());
    cout << "Possible" << '\n';
    for (auto &&e: ans) cout << e << '\n';
    return 0;
}

Measured memory_bytes: 2168
#include <stdio.h>
using namespace std;

int main(){

	int N,tmp,table[101];
	scanf("%d",&N);

	for(int i = 0; i <= 100; i++)table[i] = 0;

	for(int i = 0; i < N; i++){
		scanf("%d",&tmp);
		table[tmp]++;
	}

	if(table[100] == 100){
		printf("100\n");
		return 0;
	}

	for(int i = 99; i >= 1; i--){
		table[i] += table[i+1];
		if(i <= table[i]){
			printf("%d\n",i);
			break;
		}
	}

	return 0;
}

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

//M^N modMOD
ll modpow(ll M, ll N) {
  if(N==0) return 1;
  else if(N%2==0) return modpow(M, N/2)*modpow(M, N/2)%MOD;
  else return M*modpow(M, N-1)%MOD;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, K;
  cin >> N >> K;

  vector<ll> num(K+1);
  for(ll i=1; i<=K; ++i) num[i] = modpow(K/i, N);
  
  for(ll i=K; i>0; --i) {
    set<ll> divisor;
    for(ll j=1; j*j<=i; ++j) if(i%j==0) divisor.insert(i/j);
    for(ll j: divisor) divisor.insert(i/j);
    divisor.erase(i);
    
    for(ll j: divisor) num[j] -= num[i];
  }
  
  ll ans=0;
  for(ll i=1; i<=K; ++i) ans += i*num[i];
  
  cout << ans%MOD << '\n';
  return 0;
}


Measured memory_bytes: 3992
#include <stdio.h>
#include <stdlib.h>
int main()
{
	int n;
	scanf("%d", &n);
	int* a = (int*)malloc(sizeof(int) * n );
	for(int i = 0; i < n; ++i)
	{
		int k;
		scanf("%d",&k);
		a[i] = k;
	}

	for(int i = 0; i < n; ++i)
	{
		printf("%d", a[n - 1 - i]);
		if( i != n -1 )
			printf(" ");
		else
			printf("\n");
	}
	
	free(a);
	return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main {

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

	void solve() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long[] SMatch = new long [5];
		for(int i=0;i<n;i++) {
			String s = sc.next();
				 if(s.substring(0, 0+1).equals("M"))SMatch[0]++;
			else if(s.substring(0, 0+1).equals("A"))SMatch[1]++;
			else if(s.substring(0, 0+1).equals("R"))SMatch[2]++;
			else if(s.substring(0, 0+1).equals("C"))SMatch[3]++;
			else if(s.substring(0, 0+1).equals("H"))SMatch[4]++;
		}
		sc.close();
		long res=0;
		int[] P={0,0,0,0,0,0,1,1,1,2};
		int[] Q={1,1,1,2,2,3,2,2,3,3};
		int[] R={2,3,4,3,4,4,3,4,4,4};
		for(int i=0;i<10;i++)res += SMatch[P[i]]*SMatch[Q[i]]*SMatch[R[i]];

		System.out.println(res);
	}

}


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

int main() {
    long long n, m, ans=0, a, b, cnt=0;
    cin >> n >>m;
    vector<pair<int, int>> p(n);
    for(int i=0; i<n; i++) {
        cin >> a >> b;
        p[i]=make_pair(a, b);
    }
    sort(p.begin(), p.end());

    for(int i=0; i<n; i++) {
        a=p[i].first;
        b=p[i].second;
        if(cnt+b<m) {
            ans+=a*b;
        }
        else {
            ans+=a*(m-cnt);
            break;
        }
        cnt+=b;
    }
    cout << ans;
}

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

using namespace std;

const int MAXN = 300 + 10;
long double dp[MAXN][MAXN][MAXN];

int main()
{
    long double n;
    cin >> n;
    cout << setprecision(10) << fixed;
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        int in;
        cin >> in;
        cnt[in]++;
    }

    for (int k = 0; k < 302; k++) {
        for (int j = 0; j < 302; j++) {
            for (int i = 0; i < 302; i++) {
                if (i == 0 && j == 0 && k == 0)
                    continue;
                long double ii = 0, jj = 0, kk = 0;
                if (k != 0)
                    kk = (k / (long double)(i+j+k)) * (dp[i][j+1][k-1]);
                if (j != 0)
                    jj = (j / (long double)(i+j+k)) * (dp[i+1][j-1][k]);
                if (i != 0)
                    ii = (i / (long double)(i+j+k)) * (dp[i-1][j][k]);
                dp[i][j][k] = kk + jj + ii + 1 + ((n - (i+j+k)) / (long double)(i+j+k));
            }
        }
    }

    cout << dp[cnt[1]][cnt[2]][cnt[3]];
    return 0;
}

Measured memory_bytes: 454912
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int main()
{
  lint n, k, q;
  cin >> n >> k >> q;
  std::vector<lint> a(q);
  REP(i,q) cin >> a[i];

  std::vector<lint> points(n);
  REP(i,q){
    points[a[i]-1]++;
  }
  REP(i,n){
    if(k+points[i]-q > 0) cout << "Yes" <<endl;
    else cout << "No" <<endl;
  }
  return 0;
}


Measured memory_bytes: 2176
#include<cstdio>
#include<vector>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const long long MAXN=200005,MOD=1e9+7;
long long jc[MAXN],inv[MAXN];
long long h,w,a,b;
long long ksm(long long x,long long y)
{
	long long k=1;
	while(y)
	{
		if(y&1)
			k=(k*x)%MOD;
		x=(x*x)%MOD;
		y>>=1;
	}
	return k;
}
void Init()
{
	jc[0]=1;
	for(long long i=1;i<MAXN;i++)
		jc[i]=(jc[i-1]*i)%MOD;
	inv[MAXN-1]=ksm(jc[MAXN-1],MOD-2);
	for(long long i=MAXN-2;i>=0;i--)
		inv[i]=(inv[i+1]*(i+1))%MOD;
}
long long C(long long n,long long m)
{
	if(m<n||n<0)
		return 0;
	return ((jc[m]*inv[n])%MOD*inv[m-n])%MOD;
}
int main()
{
	Init();
	scanf("%lld %lld %lld %lld",&h,&w,&a,&b);
	long long ans=C(h-1,h+w-2);
	for(int i=0;i<b;i++)
	{
		ans-=C(h-a+i,h-a+b-1)*C(a-1-i,h+w-2-(h-a+b-1));
		ans=ans%MOD;
	}
	ans=(ans%MOD+MOD)%MOD;
	printf("%lld\n",ans);
}

Measured memory_bytes: 3328
N,M=map(int,input().split())
String=[str(0) for _ in range(N)] #indexは0からに注意
flag=1
for _ in range(M):
    s,c=map(int,input().split())
    if c!=String[s-1] and String[s-1]!=str(0):
        flag=0
    String[s-1]=c
if String[0]==0:
    if N!=1:
        flag=0
elif String[0]=='0':
    if N!=1:
        String[0]=1
String=list(map(str,String))
if flag:
    print(int(''.join(String)))
else:
    print(-1)

Measured memory_bytes: 9160
import java.io.*;
import java.util.*;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        if(a==b)
            System.out.println("Draw");
        else{
            if (a==1)
                System.out.println("Alice");
            else if (b==1)
                System.out.println("Bob");
            else if(a>b)
                System.out.println("Alice");
            else
                System.out.println("Bob");

        }
    }


}


Measured memory_bytes: 21204
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    FOR(i,1,11){
        if(n<=i*1000){
            cout << i*1000 - n << endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 100100;
string z;
int m;
int f[MAX],il[MAX];
const int alfa = 'z' - 'a' + 1;
void pol(int& a){
  a = min(a, SZ(z) - a);
}
int find(int a){
  return f[a] == a ? a : f[a] = find(f[a]);
}
void uni(int a,int b){
  a = find(a);
  b = find(b);
  if(a == b)return;
  f[a] = b;
  il[b] += il[a];
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> z;
  R(i,SZ(z)/2 + 1){
    f[i] = i;
    if(i){
      if(i * 2 == SZ(z)){
        il[i] = z[i] - z[i-1];
        debug(il[i]);
      }else
        il[i] = (z[i] - z[i-1]) - (z[SZ(z) - i - 1] - z[SZ(z) - i]);
    }
    debug(i,il[i]);
  }
  cin >> m;
  R(i,m){
    int l,r;
    cin >> l >> r;
    l--;
    pol(l);
    pol(r);
    debug(l,r);
    uni(r,l);
  }
  R(i,SZ(z)/2 + 1){
    if(f[i] == i){
      if(il[i] % alfa != 0 && find(0) != i){
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n";
}


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

using namespace std ;

const int MAX = 1e5 + 10 ;

int dist[MAX] , prv[MAX] ;
int n , m ;

vector< vector<int> >adj(MAX) ;

void bfs(int src)
{
	memset(dist , -1 , sizeof(dist)) ;
	queue<int>q ;
	q.push(1) ;
	dist[1] = 0 ;
	while(!q.empty())
	{
		int node = q.front() ;
		q.pop() ;
		for(auto &child : adj[node])
		{
			if(dist[child] == -1)
			{
				prv[child] = node ;
				dist[child] = dist[node] + 1 ;
				q.push(child) ;
			}
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>m ;
	for(int i = 0 ; i < m ; ++i)
	{
		int x , y ;
		cin>>x>>y ;
		adj[x].push_back(y) ;
		adj[y].push_back(x) ;
	}
	bfs(1) ;
	for(int i = 2 ; i <= n ; ++i)
	{
		if(dist[i] == -1)
			return cout<<"No\n" , 0 ;
	}
	cout<<"Yes\n" ;
	for(int i = 2 ; i <= n ; ++i)
		cout<<prv[i]<<"\n" ;
	return 0 ;
}		

Measured memory_bytes: 10704
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

map<int, int> cnt;
ll sum = 0;

int main(void){
    int N; cin >> N;
    for (int i = 0; i < N; ++i){
        int ai; cin >> ai;
        ++cnt[ai];
        sum += ai;
    }
    int Q; cin >> Q;
    while (Q--){
        int b, c; cin >> b >> c;
        sum -= (ll)b * cnt[b];
        sum += (ll)c * cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }
    return 0;
}

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

using namespace std;
using pii = pair<int, int>;

const int INF = 1 << 29;
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W;
  cin >> H >> W;
  vector<string> A(H);
  for (int i = 0; i < H; i++)
    cin >> A[i];

  queue<pii> que;
  vector<vector<int>> M(H, vector<int>(W, -1));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A[i][j] == '#') {
        que.push(make_pair(i, j));
        M[i][j] = 0;
      }
    }
  }
  int res = 0;
  while (!que.empty()) {
    pii now = que.front();
    que.pop();
    int x = now.second, y = now.first;
    for (int k = 0; k < 4; k++) {
      int nx = x + dx[k], ny = y + dy[k];
      if (nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
      if (M[ny][nx] != -1) continue;
      que.push(make_pair(ny, nx));
      M[ny][nx] = M[y][x] + 1;
      res = max(res, M[ny][nx]);
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 13456
n = gets.to_i
h = Hash.new
pre = "0"
n.times do 
    w = gets.chomp
    if (pre == "0" || w[0] == pre) && !h[w]
        pre = w[-1]
        h[w] = true
    else
        puts "No"
        exit
    end
end
puts "Yes"

Measured memory_bytes: 1788
def f(x):
    x1, y1, x2, y2, x3, y3, xp, yp = x
    ax = x3 - x1
    ay = y3 - y1
    bx = x2 - x1
    by = y2 - y1
    xp -= x1
    yp -= y1
    k = (by * xp - bx * yp) / (ax * by - ay * bx)
    l = (ay * xp - ax * yp) / (ay * bx - ax * by)
    if (k > 0 and l > 0 and k + l < 1):
        print('YES')
    else:
        print('NO')
while True:
    try:
        point = list(map(float, input().split()))
        f(point)
    except EOFError:
        break



Measured memory_bytes: 5584
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
//struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


void solve(long long N, std::string S){
	ll res = 0;
	//REP(i, S.size()) cout << S[i]+N << "\n";
	REP(i, S.size()) {
		ll n = N;
		if (S[i]+N>=91) n -= 26;
		printf("%c", S[i]+n);
	}
	printf("\n");
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
use proconio::{input};

#[derive(Debug, Clone)]
struct UnionFind {
    vec: Vec<Node>
}

#[derive(Debug, Copy, Clone)]
enum Node {
    Root(u32),
    Vertex(usize),
}

impl UnionFind {
    #[allow(dead_code)]
    fn new(n: usize) -> Self {
        UnionFind{
            vec: vec![Node::Root(1); n]
        }
    }

    #[allow(dead_code)]
    fn root(&self, x: usize) -> usize {
        match self.vec[x] {
            Node::Root(_) => x,
            Node::Vertex(parent) => self.root(parent),
        }
    }

    #[allow(dead_code)]
    fn root_update(&mut self, x: usize) -> usize {
        match self.vec[x] {
            Node::Root(_) => x,
            Node::Vertex(parent) => {
                let root = self.root(parent);
                self.vec[x] = Node::Vertex(root);
                root
            },
        }
    }

    #[allow(dead_code)]
    fn unite(&mut self, x: usize, y: usize) -> u32 {
        let (rx, ry) = (self.root_update(x), self.root_update(y));
        if rx == ry {
            return 0;
        }
        if let (Node::Root(x_root_size), Node::Root(y_root_size)) = (self.vec[rx], self.vec[ry]) {
            if x_root_size > y_root_size {
                self.vec[ry] = Node::Root(x_root_size + y_root_size);
                self.vec[rx] = Node::Vertex(ry);
            } else {
                self.vec[rx] = Node::Root(x_root_size + y_root_size);
                self.vec[ry] = Node::Vertex(rx); 
            }
            return x_root_size + y_root_size;
        } else {
            unreachable!();
        }
    }

    #[allow(dead_code)]
    fn size(&self, x: usize) -> u32 {
        if let Node::Root(s) = self.vec[self.root(x)] {
            return s;
        } else {
            unreachable!();
        }
    }

    #[allow(dead_code)]
    fn max_size(&self) -> u32 {
        let mut answer = 0;
        for i in &self.vec {
            match i {
                Node::Root(size) => {
                    if answer < *size {
                        answer = *size;
                    }
                },
                _ => {},
            }
        }
        return answer;

    }
}
 
fn main() {
    input! {
        n: usize,
        m: usize,
        t: [(usize, usize); m],
    }
 
    let mut uf = UnionFind::new(n);
 
    let mut answer = 1;
    for (a, b) in t {
        let root_size = uf.unite(a-1, b-1);
        if root_size > answer {
            answer = root_size;
        }
    }
    
    println!("{}", answer);
}

Measured memory_bytes: 10764
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
h,w = readInts()
A = [readInts() for _ in range(h)]
ans = []
cnt = 0
for y in range(h):
    for x in range(w):
        if A[y][x]%2:
            if x + 1 < w:
                cnt += 1
                A[y][x] -= 1
                A[y][x+1] += 1
                ans.append([y+1,x+1,y+1,x+2])
# saigo
for y in range(h):
    if A[y][-1]%2:
        if y + 1 < h:
            cnt += 1
            A[y][-1] -= 1
            A[y+1][-1] += 1
            ans.append([y+1,w,y+2,w])
print(cnt)
for a in ans:
    print(*a)


Measured memory_bytes: 30588
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll>x(n);
    rep(i, n)scanf("%lld", &x[i]);

    ll ans = 10000000000000000;
    ll pos = lower_bound(ALL(x), 0) - x.begin();
    x.insert(x.begin()+pos, 0);
    //rep(i, x.size())cout << x[i] << " ";
    
    rep(i, k+1){
        ll left = pos - (k-i);
        ll right = pos+i;
        if(left >= 0 && right < n+1){
            ll time = min(abs(x[left]), x[right])*2 + max(abs(x[left]), x[right]);
            if(time < ans)ans = time;
            //cout << x[left]<< "+" << x[right] << "time:";
            //cout << time << endl;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 1792
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const int MAX_N = 18;
const int MAX_V = 51;

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

  vector<int> A;
  vector<int> B;

  int a, b;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    A.push_back(a);
  }

  for (int i = 0; i < N; ++i) {
    cin >> b;
    B.push_back(b);
  }

  int dp[1 << N][MAX_V];
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;

  for (int c = 0; c < N; ++c) {
    for (int mask = 0; mask < (1 << N); ++mask) {
      if (__builtin_popcount(mask) != c) continue;

      for (int v = 0; v <= 50; ++v) {
        int cnt = dp[mask][v];
        if (cnt == -1) continue;

        int shift_cnt = 0;

        for (int i = N - 1; i >= 0; --i) {
          if (mask >> i & 1) {
            shift_cnt++;
            continue;
          }

          int move_cnt = abs((i + shift_cnt) - c);
          int num = (abs(i - c) % 2 == 0) ? A[i] : B[i];

          if (num < v) continue;

          int nmask = mask | (1 << i);
          /*
          fprintf(stderr, "%d: c: %d, move_cnt: %d, mask: %d, nmask: %d, num: %d\n",
              i, c, move_cnt, mask, nmask, num);
              */

          if (dp[nmask][num] == -1) {
            dp[nmask][num] = dp[mask][v] + move_cnt;
          } else {
            dp[nmask][num] = min(dp[nmask][num], dp[mask][v] + move_cnt);
          }
        }
      }
    }
  }

  int ans = INT_MAX;

  for (int v = 1; v <= 50; ++v) {
    if (dp[(1 << N) - 1][v] == -1) continue;

    ans = min(ans, dp[(1 << N) - 1][v]);
  }

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

  return 0;
}


Measured memory_bytes: 55852
#include <iostream>
#include <unordered_map>

using namespace std;

typedef unsigned long long ull;

ull N,V;
ull p[4][1001];

ull solve() {
  unordered_map<ull, ull> c[2];
  for (int i=0; i<2; ++i) {
    for (int j=0; j<N; ++j) {
      for (int k=0; k<N; ++k) {
        ++c[i][p[i*2][j]+p[i*2+1][k]];
        //cout<<i<<" "<<j<<" "<<k<<" "<<p[i*2][j]+p[i*2+1][k]<<" "<<c[i][p[i*2][j]+p[i*2+1][k]]<<endl;
      }
    }
  }
  ull ans = 0;
  for(unordered_map<ull, ull>::const_iterator it = c[0].begin(); it != c[0].end(); ++it) {
    if (V > it->first) {
      ans += (it->second)*c[1][V-it->first];
    }
  }
  return ans;
}

int main() {
  cin>>N>>V;
  for (int i=0; i<4; ++i) {
    for (int j=0; j<N; ++j) {
      cin>>p[i][j];
    }
  }
  cout<<solve()<<endl;
  return 0;
}


Measured memory_bytes: 121500
n, q = map(int, input().split())
st = input()
questions = [tuple(map(int, input().split())) for i in range(q)]
lis = []
cnt = 0
for i in range(len(st)-1):
    if st[i-1:i+1] == 'AC':
        cnt += 1
    lis.append(cnt)
if st[-2:] == 'AC':
    cnt += 1
lis.append(cnt)
for l, r in questions:
    print(lis[r-1] - lis[l-1])

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

const ll MAX = 1E+18;

int main() {
    ll N;
    cin >> N;

    ll A[N];
    rep(i, N) cin >> A[i];

    ll ans = 1;
    rep(i, N) {
        if (ans > (MAX + A[i] -1)/A[i]) {
            ans = -1;
            break;
        }
        ans *= A[i];
        if (ans > MAX) {
            ans = -1;
            break;
        }
    }

    rep(i, N) if (A[i] == 0) ans = 0;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4416
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
using namespace std;
static const int MAX_N = 100;

int N;
double t[MAX_N + 1], v[MAX_N];
double v2[MAX_N + 1];

int main(){
	cin >> N;
	t[0] = 0.0;
	for(int i = 1; i <= N; i++){
		cin >> t[i];
		t[i] += t[i - 1];
	}
	for(int i = 0; i < N; i++) cin >> v[i];

	v2[0] = 0.0, v2[N] = 0.0;
	for(int i = 1; i < N; i++) v2[i] = min(v[i - 1], v[i]);

	for(int i = 0; i < N + 1; i++){
		for(int j = 1; j < N; j++){
			if(i == j) continue;
			v2[j] = min(v2[j], v2[i] + abs(t[i] - t[j]));
		}
	}

	double res = 0.0;
	for(int i = 1; i < N + 1; i++){
		double diff_v = abs(v2[i - 1] - v2[i]);
		double diff_t = t[i] - t[i - 1];
		double peak_v = min(v2[i - 1], v2[i]) + (diff_t + diff_v) / 2.0;
		res += peak_v * peak_v - (v2[i - 1] * v2[i - 1] + v2[i] * v2[i]) / 2.0;
		if(peak_v > v[i - 1]) res -= (peak_v - v[i - 1]) * (peak_v - v[i - 1]);
	}
	cout << fixed;
	cout << setprecision(10) << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
        string a;
        cin >> a;
        ll k;
        cin >> k;
        int len = a.size();
        if (len == 1) {
                cout << k / 2 << endl;
        } else if (len == 2) {
                if (a[0] == a[1]) {
                        cout << k << endl;
                } else {
                        cout << 0 << endl;
                }
        } else {
                bool flg = 1;
                for (int i = 1; i < len; i++) {
                        if (a[i] != a[0]) {
                                flg = 0;
                                break;
                        }
                }
                if (flg) {
                        cout << 1LL * len * k / 2 << endl;
                        return 0;
                }
                ll ans = 0;
                char ch = '0';
                int now = 0;
                for (int i = 0; i <= len; i++) {
                        if (i == len || a[i] != ch) {
                                ans += now / 2;
                                ch = a[i];
                                now = 1;
                                continue;
                        }
                        now++;
                }
                int l = 0, r = 0;
                if (a[0] == a[len - 1]) {
                        for (l = 0; l < len; l++)
                                if (a[l] != a[0]) {
                                        l--;
                                        break;
                                }
                        for (r = len - 1; r >= 0; r--)
                                if (a[r] != a[0]) {
                                        r++;
                                        break;
                                }
                        r = len - r;
                        l++;
                        ans -= l / 2 + r / 2;
                }
                ans *= k;
                ans += 1LL * (l + r) / 2 * (k - 1);
                ans += l / 2 + r / 2;
                cout << ans << endl;
        }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  ll a,b;
  for(int i=0;i<N;i++){
    cin >> a >> b;
    A[N-1-i]=a;
    B[N-1-i]=b;
  }
  ll ct=0;
  for(int i=0;i<N;i++){
    ll tmp=(ct+A[i])%B[i]==0?0:B[i]-(ct+A[i])%B[i];
    ct+=tmp;
  }
  cout << ct << endl;
}


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

int main(){
    int n;
    scanf("%d",&n);
    int ar[n],Max=0;

    for(int i=0; i<n; i++){
        scanf("%d",&ar[i]);
        if(Max<ar[i]) Max=ar[i];
    }

    Max+=1;
    int cnt[Max]={0};
    for(int i=0; i<n; i++){
        ++cnt[ar[i]];
    }
    for(int i=1; i<Max; i++){
        cnt[i]=cnt[i]+cnt[i-1];
    }

    int br[n];
    for(int i=n-1; i>=0; i--){
        br[--cnt[ar[i]]]=ar[i];
    }

    printf("%d",br[0]);
    for(int i=1; i<n; i++) printf(" %d",br[i]);
    printf("\n");
    return 0;
}



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

int main() {
  string N;
  cin >> N;
  char n = N.at(N.size()-1);
  if (n=='3') {
    cout << "bon" << endl;
  } else if (n=='0' || n=='1' || n=='6' || n=='8') {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
  return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <algorithm> 
#include <ctime>

#define MaxN 105
#define INF 2140000000

using namespace std;

int N,stack[105],Size=0;
string S,S2;

int main()
{
	cin>>N;
	cin>>S;
	S2=S;
	for(int i=0;i<N;i++)
	{
		if(Size>0&&S[stack[Size]]=='('&&S[i]==')')
			Size--;
		else stack[++Size]=i;
	}
	while(Size&&S[stack[Size]]=='(')
		S2.push_back(')'),Size--;
	while(Size&&S[stack[Size]]==')')
		cout<<'(',Size--;
	cout<<S2;
	return 0;
}

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


int solve(int arr[],int i,int arr1[],int n)
{
	if(i==n-2)
	{
	 arr1[n-2]  = abs(arr[i]-arr[i+1]);
	 return arr1[n-2];
	}
	if(arr1[i]!=-1)
	{
	return arr1[i];
	}
	int temp = abs(arr[i+1]-arr[i])+solve(arr,i+1,arr1,n);
	int temp1 = abs(arr[i+2]-arr[i])+solve(arr,i+2,arr1,n);
	arr1[i]  = min(temp,temp1);
	return arr1[i];
}


int main()
{
	int n;
	cin>>n;
	int i=0;
	int arr[n];
	for(i=0;i<n;i++)
	{
      cin>>arr[i];
	}
	int arr1[n];
	memset(arr1,-1,sizeof(arr1));
	arr1[n-1] = 0;
	cout<<solve(arr,0,arr1,n)<<endl;
	
}

Measured memory_bytes: 8832
import java.lang.Math

fun main(args: Array<String>)
{
    val (n, k, q) = readInts()
    val a = IntArray(q)
    for (i in 0 until q)
        a[i] = readInt()

    val cnt = IntArray(n)
    for (i in 0 until q)
        cnt[a[i]-1]++

    val score = IntArray(n)
    for (i in 0 until n)
        score[i] = k - (q - cnt[i])

    for (s in score)
        println(if (s > 0) "Yes" else "No")
}

fun readInt(): Int = Integer.parseInt(readLine()!!)

fun readInts(): List<Int> = readLine()!!.split(" ").map(String::toInt)
fun readLongs(): List<Long> = readLine()!!.split(" ").map(String::toLong)

fun readIntArr(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray()
fun readLongArr(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray()

fun readIntArrS(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray().sortedArray()
fun readLongArrS(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray().sortedArray()

fun readIntArrSD(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray().sortedArrayDescending()
fun readLongArrSD(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray().sortedArrayDescending()

fun readString() = readLine()!!


Measured memory_bytes: 45932
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N;
int Y;

signed main(){
    cin>>N>>Y;
    for(int i=0;i<=N;++i){
        for(int j=0;j<=N-i;++j){
            int x=i,y=j,z=N-i-j;
            if(10000*x+5000*y+1000*z==Y){
                cout<<x<<" "<<y<<" "<<z<<endl;
                return 0;
            }
        }
    }
    printf("%d %d %d\n",-1,-1,-1);
}


Measured memory_bytes: 256
// #Badhi moh maya chhe!
/*
AUTHOR NAME:
	         ,--.                         ____                          ,--.
	       ,--.'|   ,---,               ,'  , `.   ,---,              ,--.'|
	   ,--,:  : |  '  .' \           ,-+-,.' _ |  '  .' \         ,--,:  : |
	,`--.'`|  ' : /  ;    '.      ,-+-. ;   , || /  ;    '.    ,`--.'`|  ' :
	|   :  :  | |:  :       \    ,--.'|'   |  ;|:  :       \   |   :  :  | |
	:   |   \ | ::  |   /\   \  |   |  ,', |  '::  |   /\   \  :   |   \ | :
	|   : '  '; ||  :  ' ;.   : |   | /  | |  |||  :  ' ;.   : |   : '  '; |
	'   ' ;.    ;|  |  ;/  \   \'   | :  | :  |,|  |  ;/  \   \'   ' ;.    ;
	|   | | \   |'  :  | \  \ ,';   . |  ; |--' '  :  | \  \ ,'|   | | \   |
	'   : |  ; .'|  |  '  '--'  |   : |  | ,    |  |  '  '--'  '   : |  ; .'
	|   | '`--'  |  :  :        |   : '  |/     |  :  :        |   | '`--'  
	'   : |      |  | ,'        ;   | |`-'      |  | ,'        '   : |      
	;   |.'      `--''          |   ;/          `--''          ;   |.'      
	'---'                       '---'                          '---'        

*/



#include <bits/stdc++.h>

using namespace std;
#define endl "\n"
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define all(x) x.begin(),x.end()
#define pb push_back
#define Fo(i,k,n) for(ll i=k;i<=n;i+=1)
#define deb(x) cout << #x << "=" << x << endl
#define in(a,n) Fo( i,0,n-1)cin>>a[i]
#define out(a,n) Fo( i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define IOS     ios_base::sync_with_stdio(0); cin.tie(NULL);

ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
void fileio()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
 




int main() {
	IOS
    ll t=1;
	//cin>>t;	
	
	while(t--)
	{
	 ll  n;
	 cin>>n;
	 ll ar[n];
	 map<ll,ll> mp;
	 Fo(i,0,n-1)
	 {
	     cin>>ar[i];
	     mp[ar[i]]++;
	     
	 }
	 ll ans=0;
	  map<ll,ll> mp1;
	 for(auto x:mp)ans+=(x.second)*(x.second-1)/2;
	 //deb(ans);
    Fo(i,0,n-1)
    {  ll x=ar[i];
       //deb(mp[x]);
        cout<<ans-(mp[x]-1)<<endl;
    }
	 
	 
	 
	}
	
    
}

Measured memory_bytes: 11136
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let d: usize = iterator.next().unwrap().parse().unwrap();
    let c: Vec<isize> = (0..26).map(|_| iterator.next().unwrap().parse().unwrap()).collect();
    let mut s: Vec<Vec<isize>> = vec![vec![0; 26]; d];
    for i in 0..d {
        for j in 0..26 {
            s[i][j] = iterator.next().unwrap().parse().unwrap();
        }
    }
    let t: Vec<usize> = (0..d).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut last: Vec<usize> = vec![0; 26];

    let mut result = String::new();
    let mut ans: isize = 0;
    for i in 0..d {
        ans += s[i][t[i] - 1];
        last[t[i] - 1] = i + 1;
        for j in 0..26 {
            ans -= c[j] * (i + 1 - last[j]) as isize;
        }
        result.push_str(&format!("{}\n", ans));
    }
    return result.trim().to_string();
}


Measured memory_bytes: 2304
#include <queue>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
struct state { int pos, cost; };
bool operator<(const state& s1, const state& s2) { return s1.cost > s2.cost; }
int H, W, N, x[109], y[109], dist[109][1009];
int main() {
	cin >> H >> W >> N;
	for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= H + W - 2; j++) {
			dist[i][j] = inf;
		}
	}
	priority_queue<state> que;
	for (int i = 0; i < N; i++) {
		int d = x[i] + y[i] - 2;
		dist[i][d] = d;
		que.push(state{ i + d * N, d });
	}
	while (!que.empty()) {
		int u = que.top().pos; que.pop();
		int pos = u % N, cur = u / N;
		if (cur < H + W - 2 && dist[pos][cur + 1] > dist[pos][cur] + 1) {
			dist[pos][cur + 1] = dist[pos][cur] + 1;
			que.push(state{ u + N, dist[pos][cur + 1] });
		}
		for (int i = 0; i < N; i++) {
			int d = abs(x[i] - x[pos]) + abs(y[i] - y[pos]);
			int cc = max(d - cur - 1, 0);
			if (dist[i][cc] > dist[pos][cur] + cc) {
				dist[i][cc] = dist[pos][cur] + cc;
				que.push(state{ i + cc * N, dist[i][cc] });
			}
		}
	}
	int ret = inf;
	for (int i = 0; i < N; i++) {
		int d = W - x[i] + H - y[i];
		for (int j = d; j <= H + W - 2; j++) {
			ret = min(ret, dist[i][j]);
		}
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3944
import heapq as hq
def main():
    n,m=map(int,input().split(' '))
    a=[-1*i for i in list(map(int,input().split(' ')))]
    hq.heapify(a)
    for i in range(m):
        a_max = hq.heappop(a)
        a_max = (-1*a_max)//2
        hq.heappush(a,-1*a_max)
    print(-1*sum(a))
if __name__ == '__main__':
    main()

Measured memory_bytes: 14180
<?php
	$sumple = str_split(trim(fgets(STDIN)));
	$text = str_split(trim(fgets(STDIN)));
	$count = 0;
	
	for($i=0; $i<count($sumple); $i++){
	    if($sumple[$i] != $text[$i]){
	        $count += 1;
	    }
	}
	echo $count;
?>

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

int sumVector(vector<int> v, int problem, int time){
  int sum = 0;
  v[problem] = time;
  for(auto c : v) sum += c;
  return sum;
}

int main() {
  int n, m;
  cin >> n;
  vector<int> times(n);
  rep(i, n) cin >> times[i];
  cin >> m;
  vector<int> tottimes(m);
  rep(i, m) {
    int problem, time;
    cin >> problem >> time;
    --problem;
    tottimes[i] = sumVector(times, problem, time);
  }

  for (auto c : tottimes) cout << c << endl;
}

Measured memory_bytes: 3628
N = int(input())

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

for i in range(N):
    if(A[i] % 2 == 1):
        continue
    else:
        if(A[i] % 3 == 0 or A[i] % 5 == 0):
            continue
        else:
            print('DENIED')
            exit()
print('APPROVED')

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    vector<ll> A,S;
    rep(i,N) {
        int a;
        cin >> a;
        A.push_back(a);
        if (i==0) S.push_back(a);
        else S.push_back(S[i-1]+a);
    }
    ll ans1 = 0;
    ll sub = 0;
    
    rep(i,N) {
        if (i%2==0) {
            if (S[i]+sub>=0) {
                ans1 += S[i]+sub+1;
                sub -= S[i]+sub+1;
            }
        }
        else {
            if (S[i]+sub<=0) {
                ans1 -= S[i]+sub-1;
                sub -= S[i]+sub-1; 
            }
        }
    }

    ll ans2 = 0;
    sub = 0;
    rep(i,N) {
        if (i%2!=0) {
            if (S[i]+sub>=0) {
                ans2 += S[i]+sub+1;
                sub -= S[i]+sub+1;
            }
        }
        else {
            if (S[i]+sub<=0) {
                ans2 -= S[i]+sub-1;
                sub -= S[i]+sub-1; 
            }
        }
    }

    ll ans = min(ans1,ans2);
    cout << ans << endl;

}


Measured memory_bytes: 5096
class _UnionFind:
    __slots__ = ['id']
    def __init__(self, n):
        self.id = [-1] * n
    def find(self, x):
        if self.id[x] < 0:
            return x
        else:
            self.id[x] = self.find(self.id[x])
            return self.id[x]
    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        res = self.id[x] * self.id[y]
        self.id[x] += self.id[y]
        self.id[y] = x
        return res

N, *A = map(int, open(0).read().split())
uf = _UnionFind(N)
idx = {A[i]: i for i in range(N)}
ans = 0
for a in range(N, 0, -1):
    i = idx[a]
    ans += a
    if i - 1 >= 0 and A[i - 1] > A[i]:
        ans += uf.union(i - 1, i) * a
    if i + 1 < N and A[i + 1] > A[i]:
        ans += uf.union(i + 1, i) * a
print(ans)

Measured memory_bytes: 39804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c;
  in3(a, b, c);
  out(min(b / a, c));
  memi;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int V[100000];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	priority_queue<int> Q;
	int X, Y, A, B, C;
	long long ans=0;
	cin>>X>>Y>>A>>B>>C;
	for(int i=0;i<A;i++) cin>>V[i];
	sort(V,V+A,greater<int>());
	for(int i=0;i<X;i++) Q.push(V[i]);
	for(int i=0;i<B;i++) cin>>V[i];
	sort(V,V+B,greater<int>());
	for(int i=0;i<Y;i++) Q.push(V[i]);
	for(int i=0;i<C;i++) {
		int a;
		cin>>a;
		Q.push(a);
	}
	for(int c=X+Y;c--;) {
		ans+=Q.top();
		Q.pop();
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 2804
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayLong();
            var A = input[0];
            var B = input[1];
            if (A >= 1 && A <= 9 && B >= 1 && B <= 9)
            {
                Console.WriteLine(A * B);
            }
            else
            {
                Console.WriteLine(-1);
            }

            Console.WriteLine();
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h> 
typedef double ll;
#define pb push_back
#define MP make_pair

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char s[1000];
    cin>>s;
    int n=strlen(s);
    for(int i=0;i<n;i++)
    {
        s[i]='x';
        cout<<s[i];
    }
   
    

    
     
    
     return 0;
}


Measured memory_bytes: 3624