akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include <utility>
#define rep(i,n) for (int i=0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
	priority_queue<P>que;
	ll n, m, ans = 0;
	cin >> n >> m;
	rep(i, n) {
		ll a;
		cin >> a;
		que.push(P(a, 1));
	}
	rep(i, m) {
		ll b, c;
		cin >> b >> c;
		que.push(P(c, b));
	}

	rep(i, n) {
		P top = que.top();
		que.pop();
		ans += top.first;
		if (top.second > 1) {
			top.second--;
			que.push(top);
		}
	}
	cout << ans << endl;
}

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

// void max_self(int& a, int b){
// 	a = max(a, b);
// }

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


	int n, W;
	cin >> n >> W;
 	vector<long long> weight(n), value(n);
 	vector<long long> dp(W + 1);

 	for (int i = 0; i < n; i++) {
 		cin >> weight[i] >> value[i];

 		// for (int cur_weight = 0; cur_weight <= W - weight[i]; cur_weight++) {
 		for (int cur_weight = W - weight[i]; cur_weight >= 0; cur_weight--){
 			dp[cur_weight + weight[i]] = max(dp[cur_weight + weight[i]], dp[cur_weight] + value[i]);
 		}
 	}

 	cout << *max_element(dp.begin(), dp.end()) << endl;
}

Measured memory_bytes: 1024
from itertools import permutations
import sys


input = sys.stdin.readline


N, M, R = map(int, input().split())

dest = [x-1 for x in map(int, input().split())]


inf = float('inf')
mat = [[inf]*N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    mat[a-1][b-1] = mat[b-1][a-1] = c


for i in range(N):
    for j in range(N):
        for k in range(N):
            mat[j][k] = min(mat[j][k], mat[j][i]+mat[i][k])


ans = inf
for l in permutations(dest):
    tmp = 0
    for u, v in zip(l, l[1:]):
        tmp += mat[u][v]
    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 68700
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ga = sc.nextInt();
        int sa = sc.nextInt();
        int ba = sc.nextInt();
        int gb = sc.nextInt();
        int sb = sc.nextInt();
        int bb = sc.nextInt();

        int[] ab = new int[N+1];

        if(N>1) ab[1] = 1;
        for(int i = 1; i<N+1; i++) {
            ab[i] = i;
            if(i-ga>=0) {
                ab[i] = Math.max(ab[i], ab[i - ga] + gb);
            }
            if(i-sa>=0) {
                ab[i] = Math.max(ab[i] , ab[i - sa] + sb);
            }
            if(i-ba>=0) {
                ab[i] = Math.max(ab[i] , ab[i - ba] + bb);
            }

        }

        int M = ab[N];
        //System.out.println(M);
        long[] btoa = new long[M+1];
        for(int i = 1; i<M+1; i++) {
            //btoa[i] = btoa[i-1]+1;
            btoa[i] = i;
            if(i-gb>=0) {
                btoa[i] = Math.max(btoa[i], btoa[i - gb] + ga);
            }
            if(i-sb>=0) {
                btoa[i] = Math.max(btoa[i] , btoa[i - sb] + sa);
            }
            if(i-bb>=0) {
                btoa[i] = Math.max(btoa[i] , btoa[i - bb] + ba);
            }
        }
        System.out.println(btoa[M]);

    }
}

Measured memory_bytes: 217556
n,i,j,k;
long sum[444],dp[444][444];
main(a)
{
	scanf("%d",&n);
	for(;~scanf("%d",&a);i++)sum[i+1]=sum[i]+a;
	for(i=n;i--;)
	{
		for(j=i+2;j<=n;j++)
		{
			dp[i][j]=9e18;
			for(k=i;++k<j;)
			{
				dp[i][j]=fmin(dp[i][j],dp[i][k]+dp[k][j]+sum[j]-sum[i]);
			}
		}
	}
	printf("%ld",dp[0][n]);
}

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

typedef long long ll;

double dist(vector<vector<int>> X, int i, int j){
  double sum=0;
  for(int t=0; t<X.at(0).size(); t++){
    sum+=(double)(X[i][t]-X[j][t])*(X[i][t]-X[j][t]);
  }
  return pow(sum, 0.5);
}

int main(){
  int N, D;
  cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++){
      cin >> X[i][j];
    }
  }
  
  int cnt=0;
  
  for(int i=0; i<N; i++){
    for(int j=0; j<i; j++){
      double d=dist(X, i, j);
      int s=floor(d);
      if (s==d) cnt++;
    }
  }
  cout << cnt <<endl;
}


