akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
  	A--; B--; C--; D--;
  	
  	int S[N+3];
  	char s[N+1];
  
  	cin >> s;
    for(int i=0; i<N; i++){
        S[i] = s[i] == '#';
    }
  	for(int i=0; i<3; i++) S[N+i]=1;

    bool can=true;
  	int CD=max(C,D); 

    for(int i=A+1; i<CD; i++){
        if (S[i]&&S[i+1]) can=false;
    }

    if (C>D){
      	bool good=false;
        for(int i=B-1; i<D; i++){
            if (!S[i] && !S[i+1] && !S[i+2]) good = true;
        }
        if (!good) can=false;
    }
    if (can) cout << "Yes";
    else cout << "No";
}


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

#define int long long
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
#define rep(i,a,n) for(int i=a; i<n; i++)
#define endl "\n"
#define e "\n"
#define show(arr) REP(i,arr.size()){cout<<arr[i]<<" ";}
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

#define N 5010

void solve()
{
    int n,x;
    cin >> n >> x;
    vi a;
    for(int i=0;i<n;i++){
        int y;
        cin>>y;
        a.pb(y);
    }
    sort(a.begin(),a.end());
    bool run=true;
    int i=0;
    while(run && i<n){
        if (a[i]<=x){
            if ((i==n-1)&&a[i]!=x) break;
            x-=a[i];
            i++;
        }
        else{
            run = false;
        }
    }
    cout<<i;
}

signed main()
{
    int t=1;
    //cin>>t;
    WL(t)solve();

    return 0;
}




Measured memory_bytes: 3620
s=input()
cnt=0
prev=''
pre_max=0
ans=0
for w in s:
    if prev==w:
        cnt+=1
    else:
        ans+=cnt*(cnt+1)//2
        if w=='<':
            shou=min(pre_max, cnt)
            ans-=shou
        pre_max=0
        pre_max+=cnt
        cnt=1
    prev=w
ans+=cnt*(cnt+1)//2
if w=='>':
    shou=min(pre_max, cnt)
    ans-=shou
print(ans)

Measured memory_bytes: 4108
# 各位の値を足し算する処理2
def sum_each_digit(n):
    total_each_digit = 0
    while n >= 1:
        total_each_digit += n % 10
        n //= 10
    return total_each_digit


N, A, B = map(int, input().split())
target_total = 0    # 加算対象の数値の和

for n in range(1, N + 1):

    if A <= sum_each_digit(n) <= B:
        target_total += n

print(target_total)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner( System.in);
		String  x;
		int i=0,j=0;
		x =stdin.next();
		for(int k=1;k<=x.length();k++){
			String xx=x.substring(k-1,k);
			if(xx.equals("S")){i++;
			}else{i--;
			}
			if(i<0){
				j++;
				i=0;
			}
		}
		System.out.print(j*2);
	}
}


Measured memory_bytes: 37124
#include <bits/stdc++.h>
using namespace std;
#include<chrono>
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define mt make_tuple
#define tc  ll t; cin>>t; while(t--)
#define io ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define F first
#define S second
#define vi vector<ll>
#define pii pair<ll,ll>
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define vii vector<pair<ll,ll>>
ll gcd(ll n,ll m)
{
    if(n==0)
            return m;
    return gcd(m%n,n);
}
bool ifprime(ll n)
{
if(n==1)
return false;
    ll i;
for(i=2;i*i<=n;i++)
{
if(n%i==0)
return false;
 
}
return true;
}
void disp(vi v)
{
    for(auto u:v)
    cout<<u<<" ";
    cout<<"\n";
}
void remleadzero(vector<int> &v)
{
    vector<int> u;
    int i=0;
    while(v[i]==0)
        i++;
    while(i<v.size())
    {
        u.push_back(v[i]);
        i++;
    }
    v=u;
}
#define mod 1000000007LL
/*
void myscanf(long long *n)
{
    register long long c=getchar_unlocked();
    *n=0;
    for(;(c<48 ||c>57);c=getchar_unlocked())
        ;
    for(;(c>47 && c<58);c=getchar_unlocked())
    {
        *n=(*n<<1)+(*n<<3)+(c&15);
    }
 
}
void fastscan(long long &number)
{
    bool negative = false;
    register long long c;
 
    number = 0;
 
    c = getchar_unlocked();
    if (c=='-')
    {
 
        negative = true;
 
        c = getchar_unlocked();
    }
 
 
    for (; (c>47 && c<58); c=getchar_unlocked())
        number = number *10 + c - 48;
 
 
    if (negative)
        number *= -1;
}
*/
ll fast_expo(ll n,ll m, ll md)
{
    ll a=1;
    while(m>0)
    {
        if(m&1) a=(a*n)%md;
        n=(n*n)%md;
        m/=2;
    }
    return a%md;
}
long long sqroot(long long n){
    long double N = n;
    N = sqrtl(N);
    long long sq = N-2;
    sq = max(sq,0LL);
    while(sq*sq<n){
        sq++;
    } 
    if((sq*sq)==n)
        return sq;
    return -1;
}
int main()
{
    io;
    ll n,d,a,ans=0;
    cin>>n>>d>>a;
    pair<int,int> p[n];
    ll c[200005]{};
    for(int i=0;i<n;i++)
        cin>>p[i].first>>p[i].second;
    int i,j=0;
    sort(p,p+n);
    for(i=0;i<n;i++){
        // cout<<p[i].first<<'\n';
        while(j<n and (p[j].first-p[i].first)<=(2*d))
            j++;
        ll req = max(0LL,(p[i].second-(c[i]*a) + a-1)/a);
        ans+=req;
        c[i]+=req;
        c[j]-=req;
        c[i+1]+=c[i];
    }
    cout<<ans;
    return 0;
}


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

