akhauriyash/Code-Regression huggingface dataset:
# 日立コン
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

A, B, M = map(int, readline().split())

Alist = list(map(int, readline().split()))
Blist = list(map(int, readline().split()))

min_a = min(Alist)
min_b = min(Blist)
answer = min_a + min_b

for _ in range(0, M):
    x, y, c = map(int, readline().split())
    tmp = Alist[x-1] + Blist[y-1] - c
    answer = min(answer, tmp)

if answer > 0:
    print(answer)
else:
    print(0)

Measured memory_bytes: 17012
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 105;
const int MOD = 1e9 + 7;

inline int add(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }

int n, a[MAXN], dp[MAXN][MAXN][MAXN];

int f(int i, int idx, int tot) {
  if (i < 0) return 1;
  if (dp[i][idx][tot] != -1) return dp[i][idx][tot];

  int ret = 0;

  int add_first = (a[i-1] == a[i]) ? 0 : 1;
  int add_last = (a[2*n-1-i] == a[2*n-2-i]) ? 0 : 1;

  FOR(j, 1, tot + 1) {
    int rem = max(abs(j - idx) - 1, 0);
    int new_idx = (idx < j) ? idx + 1 : j;
    ret = add(ret, f(i-1, new_idx+add_first, tot-rem+add_first+add_last));
  }

  //TRACE(i _ idx _ tot _ ret);
  return dp[i][idx][tot] = ret;
}

int main(void) {
  memset(dp, -1, sizeof(dp));
  scanf("%d",&n);
  REP(i, 2*n-1) scanf("%d",&a[i]);
  sort(a, a + (2*n-1));

  printf("%d\n",f(n-1,1,1));
  
  return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
int l[100];
int max=0,sum=0;
for(int j=0;j<n;j++){
	scanf("%d",&l[j]);
if (max<l[j])max=l[j];
sum+=l[j];
}

sum-=max;

if(max<sum) printf("Yes");
else printf("No");

return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int n;cin >>n;
    int c=n;
    int sum=0;
    while(c>0){
        sum+=c%10;
        c/=10;
    }
    if(n%sum==0)puts("Yes");
    else puts("No");
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);
    vector< char[12] > s(N);
    vector< int > a(N);
    // 0:X 1:-A 2:B-

    int ans[4] = {};
    Rep(i,N){
        Scs(s[i]);
        int n = strlen(s[i]);
        Rep(j,n){
            if( s[i][j] == 'A' )
                a[i] = 1;
            else if( s[i][j] == 'B' && a[i] == 1 )
                ans[0]++, a[i] = 0;
            else
                a[i] = 0;
        }
        if( s[i][0] == 'B' ) a[i] += 2;
        if( a[i] ) ans[a[i]]++;
    }
    if( max(ans[1],ans[2]) == 0 && ans[3] ) ans[3]--;
    ans[0] += ans[3];

    printf ("%d\n", ans[0] + min(ans[1],ans[2]));


    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i, n) FOR(i,0,n)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

int N;
int T[100000];
int A[100000];
typedef pair<bool,int> mount;
mount res_t[100000];
mount res_a[100000];

void solve(){
    int max_t = -1;
    int max_a = -1;
    REP(i,N){
        if(max_t < T[i]) {
            res_t[i] = make_pair(true,T[i]);
            max_t = T[i];
        } else {
            res_t[i] = make_pair(false,T[i]);
        }
    }
    for(int i = N-1; i>=0;i--){
        if(max_a < A[i]){
            res_a[i] = make_pair(true,A[i]);
            max_a = A[i];
        } else {
            res_a[i] = make_pair(false,A[i]);
        }
    }
    ll res = 1;
    REP(i,N){
        mount a = res_a[i];
        mount t = res_t[i];
        if((a.first==true)&&(t.first==true)){
            if(a.second != t.second){
                cout << 0 << "\n";
                return;
            }
        } else if ((a.first==true)&&(t.first==false)){
            if(a.second > t.second) {
                cout << 0 << "\n";
                return;
            }
        } else if((a.first==false)&&(t.first==true)){
            if(a.second < t.second) {
                cout << 0 << "\n";
                return;
            }
        } else {
            ll m = min(a.second,t.second);
            res = (res*m)%MOD;
        }
    }
    cout << res << "\n";
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i,N){
        cin >> T[i];
    }
    REP(i,N){
        cin >> A[i];
    }
    solve();
    return 0;
}

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