Measured memory_bytes: 256
#include <cstdio>
typedef long long ll;
using namespace std;
const int N=405;
namespace HASH{/*{{{*/
	const int N=10000000;
	const int MOD=9875321;
	int sz,h[MOD],nex[N],val[N];
	ll key[N];
	inline int getHash(ll x){
		return x%MOD;
	}
	void add(ll x,int y){
		int pos=getHash(x),u;
		for(u=h[pos];u&&nex[u]&&key[u]!=x;u=nex[u]);
		if(key[u]==x)
			val[u]+=y;
		else{
			if(!h[pos])
				h[pos]=++sz;
			else nex[u]=++sz;
			key[sz]=x;
			val[sz]=y;
		}
	}
	int query(ll x){
		int pos=getHash(x),u;
		for(u=h[pos];u&&nex[u]&&key[u]!=x;u=nex[u]);
		return key[u]==x?val[u]:0;
	}
}/*}}}*/
int n;
int c[N][4];
inline ll getKey(int *c){
	return c[0]+c[1]*1000+1ll*c[2]*1000000+1ll*c[3]*1000000000;
}
inline void rotate(int *c){
	int c0=c[0];
	for(int i=0;i<3;i++)
		c[i]=c[i+1];
	c[3]=c0;
}
inline void pattern_add(int *c,int x){
	for(int i=0;i<4;i++){
		HASH::add(getKey(c),x);	
		rotate(c);
	}
}
void readData(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d%d",&c[i][1],&c[i][0],&c[i][3],&c[i][2]);
		pattern_add(c[i],1);
	}
}
void solve(){
	ll ans=0;
	for(int i=1;i<n;i++){
		pattern_add(c[i],-1);
		for(int j=i+1;j<=n;j++){
			pattern_add(c[j],-1);
			for(int l=0;l<4;l++){// up rotate 
				static int tp[4];
				ll now=1;
				int k;
				for(k=0;k<4&&now;k++){// count 4 sides
					tp[0]=c[j][3-k]; tp[1]=c[j][3-((k+1)%4)]; tp[2]=c[i][(k+1)%4]; tp[3]=c[i][k];
					now*=HASH::query(getKey(tp));
					pattern_add(tp,-1);
				}
				ans+=now;
				for(k--;k>=0;k--){// count 4 sides
					tp[0]=c[j][3-k]; tp[1]=c[j][3-((k+1)%4)]; tp[2]=c[i][(k+1)%4]; tp[3]=c[i][k];
					pattern_add(tp,1);
				}
				rotate(c[j]);
			}
			pattern_add(c[j],1);	
		}
	}
	printf("%lld\n",ans);
}
int main(){
	readData();
	solve();
	return 0;
}

Measured memory_bytes: 61824
N=int(input())
st=[0]*N
for i in range(N):
    st[i]=input()
ans=0
c1=0 #b_start,a_end
c2=0#b_start
c3=0#a_end
for i in st:
    ans+=i.count("AB")
    if i[0]=="B" and i[-1]=="A":
        c1+=1
    elif i[0]=="B":
        c2+=1
    elif i[-1]=="A":
        c3+=1
if c1==0:
    ans+=min(c2,c3)
elif c2+c3>0:
    ans=ans+c1+min(c2,c3)
else:
    ans=ans+c1-1