#define int long long

vector<vector<int> > w_line;

signed main() {
  int n, m, a;
  while ( cin >> n >> m >> a, n ) {
    int w_line[1001][101] = {0};
    for ( int i = 0; i < m; i++ ) {
      int h, p, q;
      cin >> h >> p >> q;
      w_line[h][p] = q;
      w_line[h][q] = p;
    }
    
    for ( int i = 1000; i >= 1; i-- ) {
      if ( w_line[i][a] ) a = w_line[i][a];
    }

    cout << a << endl;
  }
  return 0;
}



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

signed main()
{
	ios::sync_with_stdio(0);
	long long n,m,k,ans=0;
    cin >> n >> m >> k;
    
    long long a[n+5]={0};
	long long b[m+5]={0};
	
    for(long long i=1; i<=n; i++)
    {
    	cin >> a[i];
		a[i] += a[i-1];
    }
    for(long long i=1; i<=m; i++)
    {
    	cin >> b[i];
		b[i] += b[i-1];
    }
    
    for(long long i=0; i<=n; i++) 
    { 
		if(k>=a[i])
		{ 
			ans = max(ans,upper_bound(b+1,b+1+m,k-a[i])-b-1+i);
		} 
	} 
    
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 6748
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

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

	int ans = 0;
	int a, b, n;
	cin >> a >> b >> n;
	auto tr = [&](int x) {
		ans = max(ans, (x % b) * a - (a * x) % b);
	};
	tr(min(n, b - 1));
	cout << ans / b << endl;
}


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i + 1 < n; i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << ' ' << i + 2 << '\n';
            return 0;
        }
    }
    for (int i = 0; i + 2 < n; i++) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << ' ' << i + 3 << '\n';
            return 0;
        }
    }
    cout << -1 << ' ' << -1 << '\n';
    return 0;
}

Measured memory_bytes: 512
N,A,B=map(int,input().split())
S=input()
an=0
bn=0

for i in list(S):
    if i == "a" and an+bn<A+B :
        print("Yes")
        an+=1
    elif i == "b" and an+bn<A+B and bn<B:
        print("Yes")
        bn+=1
    else:
        print("No")

Measured memory_bytes: 57336
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  int A,B;
  cin>>A>>B;
  int C;
  if(A>=13) C=B;
  if(A<13&&A>5) C=B/2;
  if(A<=5) C=0;
  cout<<C<<endl;
}

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

using namespace std;

int main() {
	int l, r, d;
	cin >> l >> r >> d;
	int ans = 0;
	for (int i = 1; i <= r; i++) {
		if (i * d <= r && i * d >= l) {
			ans++;
		}
	}
	cout << ans;
}

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

#define For(i, j, k) for (int i = j; i <= k; i++)

typedef long long LL;

LL A, B, C, D;

LL gcd(LL x, LL y) {
	return !y ? x : gcd(y, x % y);
}

