akhauriyash/Code-Regression huggingface dataset:
// Water Bottle    WAだった
#include <iostream>
#include <limits>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
    //const double pi=3.14159265;
    double a, b, x;
    cin >> a >> b >> x;
    cout << fixed << setprecision(20);
    if(x==a*a*b){
        cout << 0 << endl;
    }
    else if(x>=a*a*b/2){
        double c=2*b-2*x/(a*a);
        cout << 360*atan(c/a)/(2*M_PI) << endl;
    }
    else{
        double c=2*x/(a*b);
        cout << 360*atan(b/c)/(2*M_PI) << endl;
    }
    return 0;

}

Measured memory_bytes: 512
from math import factorial
def sol(inp=input):
    mod=10**9+7
    n,k=map(int,inp().split())
    res=[n-k+1 for _ in range(k)]
    def comb(n,k):
        if k>n:return 0
        return factorial(n)//(factorial(k)*factorial(n-k))
    for i in range(1,k):
        res[i]=comb(k-1,i)*comb(n-k+1,i+1)
    res=['{}'.format(r%mod) for r in res]
    return '\n'.join(res)
print(sol())

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

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

    cout << max(a + b, (max(a * b, a - b))) << endl;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
num = [0 for i in range(9)]
for i in range(N):
    if a[i] < 3200:
        num[a[i]//400] += 1
    else:
        num[-1] += 1

if num[-1] == 0:
    num = [i for i in num if i != 0]
    print(len(num),len(num))
else:

    n = num.pop(-1)

    num2 = [i for i in num if i != 0]
    print(max(1,len(num2)),len(num2)+n)

    

Measured memory_bytes: 3064
N=int(input())
i=0
f = 0
t0,x0,y0 = 0,0,0
while i <N:
    t1,x1,y1 = map(int,input().split(' '))
    dt = int(t1 - t0)
    dl = int(abs(x0-x1)+abs(y0-y1))
    if dt >= dl and int(dt-dl)%2 == 0:
        t0 = t1
        x0 = x1
        y0 = y1
        i += 1
    else:
        f = 1
        break
if f == 1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    if(a+b<=2*c)cout << a*x+b*y << endl;
    else{
        if(x<=y)cout << x*2*c+min((y-x)*b,(y-x)*2*c) << endl;
        else cout << y*2*c+min((x-y)*a,(x-y)*2*c) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;

int main(){

  int n,k;
  cin >> n >> k;
  ll r = 1;
  ll count = 0;
  while(n>=r){
    r *= k;
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long  T,X;
		long max=0;
		long sum=0;
		T = sc.nextInt();
		for(int i=0;i<T;i++) {
		X = sc.nextInt();
		if(X>max)max=X;
		sum=sum+X;
		}
		if(max>=(sum-max)){System.out.println("No");
		}else {System.out.println("Yes");
			
		}
		
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	while(1){
		int n,i,h,w,ans=0;
		double bmi,d=2000001;
		cin>>n;
		if(n==0) break;
		rep(j,0,n){
			cin>>i>>h>>w;
			bmi=(double)w/(h*h)*10000;
			//o(bmi);
			if(abs(22-bmi)<d){
				d=abs(22-bmi); ans=i;
			}if(abs(22-bmi)==d) ans=min(i,ans);
		}
		o(ans);
	}
}

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

using namespace std;
#define el '\n'
#define ll long long
typedef vector<int> vi;
const int N = 107;

int n;
ll memo[107][100007];
vector<pair<ll, ll>> items(N);

ll knapsack(int i, ll cap) {
    if (cap < 0)
        return 0;
    if (i == n || cap == 0)
        return 0;

    if (memo[i][cap] != -1)
        return memo[i][cap];

    ll take = 0;
    if (items[i].first <= cap)
        take = items[i].second + knapsack(i + 1, cap - items[i].first);
    ll leave = knapsack(i + 1, cap);
    ll ans = max(leave, take);
    return memo[i][cap] = ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll s;
    cin >> n >> s;

    ll a, b;
    for (int i = 0; i < n; ++i) {
        cin >> a >> b;
        items[i].first = a;
        items[i].second = b;
    }
    memset(memo, -1, sizeof(memo));
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < s + 1; ++j) {
            knapsack(i, j);
        }
    }
    cout << knapsack(0, s) << el;

    return 0;
}

Measured memory_bytes: 87236
#include <stdio.h>
#include <vector>
using namespace std;
int n, q;
int a, b, c;
vector<int>g[200000];
int p[200000];
long long x[200000];
int num[200000];
int inum[200000];
int range[200000];
long long dis[200001];
long long ans;
long long se[200000];
void dfs(int e, int f) {
	num[e] = c;
	c++;
	for (int i = 0; i < g[e].size(); i++) {
		if (g[e][i] != f)dfs(g[e][i], e);
	}
}
int efs(int e, int f) {
	int y = num[e];
	for (int i = 0; i < g[e].size(); i++) {
		if (g[e][i] != f) {
			c = efs(g[e][i], e);
			if (y < c)y = c;
		}
	}
	range[e] = y;
	return y;
}
int main() {
	scanf("%d%d", &n, &q);
	for (int i = 0; i < n - 1; i++) {
		scanf("%d%d", &a, &b);
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0, -1);
	for (int i = 0; i < n; i++) {
		inum[num[i]] = i;
	}
	efs(0, -1);
	for (int i = 0; i < q; i++) {
		scanf("%d%lld", p + i, x + i);
		p[i]--;
		dis[num[p[i]]] += x[i];
		dis[range[p[i]] + 1] -= x[i];
	}
	ans = 0;
	for (int i = 0; i < n; i++) {
		ans += dis[i];
		se[inum[i]] = ans;
	}
	for (int i = 0; i < n; i++) {
		if (i != (n - 1))printf("%lld ", se[i]);
		else printf("%lld\n", se[i]);
	}
}

Measured memory_bytes: 36480
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  
  int i;
  for (i = 0; i < N; i++){
  	cin >> a.at(i);
    a.at(i)--;
  }
  
  vector<int> b(N);
  int index = 0;
  int counter = 0;
  while(true){
    if (b.at(a.at(index)) == 0){
      b.at(a.at(index)) = 1;
      index = a.at(index);
      counter++;
    } else {
      cout << -1 << endl;
      break;
    }
    if (index == 1){
      cout << counter << endl;
      break;
    }
  }
}

