akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	vector<string> A(N);
	vector<string> B(M);
	for (auto i = 0; i < N; ++i)
	{
		cin >> A[i];
	}

	for (auto i = 0; i < M; ++i)
	{
		cin >> B[i];
	}

	auto result = "No";
	for (auto i = 0; i <= N - M; ++i)
	{
		for (auto j = 0; j <= N - M; ++j)
		{
			auto isFound = true;
			for (auto k = 0; k < M; ++k)
			{
				for (auto l = 0; l < M; ++l)
				{
					if (A[i + k][j + l] != B[k][l])
					{
						isFound = false;
					}
				}
			}
			if (isFound)
			{
				result = "Yes";
			}
		}
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;

int a,b;
int main() {
    cin >> a >> b;
    int k = (max(a,b) - min(a,b)) / 2 + min(a,b);
    if((max(a,b) - min(a,b)) % 2 ) cout << "IMPOSSIBLE" << endl;
    else cout << k << endl;
    return 0;
}

Measured memory_bytes: 3524
import math

n, d = list(map(int, input().split()))
p = []
ans = 0
for i in range(n):
    x, y = list(map(int, input().split()))
    p.append([x, y])

for i in p:
    distance = math.sqrt(i[0]**2 + i[1]**2)
    if distance <= d:
        ans += 1
print(ans)

Measured memory_bytes: 39292
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

ll gcd(ll a,ll b){
  ll r=a%b;
  while(r>0){a=b;b=r;r=a%b;}return b;
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
pair<ll,ll> dfs(string s,ll dep){
  if(s.size()==1){
    if(s[0] == 'n')
      return mp(0,1);
    else return mp(90,1);
  }
  string s2 = "";
  for(int i=1;i<s.size();i++)
    s2+=s[i];
  pair<ll,ll>sum = dfs(s2,dep-1);
  pair<ll,ll>now = mp(90,pow(2,dep));
  ll hoge = lcm(sum.S,now.S);

  if(s[0] == 'n'){
    ll dir = sum.F*hoge/sum.S-now.F*hoge/now.S;
    ll GCD = gcd(dir,hoge);
    return mp(dir/GCD,hoge/GCD);
  }else{
    ll dir = sum.F*hoge/sum.S+now.F*hoge/now.S;
    ll GCD = gcd(dir,hoge);
    return mp(dir/GCD,hoge/GCD);
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  while(cin>>s,s!="#"){
    string ss = "";
    for(int i=0;i<s.size();i++){
      ss+=s[i];
      if(s[i] == 'n')i+=4;
      else i+=3;
    }
    //reverse(ALL(ss));
    pair<ll,ll>ans = dfs(ss,ss.size()-1);
    if(ans.S == 1)cout<<ans.F<<endl;
    else cout<<ans.F<<"/"<<ans.S<<endl;
  }
  return 0;
}



Measured memory_bytes: 3372
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

const int timeLimit = 1980;

i64 xor128()
{
  static i64 x = 123456789, y = 362436069, z = 521288629, w = 88675123;
  i64 t = (x ^ (x << 11));
  x = y;
  y = z;
  z = w;
  return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

i64 D;
i64 c[26];
i64 s[365][26];
vector<i64> ans;

i64 eval(vector<i64> &ans)
{
  i64 score = 0;
  i64 last[26] = {};
  for (i64 i = 0; i < D; i++)
  {
    score += s[i][ans[i]];
    last[ans[i]] = i + 1;
    for (i64 j = 0; j < 26; j++)
      score -= c[j] * (i + 1 - last[j]);
  }
  return score;
}

void solve()
{
  chrono::system_clock::time_point start = chrono::system_clock::now();
  i64 bestScore = -1e18, nowScore = -1e18, loop = 0;
  double C = timeLimit * 100, forceLine;
  i64 currentTime;
  vector<i64> now = ans;
  while ((currentTime = chrono::duration_cast<chrono::microseconds>(chrono::system_clock::now() - start).count() / 1000) < timeLimit)
  {
    i64 t[3] = {xor128() % D, xor128() % 26};
    t[2] = now[t[0]];
    now[t[0]] = t[1];
    i64 score = eval(now);
    forceLine = (timeLimit - currentTime) / C;
    if (bestScore < score)
    {
      ans = now;
      bestScore = score;
    }
    if (nowScore < score || forceLine * 1000 > rand() % 1000)
    {
      nowScore = score;
    }
    else
    {
      now[t[0]] = t[2];
    }
    loop++;
  }
  cerr << "score: " << bestScore + (i64)(1e6) << endl
       << "loop: " << loop << endl;
}

void init()
{
  for (i64 i = 0; i < D; i++)
    ans[i] = xor128() % 26;
}

void input()
{
  cin >> D;
  for (i64 i = 0; i < 26; i++)
    cin >> c[i];
  for (i64 i = 0; i < D; i++)
    for (i64 j = 0; j < 26; j++)
      cin >> s[i][j];
  ans.resize(D);
}

void output()
{
  for (i64 i = 0; i < D; i++)
    cout << ans[i] + 1 << endl;
}

int main()
{
  input();
  init();
  solve();
  output();
  return 0;
}


Measured memory_bytes: 3704
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

int n;
unsigned long long ans = 0;
vector<long long> a, b, l, r;


int main() {
	cin >> n;
	a.resize(n);
	b.resize(n);
	l.resize(n);
	r.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[a[i] - 1] = i;
	}
	for (long long i = n - 1; i >= 0; i--) {
		bool rcheck = false;
		if (b[i] + 1 < n) {
			if (r[b[i] + 1] > 0) {
				r[b[i]] = r[b[i] + 1] + 1;
				rcheck = true;
			}
			else
				r[b[i]] = 1;
		}
		else {
			r[b[i]] = 1;
		}
		if (b[i] - 1 >= 0) {
			if (l[b[i] - 1] > 0) {
				l[b[i]] = l[b[i] - 1] + 1;
			}
			else
				l[b[i]] = 1;
		}
		else {
			l[b[i]] = 1;
		}
		if (b[i] + 1 < n) {
			if (r[b[i] + 1] > 0) {
				l[b[i] + r[b[i] + 1]] += l[b[i]];
			}
		}
		if (b[i] - 1 >= 0) {
			if (l[b[i] - 1] > 0) {
				r[b[i] - l[b[i] - 1]] += r[b[i]];
			}
		}
		ans += (i + 1) * l[b[i]] * r[b[i]];
	}
	cout << ans << endl;

//	cin >> n;

	return 0;
}

Measured memory_bytes: 6528
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];
    sort(a.begin(), a.end());

    if(n == 2){
        cout << (a[1] - a[0]) << endl;
        cout << a[1] << ' ' << a[0] << endl;
        return 0;
    }

    auto it = lower_bound(a.begin(), a.end(), 0);
    multiset<int> x(a.begin(), it);
    multiset<int> y(it, a.end());

    vector<pair<int, int> > ans;
    if(x.empty()){
        int a = *y.begin();
        y.erase(y.begin());
        int b = *y.begin();
        y.erase(y.begin());
        ans.push_back(make_pair(a, b));
        x.insert(a - b);
    }
    else if(y.empty()){
        int a = *x.rbegin();
        x.erase(--x.end());
        int b = *x.rbegin();
        x.erase(--x.end());
        ans.push_back(make_pair(a, b));
        y.insert(a - b);
    }

    while(y.size() > 1){
        int a = *x.begin();
        x.erase(x.begin());
        int b = *y.begin();
        y.erase(y.begin());
        ans.push_back(make_pair(a, b));
        x.insert(a - b);
    }
    while(!x.empty()){
        int a = *y.begin();
        y.erase(y.begin());
        int b = *x.begin();
        x.erase(x.begin());
        ans.push_back(make_pair(a, b));
        y.insert(a - b);
    }

    cout << *y.begin() << endl;
    for(int i=0; i<n-1; ++i)
        cout << ans[i].first << ' ' << ans[i].second << endl;

    return 0;
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,sum=0;
	cin>>n;
	vector<long long int> a(n);
	for(int i=0;i<n;i++)
	cin>>a[i];
	vector<long long int> c(n);
	map<long long int,long long int> m;
	for(int i=n-1;i>=0;i--){
		c[i]=m[i+a[i]];
		m[i-a[i]]++;
	}
	for(int i=0;i<n;i++){
		sum+=c[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 29080
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] count = new int[1];
            dfs(1, N, 0, count, new int[8]);
            System.out.println(count[0]);
        }
    }

    private static void dfs(long i, long N, long number, int[] count, int[] used) {
        if (number > N) {
            return;
        }

        if (number >= 100 && number <= N && used[3] >= 1 && used[5] >= 1 && used[7] >= 1) {
            count[0]++;
        }

        for (int j = 3; j <= 7; j += 2) {
            used[j]++;
            dfs(i * 10, N, number + j * i, count, used);
            used[j]--;
        }
    }
}


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