int main() {

	scanf("%*d");
	while (scanf("%lld%lld%lld%lld", &A, &B, &C, &D) == 4) {
		if (A < B || B > D) { puts("No"); continue; }
		if (C >= B) { puts("Yes"); continue; }
		LL d = gcd(B, D);
		A %= d;
		LL x =( (C / d) * d) + A;
		if (x <= C) x += d;
		puts(x < B ? "No" : "Yes");
	}

	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 rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, W, w0, w, v;
vi vs[4];

int main() {
	cin >> n >> W;
	cin >> w0 >> v;
	vs[0].pb(v);
	// w0と比較した相対的な重さで分ける 0,1,2,3の4通りしかない
	reps(i,1,n) {
		cin >> w >> v;
		vs[w-w0].pb(v);
	}
	// 降順ソートして価値が高い順に取り出せるようにしとく
	rep(i,4) sort(vs[i].rbegin(), vs[i].rend());
	// ↓で毎回手前からi個、j個…って取ってると時間かかるから累積和をとっておく
	// 毎回合計求めてもたかだか100回だから本番だったら実装の手間かかるだけかも
	int vsum[4][101] = {{}};
	ll wsum[4][101] = {{}};
	rep(i,4) {
		repst(j,1,vs[i].size()) {
			vsum[i][j] = vsum[i][j-1] + vs[i][j-1];
			wsum[i][j] = wsum[i][j-1] + w0 + i;
		}
	}
	// それぞれの重さから何個取るか決めて全列挙し、重さの合計がW以下なら価値の合計でansを更新
	int ans = 0;
	rept(i,vs[0].size()) {
		rept(j,vs[1].size()) {
			rept(k,vs[2].size()) {
				rept(l,vs[3].size()) {
					int Vs = vsum[0][i] + vsum[1][j] + vsum[2][k] + vsum[3][l];
					ll Ws = wsum[0][i] + wsum[1][j] + wsum[2][k] + wsum[3][l];
					if (Ws<=W) chmax(ans, Vs);
					else break;
				}
			}
		}
	}
	cout << ans << ln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int M;
int N;
bool bpm(ll bpGraph[101][101], int u, bool seen[], int matchR[])
{
   
    for (int v = 0; v < N; v++)
    {
      
        if (bpGraph[u][v] && !seen[v])
        {
            seen[v] = true;
 
        
            if (matchR[v] < 0 || bpm(bpGraph, matchR[v], seen, matchR))
            {
                matchR[v] = u;
                return true;
            }
        }
    }
    return false;
}
 

int maxBPM(ll bpGraph[101][101])
{
  
    int matchR[N];
 

    memset(matchR, -1, sizeof(matchR));
 
    int result = 0; 
    for (int u = 0; u < M; u++)
    {
     
        bool seen[N];
        memset(seen, 0, sizeof(seen));
 
       
        if (bpm(bpGraph, u, seen, matchR))
            result++;
    }
    return result;
}

int main()
 {
   ll n;
   cin>>M;
   n=M;
//cout<<N<<M;
N=M;
vector<pair<ll,ll>> v,s;
    for(ll i=0;i<n;i++)
     { ll a,b;
       cin>>a>>b;
       v.push_back(make_pair(a,b));
     }
       for(ll i=0;i<n;i++)
     { ll a,b;
       cin>>a>>b;
       s.push_back(make_pair(a,b));
     }
 ll mat[101][101]={0};   
   for(ll i=0;i<n;i++)
      {
         for(ll j=0;j<n;j++)
            {   
               if((v[i].first<s[j].first)&&(v[i].second<s[j].second))
                     mat[i][j]=1;  
                    
                 }
               }
  
            cout<<maxBPM(mat);
 
   return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<cctype>
int main(void) {
	std::string InputS, InputP;
	std::cin >> InputS >> InputP;
	bool Answer = false;
	int count = 0;
	while (count < InputS.size()) {
		if (InputS[count] == InputP[0]) {
			bool flag = false;
			for (int i = 0; i < InputP.size(); ++i) {
			
				if (InputS[(count + i) % InputS.size()] != InputP[i]) {
					flag = false;
					break;
				}
				else { flag = true; }
			}
			if (flag == true) {
				Answer = true;
				break;
			}
		}
		++count;
	}
	std::cout << (Answer ? "Yes" : "No") << std::endl;
//system("pause");
	return 0;
}

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

typedef long long ll;
typedef long double ld;
#define pb push_back
#define pll pair<ll,ll>
#define vl vector<ll>
#define vll vector < pll >
#define sl set<ll>
#define mll map<ll,ll>
#define itr :: iterator
#define pf push_front
#define ff first
#define ss second
#define stkl stack <ll>
#define quel queue <ll>
#define pquel priority_queue <ll>
#define rep(i,n) for(i=0;i<n;i++)
#define MOD 1000000007
#define SIZE 200005
#define PI 3.14159265358979323846

#define debug(var) cout << "[" << __LINE__ << "] " << #var << " = " << (var) << endl;

struct edge {
    ll A;
    ll B; 
};

// Implementation of DSU (Union by Rank)
/*
ll parent[SIZE],rank[SIZE];

ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void make_set(ll v) {
    parent[v] = v;
    rank[v] = 0;
}

void union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rank[a] < rank[b])
            swap(a, b);
        parent[b] = a;
        if (rank[a] == rank[b])
            rank[a]++;
    }
}
*/
//*********************************************

ll power(ll a, ll b, ll mod){
    ll x = 1, y = a;
    while (b > 0){
        if (b%2){
            x = (x*y)%mod;
        }
        y = (y*y)%mod;
        b /= 2;
    }
    return x%mod;
}   
 
// FOR FINDING MODULAR INVERSE 

ll modular_inverse(ll n, ll mod){
    return power(n, mod-2, mod);
}


bool edgecompare(edge lhs, edge rhs) { if(lhs.B!=rhs.B)return lhs.B < rhs.B;
else return lhs.A<rhs.A;}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<setprecision(25);

    // ll i,n;
    // ld a[SIZE],b[SIZE];
    // cin>>n;
    
    // rep(i,n)
    // {
    //     cin>>a[i];
        
    // }

    ll n,m,i,j,k,x;
    ll *a;//[SIZE];
    
    cin>>n;
    edge* v = new edge[n];
    rep(i,n)
    {
        cin>>v[i].A;
        cin>>v[i].B;
    }

    sort(v,v+n,edgecompare);

    ll curr = 0;
    bool flag = 0;
    for(i=0;i<n;i++){
        curr+=v[i].A;
        if(curr>v[i].B){
            flag = 1;
            break;
        }
    }

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

    delete v;

   return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = abs(a[0] - a[n-1]);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
/* Author - Ankur Kumar Singh 
	IDE :- Offine Linux
 ---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
/* variable type :- */
	/* variable type :- */
	# define ll  long long int
	# define ld long double
	# define I int
	# define mod 1000000007
/* map */
	# define abc  pair<long long int,long long int>
	map < pair < abc,abc > , long long int > pqr;
	map <  pair < long long int,long long int > ,long long int > xyz;	
/* vector */
	# define pb push_back
	# define pp pop_back
	# define ff first
	# define ss second
	# define mp make_pair
	# define ac accumulate
	vector<pair<ll,string>>a1;
	vector<pair<ll,string>>a2;
	vector<pair<ll,string>>a3;
	vector<pair<ll,string>>a4;
	vector<pair<ll,string>>a5;
	vector<pair<ll,string>>a6;
	vector<pair<ll,string>>a7;
	vector<pair<pair<ll,ll>,ll>>b;
bool compare( const pair<long long int,long long int>&x , const pair<long long int,long long int>&y )
{
	return x.ff>y.ff;
}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
{
        return (a.ss < b.ss);
}
bool isPowerOfTwo(ll n) 
{ 
   return (ceil(log2(n)) == floor(log2(n))); 
} 
int main()
{
	ios_base::sync_with_stdio(false); 
    	cin.tie(NULL);   
	ll n,m,x,y;
	cin>>n>>m>>x>>y;
	ll arr1[n+1];
	ll arr2[m+1];
	for(ll i=0;i<n;i++)
	{
		cin>>arr1[i];
	}
	for(ll i=0;i<m;i++)
	{
		cin>>arr2[i];
	}
	sort(arr1,arr1+n);
	sort(arr2,arr2+m);
	ll k=arr1[n-1];
	ll w=arr2[0];
	k=max(k,x);
	w=min(w,y);
	if(k<w)
	{
		cout<<"No War";return 0;
	}
	else
	{
		cout<<"War";return 0;
	}
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdint>
#include <iostream>

using namespace std;

int main() {
  long double a, b, c;
  cin >> a >> b >> c;
  if (a + b + (2 * sqrt(a * b)) < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll A, B;
    cin >> A >> B;
    cout << A * B << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    REP(i, 100) {
        REP(j, 100) {
            if(i * 4 + j * 7 == N) {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define INF2 (1e18)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

using mint = modint998244353;

const mint inv9 = mint(1) / mint(9);

struct S {
    mint x, w;
    S(mint x=0, mint w=1) : x(x), w(w) {}
};

S op(S a, S b) { return S(a.x*b.w+b.x, a.w*b.w); }

S e() { return S(0, 1); }

S mapping(int f, S s) {
    if (f == 0) return s;
    else return S((s.w-1)*inv9*f, s.w);
}

int composition(int g, int f) {
    if (g == 0) return f;
    else return g;
}

int id() { return 0; }

int main(){
    int n, q;
    cin >> n >> q;
    lazy_segtree<S, op, e, int, mapping, composition, id> seg(n);
    rep(i, n) seg.set(i, S(1, 10));
    rep(i, q) {
        int l, r, d;
        cin >> l >> r >> d;
        --l;
        seg.apply(l, r, d);
        printf("%u\n", seg.all_prod().x.val());
    }
    return 0;
}


Measured memory_bytes: 9812
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll lcm(ll ans,ll y)
{
	ll g=__gcd(ans,y);
	
	return ans/g*y;
}
int main()
{
	int t=1;// cin>>t;
	while(t--)
	{
		int n; cin>>n;
		ll a[n];
		for(int i=0;i<n;i++) cin>>a[i];
		
		ll ans=a[0];
		for(int i=1;i<n;i++)
		{
			ans=lcm(ans,a[i]);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
struct ab{
	int id,x,y;
};
long op(int a){
	return a*a;
}
int b[8]={1,2,6,24,120,720,5040,40320};
bool cmp(ab a,ab b){
	if(a.id>b.id) return false;
	else if(a.id<b.id)return true;
	else if(a.id==b.id) return true;
}
int main(){
	int n,i,j;
	long double sum=0;
	cin>>n;
	ab a[n];
	for(i=0;i<n;i++){
		cin>>a[i].x>>a[i].y;
		a[i].id=i;
	}
	do{
		for(i=0;i<n-1;i++){
			sum+=double(sqrt((op(a[i].x-a[i+1].x)+op(a[i].y-a[i+1].y))*1.0));
		}
	}while(next_permutation(a,a+n,cmp));
	cout<<fixed<<setprecision(10)<<double(sum*1.0/b[n-1]);
	
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
x = list(map(int, input().split()))

res = []

for i in range(N-K+1):
    l_r = abs(x[i]) + abs(x[i+K-1] - x[i])
    r_l = abs(x[i+K-1]) + abs(x[i+K-1] - x[i])
    res.append(min(l_r, r_l))

print(min(res))

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll a, b, x;
  cin >> a >> b >> x;

  ll aa = x * ((a + x - 1) / x);
  ll bb = x * (b / x);

  if(bb - aa < 0){
    cout << 0 << endl;
  }else{
    cout << (bb - aa) / x  + 1<< endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


#define int ll




int n;
string s1,s2;
int cnt;
bool can[55];
signed main(){
    cin>>n>>s1>>s2;
    rep(i,0,55)can[i]=false;
    if(s1[0]==s2[0]){
        can[0]=true;
        cnt=3;
    }else cnt=6;
    
    rep(i,1,s1.size()){
        if(s1[i]==s2[i])can[i]=true;
        if(s1[i-1]!=s1[i]){
            if(can[i-1]==false && can[i]==false){
                cnt*=3;
            }else if(can[i-1]==false && can[i]==true){
                cnt*=1;
            }else cnt*=2;
            cnt%=1000000007;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

long long int MOD = 1000000007;

long long int modpow(long long int a, long long int n) {
  long long int res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

int main() {
  int N;
  cin >> N;
  long long int C = 0;
  map<pair<long long int, long long int>, long long int> M;
  for (int i = 0; i < N; i++) {
    long long int A, B;
    cin >> A >> B;
    if (A == 0 && B == 0) {
      C++;
      continue;
    }
    else if (A == 0) B = 1;
    else if (B == 0) A = 1;
    else {
      if (A < 0) {
        A *= -1;
        B *= -1;
      }
      long long int G = __gcd(abs(A), abs(B));
      A /= G;
      B /= G;
    }
    pair<long long int, long long int> P = make_pair(A, B);
    if (M.count(P)) M.at(P)++;
    else M[P] = 1;
  }
  long long int ans = 1;
  for (auto P : M) {
    long long int X = P.first.first, Y = P.first.second;
    pair<long long int, long long int> Q;
    if (Y > 0) Q = make_pair(Y, -X);
    else Q = make_pair(-Y, X);
    if (M.count(Q)) ans *= (modpow((long long int)2, M[P.first]) + modpow((long long int)2, M[Q]) - 1) % MOD;
    else ans *= modpow((long long int)2, M[P.first]);
    ans %= MOD;
    M.erase(P.first);
    if (M.count(Q)) M.erase(Q);
  }
  ans = (ans + C - 1 + MOD) % MOD;
  cout << ans << endl;
}


Measured memory_bytes: 15924
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

    ll k;
    cin >> k;
    ll a, b;
    cin >> a >> b;

    ll left = a % k;

    if (left)
        a += k - left;

    cout << (a <= b ? "OK" : "NG");
}

Measured memory_bytes: 3604
a , b =map(int,input().split())
#print(a,b)

if a < b :
    print(str(a)*b)
else :
    print(str(b)*a)
'''
a , b =input().split()
#print(a,b)

if a < b :
    print(a*int(b))
else :
    print(b*int(a))
'''

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int W, H;
	cin >> W >> H;
	vector<pll> p;
	rep(i,W+H) {
		int a;
		cin >> a;
		p.push_back(pll(a,i<W ? 0:1));
	}
	sort(all(p));
	ll c, r;
	ll res = 0;
	c = r = 0;
	rep(i,p.size()) {
		if(p[i].se == 0) {
			res += (H+1-c) * p[i].fi;
			r++;
		}
		else {
			res += (W+1-r) * p[i].fi;
			c++;
		}
	}
	cout << res << endl;
	return 0;
}


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


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

    vector<int> costs(n);
    vector<int> values(n);
    for (int i=0; i < n; i++)
    {
        cin >> values[i];
    }
    for (int i=0; i < n; i++)
    {
        cin >> costs[i];
    }

    int maxValue = 0;
    for (int i=0; i < n; i++)
    {
        int temp = values[i] - costs[i];
        if (temp > 0)
        {
            maxValue += temp;
        }
    }

    cout << maxValue << std::endl;

    return 0;
}

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

int n, t, a, x;
int h[1000];

int main() {
  int res = 0;
  int min_diff = 1<<30;
  cin >> n >> t >> a;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    int diff = (t * 1000 - x * 6) - a * 1000;
    if (diff < 0) diff = -diff;
    if (diff < min_diff) {
      res = i;
      min_diff = diff;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<int, int> a, pair<int, int> b) {
	return a < b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	vint a(n);
	int cnt = 0;
	rep(i, n) {
		cin >> a[i];
		if (a[i] != i + 1) {
			cnt++;
		}
	}
	YES(cnt == 2 || cnt == 0);
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  
  sort(p.begin(), p.end(), greater<int>());
  
  int res = 0;
  
  for (int i = 0; i < n; i++) {
	if (i == 0) res += p[i]/2;
    else res += p[i];
  }
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int x = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextInt();
		
		quickSort(a);
		
		System.out.println(maxNum(a, x));

	}
	
	public static void quickSort(int[] list) {
		quickSort(list, 0, list.length - 1);
	}
	
	public static void quickSort(int[] list, int first, int last) {
		if (last > first) {
			int pivotIndex = partition(list, first, last);
			quickSort(list, first, pivotIndex - 1);
			quickSort(list, pivotIndex + 1, last);
		}
	}
	
	public static int partition(int[] list, int first, int last) {
		int pivot = list[first];
		int low = first + 1;
		int high = last;
		
		while (high > low) {
			while (low <= high && list[low] <= pivot)
				low++;
			
			while (low <= high && list[high] > pivot)
				high--;
			
			if (high > low) {
				int temp = list[high];
				list[high] = list[low];
				list[low] = temp;
			}
		}
		
		while (high > first && list[high] >= pivot)
			high--;
		
		if (pivot > list[high]) {
			list[first] = list[high];
			list[high] = pivot;
			return high;
		}
		else
			return first;
	}
	
	public static int maxNum(int[] list, int x){
		int index = 0;
		while (x >= list[index]){
			x -= list[index];
			index++;
			if (index == list.length - 1){
				if (x == list[index])
					return list.length;
				else 
					return list.length - 1;
			}
		}
		return index;
	}

}

Measured memory_bytes: 22100
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::vector< ll > va(N, 0LL);

  std::map<ll, ll> mc;
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
    mc[va[i]]++;
  }

  ll ans = 0LL;
  for (auto a : va) {
    ans = std::max(ans, mc[a-1] + mc[a] + mc[a+1]);
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define endl '\n'
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
const int MX=2e6+7;
const int mod=998244353;
const double pi=3.1415926535897932384;
double isp=1e-13;
using namespace std;
ll qpow(ll a,ll b,ll MOD=mod){for(ll ans=1;;a=a*a%MOD,b>>=1){if(b&1)ans=ans*a%MOD;if(!b)return ans;}}
ll inv(ll a,ll MOD=mod){return qpow(a,MOD-2,MOD);}//要求MOD为质数
ll exgcd(ll a,ll b,ll &x,ll &y){if(b==0){x=1,y=0;return a;}ll ret=exgcd(b,a%b,y,x);y-=a/b*x;return ret;}
ll getInv(int a,int mod){ll x,y;ll d=exgcd(a,mod,x,y);return d==1?(x%mod+mod)%mod:-1;}//求a在mod下的逆元，不存在逆元返回-1，不要求MOD为质数
int main()
{
  ios::sync_with_stdio(0),cin.tie(0);
  ll n,s;
  cin>>n>>s;
  ll m=sqrt(n);
  if(n==s)
  {
      cout<<n+1<<endl;
      return 0;
  }
  for(int i=2;i<=m;i++)
  {
      ll cnt=0;
      ll k=n;
      while(k)
      {
          cnt+=k%i;
          k/=i;
      }
      if(cnt==s)
      {
          cout<<i<<endl;
          return 0;
      }
  }
  for(ll k=m;k>=1;k--)
  {
      if((n-s)%k==0&&k<(n-s)/k+1&&n-k*((n-s)/k+1)<(n-s)/k+1&&n-k*((n-s)/k+1)>=0)
      {
          cout<<(n-s)/k+1<<endl;
          return 0;
      }
  }
  cout<<-1<<endl;
  return 0;
}



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

public class Main {

	static ArrayList<Integer>[] adj;
	static int INF = (int) 1e9;
	static int[] l, r;

	static boolean dfs(int u, int p) {
		boolean decided = l[u] != -INF;
		for (int v : adj[u])
			if (v != p) {
				dfs(v, u);
				l[u] = Math.max(l[v] - 1, l[u]);
				r[u] = Math.min(r[v] + 1, r[u]);
			}
		if (l[u] > r[u])
			return false;
//		if (!decided) {
//			l[u]--;
//			r[u]++;
//
//		}
		return true;
	}

	static boolean solve(int u, int p) {
		int prev = l[p];
		boolean ans = false;
		for (int i = -1; i <= 1; i += 2)
			if (prev + i >= l[u] && prev + i <= r[u]) {
				l[u] = prev + i;
				ans = true;
				break;
			}
		if (!ans)
			return false;
		for (int v : adj[u])
			if (v != p) {
				ans &= solve(v, u);
			}
		return ans;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		adj = new ArrayList[n];
		for (int i = 0; i < n; i++)
			adj[i] = new ArrayList();
		for (int i = 1; i < n; i++) {
			int u = sc.nextInt() - 1, v = sc.nextInt() - 1;
			adj[u].add(v);
			adj[v].add(u);

		}
		int k = sc.nextInt();
		int root = -1;
		l = new int[n];
		r = new int[n];
		Arrays.fill(l, -INF);
		Arrays.fill(r, INF);
		while (k-- > 0) {
			root = sc.nextInt() - 1;
			int x = sc.nextInt();
			l[root] = x;
			r[root] = x;
		}
		
		boolean ans = dfs(root, root);
		

		
		for (int v : adj[root])
			ans &= solve(v, root);
		out.println(ans ? "Yes" : "No");
		if (ans)
			for (int i = 0; i < n; i++)
				out.println(l[i]);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

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

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

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

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

		int[] nxtArr(int n) throws IOException {
			int[] ans = new int[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextInt();
			return ans;
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

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

using namespace std;

int in()
{
    int a;
    scanf("%d",&a);
    return a;
}

int main()
{
    int a[305][305];
    int n=in();
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++){
            a[i][j]=in();
        }
    }
    long long ans=0;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<i; j++)
        {
            bool hoise=1;
            for(int k=0; k<n; k++)
            {
                if(a[i][j]==(a[i][k]+a[k][j])&&(a[i][j]!=a[i][k])&&(a[k][j]!=a[i][j]))
                    hoise=0;
                else if(a[i][j]>(a[i][k]+a[k][j])&&a[i][k]&&a[k][j])
                {
                    printf("-1\n");
                    return 0;
                }
            }
            if(hoise)
            {
                ans+=a[i][j];
            }
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0; i<N; i++)

using namespace std;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n-1) cin >> c[i];

  int ans = 0;

  int food = 0;
  int before_food = 0;
  for(int i = 0; i < n; i++){
    food = a[i];
    ans += b[food-1];
    if(before_food == food - 1){
      ans += c[before_food-1];
    }
    before_food = a[i];
  }
  cout << ans << endl;
}

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

int main() {
  int N;
  cin>>N;
  vector<int> p(3*N);
for (int i = 0; i < 3*N; i++) {
  cin >> p.at(i);
}
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  int64_t Z=0;
  for(int i=1;i<2*N;i+=2){
    Z+=p.at(i);
  }
  cout<<Z<<endl;

}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

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

	vector<long int> A(n+1);
	vector<long int> B(n+1);

	for(int i=0; i<n+1; i++){
		cin >> A[i];
	}
	for(int i=0; i<n; i++){
		cin >> B[i];
	}
	B[n]=0;

	long int r=0;
	long int d=0;

	for(int i=0; i<n+1; i++){
		if(A[i]<=d){
			r+=A[i];
			d=B[i];
		}else{
			A[i]-=d;
			r+=d;
			if(A[i]<=B[i]){
				d=B[i]-A[i];
				r+=A[i];
			}else{
				d=0;
				r+=B[i];
			}
		}
	}

	cout << r << endl;

	return 0;

}



Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Scanner;

public class Main
{
    public static void main(String argp[])
    {
        Scanner in=new Scanner(System.in);
        int N,K;
        N=in.nextInt();
        K=in.nextInt();
        ArrayList<Integer> H=new ArrayList<>();
        ArrayList<Integer> dp=new ArrayList<>();
        for(int i=0;i<N;i++)
        {
            dp.add(Integer.MAX_VALUE);
            H.add(in.nextInt());
        }
        dp.set(0,0);
        for(int i=0;i<N;i++)
        {
            for(int j=1;j<=K;j++)
            {
                if(j+i<N)
                {
                    dp.set(i+j,Math.min(dp.get(i+j),dp.get(i)+Math.abs(H.get(i)-H.get(i+j))));
                }
            }
        }
        System.out.println(dp.get(N-1));
    }
}


Measured memory_bytes: 98964
#include<iostream>

int main(){
  int a,b;
  while(std::cin >> a >> b){
    int sum = a + b;
    int i = 0;
    do{
      sum /= 10;
      i++;
    }while(sum > 0);
    std::cout << i << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main()
{
        int a,b,c;
        scanf("%d %d",&a,&b);

        int i;

        for(i=0; i<2; i++){
        if(a > b){
                c += a;
                a--;
        }
        else{
                c += b;
                b--;
        }
        }

        printf("%d\n",c);
        return 0;
}


Measured memory_bytes: 128
l=input()
deg=len(l)-1
mod=10**9+7
ans=(3**deg)%mod
x=[]
n=len(l)
for i in range(1,n+1):
    if l[-i]=='1':
        x.append(i)
c=len(x)
ans+=2**c
two=(2**c)%mod
three=1
x_ref=1
for i in range(1,c):
    if two%2==0:
        two=two//2
    else:
        two=(two+mod)//2
    three=(three*3**(x[i-1]-x_ref))%mod
    x_ref=x[i-1]
    ans+=(two%mod)*(three%mod)
    ans%=mod
print(ans)

Measured memory_bytes: 45552
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();

    if a + b == 15 {
        println!("+");
    } else if a * b == 15 {
        println!("*");
    } else {
        println!("x");
    }
}


Measured memory_bytes: 4352
n = int(input())
a =list(map(int, input().split()))
if 0 in a:
  print(0)
else :
  prod = 1
  for x in a:
    prod *= x
    if prod:
      if prod > 10**18:
        print(-1)
        break
    else :
      print(0)
      break
  else :
    print(prod)


Measured memory_bytes: 21656
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, d, a;
	cin >> n >> d >> a;
	vector<pair<int, int>> vp(n);
	rep(i, n){
		int x, h;
		cin >> x >> h;
		vp.at(i) = make_pair(x, h);
	}
	sort(vp.begin(), vp.end());
	vector<ll> za;
	vector<ll> co;
	ll ans = 0;
	rep(i, n){
		ll x, h;
		tie(x, h) = vp.at(i);
		int n = lower_bound(za.begin(), za.end(), x) - za.begin();
		ll atkc = 0;
		if(co.size() != 0) atkc = co.back();
		if(n != 0) atkc -= co.at(n-1);
		h -= (ll)atkc * a;
		if(h <= 0) continue;
		ll ac = (h+a-1)/a;
		ans += ac;
		za.push_back((ll)x+2*d);
		if(co.size() != 0)ac += co.back();
		co.push_back(ac);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5100
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

void main()
{
    auto n = readln.chomp.to!int;
    auto as = readln.split.to!(long[]);

    auto x = as[0];
    auto y = reduce!"a + b"(0L, as[1..$]);
    auto d = abs(x - y);

    for (int i = 1; i < n-1; ++i) {
        x += as[i];
        y -= as[i];
        auto dd = abs(x - y);
        if (dd < d) d = dd;
    }

    writeln(d);
}

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

using namespace std;
typedef long long ll;

int N;
vector<ll> A;
ll cache[3000][3000];

ll dfs(int l, int r, int turn = 0) {
  if (turn == N - 1) {
    if (turn % 2 == 0) {
      return A[l];
    } else {
      return -A[l];
    }
  }

  if (cache[l][r] != -1) {
    return cache[l][r];
  }

  if (turn % 2 == 0) {
    ll v1 = A[l] + dfs(l + 1, r, turn + 1);
    ll v2 = A[r] + dfs(l, r - 1, turn + 1);

    return cache[l][r] = max(v1, v2);
  } else {
    ll v1 = dfs(l + 1, r, turn + 1) - A[l];
    ll v2 = dfs(l, r - 1, turn + 1) - A[r];

    return cache[l][r] = min(v1, v2);
  }
}

int main() {
  memset(cache, -1, sizeof(cache));
  cin >> N;

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

  cout << dfs(0, N - 1) << endl;

  return 0;
}


Measured memory_bytes: 70784