akhauriyash/Code-Regression huggingface dataset:
p=int(input())
alist=list(map(int,input().split()))

fact_list=[1]
fact_inv_list=[1]
for i in range(1,p):
  fact=(fact_list[-1]*i)%p
  fact_list.append(fact)
  fact_inv_list.append(pow(fact,p-2,p))
def comb_mod(n,r):
  return fact_list[n]*fact_inv_list[r]*fact_inv_list[n-r]
  
answer_list=[0]*p
for i in range(p):
  a=alist[i]
  if a==1:
    #1-(x-i)^(p-1)
    coeff_list=[0]*p
    coeff_list[0]=1
    for j in range(p):
      coeff_list[j]-=comb_mod(p-1,j)*pow(-i,p-1-j,p)
      
    #print(i,coeff_list)
    for i in range(p):
      answer_list[i]+=coeff_list[i]
      
for i in range(p):
  answer_list[i]%=p

print(*answer_list)

Measured memory_bytes: 75240
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
 
int main() {
  string w;
  cin >> w;
  if(w[0] == 'S') cout << "Cloudy" << endl;
  else if(w[0] == 'C') cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
}

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

#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const multiset<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


int main(int argc, char const *argv[]) {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; ++i) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int ans = 0;
    for (int i = 0; i < K; ++i) {
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    A, B = (int(_) for _ in input().split())
    cnt = 0
    for i in range(A,B+1):
        if str(i) == str(i)[::-1]:
            cnt += 1
    print(cnt)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<28;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S,T;cin>>S>>T;
    int A,B;cin>>A>>B;
    string U;cin>>U;
    if(S==U) cout<<A-1<<" "<<B<<endl;
    else cout<<A<<" "<<B-1<<endl;
}




Measured memory_bytes: 256
#include<set>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define gt getchar()
#define ll long long
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
inline int in()
{
	int k=0;char ch=gt;bool p=1;
	while(ch<'-')ch=gt;if(ch=='-')ch=gt,p=0;
	while(ch>'-')k=k*10+ch-'0',ch=gt;
	return p?k:-k;
}
const int N=3e5+5;
int lz[N<<2];
#define lc k<<1
#define rc k<<1|1
struct node
{
	int l,r,cov;
	node(int l=0,int r=0,int cov=0):l(l),r(r),cov(cov){}
	inline bool operator<(const node &t)const{return l<t.l;}
};
typedef std::set<node>::iterator P;
std::set<node>cx;
P split(int l)
{
	P it=cx.lower_bound(l);
	if(it!=cx.end()&&it->l==l)return it;
	--it;node now=*it;cx.erase(it);
	cx.insert(node(now.l,l-1,now.cov));
	return cx.insert(node(l,now.r,now.cov)).first;
}
inline void cov(int l,int r,int x)
{	
	if(l>r)return;P itr=split(r+1),itl=split(l);
	cx.erase(itl,itr);cx.insert(node(l,r,x));
}
ll a[N],b[N],s[N],f[N],K;
int tot,L[N],R[N],ls[N];
inline int MO(const int &x){return x>=K?x-K:x;}
inline ll query(int p)
{
	P itl=split(p);int x=itl->cov;
	return (x?f[x]+MO(L[x]-p+K):0);
}
int main()
{
	int n=in();K=in();
	for(int i=1;i<=n;++i)
	{
		s[i]=s[i-1]+(a[i]=in()),b[i]=in();
		if(b[i]==2)L[i]=0,R[i]=K-1;
		else L[i]=MO(K-s[i-1]*2%K),R[i]=MO(K-s[i]*2%K);
		if(b[i]==1&&a[i]*2>K)return puts("-1"),0;
	}
	cx.insert(node(0,K-1,0));
	for(int i=n;i>=1;--i)
	{
		f[i]=query(L[i]);
		if(L[i]>R[i])cov(R[i]+1,L[i]-1,i);
		else cov(0,L[i]-1,i),cov(R[i]+1,K-1,i);
	}
	ll ans=f[1];
	for(int i=1;i<=n;++i)ans=std::min(ans,query(L[i]));
	for(int i=1;i<=n;++i)ans=std::min(ans,query(R[i]));
	printf("%lld\n",ans+s[n]*2);
	return 0;
}


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


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