// {u}{int,long,llong}_{max,min}
#define inf         int_max/3
#define llinf       llong_max/3
#define mod         (1000000007ll)
#define moda(a, b)  a=((a)+(b))%mod
#define modp(a, b)  a=((a)*(b))%mod
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using ll  = long long;
using g   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string ans = "x";
    int a, b;cin >> a >> b;
    if(a+b == 15) ans = "+";
    if(a*b == 15) ans = "*";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define mod 1000000007 
#define check exit(0)
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;

int n,m,k;
int nodes;
vector<int> ans(200005,0);
vector<int> g[200005];
vector<int> color(200005,0);
void dfs(int n,int next)
{
    color[n]=next;
    nodes++;
    for(int child:g[n]) 
    {
        if(!color[child]) dfs(child,next);
    }
}
int main()
{
    jaldi
    cin>>n>>m>>k;
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
        ans[u]--;
        ans[v]--;
    }
   // for(int i=1;i<=n;i++) cout<<ans[i]<<" ";
    int next=1;
    vector<int> sz(200005,0);
    for(int i=1;i<=n;i++)
    {
        nodes=0;
        if(!color[i]) dfs(i,next),sz[next]=nodes,next++;
    }
    for(int i=1;i<=n;i++)
    {
         ans[i]+=sz[color[i]]-1;
         //cout<<color[i]<<" -- > "<<sz[color[i]]<<endl;;
    }
    for(int i=1;i<=k;i++)
    {
        int u,v;
        cin>>u>>v;
        if(color[u]==color[v]) { ans[u]--;ans[v]--; }
    }
    for(int i=1;i<=n;i++) cout<<ans[i]<<" ";
    return 0;
}


Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define ll   long long
#define ld   long double
#define N    300256
#define M    998244353
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() );
using namespace std;
ll tests;
ll n, k, a[ N ], b[ N ], ans;
set < ll > s;
bool ok;
priority_queue< ll, vector < ll >, greater < ll > > q;
priority_queue < ll > pq;
void solve()
{
    sc( "%I64d%I64d", &n, &k );
    for( int i = 1; i <= n; i ++ )
    {
        sc( "%I64d", &a[ i ] );
        if( i > 1 && a[ i ] > a[ i - 1 ] )b[ i ] = b[ i - 1 ];
        else b[ i ] = b[ i - 1 ]  + 1;
        if( i <= k )
        {
            s.insert( a[ i ] );
            q.push( a[ i ] );
            pq.push( a[ i ] );
        }
    }
    ans = !( b[ k ] == b[ 1 ] );
    ok = b[ k ] == b[ 1 ];
    for( int l = k + 1; l <= n; l ++ )
    {
        while( s.find( q.top() ) == s.end() )q.pop();
        while( s.find( pq.top() ) == s.end() )pq.pop();
        if( a[ l - k ] == q.top() && pq.top() < a[ l ] );
        else if( b[ l ] == b[ l - k + 1 ] )ok = 1;
        else
        {
            ans ++;
        }
        s.erase( a[ l - k ] );
        s.insert( a[ l ] );
        pq.push( a[ l ] );
        q.push( a[ l ] );
    }
    ans += ok;
    pr( "%I64d", ans );
}