int main() {
  string a;
  int n = 0, i;
  
  cin >> a;
  
  for (i = 0; i+1 < a.length(); i++){
    if (a[i] == a[i+1]){
      n++;
    }else n = 0;
    
    if (n >= 2){
      puts("Yes");
      exit(0);
    }
  }
  
  puts("No");
  exit(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    string s;
    cin >> s;
    if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]){
        cout << "Yes" << endl;
    }
    else if(s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]){
        cout << "Yes" << endl;
    }
    else if(s[0]==s[3] && s[1]==s[2] && s[0]!=s[1]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main()
{
  int n;
  vector<int> l;

  cin >> n;
  for (int i = 0; i < n * 2; i++) {
    int tmp; cin >> tmp;
    l.push_back(tmp);
  }

  int result = 0;
  sort(l.begin(), l.end());
  
  for (int i = 0; i < n; i++) {
    result += l[i*2];
  }

  cout << result << endl;
}


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

int main() {
	int n, k;
	int sunuke[102] = {0};
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int a;
			cin >> a;
			sunuke[a-1] = 1;
		}
	}
	int sum = 0;
	for (int i = 0; i < n; i++) if (sunuke[i] == 0) sum++;
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	string s;
	cin>>s;
	s[3]='8';
	cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const ll maxn=200010;