int main()
{
    long long a;
    cin >> a;
    cout << (a*2)/gcd(a,2) << endl;

    return 0;
}






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

using namespace std;

int N, A, B;
long long K;
const int mod = 998244353;

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int subtract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}
void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;}

int power (int a, int b)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = mul (p, a);
        a = mul (a, a);
    }
    return p;
}

int fac[600009], inv[600009];
void Prec (int lim){fac[0] = inv[0] = 1;for (int i=1; i<=lim; i++)fac[i] = mul (fac[i - 1], i);
inv[lim] = power (fac[lim], mod - 2);for (int i=lim - 1; i>=0; i--)inv[i] = mul (inv[i + 1], i + 1);}
int comb (int N, int K){int ans = mul (fac[N], inv[N - K]);ans = mul (ans, inv[K]);return ans;}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d %d %lld", &N, &A, &B, &K), Prec (N + 2);
int ans = 0;
for (int i=0; i<=N && 1LL * A * i <= K; i++)
    if ((K - 1LL * A * i) % B == 0)
    {
        long long j = (K - 1LL * A * i) / B;
        if (j > N) continue;
        adto (ans, mul (comb (N, i), comb (N, j)));
    }
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 3456
import java.io.*;
import java.io.IOException;
import java.util.*;

class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        long[] M = new long[(int)(2)];
        long[] D = new long[(int)(2)];
        for(int i = 0 ; i < 2 ; i++){
                M[i] = sc.nextLong();
                D[i] = sc.nextLong();
        }
        solve(M, D);
    }

    static void solve(long[] M, long[] D){
        if(M[0]!=M[1])System.out.println(1);
        else System.out.println(0);
    }


    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


Measured memory_bytes: 22868
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
using namespace std;
const int MAX = 1e5 + 10; //N
const ll MOD = 1e9 + 7;
int N, M, K, Q;

int main()
{
	int i, j, k;
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int ans = min(c, b / a);
	printf("%d", ans);

}

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

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	map<int, long long> m;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		m[x]++;
	}

	vector<int> a;
	for (auto x : m) a.push_back(x.first);
	long long ans = 0;

	for (int i = 0; i < a.size(); i++)
		for (int j = i + 1; j < a.size(); j++)
			for (int k = j + 1; k < a.size(); k++)
				if (a[i] + a[j] > a[k])
					ans += m[a[i]] * m[a[j]] * m[a[k]];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;