int main()
{
    /*sc( "%I64d", &tests );
    while( tests -- )*/
        solve();
}








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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	int N, A, B;
	cin >> N >> A >> B;

	int ans = 0;
	for (int i = 1; i <= N; ++i) {
		int div = i;
		int sum = 0;
		while (div != 0) {
			int mod = div % 10;
			sum += mod;
			div = div / 10;
		}

		if (A <= sum && sum <= B) {
			ans += i;
		}
	}

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


Measured memory_bytes: 3548
import java.util.Scanner;

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

        // distance
        int d = sc.nextInt();

        // time
        int t = sc.nextInt();
      	
      	//speed
      	int s=sc.nextInt();

		if(t*s>=d){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
      
    }
}

Measured memory_bytes: 35812
import sys
sys.setrecursionlimit(10 ** 7)

def dfs(G, p, pre, t, edge, x):
    for nxt in G[p]:
        if nxt == pre:
            continue
        a, b = p, nxt
        if b < a:
            a, b = b, a
        if nxt == t:
            edge[(a, b)] += x
            return True
        if dfs(G, nxt, p, t, edge, x):
            edge[(a, b)] += x
            return True
    return False

def main():
    n = int(input())
    G = [[] for _ in range(n)]
    edge = {}
    for _ in range(n-1):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        G[a].append(b)
        G[b].append(a)
        if b < a:
            a, b = b, a
        edge[(a, b)] = 0
    m = int(input())
    for i in range(m):
        u, v = map(int, input().split())
        u, v = u-1, v-1
        x = 1<<i
        dfs(G, u, -1, v, edge, x)
    ans = 2**(n-1)
    for i in range(1, 2**m):
        bit_cnt = 0
        for j in range(m):
            if (i & (1<<j)) != 0:
                bit_cnt += 1
        cnt = 0
        for v in edge.values():
            if (v & i) != 0:
                cnt += 1
        x = 2**(n-1 - cnt)
        if bit_cnt % 2 == 0:
            ans += x
        else:
            ans -= x
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 73324
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