print(ans)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int a;
    vector<P> vec;
    REP(i,n){
        cin >> a;
        vec.push_back(P(a, i + 1));
    }
    sort(ALL(vec));
    REP(i,n){
        cout << vec[i].second;
        if(i != n - 1){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1780
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
using namespace std;
const long long MAX=1e9+7;
const int Mod=998244353;
int n,a[10010],b[10010],c[10010],u,v,sum,ans[10010];
int que[10010],l,r,vis[10010],tot;
vector <int> edge[10010];
bool cmp(int x,int y){
	return x>y;
}
void bfs(){
	while(l<=r){
		for(int i=0;i<edge[que[l]].size();i++){
			if(vis[edge[que[l]][i]]==1) continue;
			vis[edge[que[l]][i]]=1;
			tot++;
			ans[edge[que[l]][i]]=c[tot];
			r++;
			que[r]=edge[que[l]][i];
		}
		l++;
	}
	return ;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	for(int i=1;i<=n;i++)
		scanf("%d",&c[i]);
	sort(c+1,c+n+1,cmp);
	for(int i=2;i<=n;i++)
		sum+=c[i];
	l=1;
	r=1;
	que[r]=1;
	vis[1]=1;
	tot=1;
	ans[1]=c[tot];
	bfs();
	printf("%d\n",sum);
	for(int i=1;i<=n;i++)
		printf("%d ",ans[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 1024
H,N = map(int,input().split())
A = list(map(int,input().split()))
B = [0]*len(A)

while(H>0):
    for i in range(0,N):
        H-=A[i]
        B[i]+=1
ans = True
for i in range(0,N):
    if(B[i]!=1):
        ans=False
        break

print("Yes" if ans else "No")

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

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  
  if(k <= a){
	cout << k << endl;
    return 0;
  }
  
  if(a + b >= k){
    cout << a << endl;
    return 0;
  }
  ll d = k - (a + b);
  
  cout << a - d << endl;
  return 0;

}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <queue>
#define MAXn 1000002
#define MAXm 1000010
using namespace std;

int main()
{
    int k,n,s;
    scanf("%d %d",&k,&n);
    if(n<=k)
    {
        s=(n+2)*(n+1)/2;
    }
    else if(n<=2*k)
    {
        s=(n+2)*(2*k-n+1)/2+(3*k-n+1)*(n-k)/2;
    }
    else
    {
        s=(3*k-n+2)*(3*k-n+1)/2;
    }
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    if(i):
        print(" ", end="")
    if(i <= (n-1)//2):
        index = n-1-i*2
        print(a[index], end="")
    else:
        index = (i-(n-1)//2-1)*2+n%2
        print(a[index], end="")


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

int main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    int a, b, c, d; cin>>a>>b>>c>>d;
    while(true){
        c-=b;
        if(c<=0){cout<<"Yes"; return 0;}
        a-=d;
        if(a<=0){cout<<"No"; return 0;}
    }
}

Measured memory_bytes: 3648
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M,P = inpl()
lines = defaultdict(set)

for _ in range(M):
    a,b,c = inpl()
    a,b = a-1,b-1
    lines[a].add((b,-c+P))

#ベルマンフォード(始点と終点が決まってる時)
def BellmanFord(Start,Goal):
    Costs=[INF]*N
    Costs[Start] = 0
    #upd8s = [True]*N
    for i in range(2*N): #2N回ループ(負閉路の検出までみる)
        #will_upd8s = [False]*N
        for s in range(N):
            #if not upd8s[s]: continue    #前回更新してないので見ない
            for t,c in lines[s]:
                if c + Costs[s] < Costs[t]:
                    Costs[t] = Costs[s]+c
                    #will_upd8s[t] = True #更新した点だけ次に見る
                    if i >= N:
                        Costs[t] = -INF

        if i == N-1: #Nループ目のGoalのCostを記録
            tmp = Costs[Goal]

        #upd8s = will_upd8s[:]

    if tmp != Costs[Goal]:
        return -INF
    else:
        return Costs[Goal]

ans = -BellmanFord(0,N-1)
if ans == INF:
    print(-1)
else:
    print(max(0,ans))


Measured memory_bytes: 50980
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner (System.in);
		int N=in.nextInt();
		int sum=0;
		for (int i = 1; i <= N; i++) {
			sum=sum+i;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 26996
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define fr(i,a,b) for(ll i=(a);i<(b);i++)
#define frd(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl "\n"
#define inf ((long long) 1e18 + 10)
#define ve vector<ll>
using namespace std;
int main() {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int count = 0;
        while(1){
                if(count % 2 == 0){
                        c -= b;
                        if(c <= 0){
                                cout<<"Yes\n";
                                break;
                        }
                }
                else{
                        a -= d;
                        if(a<=0){
                                cout<<"No\n";
                                break;
                        }
                }
                count += 1;
        }
        return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=1010;

ll n, m, k, u, v, x, y, t, a, b, ans=1;
int A[MAXN], B[MAXN];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m;
	for (int i=0; i<n; i++) cin>>A[i];
	for (int i=0; i<m; i++) cin>>B[i];
	sort(A, A+n);
	sort(B, B+m);
	reverse(A, A+n);
	reverse(B, B+m);
	int i=0, j=0, t=0;
	for (int num=n*m; num; num--, t++){
		if (A[i]!=num && B[j]!=num) ans=ans*(i*j-t)%mod;
		if (A[i]!=num && B[j]==num) ans=ans*i%mod;
		if (A[i]==num && B[j]!=num) ans=ans*j%mod;
		
		i+=(A[i]==num);
		j+=(B[j]==num);
	}
	cout<<ans<<"\n";
	
	return 0;
}


Measured memory_bytes: 3628
n=int(input())
mod=10**9+7
dp=[[[[0]*4 for i in range(4)] for j in range(4)] for k in range(n+1)]
for i in range(4):
  for j in range(4):
    for k in range(4):
      dp[3][i][j][k]=1
dp[3][0][2][1]=0
dp[3][0][1][2]=0
dp[3][2][0][1]=0
for i in range(4,n+1):
  for j in range(4):
    for k in range(4):
      for l in range(4):
        for m in range(4):
          dp[i][j][k][l]=(dp[i][j][k][l]+dp[i-1][m][j][k])%mod
          if m==0 and k==2 and l==1:
            dp[i][j][k][l]=0
          if m==0 and j==2 and l==1:
            dp[i][j][k][l]=0
  dp[i][0][2][1]=0
  dp[i][0][1][2]=0
  dp[i][2][0][1]=0
ans=0
for i in range(4):
  for j in range(4):
    for k in range(4):
      ans=(ans+dp[n][i][j][k])%mod
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
typedef long long LL;
using namespace std;
const int N=1e7+100,mod=1e9+7;
int n,m,K,fac[N],inv[N],ans;
int qpow(int x,int y) {
	int res=1;
	while(y) {
		if(y&1) res=(LL)res*x%mod;
		x=(LL)x*x%mod, y>>=1;
	}
	return res;
}
int C(int x,int y) {
	if(y<0 || x<y) return 0;
	return (LL)fac[x]*inv[y]%mod*inv[x-y]%mod;
}
void init(int mx) {
	fac[0]=1;
	for(int i=1;i<=mx;++i) fac[i]=(LL)fac[i-1]*i%mod;
	inv[mx]=qpow(fac[mx],mod-2);
	for(int i=mx-1;~i;--i) inv[i]=(LL)inv[i+1]*(i+1)%mod;
}
int main() {
	scanf("%d%d%d",&n,&m,&K);
	init(n+m+K);
	int tms=qpow(3,m+K),iv=qpow(3,mod-2);
	for(int t=0,s=1;t<=m+K;++t,tms=(LL)tms*iv%mod) {
		if(t) s=(2ll*s+mod-C(t-1,K)+mod-C(t-1,t-1-m))%mod;
		else s=1;
		ans=(ans+(LL)C(t+n-1,n-1)*s%mod*tms%mod)%mod;
	}
	printf("%d\n",ans);
	return 0;
}

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

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

    bool is=false;
    for(int k=1;k<=b;k++){
        if(k*a%b==c){
            is = true;
        }
    }

    if(is) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b))?(b):(a))
#define chmin(a, b) a = (((a)<(b))?(a):(b))

const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill((T*)array, (T*)(array+N),val);}

class CompareDist
{
public:
    bool operator()(PLL n1,PLL n2) {
				if(n1.first!=n2.first) return n1.first<n2.first;
				else return n1.second<n2.second;
    }
};

#define lengthof(x) (sizeof(x) / sizeof(*(x)))


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool contain(int mask, int position){
  if((mask&(1<<position))) return true;
  else return false;
}

// GCD,LCMを求める関数
ll gcd(ll a,ll b){
	if(a%b==0) return(b);
	else return(gcd(b,a%b));
}
ll lcm(ll a, ll b){
	return a*b/gcd(a,b);
}


signed main(){
	int n,m; cin>>n>>m;
  VL a(n); rep(i,n) cin>>a[i];
  ll l = 1;
  rep(i,n){
    a[i] /= 2;
    l = lcm(l,a[i]);
  }
  VL d(n,0);
  rep(i,n){
    while(a[i]%2==0){
      a[i]/=2; d[i]++;
    }
  }
  rep(i,n){
    if(d[0]!=d[i]){
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = (m/l+1)/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];        
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        int gcd = A[0];
        for (int i = 1; i < N; i++) {
            int now = A[i];
            gcd = gcd(gcd, now);
        }
        System.out.println(gcd);
      
    }
    
    private static int gcd(int a, int b) {
        int mod = a%b;
        int ans = 0;
        if (mod != 0) {
             ans = gcd(b, mod);
        } else {
            ans = b;
        }
        return ans;
    }
}


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

int main(){
	int W,H;
	cin >> W >> H;

	int x,y,r;
	cin >> x >> y >> r;

	if(x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H){
	cout <<"Yes"<<endl;
	} else {
	cout << "No" << endl;
	}
	return 0;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k; cin>>n>>k;
    int ans=0;
    if(k==1) ans=0;
    else if (n>=k) ans=n-k;
    else ans=1;
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(long long &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char S[102];
long long K;
int main(){
  int i;
  rd(S);
  rd(K);
  for(i=0;;i++){
    if(S[i] > '1'){
      wt_L(S[i]);
      wt_L('\n');
      break;
    }
    if(--K==0){
      wt_L('1');
      wt_L('\n');
      break;
    }
  }
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// char S[102];
// ll K;
// {
//   int i;
//   rd(S,K);
//   for(i=0;;i++){
//     if(S[i] > '1') wt(S[i]), break;
//     if(--K==0) wt('1'), break;
//   }
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int mod = int(1e+9) + 7;


int main() {
  double n, m, d;
  cin >> n >> m >> d;

  double pat = (n - d) * (m - 1);
  if (d != 0) pat *= 2;
  double ans = pat / (n * n);

  printf("%.10f\n", ans);

  return 0;
}


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

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    int a, b, h;
    cin >> a >> b >> h;

    cout << (a + b) * h / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
namespace diverta2019.A
{
    using System;

    using System.Collections.Generic;
    using System.Linq;
    using static System.Console;
    public class Program
    {
        public static void Main(string[] args)
        {
            var l = ReadLineAsInts().ToList();
            var n = l[0];
            var k = l[1];

            WriteLine(Solve(n, k));
        }

        public static IEnumerable<int> ReadLineAsInts() => ReadLine().Split(' ').Select(x => int.Parse(x));
        public static int Solve(int n, int k) => n - k + 1;
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int n,a[105];
int ans[105],x;
int Max;

int main(){
	scanf("%d",&n);
	x=n;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		Max=0;
		for(int j=1;j<=n-i+1;j++){
			if(a[j]>j){
				printf("-1\n");
				return 0;
			}
			if(a[j]==j) Max=max(Max,j);                                     
		}
		ans[x]=Max;
		x--;
		for(int j=Max;j<=n-i;j++){
			a[j]=a[j+1];
		}
	}
	for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
	
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int N; vi A;
void input(){
    cin>>N;
    rep(i,N){
        int a; cin>>a; A.emplace_back(a);
    }
    return;
}

void solve(){
    double ans;
    rep(i,N) ans+=1.0/A[i];
    cout<<fixed<<setprecision(10)<<1.0/ans<<endl;
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

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

int main(){
    long long int l,r,a,b,z,e=0;

    cin>>a>>b;

    for(int i=a;i<=b;i++){
        if(i%2019==0){
            e=1;
            break;
        }
    }

    if(e==1)
        cout<<0<<endl;

    else{
        int l=a%2019;
        int r=b%2019;
        int a=2019;
        int mn=min(l,r);
        int mx=max(l,r);

        for(int i=mn;i<=mx-1;i++){
            for(int j=mn+1;j<=mx;j++){
                a=min(a,(i*j)%2019);
            }
        }




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







}

Measured memory_bytes: 256
n, m, k = map(int,input().split(' '))
a = [0] + list(map(int, input().split(' ')))
b = [0] + list(map(int, input().split(' ')))
j = m
ta, tb =0, sum(b)
r = 0
for i in range(n + 1):
    ta += a[i]
    if ta > k:
        break
    while tb > k - ta:
        tb -= b[j]
        j -= 1
    r = max(r, i + j)
print(r)

Measured memory_bytes: 39828
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READAR(V,N);
    READAR(C,N);
    ll ans=0;
    FORI(i,0,1<<N)
    {
        ll x=i;
        ll X=0,Y=0;
        FORI(j,0,N)
        {
            if(x%2==1)
            {
                X+=V[j];
                Y+=C[j];
            }
            x=x/2;
        }
        ans=max(ans,X-Y);
    }
    cout<<ans<<endl;

//-----------------------------------------------------------------------------------------------------------//


 
    return 0;
}

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

ans=10**10
for i in range(N-K+1):
    if x[i]<=0 and x[i+K-1]<=0:
        ans=min(ans,abs(x[i]))
    elif x[i]<=0 and x[i+K-1]>=0:
        ans=min(ans,x[i+K-1]-x[i]+min(x[i+K-1],abs(x[i])))
    else:
        ans=min(ans,x[i+K-1])
print(ans)

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

typedef long long LL;

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

int main() {
    int D, T, S;
    cin >> D >> T >> S;
    int r = (D + S - 1)/S;
    if(r <= T) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
typedef long long LL;
using namespace std;
const int INF=1e9+7;

LL n;
int le, a[100];

int main(){
	scanf("%lld", &n);
	while (n) a[++le]=n%10, n/=10;
	int Ans=0, sum=0;
	for (int i=le; i>=1; --i){
		Ans=max(Ans, sum+a[i]-1+9*(i-1));
		sum+=a[i];
	}
	Ans=max(Ans, sum);
	printf("%d\n", Ans);
	
	return 0;
}


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

int main() {
  int X ;
  cin >> X ;
  
  for( int i=2 ; i<10 ; i++ ){
    if( i * 200 <= X && X <= ( (i+1) * 200 - 1 ) ){
        cout << (10 - i ) << endl ;
        
        break;
    }
  }
}



Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2752>
 問題文============================================================
 =================================================================
 解説=============================================================
 
 ================================================================
 */

ll solve(){
    ll ret = 0;
    ll n; cin >> n;
    if(n == 0) return ret;
    ll x = 1;
    while((x-1) < n){ret++; x <<= 1; }
    return ret;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 3188
N=int(input())
Info=[list(map(int,input().split(' '))) for i in range(N-1)] #[[C S F] [C S F] ...]
C=[info[0] for info in Info]
S=[info[1] for info in Info]
F=[info[2] for info in Info]

def gotoN(start): #startは駅番号と同一にする
	global C,S,F
	if start==N:
		return 0
	else:
		stn = start
		t = S[stn-1]
		while stn < N:
			t = max(((t-1)//F[stn-1]+1)*F[stn-1], S[stn-1])+C[stn-1]
			stn += 1
		return t

for i in range(1,N+1):
	print(gotoN(i))

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>

using namespace std;
typedef long long LL;
const int N=1000005;
const int MOD=1e9+7;

int n,m,k,ans,fac[N],inv[N],sum;

inline int fast_pow(int x,int y){
	int ret=1;
	for(;y;y>>=1){
		if(y&1) ret=1ll*ret*x%MOD;
		x=1ll*x*x%MOD;
	}
	return ret;
}

inline int C(int x,int y){
	return 1ll*fac[x]*inv[y]%MOD*inv[x-y]%MOD;	
}

signed main(){
	scanf("%d%d%d",&n,&m,&k);
	fac[0]=inv[0]=1; sum=n+m+k;
	for(int i=1;i<=sum;i++) fac[i]=1ll*fac[i-1]*i%MOD;
	inv[sum]=fast_pow(fac[sum],MOD-2);
	for(int i=sum-1;i;i--) inv[i]=1ll*inv[i+1]*(i+1)%MOD;
//	for(int i=n;i<=sum;i++){
//		int now=0;
//		for(int j=max(i-n-m,1ll*0);j<=min(k,i-n);j++)
//			(now+=C(i-n,j))%=MOD;
//		ans+=now%MOD*C(i-1,n-1)%MOD*fast_pow(3,sum-i)%MOD;
//		ans%=MOD;
//	}
//	cout<<ans<<endl; ans=0;
	if(m<k) swap(m,k); int now=1;
	for(int i=n;i<=sum;i++){
		if(k+n>=i) {
			(ans+=1ll*C(i-1,n-1)*fast_pow(3,sum-i)%MOD*now%MOD)%=MOD;
			if(k+n!=i) now=now*2%MOD; 	
		}
		else if(n+m>=i) {
			now=now*2-C(i-n-1,k);
			now=(now%MOD+MOD)%MOD;
			(ans+=1ll*now*C(i-1,n-1)%MOD*fast_pow(3,sum-i)%MOD)%=MOD;
		}
		else {
			now=now*2-C(i-n-1,k); now=(now%MOD+MOD)%MOD;
			now=(now-C(i-n-1,i-n-m-1)+MOD)%MOD;
			(ans+=1ll*now*C(i-1,n-1)%MOD*fast_pow(3,sum-i)%MOD)%=MOD;
		}
	}
//	for(int i=n;i<=sum;i++) {
//		(ans+=1ll*C(i-1,n-1)*fast_pow(2,i-n)%MOD*fast_pow(3,sum-i)%MOD)%=MOD;
//		if(i==8) cout<<ans<<endl;
//		if(n+k+1<=i) 
//			(ans-=1ll*C(i-1,n-1)*C(i-n,k+1)%MOD*fast_pow(2,i-n-k-1)%MOD*fast_pow(3,sum-i)%MOD)%=MOD;
//		if(i==8) cout<<ans<<endl;
//		if(n+m+1<=i)
//			(ans-=1ll*C(i-1,n-1)*C(i-n,m+1)%MOD*fast_pow(2,i-n-m-1)%MOD*fast_pow(3,sum-i)%MOD)%=MOD;
//		cout<<ans<<endl;
//	}
//	for(int i=n+m;i<sum;i++){
//		(ans-=1ll*now*fast_pow(3,sum-n-m)%MOD)%=MOD;
//		now=1ll*now*i%MOD; now=(now+C(n+m,i-n-m+1))%MOD;	
//	}
//	now=1;
//	for(int i=n+k;i<sum;i++){
//		(ans-=1ll*now*fast_pow(3,sum-n-k)%MOD)%=MOD;
//		now=1ll*now*i%MOD; now=(now+C(n+k,i-n-k+1))%MOD;
//	}	
	printf("%d\n",(ans+MOD)%MOD);
	return 0;
}	

Measured memory_bytes: 7680
//In the name of "ALLAH"
#include<iostream>
using namespace std;
int main()
{
    int a , b , c ;
    cin >> a >> b >> c ;
    if((a+b)==c || (b+c)==a ||(a+c)==b)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, k;
ll s;
struct N {
  ll x, y, z;
};
vector<vector<int>> p;
vector<N> ns;
bool c;
bool isc(N &l, N &r) {
  ll x = abs(l.x - r.x);
  ll y = abs(l.y - r.y);
  ll z = abs(l.z - r.z);
  ll w = s - x;
  ll h = s - y;
  ll d = s - z;
  return w > 0 && h > 0 && d > 0;
}
ll f(N &l, N &r) {
  ll x = abs(l.x - r.x);
  ll y = abs(l.y - r.y);
  ll z = abs(l.z - r.z);
  ll w = s - x;
  ll h = s - y;
  ll d = s - z;
  return 2 * w * h + 2 * h * d + 2 * d * w;
}
vector<bool> used;
int dfs(int i, int root, int from) {
  if (used[i])
    return 0;
  used[i] = true;
  int ret = 1;
  for (auto &j : p[i]) {
    if (j == root) {
      if (root != from)
        c = true;
      continue;
    }
    ret += dfs(j, root, i);
  }
  return ret;
}

vector<int> buf;
set<int> visit;
void dfs2(int i, int from) {
  if (visit.find(i) != visit.end())
    return;
  visit.insert(i);
  if (from < 0) {
    buf.push_back(i);
    if (p[i].size() == 2) {
      dfs2(p[i][1], i);
      reverse(buf.begin(), buf.end());
    }
    if (p[i].size() > 0)
      dfs2(p[i][0], i);
  } else {
    buf.push_back(i);
    for (auto &j : p[i]) {
      if (j == from)
        continue;
      dfs2(j, i);
    }
  }
}

ll solve(int i, bool loop, bool spe) {
  buf.clear();
  visit.clear();
  dfs2(i, -1);

  if (loop && spe) {
    ll ret = 6 * s * s * buf.size();
    for (int j = 0; j < buf.size(); j++) {
      ret -= f(ns[buf[j]], ns[buf[(j + 1) % buf.size()]]);
    }
    return ret;
  } else if (loop) {
    ll ret = 6 * s * s * k;
    vector<ll> sum(2 * buf.size() + 1);
    ll submax = 0;
    for (int j = 0; j < buf.size() * 2; j++) {
      sum[j + 1] =
          sum[j] + f(ns[buf[j % buf.size()]], ns[buf[(j + 1) % buf.size()]]);
    }
    for (int j = 0; j < buf.size(); j++) {
      submax = max(submax, sum[j + k - 1] - sum[j]);
    }
    ret -= submax;
    return ret;
  } else {
    ll ret = 6 * s * s * k;
    vector<ll> sum(buf.size() + 1);
    ll submax = 0;
    for (int j = 1; j < buf.size(); j++) {
      sum[j] = sum[j - 1] + f(ns[buf[j - 1]], ns[buf[j]]);
    }
    for (int j = 0; j + k - 1 < buf.size(); j++) {
      submax = max(submax, sum[j + k - 1] - sum[j]);
    }
    ret -= submax;
    return ret;
  }
}

int main() {
  while (true) {
    ll ans = 100000000000LL;
    cin >> n >> k >> s;
    if (n == 0)
      break;
    ns.resize(n);
    p.clear();
    p.resize(n);
    used.clear();
    used.resize(n);
    for (int i = 0; i < n; i++)
      cin >> ns[i].x >> ns[i].y >> ns[i].z;
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++) {
        if (isc(ns[i], ns[j])) {
          p[i].push_back(j);
          p[j].push_back(i);
        }
      }
    for (int i = 0; i < n; i++) {
      if (used[i])
        continue;
      c = false;
      int size = dfs(i, i, -1);
      if (size < k)
        continue;
      ans = min(ans, solve(i, c, k == size));
    }
    if (ans == 100000000000LL)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }
  return 0;
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4");
            WillReturn.Add("2 3 7 9");
            //7
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("8");
            WillReturn.Add("3 1 4 1 5 9 2 6");
            //8
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();

        Console.WriteLine(wkArr.Max() - wkArr.Min());
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<lint> vl;
typedef pair<lint,lint> pll;

#define mpr make_pair


int main()
{
    ios_base::sync_with_stdio(0);    cin.tie(NULL);    cout.tie(NULL);
    int a,b, c,d;//health and strength
    cin>>a>>b>>c>>d;

    bool turnA = true;
    while(1){
        if (turnA){
            c -= b;
        } else {
            a -= d;
        }
        if (c<=0 || a<=0 )break;
        turnA = !turnA;
    }
    cout<<(turnA?"Yes":"No");

}


Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>

#define endl '\n'
#define F first
#define S second

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

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

	ll a, b, v, w, t, s1, s2, d;
	cin >> a >> v >> b >> w >> t;
	
	d = abs(a - b);
	s1 = v * t;
	s2 = w * t;
	
	if(s1 >= s2) {
		if(s1 - s2 >= d) {
			puts("YES");
		} else {
			puts("NO");
		}
	} else {
		puts("NO");
	}
	
	return 0;
}




Measured memory_bytes: 3608
from collections import deque
import copy

N = int(input())
a = [int(input()) for i in range(N)]
a.sort()
b = copy.copy(a)

A = deque(a)

r = A[0]
l = A.popleft()

ans = 0
while True:
    if len(A) == 0:
        break
    c = A.pop()
    ans += abs(l-c)
    l = c
    if len(A) == 0:
        break
    c = A.pop()
    ans += abs(r-c)
    r = c
    if len(A) == 0:
        break
    c = A.popleft()
    ans += abs(l-c)
    l = c
    if len(A) == 0:
        break
    c = A.popleft()
    ans += abs(r-c)
    r = c

B = deque(b)
r = B[-1]
l = B.pop()
ans2 = 0
while True:
    if len(B) == 0:
        break
    c = B.popleft()
    ans2 += abs(l-c)
    l = c
    if len(B) == 0:
        break
    c = B.popleft()
    ans2 += abs(r-c)
    r = c
    if len(B) == 0:
        break
    c = B.pop()
    ans2 += abs(l-c)
    l = c
    if len(B) == 0:
        break
    c = B.pop()
    ans2 += abs(r-c)
    r = c
print(max(ans,ans2))


Measured memory_bytes: 9116
import numpy

x, n = map(int, input().split())
pList = list(map(int, input().split()))

nmap = [i for i in range(0, 102)]

for (i, v) in enumerate(nmap):
  nmap[i] = abs(v-x)

for (i, v) in enumerate(pList):
  nmap[v] = 102

ans = numpy.argmin(nmap)
print(ans)


Measured memory_bytes: 27000
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)

	s := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &s[i])
	}

	var ac int
	var wa int
	var tle int
	var re int
	for i := 0; i < n; i++ {
		if s[i] == "AC" {
			ac++
		} else if s[i] == "WA" {
			wa++
		} else if s[i] == "TLE" {
			tle++
		} else if s[i] == "RE" {
			re++
		}
	}

	fmt.Println("AC x ", ac)
	fmt.Println("WA x ", wa)
	fmt.Println("TLE x ", tle)
	fmt.Println("RE x ", re)
}


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

using namespace std;
using   ll=long long;

#define fast            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl            "\n"
#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second
#define int             long long int
#define pll                pair<int , int>

#define ALL(v)          v.begin(),v.end()
#define ALLR(v)         v.rbegin(),v.rend()
#define pii             3.14159265358979323
#define inf             LLONG_MAX
#define ones(x)         __builtin_popcount(x)
#define fill(a,b)       memset(a,b,sizeof(a))
#define mod             1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)    
    {
        if(b&1)     
        {
            res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
    return mod_pow(a , mod-2 , mod);
}

void solve() 
{
	int n;
	
	string s;
	
	cin >> n >> s;
	
	vector<int> d;
	
	for(int i = 0; i < n; ++i) {
		if(s[i] == 'R') {
			d.pb(i);
		}
	}
	
	int tot = 0;
	
	for(int i = 0; i < n; ++i) {
		
		if(d.size() == 0) {
			break;
		}
		
		if(s[i] == 'W') {
			int hm = d.back();
			
			if(hm > i) {
				s[hm] = 'W';
				tot++;
				d.pop_back();
			}
			else {
				break;
			}
		}
	}
	
	cout << tot;
}

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 5436
#include <bits/stdc++.h>
//F6編譯，右上三角形執行，ctrl+c強制停止執行  F5開啟exe
#define ll long long
#define maxn 100005
#define mod 1000000007
using namespace std;

typedef pair<int, int> P;

int n;
set<int> s;

int main()
{
    cin >> n;
    bool ok = 1;
    for (int i = 0; i < n; i++)
    {
        int x;
        scanf("%d", &x);
        if (s.count(x) > 0)
            ok = 0;
        s.insert(x);
    }
    if (ok)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include <math.h>
#include <string>

#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

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

	string s[101] = {};
	int s_count[101] = {};
	int idx = 0;
	for(int i = 0; i < N; ++i){
		string tmp = "";
		cin >> tmp;
		bool flag = true;
		for(int j = 0; j < 101; ++j){
			if(s[j] == tmp){
				flag = false;
				s_count[j]++;
			}
		}
		if(flag){
			s_count[idx]++;
			s[idx++] = tmp;
		}
	}

	cin >> M;
	for(int j = 0; j < M; ++j){
		string tmp = "";
		cin >> tmp;
		for(int j = 0; j < 101; ++j){
			if(s[j] == tmp){
				s_count[j]--;
			}
		}
	}
	int max = 0;
	for(int i = 0; i < 101; ++i){
		max = MAX(max, s_count[i]);
	}
	if(max < 0){
		max = 0;
	}
	cout << max << endl;	
}



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

class UnionFind {
private:
	vector<ll> parents;
	vector<ll> ranks;

public:
	vector<ll> sizes;

	UnionFind(ll s): parents(s), ranks(s), sizes(s, 1) {
		for(ll i = 0; i < s; i++) parents[i] = i;
	}

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

	void unite(ll x, ll y) {
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(ranks[x] < ranks[y]) {
			parents[x] = y;
			sizes[y] += sizes[x];
		} else {
			parents[y] = x;
			sizes[x] += sizes[y];
			if(ranks[x] == ranks[y]) ranks[x]++;
		}
	}

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

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

    int N, M;
    cin >> N >> M;

    vector<int> p(N);

    for(int i = 0; i < N; i++) {
        cin >> p[i];
        p[i]--;
    }

    UnionFind uf(N);

    for(int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        uf.unite(x, y);
    }

    vector<bool> checker(N);
    vector<vector<int> > A(N);
    vector<vector<int> > B(N);

    for(int i = 0; i < N; i++) {
        int x = uf.find(i);
        checker[x] = true;
        A[x].push_back(i);
        B[x].push_back(p[i]);
    }

    int ans = 0;

    for(int i = 0; i < N; i++) {
        if(!checker[i]) continue;
        sort(A[i].begin(), A[i].end());
        sort(B[i].begin(), B[i].end());
        int a = 0;
        int b = 0;
        while(a < A[i].size() && b < B[i].size()) {
            if(A[i][a] == B[i][b]) {
                ans++;
                a++;
                b++;
            } else if(A[i][a] < B[i][b]) a++;
            else b++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 13952
// D - Water Bottle
#include <bits/stdc++.h>
using namespace std;
using dbl = double;
#define PI (M_PI)
#define DEG(rad) ((rad)*180/PI)
#define EPS (0.000000001) // 誤差範囲

dbl f(dbl a, dbl b, dbl rad){//rad 傾けたとき a*a*b の容器にあふれずに入れられる水の量は？
	if(PI/2 - rad < EPS) return 0.0;//誤差範囲で90°といえるなら0を返す
	dbl c = tan(rad);//rad 傾けてみる
	//入れられる水の量: 傾き b/a 以下？ yes:容器の体積-空き容量(横から見て、奥行き*△) no:奥行き*△
	return c<=b/a? a*a*b - a*(a*(a*c)/2): a*(b*(b/c)/2);
}

dbl solve(dbl a, dbl b, dbl x){
	dbl ok = PI/2;
	dbl ng = 0;
	dbl volume = 0;
	while(abs(x - volume) >= EPS){
		dbl mid = (ok+ng)/2;// mid: この角度でどれだけ水を入れられるか？
		volume = f(a,b,mid);
		if(volume <= x) ok = mid;// 角度を小さくして、もっと多く入るようにする
		else ng = mid;// 角度を大きくして、もっと少なく入るようにする
	}
	return ok;
}

int main(){
	dbl a,b,x; cin>>a>>b>>x;
	printf("%.10f\n", DEG(solve(a, b, x)));
}

Measured memory_bytes: 256