int main() {
	string S;
	cin >> S;
	if (S.size() == 2)cout << S << endl;
	else if (S.size() == 3)cout << S[2] << S[1] << S[0] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>


int main(void) {
  int a;
  char s[11];

  scanf("%d", &a);
  scanf("%s", s);

  if (a >= 3200) {
    printf("%s", s);
  } else {
    printf("red");
  }

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   string x, y;
   cin >> x >> y;

   if(x < y){cout << "<" << endl;}
   else if(x > y){cout << ">" << endl;}
   else{cout << "=" << endl;}
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int n, m; cin >> n >> m;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int s = 0;
	rep(i, n) s += a[i];
	int count = 0;
	float x = 0.25 * s / m;
	rep(i, n) if (a[i] >= x) count++;
	if (count >= m) puts("Yes");
	else puts("No");
	return 0;
}


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

int main() {
  vector<int> vec(3);
  cin >> vec.at(0) >> vec.at(1) >> vec.at(2);
  sort(vec.begin(), vec.end());
  int A, B, C;
  A = vec.at(0); 
  B = vec.at(1); 
  C = vec.at(2); 
  int count = 0;
  if(((C-B)+(C-A))%2 == 1) {
    C++;
    A++;
    count++;
  }
  count += (3*C - (A+B+C)) /2;
  cout << count << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		String res = "";
		for (char c : S.toCharArray()) {
			int code = c + N;
			if ('Z' < code) {
				code -= 26;
			}
			res += (char) code;
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 148148
#include <stdio.h>
int main(void)
{
   
    int n,max,min,i,a[10000];
    long long sum=0;
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
        sum += a[i];
     }
     max=min=a[0];
     for(i=1; i<n;i++){
         if(a[i]>max)
             max=a[i];
         if(a[i]<min)
            min=a[i];
     }
     printf("%d %d %lld\n",min,max,sum);
     
    return 0;
    
}


Measured memory_bytes: 2140
//#pragma GCC optimize("03", "unroll-loops")
//#pragma GCC target("avx2")

#include <bits/stdc++.h>

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR(i,n) for(i=0;i<n;i++)
#define FORn(i,j,n) for(i=j;i<n;i++)
#define pb push_back
#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define vli vector<lli>
#define vi vector<int>
#define vs vector<string>
#define vprint(v) for(auto t:v)cout<<t<<" "
#define endl "\n"

typedef long long int lli;
typedef long int li;

const lli mod=1000000007;
const lli limit=1000000;

using namespace std;

void fc(lli &x)
    {
        bool neg=false;
        register char c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int main() {

    fast()
    lli n,q,t;
    lli temp,temp1,temp2,temp3;
    lli i,j,k;
    cin>>i>>j>>k;
    cout<<k<<" "<<i<<" "<<j<<endl;

 
}

Measured memory_bytes: 256
# coding: utf-8
# B - YYMM or MMYY

s = [int(i) for i in input()]
f = int(s[0]*10+s[1])
s = int(s[2]*10+s[3])

def is_month(num):
    if num > 0 and num < 13:
        return True
    return False

if is_month(f) and is_month(s):
    print('AMBIGUOUS')
elif not is_month(f) and not is_month(s):
    print('NA')
elif is_month(f):
    print('MMYY')
else:
    print('YYMM')


Measured memory_bytes: 3060
n, m = map(int, input().split())
ans = 0

if n == 1 and m == 1:
    ans = 1
elif n == 1 and m >= 3:
    ans = m - 2
elif n >= 3 and m == 1:
    ans = n - 2
elif n >= 3 and m >= 3:
    ans = (n - 2) * (m - 2)
else:
    ans = 0

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef double ll ;
int main()
{
  int  n;
  cin>>n;
  ll dp[n]={0};
  ll a[n];
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  dp[0]=1;
  for(int i=0;i<n;i++)
  {
      for(int j=i+1;j>0;j--)
      {
          dp[j]=a[i]*dp[j-1]+(1-a[i])*dp[j];
      }
      dp[0]=dp[0]*(1-a[i]);
  }
  double s=0;
  for(int i=n/2+1;i<=n;i++)
  {
      s=s+dp[i];
  }
  cout<<fixed<<setprecision(10)<<s<<endl;
  // cout<<((int)(s*10000000000))/10000000000.0<<endl;
  
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x % N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % N;
		y = y >> 1;
		x = (x * x) % N;
	}
	return res;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n, m;
	cin >> n >> m;
	vector<ll> h(n+1, 0);
	f(i,1, n+1)
	{
		cin >> h[i];
	}
	vector<set<ll>> route(n+1, set<ll>());
	f(i, 0, m)
	{
		ll a, b;
		cin >> a >> b;
		route[a].insert(b);
		route[b].insert(a);
	}
	ll ans = 0;
	f(i, 1, n + 1)
	{
		ll comp = h[i];
		char flag = 'Y';
		for (auto j = route[i].begin(); j != route[i].end();
			j++)
		{
			if (h[*j] >= comp)
			{
				flag = 'N';
				break;
			}
		}
		if (flag == 'Y')
			ans += 1;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 17984
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int a,b,c,d;
    cin >> a >> b >> c >> d;


    cout << (((abs(b - a) <= d && abs(c - b) <= d) || abs(c - a) <= d) ? "Yes" : "No") << endl;

    return 0;
}


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

int main(){
  string s; cin >> s;
  int i = 0;
  int ans[100010];
  while (i < s.size()){
    int rcnt = 0, lcnt = 0, r, l;
    while (s.at(i) == 'R'){
      rcnt++;
      ans[i] = 0;
      i++;
    }
    r = i - 1; l = i;
    while (i < s.size() && s.at(i) == 'L'){
      lcnt++;
      ans[i] = 0;
      i++;
    }
    if (rcnt % 2){
      ans[l] = (rcnt + lcnt) / 2;
      ans[r] = rcnt + lcnt - ans[l];
    }else{
      ans[r] = (rcnt + lcnt) / 2;
      ans[l] = rcnt + lcnt - ans[r];
    }
  }
  for (i = 0; i < s.size(); i++){
    cout << ans[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class MainClass
{
    static int[] dx = new int[2] { 1, 0 };
    static int[] dy = new int[2] { 0, 1 };
    static void Main()
    {
        var HW = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int H = HW[0], W = HW[1];
        var map = new bool[H, W];
        for (int i = 0; i < H; i++)
        {
            var line = Console.ReadLine();
            for (int j = 0; j < W; j++)
            {
                map[i, j] = line[j] == '#';
            }
        }

        int x = 0, y = 0;
        map[0, 0] = false;
        while (true)
        {
            for (int i = 0; i < 2; i++)
            {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if (0 <= ny && ny < H && 0 <= nx && nx < W)
                {
                    if (map[ny, nx])
                    {
                        x = nx;
                        y = ny;
                        map[ny, nx] = false;
                        goto ctn;
                    }
                }
            }
            break;

        ctn:;
        }

        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (map[i, j])
                {
                    Console.WriteLine("Impossible");
                    return;
                }
            }
        }
        Console.WriteLine("Possible");
    }
}

Measured memory_bytes: 28332
#include <bits/stdc++.h>
 
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
 
using namespace std;

const int MOD=1e9+7;
int D[1000001];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, H, P, t=1, m=1;
	cin>>N>>H>>P;
	for(int i=2;i<=N;i++) m=(m+(t=(1LL*t*i)%MOD))%MOD;
	D[0]=t;
	for(int i=1;i<=P;i++) D[i]=(1LL*(m+1)*D[i-1])%MOD;
	for(int i=P+1;i<H;i++) D[i]=(1LL*m*(MOD+D[i-1]-D[i-P-1])+D[i-1])%MOD;
	cout<<(MOD+D[H-1]-D[H-P-1])%MOD<<'\n';
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

const int N = (int) 1e4 + 5;
const int M = (int) 1e9 + 7;

typedef long long ll;

int n;
ll a[N];
ll prod = 1;

ll mult(ll a, ll b) { return (a * b) % M; }

ll add(ll a, ll b) { return (a + b) % M; }

ll pwr(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) {
            res = mult(res, a);
            --b;
        }
        else {
            a = mult(a, a);
            b >>= 1;
        }
    }
    return res;
}

ll dvd(ll a, ll b) {
    return mult(a, pwr(b, M - 2));
}

unordered_map<int, int> m;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        int x = a[i];
        int k = 0;
        for (int j = 2; j * j <= x; j++)
            if (x % j == 0) {
                k = 0;
                while (x % j == 0) x /= j, k++;
                m[j] = max(m[j], k);
            }
        if (x > 1) m[x] = max(m[x], 1);
    }

    for (auto &p: m)
        for (int i = 0; i < p.second; i++) prod = mult(prod, p.first);

    ll res = 0;
    for (int i = 0; i < n; i++)
        res = add(res, dvd(prod, a[i]));

    cout << res << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<char> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (vec.at(i) == 'Y') {
      ans++;
    }
  }
  if (ans != 0) {
    cout << "Four" << endl;
  }
  else 
    cout << "Three" << endl;  
}


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