int main() { 
    string S; cin >> S;
    int minAbs = INF;
    REP(i, S.size()-2) {
        chmin(minAbs, abs(753-stoi(S.substr(i, 3))));
    }
    cout << minAbs << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n,a;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a%2==1){
            cout<<"first"<<endl;
            return 0;
        }
    }
    cout<<"second"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)


int main() {
    string s;
    int k;
    
    cin >> s >> k;
    REP(i, s.size() - 1){
        if(s[i] == 'a')continue;
        
        if(26 - (s[i] - 'a') <= k){
            k -= 26 - (s[i] - 'a');
            s[i] = 'a';
        }
    }
    s[s.size() - 1] = (char)((s[s.size() - 1] - 'a' + k) % 26 + 'a');
    
    cout << s << endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

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

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vec L(N);
    rep(i, N) cin >> L[i];
    sort(all(L));
    reverse(all(L));
    int a = L[0];
    int sum = 0;
    rep(i, N){
        sum += L[i];
    }

    if(a < sum - a) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

int n;
int A[200000];

void swap(int *a, int *b){
  int z;
  z = *a;
  *a = *b;
  *b = z;
}

int kth(int *A, int n, int k){
  int i, l, r, pivot;
  if(A[n/2] > A[0])    swap(A+n/2, A);
  if(A[n/2] > A[n-1])  swap(A+n/2, A+n-1);
  if(A[0] > A[n-1])    swap(A, A+n-1);
  pivot = A[0];
  l = 0;
  r = n;
  i = 1;
  while(i < r){
    if(A[i] < pivot) swap(A+l++, A+i++);
    else if(A[i] > pivot) swap(A+--r, A+i);
    else i++;
  } 
  if(k < l) return kth(A, l, k);
  if(k >= r) return kth(A+r, n-r, k-r);
  return pivot;
}

int main(){
  int i, m;
  long long int r;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", A+i);
    A[i] -= i+1;
  }
  m = kth(A, n, n/2);
  r = 0;
  for(i=0;i<n;i++) r += abs(A[i] - m);
  printf("%lld\n", r);
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

template< typename T >
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > bellman_ford(Edges< T > &edges, int V, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(V, INF);
  dist[s] = 0;
  for(int i = 0; i < V - 1; i++) {
    for(auto &e : edges) {
      if(dist[e.src] == INF) continue;
      dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
    }
  }
  for(auto &e : edges) {
    if(dist[e.src] == INF) continue;
    if(dist[e.src] + e.cost < dist[e.to]) return vector< T >();
  }
  return dist;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int V, E, R;
    scanf("%d %d %d", &V, &E, &R);
    Edges< int > es;
    for(int i = 0; i < E; i++) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        es.emplace_back(a, b, c);
    }
    auto dists = bellman_ford(es, V, R);
    if(dists.empty()) puts("NEGATIVE CYCLE");
    for(auto &dist : dists) {
        if(dist == numeric_limits< int >::max()) puts("INF");
        else printf("%d\n", dist);
    }

}


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

// // greatest common divisor
// int gcd(int a, int b) {
//     if (a < b)
//         return gcd(b, a);
//     int r;
//     while ((r=a%b)){
//         a = b;
//         b = r;
//     }
//     return b;
// }

// // least common multiple
// int lcm( int m, int n )
// {
// 	if ( ( 0 == m ) || ( 0 == n ) )
// 		return 0;
	