vl g[maxn];
ll ans[maxn],num[maxn];
vector<ll> dp;
void dfs(vl& dp,ll v,ll par=-1){
    ll p=num[v],pre;
    auto it=lower_bound(all(dp),p);
    pre=*it;
    *it=p;
    ll len=lower_bound(all(dp),inf)-dp.begin();
    ans[v]=len;
    for(auto nv:g[v]){
        if(nv==par)continue;
        dfs(dp,nv,v);
    }
    *it=pre;
    return;
}
int main(){
    ll n;cin >> n;
    rep(i,n)cin >> num[i];
    rep(i,n-1){
        ll a,b;cin >> a >>b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    dp.resize(n,inf);
    dfs(dp,0);
    rep(i,n)cout << ans[i] <<endl;
}   

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

int main() {
  int n, m;
  cin >> n >> m;
  int ans = (n-1) * (m-1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3680
import itertools
def warshall_floyd():
    for k in range(1, N+1):
        for i in range(1, N+1):
            for j in range(1, N+1):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
d = [[float('inf') if i != j else 0 for j in range(N+1)]for i in range(N+1)]
# print(d)
for m in range(M):
    A, B, C = map(int, input().split())
    d[A][B] = C
    d[B][A] = C
warshall_floyd()
ans = float('inf')
for p in itertools.permutations(r):
    tmp = 0
    for i in range(len(p)-1):
        tmp += d[p[i]][p[i+1]]
    ans = min(tmp, ans)
print(ans)

Measured memory_bytes: 76712
# Aizu Problem 0220: Binary Digit A Doctor Loved

import sys, math, os, struct

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")



while True:
    n = float(input())
    if n < 0:
        break
    pre = int(n)
    post = n - int(n)
    res = bin(pre)[2:].zfill(8) + '.'
    for k in range(4):
        post *= 2
        res += str(int(post))
        post -= int(post)
    if pre > 255 or post > 0:
        print("NA")
    else:
        print(res)
    #m = int(n * 16)
    #if n == m / 16. and m < 4096:
    #    res = ""
    #    for k in range(12):
    #        res += str(m % 2)
    #        m //= 2
    #        if k == 7:
    #            res += '.'
    #    print(res)
    #else:
    #    print("NA")

Measured memory_bytes: 7504
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
const int MOD = 1000000007;

const int MAX = 10000000;
int least_prime_factor[MAX + 1];
void osa_k_init(int num = MAX) {
  memset(least_prime_factor, -1, sizeof(least_prime_factor));
  least_prime_factor[0] = 0;
  least_prime_factor[1] = 1;
  FOR(i, 2, num + 1) if (least_prime_factor[i] == -1) {
    least_prime_factor[i] = i;
    for (int j = i * i; j <= num; j += i) {
      if (least_prime_factor[j] == -1) least_prime_factor[j] = i;
    }
  }
}

vector<pair<int, int> > osa_k(int num) {
  vector<pair<int, int> > res;
  while (num > 1) {
    int prime = least_prime_factor[num], exponent = 0;
    while (least_prime_factor[num] == prime) {
      ++exponent;
      num /= prime;
    }
    res.emplace_back(prime, exponent);
  }
  return res;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  osa_k_init(n);
  map<int, int> mp;
  FOR(i, 2, n + 1) {
    auto tmp = osa_k(i);
    for (auto a : tmp) mp[a.first] += a.second;
  }
  long long ans = 1;
  FOR(i, 2, n + 1) if (mp[i] > 0) (ans *= (mp[i] + 1)) %= MOD;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 39424
#include<stdio.h>
#include<algorithm>
using namespace std;

int NUM[111111]={0};

int main(){
  int n,x,cnt=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&x);
    NUM[x]++;
  }
  
  for(int i=1;i<=111111;i++){
    cnt=max(cnt,NUM[i-1]+NUM[i]+NUM[i+1]);
  }
  printf("%d\n",cnt);
  return 0;
}


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

using namespace std;

int main(){
	char c1,c2;
	for(int i=0;i<6;i++){
		char ch;
		cin>>ch;
		if(i==2){
			c1=ch;
		}
		else if(i==3){
			if(c1!=ch){
				puts("No");
				return 0;
			}
		}
		else if(i==4){
			c2=ch;
		}
		else if(i==5){
			if(c2!=ch){
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

LL pot3[40];

LL in_seg(LL a, LL b, LL c)
  {
  return a <= b && b <= c;
  }

void solve()
  {
  LL x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  x1--;
  y1--;
  x2--;
  y2--;

  if(x1 > x2)swap(x1, x2);
  if(y1 > y2)swap(y1, y2); // TODO

  LL basic_res = x2 - x1 + y2 - y1;

  LL all_res = basic_res;


  FORD(i, 31, 1)
    {
    LL pott = pot3[i];
    LL seg_poc = pot3[i-1];
    LL seg_kon = pot3[i-1]*2-1;


    REP(pomm, 2)
      {
      swap(x1, y1);
      swap(x2, y2);

      bool is_x_inside = 0;
      LL poc_x, kon_x;
      if(x1 / pott == x2 / pott && in_seg(seg_poc, x1 % pott, seg_kon) && in_seg(seg_poc, x2 % pott, seg_kon))
        {
        is_x_inside = 1;
        poc_x = (x1 / pott) * pott + seg_poc;
        kon_x = (x1 / pott) * pott + seg_kon;
        }
      else continue;

      LL poc_y, kon_y;
      if(y1 % pott < seg_poc)poc_y = (y1 / pott) * pott + seg_poc;
      else poc_y = (y1 / pott + 1) * pott + seg_poc;
      kon_y = poc_y + pot3[i-1]-1;

      debug(i, is_x_inside, I(y1), I(poc_y), I(y2), I(kon_y), I(poc_x), I(kon_x));
      if(is_x_inside && y1 < poc_y && kon_y < y2)
        {
        LL add_left = (x1 - poc_x + 1) + (x2 - poc_x + 1) - (x2 - x1);
        LL add_right = (kon_x - x1 + 1) + (kon_x - x2 + 1) - (x2 - x1);

        maxi(all_res, basic_res + min(add_left, add_right));

        debug(basic_res + min(add_left, add_right), add_left, add_right);
//        printf("%lld\n", all_res);
//        return;
        }


      }

    }

  cout << all_res << endl;
  }

int main()
  {
  pot3[0] = 1;
  FOR(i, 1, 39)pot3[i] = pot3[i-1] * 3;


  int z;
  cin >> z;
  while(z--)solve();
  }

Measured memory_bytes: 384
#include<bits/stdc++.h>
 
using namespace std;
 
#define D(x) cout << (#x) << " is " << x << endl;
#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;

#define N 200005

lli bit[N], mod = 998244353;

void update(int ind, lli val){
	ind++;
	while(ind < N){
		bit[ind] = (bit[ind]+val)%mod;
		ind += (ind)&(-ind);
	}
}

lli getsum(int ind){
	lli sum = 0;
	ind++;
	while(ind > 0){
		sum = (sum+bit[ind])%mod;
		ind -= (ind)&(-ind);
	}
	return sum;
}
 
int main()
{
    int n, k;
    cin >> n >> k;
    vector<pi> pairs(k);
    for(auto &el: pairs) cin >> el.first >> el.second;
    
    sort(pairs.begin(), pairs.end());
    update(1, 1);
	for(int i=1; i<=n; i++){
		//D(i)
		lli sm = 0;
		for(auto el: pairs){
			int r = max(i-el.second, 0);
			int l = max(i-el.first, 0);
			//D(r)D(l)
			sm += getsum(l);
			sm = (sm - getsum(r-1)+mod+mod)%mod;
		}
		//D(sm)
		update(i, sm);
	}
	lli ans = getsum(n);
	ans = (ans-getsum(n-1)+mod+mod)%mod;
	cout << ans << endl;
 
    return 0;
}


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

int main()
{
    long long x,k,d,i,j,p,s,q;

    cin>>x>>k>>d;

    if(x>=0)
    {
        p=x/d;
        if(p<=k) x=x-p*d,k=k-p;
        else x=x-k*d,k=0;
    }
    else
    {
        p=x/d;
        p=abs(p);
        if(p<=k) x=x+p*d,k=k-p;
        else x=x+k*d,k=0;
    }
    k=k%2;
    while(k--)
    {
        p=x+d; p=abs(p);
        q=x-d; q=abs(q);

        if(p<=q) x=x+d;
        else x=x-d;
    }
    x=abs(x);
    cout<<x<<endl;
}


Measured memory_bytes: 3620
import sys, math

sys.setrecursionlimit(10 ** 9)
from collections import defaultdict

IA = lambda: map(int, input().split())
IAS = lambda: map(str, input().split())

sum=0
for i in range(10):
    sum+=1
n = int(input())
print("{:.12f}".format(pow(n, 3) / 27.0))






Measured memory_bytes: 3316
// ~/Remember,remember the 6th of March

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-8;
const ll MOD = 1000000007;
const int N = 100000 + 7;

int main()
{
    ll x;
    cin>>x;
    ll ans=0;
    ans =(x/(500*1LL)) * (1000*1LL);
    x-=(x/500LL)*500LL;
    ans+=(x/5LL)*5LL;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using std::cout;
using std::endl;
using std::cin;


void output(int h, int w) {
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << "#";  
        }
        cout << endl;
    }
    cout << endl;
    return;
}

int main(void) {
    int h;
    int w;

    cin >> h >> w;

    while (h != 0 && w != 0) {
        output(h, w);
        cin >> h >> w;
    }

    return 0;
}

Measured memory_bytes: 3112
import sys
from io import StringIO
import unittest


def resolve():
    # s = input()
    n = int(input())
    # a, b = map(int, input().split())
    # l = [list(map(int, input().split())) for _ in range(n)]

    if (n % 1000) == 0:
        print(0)
    else:
        print((n % 1000 - 1000) * -1)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1900"""
        output = """100"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3000"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

void solvec(){
    ll x,k,d;
    cin>>x>>k>>d;



        x=abs(x);
        ll minvalpositive = x % d;
        ll minvalnegative = minvalpositive - d;
        ll toreach = x - minvalpositive;

        ll movestoreach = toreach / d;
    if(movestoreach>k){
        cout<<x-k*d;
        return;
    }
        if ((k - movestoreach) % 2 == 0) {
            cout << minvalpositive;
        } else {
            cout << abs(minvalnegative);
        }

}
void solved(){
    ll n,k;
    cin>>n>>k;
    ll p[n];
    ll c[n];
    for(ll i=0;i<n;i++){
        cin>>p[i];
    }
    for(ll i=0;i<n;i++){
        cin>>c[i];
    }
    ll costs[n];
    for(int i=0;i<n;i++){
        ll current=i+1;
        ll cost=0;
        ll maxcost=0;
        for(ll j=0;j<k;j++){
            cost+=c[current-1];
            current=p[current-1];
            if(cost>maxcost)maxcost=cost;
        }
        costs[i]=maxcost;
    }
    ll maximum=0;
    for(int i=0;i<n;i++){
        maximum=max(maximum,costs[i]);
    }
    cout<<maximum;
}
void solvee(){

}
void solvef(){

}
int main()
{
    ll t=1;
    //cin>>t;
    while(t--){
        solvec();
    }
}


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

int main(){
  int X,N;
  cin >> X >> N;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin >> P.at(i);
  }
  int i=0;
  while(true){
    int A=X-i,B=X+i;
    bool a=true,b=true;
    for(int i=0;i<N;i++){
      if(A==P.at(i)){
        a=false;
      }
    }
    if(a){
      cout << A << endl;
      return 0;
    }
    for(int i=0;i<N;i++){
      if(B==P.at(i)){
        b=false;
      }
    }
    if(b){
      cout << B << endl;
      return 0;
    }
    i++;
  }
}

Measured memory_bytes: 3612
def main():
    y, m, d = map(int, input().split("/"))
    if y < 2019 or y == 2019 and m < 4 or y == 2019 and m == 4 and d < 31:
        print("Heisei")
    else:
        print("TBD")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 6/16/2018 ABC100
 
 21:00-21:10 ACC
 
 Editorials:
  - https://img.atcoder.jp/abc100/editorial.pdf
  - https://youtu.be/gyJh6k9vOXs?t=685
 
 Summary:
  - I simulated without further analysis though, res = A<=8&&B<=8
 
 */

// $ g++ -std=c++11 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
int A,B;
const string yes="Yay!",no=":(";
int X[16];
void solve_org() {
  MINUS(X);
  if(A<B) swap(A,B);
  X[0]=0,--A;
  FOR(i,1,16) {
    if(X[i-1]==0&&B>0) X[i]=1,--B;
    else if(X[i-1]==1&&A>0) X[i]=0,--A;
    else if(X[i-1]==-1&&A>0) X[i]=0,--A;
    else if(X[i-1]==-1&&B>0) X[i]=1,--B;
  }
  dump2(A,B);
  dumpAR(X);
  if(A>0||B>0) cout<<no<<endl;
  else if(X[15]==X[0]) cout<<no<<endl;
  else cout<<yes<<endl;
}

void solve() {
  cout<<(A<=8&&B<=8?yes:no)<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>A>>B;
  solve();
  return 0;
}


Measured memory_bytes: 888
<?php
list($n,$m)=explode(" ",trim(fgets(STDIN)));
$q=array_fill(1,$n,0);
$ans=$q;
$ac=0;
$pena=0;
$i=0;
while($i<$m){
  list($p,$s)=explode(" ",trim(fgets(STDIN)));
  if($s=="AC"){
    if($ans[$p]==0){
      ++$ac;
      $pena+=$q[$p];
      $ans[$p]=1;
    }
  }else{
    ++$q[$p];
  }
  ++$i;
}
echo $ac ." ".$pena;

Measured memory_bytes: 12792
#include <iostream>
#include <vector>

using namespace std;

int main(){
    long long n, k;
    cin >> n >> k;

    long long d = n / k;
    long long e = n % k;
    vector <long long> a(k);
    for (long long i = 0; i < k; i++){
        a[i] = d;
    }
    if (e != 0){
        for (long long i = 1; i < e + 1; i++){
            a[i] ++;
        }
    }

    long long ans;
    if(a[0] == 1){
        ans = a[0];
    }else if(a[0] == 2){
        ans = a[0] + a[0] * (a[0] - 1) * 3;
    }else{
        ans = a[0] * a[0] * a[0];
    }
    
    if (k % 2 == 0){
        if(a[k/2] == 1){
            ans += a[k/2];
        }else if(a[k/2] == 2){
            ans += a[k/2] + a[k/2] * (a[k/2] - 1) * 3;
        }else if(a[k/2] >= 3){
            ans += a[k/2] * a[k/2] * a[k/2];
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

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

public class Main {
    static int[] dp, a;
    static int m, L;
    public static void main(String[] args)throws IOException {
        Scanner sc = new Scanner(System.in);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int cnt = 0;
        for(char c:s) cnt += c=='R'?1:0;
        String ans = cnt>(n-cnt)?"Yes":"No";
        System.out.println(ans);
    }
}

Measured memory_bytes: 21460
n = int(input())
arr = sorted(list(map(int, input().split())))

m = arr[0]
M = arr[-1]
S = []
for a in arr[1:-1]:
  if a > 0:
    S.append(str(m) + ' ' + str(a))
    m -= a
  else:
    S.append(str(M) + ' ' + str(a))
    M -= a
S.append(str(M) + ' ' + str(m))
print(M-m)
[print(s) for s in S]



Measured memory_bytes: 18584
#include <bits/stdc++.h>
#define Pb push_back
typedef long long ll;
typedef double db;
using namespace std;
const int MAXN = 1e2 + 7;
inline int R() { int rt; scanf ( "%d", &rt ); return rt; }

int dp[MAXN][MAXN][MAXN];
int Dfs ( int a, int b, int c )
{
	if ( a > 100 || b > 100 || c > 100 ) return 1e5;
	if ( dp[a][b][c] != -1 ) return dp[a][b][c];
	int nans = 2e9;
	nans = min ( nans, Dfs ( a + 1, b + 1, c ) + 1 );
	nans = min ( nans, Dfs ( a + 1, b, c + 1 ) + 1 );
	nans = min ( nans, Dfs ( a, b + 1, c + 1 ) + 1 );
	nans = min ( nans, Dfs ( a + 2, b, c ) + 1 );
	nans = min ( nans, Dfs ( a, b + 2, c ) + 1 );
	nans = min ( nans, Dfs ( a, b, c + 2 ) + 1 );
	return dp[a][b][c] = nans;
}

int main()
{
	//freopen ( "test.in", "r", stdin );
	memset ( dp, -1, sizeof dp );
	for ( int i = 0; i <= 100; ++i ) dp[i][i][i] = 0;
	printf ( "%d\n", Dfs ( R(), R(), R() ) );
	return 0;
}

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

using namespace std;

struct a{
   int value;
   int cost;
};


bool cmp(struct a a1,struct a a2)
{
    float x = (a1.value-a1.cost),y = (a2.value-a2.cost);
    return (x>y);
}

int main(){
    int n;
    cin>>n;
    struct a v[n];
    for (int i=0;i<n;i++)
    {
        cin>>v[i].value;
    }
    for (int i=0;i<n;i++)
    {
        cin>>v[i].cost;
    }
    sort (v,v+n,cmp);
    int x=0,y=0,max=0;
    for (int i=0;i<n;i++)
    {
        x+= v[i].value;
        y+= v[i].cost;
        if ((x-y)>max)
        {
            max = x-y;
        }
        else
        {
            break;
        }
    }
    cout<<max<<endl;
    
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,M = map(int, readline().split())
    A = [int(i) for i in readline().split()]

    total = sum(A)
    std = total / (4*M)

    c = 0
    for a in A:
        if a >= std:
            c += 1
    
    print("Yes" if c >= M else "No")


if __name__ == "__main__":
    main()


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

vector<vector<int>> edge;
vector<pair<int,int>> elist;
vector<int> ecolr;
vector<bool> checked;
int k;

void dfs(int i, int c=0){
  int m = 1;
  checked.at(i) = true;
  for (int ind : edge.at(i)){
    int p = elist.at(ind).first, q = elist.at(ind).second;
    int j = (p == i ? q : p);
    if (checked.at(j)) continue;
    if (m == c) m++;
    ecolr.at(ind) = m;
    dfs(j, m);
    k = max(k, m);
    m++;
  }
}

int main(){
  int n; cin >> n;
  edge.resize(n);
  for (int i = 0; i < n-1; i++){
    int a, b; cin >> a >> b; a--; b--;
    elist.push_back(make_pair(a,b));
    edge.at(a).push_back(i); edge.at(b).push_back(i);
  }
  checked.resize(n); ecolr.resize(n-1);
  dfs(0);
  cout << k << endl;
  for (int i = 0; i < n-1; i++){
    cout << ecolr.at(i) << endl;
  }
  return 0;
}

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

using namespace std;

int main(void){

  int x,y;

  while( cin >> x >> y , x || y ){

    int count = 0;
    while(y){
      if( x < y ) swap( x, y );
      int s = x % y;   
      x = y;
      y = s;
      count++;
    }
    cout << x << " " << count << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
n = int(input())
l = list(map(int,input().split()))

def ans(x,L):
    ans = 1
    flag = 0
    tmp = L[0:2]
    if tmp[0] < tmp[1]:
        flag  = 1
    elif tmp[0] > tmp[1]:
        flag = -1
    for i in range(2,n):
        tmp.append(L[i])
        if len(tmp) == 1:
            pass
        elif (flag == -1 and tmp[-2] < tmp[-1]) or (flag == 1 and tmp[-2] > tmp[-1]):
            ans += 1
            flag = 0
            tmp = [tmp[-1]]
        elif flag == 0 and tmp[-2] < tmp[-1]:
            flag = 1
        elif flag == 0 and tmp[-2] > tmp[-1]:
            flag = -1
    return(ans)
if n <= 2:
    print(1)
else:
    print(ans(n,l))
            
            
            

Measured memory_bytes: 14480
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

            int n = Integer.parseInt(br.readLine());
            String[] in = br.readLine().split(" ");
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = Long.parseLong(in[i]);
            }

            br.close();

            Arrays.sort(a);

            BigInteger ans = BigInteger.valueOf(1);
            for (long i : a) {
                ans = ans.multiply(BigInteger.valueOf(i));
                if (ans.compareTo(BigInteger.valueOf((long) 1e18)) == 1) {
                    System.out.println(-1);
                    return;
                }
            }

            System.out.println(ans);

        }
    }
}

Measured memory_bytes: 53244
#include <stdio.h>
#include <math.h>

int main() {
	double a, b, c, d, e, f;
	double det;
	double x, y;
	while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
		det = a * e - b * d;
		if (det != 0) {
			x = (e * c - b * f) / det;
			y = (a * f - d * c) / det;
			// ?????????-0???????????´??????0?????´???????????¨?????????????????§??´???
			x = (x == fabs(x)) ? fabs(x) : x;
			y = (y == fabs(y)) ? fabs(y) : y;
			// abs/labs/fabs http://homepage1.nifty.com/MADIA/vc/C/c_lang_ansi1.htm
			printf("%.3f %.3f\n", x, y);
		}
	}

	return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <functional>
#include <list>
#include <iomanip>
#include <cctype>
#include <math.h>
#include <utility>
#include <numeric>

#define REP(i,first,end) for(int i = first; i < end; i++)
#define rep(i,end) for(int i = 0; i < end; i++)

typedef long long ll;
#define mod =1000000007;

using namespace std;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int n,m,c;
    cin >> n >> m >> c;
    
    vector<int> b(m);
    rep(i,m){
        cin >> b[i];
    }
    
    vector<vector<int>> a(n, vector<int>(m));
    
    
    rep(i,n){
        rep(j,m){
            cin >> a.at(i).at(j);

        }
    }
    

    int count = 0;
    rep(i,n){
        int tmp = 0;
        rep(j,m){
            tmp += b[j] * a[i][j];
        }
        tmp += c;
        
        if (tmp > 0){
            count += 1;
        }
        
    }
    
    cout << count << endl;
    
}
    




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };



int main() {
    int N;
    cin >> N;
    vi b(N);
    rep(i,N){
        cin >> b[i];
        b[i]--;
    }
    
    vi ans;
    rep(i,N){
        int selected = -1;
        for (int j = b.size()-1; j >=0; j--)
        {
            if(b[j] == j){
                 selected=j;
                 break;
            }
        }

        if(selected == -1){
            cout << -1 << endl;
            return 0;
        }
        ans.push_back(selected+1);
        b.erase(b.begin()+selected);      
    }

    reverse(ans.begin(),ans.end());

    for(auto r:ans){
        fin(r);
    }
    
}
    



Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 8192

int dp[NUM+1];


void dfs(int current,int array[15],int depth){

	if(depth == 13)return;

	for(int i = 0; i <= depth; i++){
		if(current+array[i] > NUM)continue;

		if(dp[current+array[i]] >= depth+1){
			dp[current+array[i]] = depth+1;
			int next_array[15];
			for(int k = 0; k <= depth; k++)next_array[k] = array[k];
			next_array[depth+1] = current+array[i];
			dfs(current+array[i],next_array,depth+1);
		}
	}

	for(int i = 0; i <= depth; i++){
		if(current-array[i] <= 0)continue;

		if(dp[current-array[i]] >= depth+1){
			dp[current-array[i]] = depth+1;
			int next_array[15];
			for(int k = 0; k <= depth; k++)next_array[k] = array[k];
			next_array[depth+1] = current-array[i];
			dfs(current-array[i],next_array,depth+1);
		}
	}
}


int main(){

	dp[0] = 0;
	dp[1] = 0;
	for(int i = 2; i <= NUM; i++)dp[i] = BIG_NUM;

	int first_array[15];
	first_array[0] = 1;

	dfs(1,first_array,0);

	int N;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		printf("%d\n",dp[N]);
	}

	return 0;
}



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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

int main() {
    lli n;
    cin1(n);
    lli h[n];
    ncin1(n, h);

    if (n == 1) {
        cout << "Yes" << endl;
        return 0;
    }
    else if (n == 2) {
        if (h[0] - h[1] >= 2) {
            cout << "No" << endl;
        }
        else
            cout << "Yes" << endl;
        return 0;
    }
    REPE(i, 1, n-2) {
        lli prev = h[i-1];
        lli cur = h[i];
        lli next = h[i+1];
        if (prev < cur) {
            h[i] -= 1;
            cur -= 1;
        }
        if (cur  > next) {
            //cout1(i);
            //cout1(prev);
            //cout1(cur);
            //cout1(next);
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int n,m;
    cin >> n >> m;
    int A[m];
    REP(i,m) cin >> A[i];

    int check[n] = {};
    REP(i,m) check[A[i]] = 1;

    int q[n+1] = {};
    q[0] = 1;
    if(check[1] == 0) q[1] = 1;

    FOR(i,2,n + 1){
        if(check[i] == 1) continue;
        q[i] = q[i-1] + q[i-2];
        q[i] %= MOD;

    }
    cout << q[n] << endl;

}


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

int main () {
 int n,k;
 cin>>n>>k;
 double sum=0;
 for(double i=1;i<=n;i++){
   int cnt=0;
   for(int j=i;j<k;){ j*=2; cnt++; }
   sum+=1.0/n*pow(1.0/2.0,cnt);
 }
 cout<<fixed<<setprecision(12)<<sum;
}


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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;
constexpr int base = 1e9 + 7;

int in[N];
LL fact[N], ifact[N];

LL power(LL a, int b) {
    LL rv = 1;
    while (b) {
        if (b & 1) rv = rv * a % base;
        a = a * a % base;
        b /= 2;
    }
    return rv;
}

LL nCk(int n, int r) {
    LL rv = fact[n];
    (rv *= ifact[r]) %= base;
    (rv *= ifact[n - r]) %= base;
    return rv;
}

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

    fact[0] = 1;
    for (int i = 1; i < N; i++) fact[i] = fact[i - 1] * i % base;

    ifact[N - 1] = power(fact[N - 1], base - 2);
    for (int i = N - 2; i >= 0; i--) ifact[i] = ifact[i + 1] * (i + 1) % base;

    int n, k;
    cin >> n >> k;

    for (int i = 0; i < n; i++) cin >> in[i];
    sort (in, in + n);
    
    LL result = 0;
    for (int i = k - 1; i < n; i++) {
        result += in[i] * nCk(i, k - 1) % base;
        result %= base;
    }

    for (int i = n - k; i >= 0; i--) {
        result -= in[i] * nCk(n - i - 1, k - 1) % base;
        result %= base;
        if (result < 0) result += base;
    }

    cout << result << endl;
}

Measured memory_bytes: 2176
n = int(input())
s = input()
lis_r = []
lis_b = []
for i in range(n):
  if s[i] == "R":
    lis_r.append(s[i])
  else:
    lis_b.append(s[i])

if len(lis_r) > len(lis_b):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
  int n, num1, num2, sum1 = 0, sum2 = 0;
  scanf("%d %d %d", &n, &num1, &num2);

  for (int i = 1; i <= n; i++)
  {
    sum2 = 0;
    if (i > 9)
    {
      int temp = i;
      while (temp > 0)
      {
        sum2 += temp % 10;
        temp /= 10;
      }
      if (sum2 >= num1 && sum2 <= num2)
      {
        sum1 += i;
      }
    }
    else
    {
      if (i >= num1 && i <= num2)
      {
        sum1 += i;
      }
    }
  }
  printf("%d\n", sum1);
  return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    int a[100010];
    bool flg = true;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 2 == 0) {
            if (a[i] % 5 != 0) {
                if (a[i] % 3 != 0) {
                    flg = false;
                    cout << "DENIED" << endl;
                    return (0);
                }
            }
        }
    }

    cout << "APPROVED" << endl;

}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main() {

	int a, b, c;
	cin >> a >> b >> c;
	a -= b;
	c -= a;
	cout << max(0, c) << endl;
	
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.System.*;
import static java.lang.Math.*;

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

    int[][] dp = new int[h][w];
    int[][] map = new int[h][w];
    int max = 0;

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        map[i][j] = sc.nextInt();
        if(map[i][j] == 1){
          dp[i][j] = 0;
        }else{
          dp[i][j] = 1;
          max |= dp[i][j];
        }
      }
    }

    for (int i = 1; i < h; i++) {
      for (int j = 1; j < w; j++) {
        if(map[i][j] == 1){
          dp[i][j] = 0;
        }else{
          dp[i][j] = min(dp[i-1][j], min(dp[i-1][j-1], dp[i][j-1])) + 1;
          max = max(max, dp[i][j]);
        }
      }
    }
    out.println(max*max);
	}
}


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