Measured memory_bytes: 1024
import sys
n,m=map(int,input().split())
a=[]
b=[]
for _ in range(n):
    a.append(input())

for _ in range(m):
    b.append(input())

for iy in range(n-m+1):
    for ix in range(n-m+1):
        bflag=True
        for jy in range(m):
            for jx in range(m):
#                print(iy,ix,jy,jx)
                if(a[iy+jy][ix+jx] != b[jy][jx]):
                    bflag=False
                    break
            if(not bflag):
                break
        else:
            print("Yes")
            sys.exit()

print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K, even, odd, ans;
  cin >> K;
  even = K/2;
  if (K%2 == 1){
    odd = even + 1;
  }
  else{
      odd = even;
  }
  ans = even*odd;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b){ return (a<b ? (a=b)||1 : 0); }
int main() {
	
	deque<int> q;
	int n; cin>>n;
	for(int i=0; i<n; i++){
		int a; cin >>a;
		q.push_back(a);
	}
	sort(q.begin(),q.end());
	deque<int> p;
	p.push_back(q.back());
	q.pop_back();
	int64_t cnt{};
	while(!q.empty()){
		int tmp{}, c{1};
		if(chmax(tmp, abs(q.front()-p.front())))c=1;
		if(chmax(tmp, abs(q.front()-p.back())))c=2;
		if(chmax(tmp, abs(q.back()-p.front())))c=3;
		if(chmax(tmp, abs(q.back()-p.back())))c=4;
		if(c==1) {
			p.push_front(q.front());
			q.pop_front();
		}
		if(c==2) {
			p.push_back(q.front());
			q.pop_front();
		}
		if(c==3) {
			p.push_front(q.back());
			q.pop_back();
		}
		if(c==4) {
			p.push_back(q.back());
			q.pop_back();
		}
		cnt += tmp;
	}
	cout << cnt<<endl;
	
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	char str[9];
	char moji;
	int a, b, c, d, e, f;
	
	while (scanf("%s", str) != EOF) {
		c = 0;
		for (a = 0; a < 9; a++) {
			if (a % 3 == 2) {
				if (str[a - 2] == str[a - 1] && str[a - 1] == str[a] && str[a] != 's') {
					moji = str[a];
					c++;
					break;
				}
			}
			if (a <= 2) {
				if (str[a] == str[a + 3] && str[a + 3] == str[a + 6] && str[a] != 's') {
					moji = str[a];
					c++;
					break;
				}
			}
			if (str[0] == str[4] && str[4] == str[8] && str[0] != 's') {
				moji = str[0];
				c++;
				break;
			}
			if (str[2] == str[4] && str[4] == str[6] && str[2] != 's') {
				moji = str[2];
				c++;
				break;
			}
		}	
		if (moji == 's' || c == 0) {
			moji = 'd';
		}
		printf("%c\n", moji);
	}
	
	return (0);
}

Measured memory_bytes: 540
import sys
import math
input = sys.stdin.readline

def main():
    S = int(input())
    X1 = 0
    Y1 = 0
    X2 = int(math.sqrt(S))
    Y3 = S//X2
    if X2*Y3==S:
        X3=0
        Y2=0
    else:
        Y3+=1
        if Y3>10**9:
            X2=10**9
            Y3=10**9
        X3 = 1
        Y2 = (X2*Y3-S)
    print(X1,Y1,X2,Y2,X3,Y3)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