// 	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
// }

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(size_t i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    int ret = 0;
    for(size_t i = 0; i < N; i++)
    {
        ret+= a[i]-1;
    }
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

struct Edge{
	int from, to;
	ll cost;
	Edge(int from, int to, ll cost) : from(from), to(to), cost(cost){}
};

int n, m;

int ng = 0;

vector<Edge> es;
vector<int> dist;
void bellman_ford(int s){
	dist[s] = 0;
	for(int i = 0; i < n; ++i){
		for(auto e : es){
			if(dist[e.from] == INF)continue;
			if(dist[e.from] + e.cost < dist[e.to]){
				dist[e.to] = dist[e.from] + e.cost;
				if(i == n - 1){
					ng = 1;
					break;
				}
			}
		}
	}
}

int main(){
  int s;
  cin >> n >> m >> s;
  for(int i = 0; i < m; ++i){
  	int a, b, c;
  	cin >> a >> b >> c;
  	es.push_back(Edge(a, b, c));
  }

  dist.assign(n, INF);
  bellman_ford(s);
  if(ng){
  	cout << "NEGATIVE CYCLE" << endl;
  	return 0;
  }
  for(int i = 0; i < n; ++i){
  	if(dist[i] == INF)cout << "INF" << endl;
  	else cout << dist[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8  
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

/*******************************************************/


vi memo(1 << 15, INT_MIN);

// 0: unused, 1: used
int dfs(int x) {
  if (memo[x] == INT_MIN) {
    int sum = 0;
    int x_buf = x;
    Loop1(i, 15) {
      if (x_buf % 2 == 1) sum ^= i;
      x_buf >>= 1;
    }
    x_buf = x;
    Loop1(i, 15) {
      if (x_buf % 2 == 1) {
        int v = dfs(x - (1 << (i - 1)));
        memo[x] = max(memo[x], v);
      }
      x_buf >>= 1;
    }
    if (sum == 0) memo[x]++;
  }
  return memo[x];
}

int main() {
  int n; cin >> n;
  vi cost(n, 0);
  Loop(i, n - 1) {
    int x, y, a;
    cin >> x >> y >> a;
    cost[x] ^= a;
    cost[y] ^= a;
  }
  vi cnt(16, 0);
  Loop(i, n) {
    cnt[cost[i]]++;
  }
  int ans = 0;
  Loop1(i, 15) {
    ans += cnt[i] / 2;
    cnt[i] %= 2;
  }
  int x = 0;
  Loop1(i, 15) {
    if (cnt[i]) {
      x += (cnt[i] << (i - 1));
      ans++;
    }
  }
  memo[0] = 0;
  ans -= dfs(x);
  cout << ans << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e5;
const int size=1e5;
const int inf=1e9;
int main(){
	int N; cin>>N;
	int L[N];
	rep(i,0,N) cin>>L[i];
	sort(L, L+N);
	int cnt = 0;
	rep(i,0,N-2)rep(j,i+1,N-1)rep(k,j+1,N){
        if(L[i] == L[j] || L[j] == L[k]) continue;
		if(L[i] + L[j] > L[k]) cnt++;
	}cout<<cnt<<endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n;
  cin >> n;
  vector<double> t(n), v(n);
  rep(i, n) cin >> t[i];
  rep(i, n) cin >> v[i];
  int tm = accumulate(all(t), 0LL);
  vector<double> sp(2 * tm + 1, INF);
  int now = 0;
  rep(i, n) {
    rep(j, t[i]) {
      int t = now + j * 2;
      int tt = now + j * 2 + 1;
      cmin(sp[t], v[i]);
      cmin(sp[tt], v[i]);
    }
    now += t[i] * 2;
    cmin(sp[now], v[i]);
  }
  sp[0] = sp[2 * tm] = 0;
  for (int i = 0; i < 2 * tm + 1; i++) cmin(sp[i + 1], sp[i] + 0.5);
  for (int i = 2 * tm; i >= 0; i--) cmin(sp[i], sp[i + 1] + 0.5);

  double ans = 0;
  rep(i, 2 * tm + 1) ans += (sp[i] + sp[i + 1]) * 0.5 / 2;

  printf("%lf\n", ans);
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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 namespace std;

int main(){
    Init();
    ll h, w; cin >> h >> w;
    vector<vector<string>> s(h, vector<string>(w));
    ll ans_h, ans_w;
    rep(i, h) rep(j, w){
        cin >> s[i][j];
        if(s[i][j] == "snuke") ans_h = i, ans_w = j;
    }
    cout << (char)('A'+ans_w) << ans_h+1 << endl;
}

Measured memory_bytes: 3592
k = int(input())
x = 7 % k
cnt = 0
for i in range(2 * 10 ** 6):
    if x == 0:
        break
    x = (x * 10 + 7) % k
    cnt += 1
if cnt == 2000000:
    print(-1)
else:
    print(cnt + 1)


Measured memory_bytes: 63076
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int k, n, m;

string s;
string t;
set<int> s1;
set<int> t1;

int add(int v, int id){
	if(id == 0){
		for(int j = v; ; j++){
			auto x = s1.find(j);
			if(x == s1.end()){
				s1.insert(j);
				return j;
			} else{
				s1.erase(x);
			}
		}
	}
	if(id == 1){
		for(int j = v; ; j++){
			auto x = t1.find(j);
			if(x == t1.end()){
				t1.insert(j);
				return j;
			} else{
				t1.erase(x);
			}
		}
	}
}

void process(int v, int k){
	if(k == 0) return;
	if(s1.find(v) == s1.end() || t1.find(v) == t1.end()) return;
	int next1 = *s1.upper_bound(v);
	int next2 = *t1.upper_bound(v);
	int r = min(k, min(next1,next2) - v - 1);
	if(r > 0){
		s1.erase(v);
		t1.erase(v);
		s1.insert(v + r);
		t1.insert(v + r);
		process(v+r, k-r);
		return;
	}
	if(k == 0) return;
	//if(next1 == v+1 && next2 == v+1) assert(false);
	if(next1 == v+1){
		int d = add(v,0);
		add(v,1);
		process(d, k-1);
	} else {
		add(v,0);
		int d = add(v,1);
		process(d, k-1);
	}
}
void pr(set<int> s){
	string g;
	int last = 0;
	for(int x : s){
		for(int j = last; j < x; j++){
			g += '0';
		}
		g += '1';
		last = x + 1;
	}
	reverse(g.begin(), g.end());
	cout << g << '\n';
}
int main(){
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> n >> m >> k;
	cin >> s >> t;
	reverse(s.begin(), s.end());
	reverse(t.begin(), t.end());
	s.resize(1000000, '0');
	t.resize(1000000, '0');
	s1.insert(11000000);
	t1.insert(11000000);
	for(int v = 1000000; v >= 0; v--){
		if(s[v] == '0' && t[v] == '0') continue;
		if(s[v] == '1' && t[v] == '0') s1.insert(v);
		if(s[v] == '0' && t[v] == '1') t1.insert(v);
		if(s[v] == '1' && t[v] == '1'){
			s1.insert(v);
			t1.insert(v);
			process(v, k);
		}
	}
	s1.erase(11000000);
	t1.erase(11000000);
	pr(s1);
	pr(t1);
}


Measured memory_bytes: 63604
# TODO: unknown
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()
a.append(10 ** 9 + 1)
b.append(10 ** 9 + 2)
c.append(10 ** 9 + 3)

ab = [0] * (n + 1)
j = 0
for i in range(n + 1):
    while b[j] <= a[i]:
        j += 1
    ab[i] = j

k = 0
bc = [0] * (n + 1)
for j in range(n + 1):
    while c[k] <= b[j]:
        k += 1
    bc[j] = k

bc_acc = [0] * (n + 1)
bc_acc[n] = 0
for j in range(n-1, -1, -1):
    bc_acc[j] = bc_acc[j+1] + n - bc[j]

ans = 0
for i in range(n):
    ans += bc_acc[ab[i]]

print(ans)


Measured memory_bytes: 26932
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		long Inf = (long) 1e18;
		
		long[][] dp = new long[2][];
		int N = S.Length;
		for(int i=0;i<2;i++){
			dp[i] = new long[N + 2];
			for(int j=0;j<=N+1;j++){
				dp[i][j] = Inf;
			}
		}
		var ca = S.ToCharArray();
		Array.Reverse(ca);
		int[] a = new int[N + 1];
		for(int i=0;i<N;i++) a[i] = (int)(ca[i] - '0');
		//Console.WriteLine(String.Join(" ",a));
		dp[0][0] = 0;
		for(int i=0;i<=N;i++){
			for(int carry = 0; carry < 2; carry++){
				if(dp[carry][i] == Inf) continue;
				int v = a[i] + carry;
				if(v < 10){
					dp[0][i+1] = Math.Min(dp[0][i+1], dp[carry][i] + v); // 自分
				} else {
					dp[1][i+1] = Math.Min(dp[1][i+1], dp[carry][i]);
				}
				if(10 - v < 10){
					dp[1][i+1] = Math.Min(dp[1][i+1], dp[carry][i] + 10 - v); // 相手
				} else {
					dp[0][i+1] = Math.Min(dp[0][i+1], dp[carry][i]);
				}
			}
		}
		
		Console.WriteLine(dp[0][N+1]);
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int h, w; char s[4];
void a(){
	printf("+");
	REP(i, w-2) printf("-");
  printf("+\n");
}
int main(){
	scanf("%d%d%s", &w, &h, s);
	a();
	REP(i, h-2){
		printf("|");
		REP(j, w-2) printf("%c", (i==h/2-1 && j==w/2-1)?s[0]:'.');
    printf("|\n");
  }
  a(); 
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> divisor(ll x){vector<ll> div;
	for(ll i=1;i*i<=x;i++){if(x%i==0){div.pb(i);if(i*i!=x)div.pb(x/i);}}
	sort(div.bg,div.ed);return div;}


int main(){
	ll N,K; cin>>N>>K;
	if(N%K==0) cout<<0;
	else cout<<1;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int T=0,D=0,L=0;
		int z=0,x=0,k=0;
		long answe[]=new long[40];
		boolean w=false;
		while(true){
			T=stdIn.nextInt();
			D=stdIn.nextInt();
			L=stdIn.nextInt();
			if(T==0&&D==0&&L==0)
				break;
			long ans=0;
			x=D;
			while(z<T){
				int y=stdIn.nextInt();
				if(y>=L){
					if(x==0||x==D&&w==false)
						ans--;
					ans++;
					w=true;
					x=D;
				}
				if(y<L){
					if(x!=D&&x!=0){
						x--;
						ans++;
					}
					if(w){
						w=false;
						x--;
						ans++;
					}
				}
				z++;
			}z=0;
			w=false;
			answe[k]=ans;
			k++;
		}z=0;
		while(z<k){
			System.out.println(answe[z]);
			z++;
		}
	}
}



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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n; scanf("%d",&n);
	rep(x,n+1) if((int)(1.08*x)==n) return printf("%d\n",x),0;
	puts(":(");
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
from sys import stdin
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
    
#A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
K = int(input())

counter = 0

for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            counter = counter + gcd(a,b,c)

print(counter)

Measured memory_bytes: 69620
#include <cstdio>
#include <algorithm>

using namespace std;

unsigned long long int gcd(unsigned long long int x, unsigned long long int y)
{
    unsigned long long int r;
    if (x < y){
        swap(x, y);
    }

    while (y > 0){
        r = x % y;
        x = y;
        y = r;
    }

    return x;
}
        
int main()
{
    unsigned long long int x, y, tmp;

    scanf (" %llu %llu", &x, &y);

    printf("%llu\n", gcd(x, y));
    
    return 0;
}

    

Measured memory_bytes: 1032
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

//-----end of template-----//

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, h, w;
	cin >> n >> h >> w;
	cout << (n - h + 1) * (n - w + 1) << endl;
}

Measured memory_bytes: 256
MOD = 10**9 + 7

N = int(input())
S = input()
lis = [1] * 26
for i in range(N):
    lis[ord(S[i])-ord('a')] += 1
ans = 1
for i in range(26):
    ans *= lis[i]
    ans %= MOD
print(ans - 1)


Measured memory_bytes: 63672
#include <iostream>

using namespace std;

int main(){
  int X;
  cin >> X;
  int Happy=0;//嬉しい！
  int tempInt=0;
  tempInt=X/500;//500円玉の数
  Happy+=tempInt*1000;//500円の嬉しさ
  tempInt=X%500;//端数を取り出す
  tempInt=tempInt/5;//可能な限り端数を5円玉に
  Happy+=tempInt*5;//5円の嬉しさ
  cout << Happy << endl;
  return 0;
}

Measured memory_bytes: 256
# D
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())
ans = 0
dct = {'r': R, 's': S, 'p': P}
win = {'r': 'p', 's': 'r', 'p': 's'}
aiko = {'r': 'r', 's': 's', 'p': 'p'}
lose = {'r': 's', 's': 'p', 'p': 'r'}

hands = []
for i, s in enumerate(T):
    hand = win[s]
    if (i+1 <= K):
        hands.append(hand)
        ans += dct[hand]
    else:
        if (hands[i-K] != hand):
            ans += dct[hand]
            hands.append(hand)
        else:
            if (i < N-K):
                if (win[T[i+K]] != aiko[s]):
                    hands.append(aiko[s])
                elif (win[T[i+K]] != lose[s]):
                    hands.append(lose[s])
            else:
                hands.append(lose[s])
print(ans)

Measured memory_bytes: 50700
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <functional>
#include <queue>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> P2;

int main(){
  P2 team[51];
  int wrongCount[51][11];
  
  string message;
  int T, P, R;
  int Tid, Pid, time;
  
  while(cin >> T >> P >> R){
    if(T == 0 && P == 0 && R == 0) break;
    
    memset(wrongCount, 0, sizeof(wrongCount));
    
    for(int i = 0 ; i < T ; i++){
      team[i].first = 0; // Correct count
      team[i].second.first = 0; // time count
      team[i].second.second = i+1; // team number
    }

    for(int i = 0 ; i < R ; i++){
      cin >> Tid >> Pid >> time >> message;
      
      Tid--;
      
      if(message == "CORRECT"){
	team[Tid].first++;
	team[Tid].second.first += wrongCount[Tid][Pid]*1200 + time;
      }
      else if(message == "WRONG") wrongCount[Tid][Pid]++;
    }
    
    for(int i = 0 ; i < T ; i++){
      team[i].second.first *= -1;
      team[i].second.second *= -1;
    }
    
    sort(team, team+T);
    reverse(team, team+T);
  
    for(int i = 0 ; i < T ; i++){
      printf("%d %d %d\n", team[i].second.second*=-1, team[i].first, team[i].second.first*=-1);
    }
  }
  return 0;
}

    

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

money = 0.0
def calc(list1, money):
    if list1[1] == 'JPY':
        return money + float(list1[0])
    else:
        return money + float(list1[0]) * 380000.0

for i in range(N):
    money = calc(input().split(), money)

print(money)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  ll n;
  cin >> n;
  ll count = 0; 
  
  for(int i = 1; i <= n; i++){
    if(i % 3 != 0 && i % 5 != 0) count += i;
  }
  cout << count << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#define MAX 1000
#define NIL -1

typedef struct node{
  int parent, left, right;
}Node;

Node T[MAX];
int n, D[MAX], H[MAX];
void setDepth(int, int);
int setHeight(int );
int getSibling(int );
void print(int );

int main(){
  int i, v, l, r, root=0;
  scanf("%d",&n);

  for(i=0; i<n; i++){
    T[i].parent =NIL;
  }
  for(i=0; i<n; i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL)T[l].parent = v;
    if(r != NIL)T[r].parent = v;
  }

  for(i=0; i<n; i++){
    if(T[i].parent == NIL) root = i;
  }
  setDepth(root, 0);
  setHeight(root);

  for(i = 0; i<n; i++){
    print(i);
  }
  return 0;
}



void setDepth(int u, int d){
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  } else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

Measured memory_bytes: 624
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#define int long long
using namespace std;

int a[100000], b[100000], c[100000];
int d[100001];
int e[100001];
signed main() {
	int n; cin >> n;
	for (int i = 0; i<n; i++)cin >> a[i];
	for (int i = 0; i<n; i++)cin >> b[i];
	for (int i = 0; i<n; i++)cin >> c[i];
	sort(a, a + n, greater<int>()); sort(b, b + n, greater<int>()); sort(c, c + n, greater<int>());
	int k = 0;
	for (int i = 0; i<n; i++) {
		while (k<n&&b[i]<c[k]) { k++; }
		d[i + 1] = k;
		e[i + 1] = e[i] + d[i + 1];
	}
	int ans = 0;
	k = 0;
	for (int i = 0; i<n; i++) {
		while (k<n&&a[i]<b[k]) { k++; }
		ans += e[k];
	}
	cout << ans << endl;
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <bitset>
#include <fstream>

#define ll long long
#define scani(x) scanf("%i", &x)
#define scanll(x) scanf("%I64d", &x)
#define scanfl(x) scanf("%f", &x)
#define scanch(x) scanf("%c", &x)
#define scans(x) scanf("%s", x);
#define printi(x) printf("%i", x);
#define printll(x) printf("%I64d", x);
#define printfl(x) printf("%f", x);
#define printch(x) printf("%c", x);
#define prints(x) printf("%s", x);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define INFI (1 << 29)
#define INFL (1LL << 62)
#define sz(x) int(x.size())
#define fi first
#define se second
#define forn(i, n) for(ll i = 0; i < n; i++)
#define for1(i, n) for(ll i = 1; i <= n; i++)
#define ford(i, n) for(ll i = (n - 1); i >= 0; i--)
#define fori(i, n) for(ll i = n; i >= 1; i--)
#define fore(i, l, r) for(ll i = l; i <= r; i++)
#define get_bit(mask, x) (bool)(mask & (1LL << x))
#define set_bit(mask, x) (mask |= (1LL << x))
#define reset_bit(mask, x) (mask &= ~(1LL << x))
#define toggle_bit(mask, x) (mask ^= (1LL << x))

using namespace std;

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

    string s, t;

    cin >> s >> t;

    cout << ((s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2])) << "\n";

    return 0;
}


Measured memory_bytes: 256