int n, m, s, k, c;

int main() {
  while(cin>>n>>m){
    if(n==0) return 0;
    int ma[10010]={}, mi[10010]={};

    rep(i, m){
      cin>>s>>k;
      rep(j,k){
        cin>>c; c--;
        ma[c]+=s;
        if(k==1) mi[c]+=s;
      }
    }
    int ans = 0;
    rep(i, n)rep(j, n){
      if(i!=j) ans=max(ans, ma[i]-mi[j]+1);
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main() {
    int N; cin>>N;
    vector<int> cnt(1010,0);
    int L;
    for (int i = 0; i < N; ++i) {
        cin>>L;
        cnt[L]++;
    }
    vector<int> ruiseki(1010,0);
    for (int i = 0; i < 1005; ++i) {
        ruiseki[i+1]=ruiseki[i]+cnt[i];
    }
    ll ans=0ll;
    for (int i = 1; i <=1000; ++i) {

        ans+=max(0ll,(ll)cnt[i]*(cnt[i]-1)*(cnt[i]-2)/6); //正三角形
        if(cnt[i]>=2){
            ans+=max(0ll,(ll)cnt[i]*(cnt[i]-1)*(ruiseki[min(1005,2*i)]-ruiseki[i+1])/2);
        }
        for (int j = i+1; j <=1000; ++j) {
            ans+=max(0,cnt[j]*(cnt[j]-1)/2)*cnt[i];
            ll tmp=ruiseki[min(1005,i+j)]-ruiseki[j+1];
            ans+=tmp*cnt[i]*cnt[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	if (t >= 30) {
		cout << "Yes";
	} else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3636