int main(){
    int n,y;cin >>n >>y;
    y /= 1000;
    
    for(int i=0; i<=n; i++){
        for(int j=0; i+j<=n; j++){
            
            int p = 10*i+5*j;
            
            if(y-p == n-i-j){
                printf("%d %d %d\n",i,j,n-i-j);
                return 0;
            }
            
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int func(int t, int* r, int* g, int* b){
    int ans = 0;
    int f=1;
    if(t == *r){
        if(f){
            *r += 1;
        }
        ans++;
        f=0;
    }
    if(t == *g){
        if(f){
            *g += 1;
        }
        ans++;
        f=0;
    }
    if(t == *b){
        if(f){
            *b += 1;
        }
        ans++;
        f=0;
    }
    return ans;
}

int main(){
    int n;
    scanf("%d", &n);
    int r=0, g=0, b=0;
    long long int ans = 1;
    for(int i=0; i<n; i++){
        int a;
        scanf("%d", &a);
        ans = ans*func(a, &r, &g, &b);
        ans = ans % 1000000007;
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import static java.lang.Math.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int a = sc.nextInt();
        double min = Integer.MAX_VALUE;
        int min_num = Integer.MAX_VALUE;
        for(int i=0; i<n; i++){
            int h = sc.nextInt();
            if(min > min(min, abs(a-(t-h*0.006)))){
                min = min(min, abs(a-(t-h*0.006)));
                min_num = i;
            }
        }
        System.out.println(min_num+1);
    }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
int ice[100][100],n,m,ans;
int xx[4]={0,1,0,-1},yy[4]={1,0,-1,0};
int solve(int x,int y,int sum);

int main(){

    while(1){
    cin >> m >> n;
    if(m==0&&n==0)break;

    for(int i=1;i<=n;i++){
       for(int j=1;j<=m;j++){
        cin >> ice[j][i];
       }
    }

    for(int i=1;i<=n;i++){
       for(int j=1;j<=m;j++){
        if(ice[j][i]==1)solve(j,i,1);
       }
    }

    cout << ans << endl;
    ans=0;
    fill(ice[0],ice[99],0);
    }

return 0;
}

int solve(int x,int y,int sum){
    for(int i=0;i<4;i++){
        if(ice[x+xx[i]][y+yy[i]]==1){
            ice[x][y]=0;
            solve(x+xx[i],y+yy[i],sum+1);
            ice[x][y]=1;
        }
    }
    ans=max(ans,sum);
}

Measured memory_bytes: 1200
# スイッチ数, 電球数
n, m = gets.chomp.split(' ').map(&:to_i)

def ep(o)
  STDERR.puts o.inspect
end

def to_a(array)
  result = 0
  for i in 0..array.reverse.length-1
    result = result << 1
    result += array[i]
  end
  result
end

sls = Array.new(n){|i| Array.new(m, 0)}
for i in 0..m-1 do
  _, *ss = gets.chomp.split(' ').map(&:to_i)
  for s in ss do
    sls[s-1][i] = 1
  end
end

ep sls.inspect

dp = Array.new(2**m, 0)
dp[0] = 1
ep dp

for sl in sls do
  dp2 = dp.clone
  sum = 0
  ep sl
  sum = to_a(sl)
  ep sum
  # OFFの場合
  #   -> なにもしない
  # ONの場合
  for x in 0..dp.length-1 do
	dp2[sum^x] += dp[x]
  end
  dp = dp2
  ep dp
end
ps = gets.chomp.split(' ').map(&:to_i)

ep to_a(ps)
print dp[to_a(ps)]
print "\n"


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    string s;
    cin >> s;
    int k;
    cin >> k;
    // map<vector> 
    set<string> se;
    rep(i,s.length()){
        string t = "";
        t.push_back(s[i]);
        se.insert(t);
        for(int j = i+1;j<min((int)s.length(),i+k+1);j++){
            t.push_back(s[j]);
            se.insert(t);
        }
    }
    auto i = se.begin();
    rep(j,k-1){
        i++;
    }
    cout << *i <<endl; 
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, A, B, M, K, Q, W, H, R, C;
string S;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdi o(false);

    cin >> N >> A >> B;

    cout << N / (A + B) * A + min(N % (A + B), A) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a>b){
    cout << "a > b" <<endl;
  }
  else if(a==b){
    cout << "a == b"<<endl;
  }
  else{
    cout << "a < b"<<endl;
  }
}


Measured memory_bytes: 3112
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n = 0;
    string s;
    cin >> n;
    cin >> s;

    int count = 0;
    for (int i = 0; i < n - 2; i++)
    {
        if (s.at(i) == 'A' && s.at(i + 1) == 'B' && s.at(i + 2) == 'C')
        {
            count++;
        }
    }
    cout << count << endl;
}
// 33 ABCCABCBABCCABACBCBBABCBCBCBCABCB

Measured memory_bytes: 256
unittest
{
	assert( [ "oxoxoxoxoxoxox" ].parse.expand.solve == "YES" );
	assert( [ "xxxxxxxx" ].parse.expand.solve == "NO" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front;
	return tuple( s );
}

auto solve( string s )
{
	return ( 8 <= 15 - s.count( 'x' ) ) ? "YES" : "NO";
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();//参加者数
    int k = sc.nextInt();//参加者の持ち点
    int q = sc.nextInt();//問題数


    //参加者それぞれの点数を格納した配列
    ArrayList<Integer> plyr = new ArrayList<Integer>(n);
    for (int i=0 ; i<n ; i++){
      plyr.add(k-q);
    }
    
    for (int i=0 ; i<q ; i++){
      int se = sc.nextInt()-1;
      plyr.set(se, plyr.get(se) + 1);
    }

    //sorezore tensu
    for(int i=0;i<n;i++){
      if(plyr.get(i) < 1){
          System.out.println("No");
      }else{
          System.out.println("Yes");
      }
    }
  }
}

Measured memory_bytes: 81908
#include<stdio.h>
#include<string.h>
#include<iostream>
#define ll long long
using namespace std;

int hehe(int n){
    int ans=0;
    while(n)
    {
    ans+=n%10;n/=10;}
    return ans;
}

int main (){
    int n;
    scanf("%d",&n);
    int ans=0x3f3f3f3f;
    for(int i=1;i<n;i++){
        ans=min(hehe(i)+hehe(n-i),ans);
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 504
n = int(input())

ans = [input() for i in range(n)]

ans.sort()

s = sorted(set(ans))
t = 0
cnt = 0

result = 0
for i in range(n):
    temp = s[t]
    if ans[i] == temp:
        cnt += 1
    else:
        if cnt % 2 == 1:
            result += 1
        cnt = 1
        t += 1
else:
    if cnt % 2 == 1:
        result += 1
        
    
    

print(result)

Measured memory_bytes: 16460
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) (vec).begin(),(vec).end()
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int x;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>x;
	if(x>=30) cout<<"Yes"<<endl;
	else cout<<"No"<<endl; 
	return 0;
}


Measured memory_bytes: 3608
import copy

def Bubble(A,N):
	flag = 1
	while flag:
		flag = 0
		for i in range(N-1,0,-1):
			if int(A[i][1]) < int(A[i-1][1]):
				tmp = A[i]
				A[i] = A[i-1]
				A[i-1] = tmp
				flag = 1

def Selection(A,N):
	for i in range(N):
		minj = i
		for j in range(i,N):
			if int(A[j][1]) < int(A[minj][1]):
				minj = j
		tmp = A[i]
		A[i] = A[minj]
		A[minj] = tmp

def isStable(A,B,N):
	for i in range(N):
		if A[i] != B[i]:
			return False
	return True

N = int(input())
A = list(input().split())
B = copy.deepcopy(A)
Bubble(A,N)
Selection(B,N)
print(' '.join([str(a) for a in A]))
print('Stable')
print(' '.join([str(a) for a in B]))
print('Stable') if isStable(A,B,N) else print('Not stable')



Measured memory_bytes: 6348
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {
            var n = Input();
            var a = Input3();
            var b = Input3();
            var c = Input3();
            var ans = b[a[0]-1];

            for(int i = 1; i < n; i++)
            {
                ans += b[a[i]-1];
                if (a[i] == a[i - 1] + 1) ans += c[a[i-1]-1];
                //Console.WriteLine(ans);
            }
            Console.WriteLine(ans);


        }

       
        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>

int onde[200][2], stq = 0, maxi = 0;
char st[200][12], read[13];
int max(int a, int b){
    return a > b ? a: b;
}
void conta(int azul){
    //strcpy(dest, sourc);
    for(int i = 0; i < stq; ++i){
        if(strcmp(st[i], read) == 0){
            onde[i][azul]++;
            return;
        }
    }
    onde[stq][azul] = 1;
    strcpy(st[stq++], read);
    return;
}


int main() {
    int n, m;
    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        scanf(" %s", read);
        conta(0);
    }
    scanf("%d", &m);
    for(int i = 0; i < m; ++i){
        scanf(" %s", read);
        conta(1);
    }
    for(int i = 0; i < stq; ++i){
        maxi = max(maxi, onde[i][0]-onde[i][1]);
    }
    printf("%d\n", maxi);
}