n, m = map(int, input().split())
an = list(map(int, input().split()))
an = list(set(an))
bn = [a // 2 for a in an]

def ln2(x):
  cnt = 0
  while x % 2 == 0:
    x /= 2
    cnt += 1
  return cnt

b0 = ln2(bn[0])
for b in bn:
  if ln2(b) != b0:
    print(0)
    exit()
  
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

l = lcm(bn)
print(m // l - m // (2*l))

Measured memory_bytes: 14364
import sys

input = sys.stdin.readline


def main():
    c = input().rstrip()
    vowel = ["a", "e", "i", "o", "u"]
    if c in vowel:
        ans = "vowel"
    else:
        ans = "consonant"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
S=input()
A=int(S[0:2])
B=int(S[2:4])
if (1<=A and A<=12) and (1<=B and B<=12):
  print("AMBIGUOUS")
elif (1<=A and A<=12) and not(1<=B and B<=12):
  print("MMYY")
elif not(1<=A and A<=12) and (1<=B and B<=12):
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 9060
#include <stdio.h>

int main() {
  int W, H , x ,y ,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if(x-r<0 || x+r>W || y-r<0 || y+r>H) {
    printf("No\n");
  } else {
    printf("Yes\n"); 
  }


  return 0;
}

Measured memory_bytes: 584
// In the name of God

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

using namespace std;

const int N = (int) 0, mod = (int) 0;

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s, t = "CODEFESTIVAL2016";
    cin >> s;
    int res = 0;
    for (int i = 0; i < (int) s.size(); ++i)
        res += (s[i] != t[i]);
    cout << res << endl;
}



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

double tbl[100][100]; // iの後にjを与えたときの成長度

int main() {
    int n, m;
    while (cin >> n >> m, (n || m)) {
        for (int i=0; i<n; ++i) {
            for (int j=0; j<n; ++j) {
                cin >> tbl[i][j];
            }
        }
        double dp[101][100] = {}; // i回目にjを与えたときの最大サイズ
        for (int i=0; i<100; ++i) {
            dp[1][i] = 1.0;
        }
        for (int t=2; t<=m; ++t) {
            for (int i=0; i<n; ++i) {
                for (int j=0; j<n; ++j) {
                    dp[t][i] = max(dp[t][i], dp[t-1][j] * tbl[j][i]);
                }
            }
        }
        double res = -1e8;
        for (int i=0; i<n; ++i) {
            res = max(res, dp[m][i]);
        }
        cout.precision(2);
        cout << fixed << res << endl;
    }
    return 0;
}

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

using namespace std;
 
const long long inf = 1e9;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define rfr(i,n,a) for (int i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define endl "\n"
typedef vector<int> VI;
typedef vector<ll> VL;

ll n, m, k;
VI adj[100001];
int par[100001];
bool vis[100001];
void bfs() {
	queue<int> q;
	q.push(1);
	vis[1] = 1;
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (auto x:adj[u])if(x != par[u] && !vis[x]) {
			par[x] = u;
			vis[x] = 1;
			q.push(x);
		}
	}
}
int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	fr(i,0,m) {
		int x,y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	bfs();
	fr(i,2,n+1) {
		if (!vis[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	fr(i,2,n+1) {
		cout << par[i] << endl;
	}
	return 0;
}

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

int main() {
 vector<int> S(3);
  for(int i=0; i<3; i++){
    cin>>S.at(i);
  }
  sort(S.begin(), S.end());
  cout<<(S.at(1)-S.at(0))+(S.at(2)-S.at(1))<<endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

string ans;

string F="FESTIVAL";

signed main(){
    ans+="FESTIVA";
    int K;cin>>K;

    for(int i=0;(1ll<<i)<=K;i++){
        int p=i/9;
        if(K>>i&1){
            ans+="L";
        }
        for(int j=6;j>p;j--)ans+=F[j];
        int q=i%9;
        rep(j,1ll<<q)ans+=F[p];
    }

    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
K = int(input())

if K == 1:
    print(3)
    print(1,0,3)
elif K == 0:
    print(4)
    print(3,3,3,3)

else:
    div = -1
    
    if K <= 50:
        print(K)
        print(*[K for _ in range(K)])
    
    else:
        print(50)
        ans = [K//50+i for i in range(50)]

        for i in range(K%50):
            ans[i] += 50
            for j in range(50):
                if i != j:
                    ans[j] -= 1
        
        print(*ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define i64 long long
#define maxn (int)(1e5)
#define pii pair<int,int>
#define L first 
#define R second
#define all(x) x.begin(),x.end()
using namespace std;
int main(){
	int n,m;
	//multiset<string>blue,red;
	unordered_map<string,int>blue,red;
	cin>>n; 
	string s;
	for(int i=0;i<n;i++){
		cin>>s;
		//printf("%s\n", s.c_str());
		blue[s]++;
	}
	//printf("\n");
	cin>>m; 
	for(int i=0;i<m;i++){
		cin>>s;
		//printf("%s\n", s.c_str());
		red[s]++;
	}
	
	unordered_map<string,int>:: iterator it;
	int mx = 0;
	for(it = blue.begin();it!=blue.end(); it++){
		string s = (*it).first;
		int cnt_r = red[s], cnt_b = blue[s];
		//if(!(cnt_r>=0 and cnt_r<=m)) cnt_r =0;
		//printf("%s %d %d\n", s.c_str(), cnt_b, cnt_r);
		mx = max(mx, cnt_b-cnt_r);
	}
	printf("%d\n",mx);
	return 0;
}

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

long gcd(long a, long b){
    if(a<b){
        long t=a;
        a=b;
        b=t;
    }
    while(b!=0){
        long r=a%b;
        a=b;
        b=r;
    }
    return a;
}

bool solve(){
    long a, b, c, d;
    cin >> a >> b >> c >> d;
    if(b>d || a<b){
        return false;
    }
    {
        long g=gcd(d-b, b);
        if(g+c<b){
            return false;
        }
    }
    {
        long q = a/b;
        if(q>=2){
            a-=(q-1)*b;
        }
    }
    {
        long q = d/b;
        if(q>=2){
            d-=(q-1)*b;
        }
    }
    for(long i=0; i<10; i++){
        a-=b;
        if(a<0){
            return false;
        }
        if(a<=c){
            a+=d;
        }
    }
    return true;
}

int main(void){
    long t;
    cin >> t;
    for(long i=0; i<t; i++){
        bool b=solve();
        cout << (b ? "Yes" : "No" ) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stdlib.h>
#include<sstream>


using namespace std;

int main(){
	int countS=0,countH=0,countC=0,countD=0;
	char s,h,c,d;
	//string w;
	int S_[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
	int H_[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
	int C_[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
	int D_[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
	vector<int> S,H,C,D;
	 int n;
	cin>>n;
	char m;
	int l;
	for(int i=0;i<n;++i){
		cin>>m;
		cin>>l;
		//w=m.substr(2);
		if(m=='S'){			//??\????????????????????????????????????????????????
			//s=m.substr(2);
			S.push_back(l);			//S???H???C???D??????????????????????????°????????\??????
			countS++;
		}else if(m=='H'){
			H.push_back(l);
			countH++;
		}else if(m=='C'){
			C.push_back(l);
			countC++;
		}else if(m=='D'){
			D.push_back(l);
			countD++;		
		}
	}
	sort(S.begin(),S.end());			//?????????????????????
	sort(H.begin(),H.end());
	sort(C.begin(),C.end());
	sort(D.begin(),D.end());

	if(S.size()!=13)					//S_[13]??¨????´???°???????????????????????????
		for(int i=countS;i<=13;++i){	//S[]???????????\??????
			S.push_back(0);
		}
	if(H.size()!=13)
		for(int i=countH;i<=13;++i){
			H.push_back(0);
		}
	if(C.size()!=13)
		for(int i=countC;i<=13;++i){
			C.push_back(0);
		}
	if(D.size()!=13)
		for(int i=countD;i<=13;++i){
			D.push_back(0);
		}
		bool flagS=false;
		bool flagH=false;
		bool flagC=false;
		bool flagD=false;

		for(int i=0;i<13;++i){
			flagS=false;
			for(int j=0;j<13;++j){
				if(S_[i] == S[j]){	
					flagS=true;		
					break;			
				}
			}
			if(flagS==false)			
				cout<<"S "<<S_[i]<<endl;
		}
		for(int i=0;i<13;++i){
			flagH=false;
			for(int j=0;j<13;++j){	
				if(H_[i] == H[j]){
					flagH=true;		
					break;
				}
			}
			if(flagH==false)
				cout<<"H "<<H_[i]<<endl;
		}
		for(int i=0;i<13;++i){
			flagC=false;
			for(int j=0;j<13;++j){
				if(C_[i] == C[j]){
					flagC=true;
					break;
				}
			}
			if(flagC==false)
				cout<<"C "<<C_[i]<<endl;
		}
		for(int i=0;i<13;++i){
			flagD=false;
			for(int j=0;j<13;++j){
				if(D_[i] == D[j]){
					flagD=true;
					break;
				}
			}
			if(flagD==false)
				cout<<"D "<<D_[i]<<endl;
		}
	return 0;
}
	

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    vector<int> a(N+1, 0), b(N+1, 0);
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        a[i] += a[i-1];
    }
    for (int i = 1; i <= N; i++) {
        cin >> b[i];
        b[i] += b[i-1];
    }
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        ans = max(ans, a[i] + (b[N] - b[i-1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    double a, b;
    cin >> a >> b;
    //x 0.08 >= a  x 0.1 >= b

    int x1 = ceil(a / 0.08);
    double x2 = (a + 1) / 0.08;
    int y1 = ceil(b / 0.1);
    double y2 = (b + 1) / 0.1;

    int down = min(x1, y1);
    double up = max(x2, y2);
    if (down > up)
    {
        cout << -1;
    }
    else
    {
        for (int i = down; i < up; i++)
        {
            if (i >= x1 && i < x2 && i >= y1 && i < y2)
            {
                cout << i;
                return 0;
            }
        }

        cout << -1;
    }

    return 0;
}

Measured memory_bytes: 256
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from typing import Iterable
import sys
def main():
    input = sys.stdin.readline
    N, Q = map(int, input().split())
    uf = UnionFindTree(N)
    for _ in range(Q):
        t, u, v = map(int, input().split())
        if t == 0:
            uf.union(u, v)
        else:
            print(1 if uf.same(u, v) else 0)

class UnionFindTree:
    __slots__ = ('parent')

    def __init__(self, n: int) -> None:
        self.parent = [-1] * n

    def find(self, x: int) -> int:
        p = self.parent
        while p[x] >= 0: x, p[x] = p[x], p[p[x]]
        return x

    def union(self, x: int, y: int) -> bool:
        x, y, p = self.find(x), self.find(y), self.parent
        if x == y: return False
        if p[x] > p[y]: x, y = y, x
        p[x], p[y] = p[x] + p[y], x
        return True

    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)

    def size(self, x: int) -> int:
        return -self.parent[self.find(x)]

    def same_all(self, indices: Iterable[int]) -> bool:
        f, v = self.find, self.find(indices[0])
        return all(f(i) == v for i in indices)

if __name__ == '__main__':
    main()


Measured memory_bytes: 76160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int dis = 2*a+2*b;
		int are = a*b;
		System.out.println(are+" "+dis);
	}
}

Measured memory_bytes: 25968
import java.util.Scanner;

public class Main {
    static int[] a;
    static boolean[] canMake = new boolean[20*2000 + 1];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] m = new int[q];
        for (int i = 0; i < q; i++) {
            m[i] = sc.nextInt();
        }
        
        setCanMake(0, 0);
        canMake[0] = false;
//        UArr.printArr(canMake);
        for (int i = 0; i < q; i++)
            System.out.println(canMake[m[i]] ? "yes" : "no");
        
    }
    
    private static void setCanMake(int sum, int n) {
        if (n == a.length - 1) {
            canMake[sum] = true;
            canMake[sum + a[n]] = true;
        } else {
            setCanMake(sum, n + 1);
            setCanMake(sum + a[n], n + 1);
        }
    }
}


Measured memory_bytes: 26880
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin>>s;
    ll n=s.size();
    ll ans[100010]={},a[100010],b[100010],now=0;
    rep(i,n){
        if(s[i]=='R' && s[i+1]=='L'){
            a[now]=i;
        }
        if(s[i]=='L' && s[i+1]=='R'){
            b[now]=i;
            now++;
        }
    }
    b[now]=s.size()-1;
    now++;
    rep(i,now){
        ans[a[i]]++;
        ans[a[i]+1]++;
        if(i==0){
            ans[a[i]]+=a[i]/2;
            ans[a[i]+1]+=a[i]/2;
            ans[a[i]+1]+=a[i]%2;
            ans[a[i]]+=(b[i]-a[i]-1)/2;
            ans[a[i]+1]+=(b[i]-a[i]-1)/2;
            ans[a[i]]+=(b[i]-a[i]-1)%2;
        }
        else{
            ans[a[i]]+=(a[i]-b[i-1]-1)/2;
            ans[a[i]+1]+=(a[i]-b[i-1]-1)/2;
            ans[a[i]+1]+=(a[i]-b[i-1]-1)%2;
            ans[a[i]]+=(b[i]-a[i]-1)/2;
            ans[a[i]+1]+=(b[i]-a[i]-1)/2;
            ans[a[i]]+=(b[i]-a[i]-1)%2;
        }
    }
    rep(i,n){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 2896
#include <stdio.h>


int main() {
	int H, W, N, hasil;
	
	scanf("%d %d %d", &H, &W, &N);
	
	if(H > W) {
		hasil = (N+H-1)/H;
	} else {
		hasil = (N+W-1)/W;
	}
	
	printf("%d\n", hasil);
	
	return 0;
}

Measured memory_bytes: 1680
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
ll a[10000009];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=i;j<=n;j+=i) a[j]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++) ans+=i*a[i];
    cout<<ans;
}


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

const long long MOD = 1000000007;
long long dp[10][110];
long long fib[10];

void make_fib(int n) {
	fib[0] = 1;
	fib[1] = 1;
	for (int i = 2; i <= n; i++) {
		fib[i] = fib[i - 1] + fib[i - 2];
	}
}

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	dp[1][0] = 1;
	make_fib(10);
	for (int y = 1; y <= h; y++) {
		for (int x = 1; x <= w; x++) {
			if (x > 1) {
				dp[x][y] += dp[x - 1][y - 1] * fib[x - 2] * fib[w - x] % MOD;
			}
			if (x < w) {
				dp[x][y] += dp[x + 1][y - 1] * fib[x - 1] * fib[w - x - 1] % MOD;
			}
			dp[x][y] += dp[x][y - 1] * fib[x - 1] * fib[w - x] % MOD;
			dp[x][y] %= MOD;
		}
	}
	cout << dp[k][h] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

long long int DP[2000];

int main(){
	
	int N, M;
	
	cin >> N >> M;
	
	for(int i = 0; i < 2000; i++){
		DP[i] = 1000000000000;
	}
	
	long long int D[2000], C[2000];
	
	for(int i = 0; i < N; i++){
		cin >> D[i];
	}
	
	for(int i = 0; i < M; i++){
		cin >> C[i];
	}
	
	DP[0] = 0;
	
	for(int i = 0; i < M; i++){
		for(int j = N; j >= 1; j--){
			DP[j] = min(DP[j], DP[j - 1] + C[i] * D[j - 1]);
			//cout << DP[j] << " ";
		}
		//cout << endl;
	}
	
	cout << DP[N] << endl;
	
	return 0;
}

Measured memory_bytes: 3144
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        int a = sc.nextInt();
        if(a >= n%500){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }   
}

Measured memory_bytes: 23252
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

LL digit_sum(LL n) {
    LL ret = 0;
    while (n > 0) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

int main() {
    LL n; cin >> n;
    if (n % digit_sum(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i,j,N,sum=0,a[1000];
    
    scanf("%d",&N);
    
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    
    for(i=0;i<N;i++){
        for(j=i+1;j<N;j++){
            sum=sum+(a[i]*a[j]);
    }
    }
    
    
    printf("%d\n",sum);
    
    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
K = int(input())

# lcm & gcd not math library
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
ans = 0
for i in range(1, K + 1):
    for j in range(i, K + 1):
        for k in range(j, K + 1):
            if i == j and j == k:
                dup_num = 1
            elif i == j or j == k:
                dup_num = 3
            else:
                dup_num = 6
            ans += gcd(gcd(i, j), k) * dup_num

print(ans)

Measured memory_bytes: 9208
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int val;
    cin >> val;
    cout << (val < 30 ? "No" : "Yes");
    return 0;
}


Measured memory_bytes: 3656
import sys
input = sys.stdin.readline
S = list(input())[: -1]
d = [0] * 26
a = ord("a")
for i in range(len(S)):
  d[ord(S[i]) - a] += 1
  if d[ord(S[i]) - a] > 1:
    print("no")
    exit(0)
print("yes")

Measured memory_bytes: 38292
n = int(input())
a = [int(input()) for i in range(n)]

b = sorted(a)

if b[-1]==b[-2]:
    for i in range(n):
        print(b[-1])
else:
    for i in range(n):
        if a[i]==b[-1]:
            print(b[-2])
        else:
            print(b[-1])


Measured memory_bytes: 70360
#include<set>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, Q;
int A[200011], B[200011];
multiset<int> L, R;
LL sum, sumL, sumR;

void add(LL x) {
    if (x < 0) {
	L.insert(x);
	sumL += x;
    } else {
	R.insert(x);
	sumR += x;
    }
}

void del(LL x) {
    if (x < 0) {
	L.erase(L.find(x));
	sumL -= x;
    } else {
	R.erase(R.find(x));
	sumR -= x;
    }
}

void MAIN() {
    scanf("%d%d", &N, &Q);
    REP (i, N*2) scanf("%d", A+i);
    REP (i, N*2) scanf("%d", B+i);

    for (int i=1; i+1<N*2; i++) {
	add(B[i] - A[i]);
    }

    REP (i, N*2) sum += A[i];

    REP ($, Q) {
	int p, x, y;
	scanf("%d%d%d", &p, &x, &y);
	p--;
	sum -= A[p];
	if (0 < p && p < N*2-1) {
	    del(B[p] - A[p]);
	}
	A[p] = x;
	B[p] = y;
	if (0 < p && p < N*2-1) {
	    add(B[p] - A[p]);
	}
	sum += A[p];

	LL ans = sum;

	if (R.size() & 1) {
	    amax(ans, sum + sumR - *R.begin());
	    amax(ans, sum + sumR + *L.rbegin());
	} else {
	    amax(ans, sum + sumR);
	}

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

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 12672
#include <bits/stdc++.h>
using namespace std;
int main(){
    string O;
    string E;
    cin>>O>>E;
  for(int i = 0; i<O.size(); i++){
      cout<<O.at(i);
      if(i<E.size()){
          cout<<E.at(i);
      }
  }
  return 0;
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}
int no = 1, n1;
int recu(int n, int k, int val) {


	if (n == n1) {
		return min(val * 2, val + k);
	}
	return min( recu(n + 1, k, 2 * val), recu(n + 1, k, val + k)              );


}
int digit(int n) {

	int temp = 0;
	while (n) {
		// temp += n % 10;
		n = n / 10;
		temp++;
	}



	return temp;
}

bool check(int a[], int n) {
	for (int i = 0; i < n; ++i)
	{
		/* code */
		if (a[i] % 2)
			return false;
	}
	return true;
}


int main() {
	int i,  n, k, c = 0, sum = 0;
	c_p_c();
	// cout<<"Sd"<<endl;>
	cin>>n;
	char a[n];
	fo(i,n) cin>>a[i];

	map<char,int> ma;
	for(char ch:a)
		ma[ch]++;

	if(ma.size()==3)
		cout<<"Three"<<endl;
	else 
		cout<<"Four"<<endl;



}

Measured memory_bytes: 3580
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int H=scan.nextInt();
        int R=scan.nextInt();
        
        if(H+R>0){
        System.out.println(1);
        } else if(H+R==0){
        System.out.println(0);
        } else if(H+R<0){
        System.out.println(-1);
        }
    } 
}


Measured memory_bytes: 26096
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<int> h(n);
    for (int &x : h) {
        cin >> x;
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        int j = i + 1;
        while (j < n && h[j] <= h[j - 1]) {
            j++;
        }
        j--;
        int moves = j - i;
        res = max(res, moves);
        i = j;
    }
    cout << res << "\n";
}


Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long A =sc.nextLong();
    long B=sc.nextLong();
    long K =sc.nextLong();
    long L =Math.max(A-K,0);
    long R;
    if(L==0){R =Math.max(B+A-K,0);}else{R =B;};
    System.out.println( L +" "+R );
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;


const int MAX_N = 1000;
int par[MAX_N];
int rnk[MAX_N];

void init(int n){
    for(int i=1; i<=n; i++){
        par[i] = i;
        rnk[i] = 0;
    }
}

int find(int x){
    if(par[x] == x){
        return x;
    }
    else{
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y){
    x = find(x);
    y = find(y);

    if(x == y) return;

    if(rnk[x] < rnk[y]){
        par[x] = y;
    }
    else{
        par[y] = x;
        if(rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}


int main(){

    int n, m; cin >> n >> m;

    int a[m], b[m];
    for(int i=0; i<m; i++){
        cin >> a[i] >> b[i];
    }

    int cnt = 0;
    for(int k=0; k<m; k++){

        init(n);
        for(int i=0; i<m; i++){
            if(i != k){
                unite(a[i], b[i]);
            }
        }

        for(int i=2; i<=n; i++){
            if(!same(i, 1)){
                cnt++;
                break;
            }
        }
    }

    cout << cnt;


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		char[] mesh = new char[9];
		while ((scan.hasNext())) {

			mesh = scan.nextLine().toCharArray();

			if(mesh[4] == mesh[3] && mesh[4] == mesh[5] && mesh[4] != 's'){
				System.out.println(mesh[4]);
			}else if(mesh[4] == mesh[1] && mesh[4] == mesh[7] && mesh[4] != 's'){
				System.out.println(mesh[4]);
			}else if(mesh[4] == mesh[2] && mesh[4] == mesh[6] && mesh[4] != 's'){
				System.out.println(mesh[4]);
			}else if(mesh[4] == mesh[0] && mesh[4] == mesh[8] && mesh[4] != 's'){
				System.out.println(mesh[4]);
			}else if(mesh[1] == mesh[0] && mesh[1] == mesh[2] && mesh[1] != 's'){
				System.out.println(mesh[1]);
			}else if(mesh[7] == mesh[6] && mesh[7] == mesh[8] && mesh[7] != 's'){
				System.out.println(mesh[7]);
			}else if(mesh[3] == mesh[0] && mesh[3] == mesh[6] && mesh[3] != 's'){
				System.out.println(mesh[3]);
			}else if(mesh[5] == mesh[2] && mesh[5] == mesh[8] && mesh[5] != 's'){
				System.out.println(mesh[5]);
			}else{
				System.out.println("d");
			}
		}
	}
}

Measured memory_bytes: 11000
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cstring>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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;
}

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}
/*
ll Integer_factorization(ll n){
    ll num = 0;
    ll ndash = n;
    if(n == 1) return 1;
    ll a = 2;
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    return num;
}
*/

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}

void solve() {
    int n;
    cin >> n;
    int l[n];
    int lm = -1;
    int sum = 0;
    for(int i = 0;i < n;i++) {
        cin >> l[i];
        lm = max(lm, l[i]);
        sum += l[i];
    }
    if(lm < sum-lm) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}




int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 256
n = float(input())
x = list(map(float, input().split()))
y = list(map(float, input().split()))

D_p1 = 0.0
for i in range(len(x)):
    D_p1 += abs(x[i] - y[i])

D_p2 = 0.0
for i in range(len(x)):
    D_p2 += (x[i]-y[i])**2
D_p2 = D_p2**(1/2)

D_p3 = 0.0
for i in range(len(x)):
    D_p3 += abs((x[i] - y[i]))**3
D_p3 = D_p3**(1/3)

D_pinf = 0.0
inf_list =[]
for i in range(len(x)):
    inf_list.append(abs(x[i]-y[i]))
D_pinf = max(inf_list)

print(D_p1)
print(D_p2)
print(D_p3)
print(D_pinf)



Measured memory_bytes: 5648
n = int(input())
a = [0] + [int(input()) for i in range(n)]
cnt = 1
next_a = a[1]

if a[1] == 2:
    print(cnt)

else:
    while cnt <= 10**5:
        next_a = a[next_a]
        cnt += 1
        if next_a == 2:
            break

    if cnt <= 10**5:
        print(cnt)
    else:
        print(-1)

Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
int main(){
    int m,d; cin>>m>>d;
    int ans = 0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            int x = j % 10, y = j / 10;
            if(x>=2&&y>=2&&x*y==i) ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 110;
char a[maxn][maxn];
int l[maxn];
int c[maxn];
int n,m;

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%s",a[i]);
		for(int i=0;i<n;i++){
			int flag = 1;
			for(int j=0;j<m;j++){
				if(a[i][j]=='#'){
					flag = 0;
					break;
				}
			}
			if(flag)l[i] = 1;
		}
		for(int i=0;i<m;i++){
			int flag = 1;
			for(int j=0;j<n;j++){
				if(a[j][i]=='#'){
					flag = 0;
					break;
				}
			}
			if(flag)c[i] = 1;
		}
		for(int i=0;i<n;i++){
			int flag = 0;
			for(int j=0;j<m;j++){
				if(l[i]||c[j])continue;
				printf("%c",a[i][j]);
				flag = 1;
			}
			if(flag)
			printf("\n");
		}
	return 0;
}

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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    long a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (v * t - w * t >= abs(a - b)) {
        cout << "YES";
    } else {
        cout << "NO";
    }

    return 0;
}

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

long double pi = 3.14159265358979323846;

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

double calcAngle(double h, double m) 
{ 

	if (h == 12) h = 0; 
	if (m == 60) m = 0; 


	double hour_angle = 0.5 * (h * 60 + m); 
	double minute_angle = 6 * m; 

	double angle = abs(hour_angle - minute_angle); 

	angle = min(360 - angle, angle); 

	return angle; 
} 

int main() 
{ 
	double a,b,h,m;
	cin >> a >> b >> h >> m;
	double angle = calcAngle(h, m);
	//cout << fixed << setprecison(12) << angle << endl;
	long double fangl = 	(2*pi/360)*angle;
	long double cangl = cos(fangl);
    //cout <<  cangl << endl;
    long double ssq = a*a + b*b - 2*a*b*cangl;
    long double ans = sqrt(ssq);
    cout << fixed <<  setprecision(15) << ans << endl ;
	return 0; 
} 



Measured memory_bytes: 4164
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m, k;
  cin >> n >> m >> k;

  vll as(n), bs(m);

  rep(i, n) { cin >> as[i]; }
  vll csuma(n + 1, 0);
  rep(i, n) csuma[i + 1] = csuma[i] + as[i];

  rep(i, m) { cin >> bs[i]; }
  vll csumb(m + 1, 0);
  rep(i, m) csumb[i + 1] = csumb[i] + bs[i];

  ll ans = 0;
  rep(i, n+1) {
    ll th = k - csuma[i];
    if (th < 0) continue;
    ll jj = Upper_bound(csumb, th);
    chmax(ans, i+jj-1);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9508
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    vector<int>alp2(26,1e9);
    for(int i=0; i<n; i++){
        vector<int>alp1(26,0);
        cin >> s;
        for(int i=0; i<s.size(); i++){
            alp1[s[i]-'a']++;
        }
        for(int i=0; i<26; i++){
            alp2[i] = min(alp1[i],alp2[i]);
        }
    }
    for(int i=0; i<26; i++){
        if(alp2[i]==1e9) continue;
        else{
            for(int j=0; j<alp2[i]; j++)
            cout << (char)(i+'a');
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define debug(x) cerr << #x << ": " << x << '\n'

int main() {
    int N;
    cin >> N;
    cout << (N/2) + (N%2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if( s < t ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int a,b;cin>>a>>b;
  if(a<=12)b/=2;
  if(a<6)b=0;
  cout<<b<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	int p, q, a, n, c;
	int count = 0;
	
	void loop(int x, int y, int z, int w){
		if(z==c){
			if(p*x==q*y) count++;
			return;
		}
		for(int i=w;x*i<=a;i++) loop(x*i, y*i+x, z+1, i);
	}
	
	void func(){
		for(int i=1;i<=n;i++){
			c = i;
			loop(1,0,0,1);
		}
		System.out.println(count);
	}
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
				
			Main A = new Main();
			A.p = sc.nextInt();
			A.q = sc.nextInt();
			A.a = sc.nextInt();
			A.n = sc.nextInt();
			if(A.p==0 && A.q==0 && A.a==0 && A.n==0) break;
			
			A.func();
		}	
	}	
}

Measured memory_bytes: 23640
#include<bits/stdc++.h>
using namespace std;
int ans =0 ;
int main(){
  int n,m;
  cin >> n >> m;
  map<int,int> cnt;
  
  for(int i = 0;i<n;i++){
    int k;
    cin >> k;
    
    for(int j = 0;j<k;j++){
      int x;
      cin >> x;
      cnt[x]++;
    }
  }
  for(auto i:cnt){
    if(i.second==n)ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256