Measured memory_bytes: 128
//file_name:ABC90_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    string s;
    cin >> s;
    cout << s[0];
    cin >> s;
    cout << s[1];
    cin >> s;
    cout << s[2];



    ll ans = 0;

    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>
#include <numeric>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<30)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  bool flag=false;
  if(S[5]=='1'){
    flag=true;
  }
  if(S[6]-'0'>=5){
    flag=true;
  }

  if(flag){
    cout << "TBD" << endl;
  }else{
    cout << "Heisei" << endl;
  }
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  bool judge = true;
  for (int i=0; i<3; i++) {
    if (S[i] == S[i+1]) {
      judge = false;
    }
  }
  cout << (judge ? "Good" : "Bad") << endl;
}

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

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

  if (n % 2 != 0) {
    cout << "No" << endl;
  } else {
    string ans = "Yes";
    rep(i, n / 2) {
      if (s[i] != s[i + (n / 2)]) {
        ans = "No";
        break;
      }
    }
    cout << ans << endl;
  }
}

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

using namespace std;

int main(){
  int accm = 0;
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
    accm += A[i];
  }
 sort(A.begin(), A.end());
 accm -= A[N - 1];
 if(accm > A[N - 1]){
  cout << "Yes";
 }else{
  cout << "No";
 }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++)
    {
        int j = i - 1;
        int P = A[i];
        while (j >= 0 && A[j] > P)
        {
            A[j + 1] = A[j];
            A[j] = P;
            j--;
        }
        for (int i = 0; i < N; i++)
        {
            cout << A[i];
            if (i < N - 1)
            {
                cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int N = sc.nextInt();
			int[] a = new int[N];
			
			long money = 1000;
			long stock = 0;
			for(int i=0;i<N;i++) {
				a[i] = sc.nextInt();
			}
			
			for(int i=0;i<N-1;i++) {
				if(a[i] < a[i+1]) {
					stock += money/a[i];
					money %=a[i];
				}else {
					money+=stock*a[i];
					stock=0;
				}
			}
			money+=stock*a[N-1];
			System.out.println(money);
		}	
	}
}


Measured memory_bytes: 35940
#include <stdio.h>
#include <string.h>
int main()
{
	int a,b;
	char s[20];
	scanf("%d %d",&a,&b);
	scanf("%s",&s);
	bool flag=true;
	if(s[a]!='-')
	flag=false;
	for(int i=0;i<(a+b+1);i++)
	{
		if(i==a)continue;
		if(s[i]>='0'&&s[i]<='9')continue;
		else
		{
			flag=false;
			break;
		}
	}
	if(flag)
	printf("Yes\n");
	else
	printf("No\n");
}

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

typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    
    int sum=0, cnt=0;
    bool flag=false;
    
    while(1){
        sum += a;
        if(sum%b==c) flag=true;
        cnt++;
        if(cnt==b) break;
    }
    cout << ((flag)?"YES":"NO") << endl;
}


Measured memory_bytes: 256
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  if (a < b) {
    return b - a;
  } else {
    return a - b;
  }
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a) {
    a = b;
  }
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b) {
    a = b;
  }
}
template <class F> class fix_point : private F {
public:
  explicit constexpr fix_point(F &&f) : F(std::forward<F>(f)) {}

  template <class... Args>
  constexpr decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};
template <class F> constexpr decltype(auto) make_fix(F &&f) {
  return fix_point<F>(std::forward<F>(f));
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const u32 m1 = scan<u32>();
  const u32 d1 = scan<u32>();
  const u32 m2 = scan<u32>();
  const u32 d2 = scan<u32>();
  std::cout << (m1 != m2 ? 1 : 0) << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256