akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define MP make_pair
#define FF first
#define SS second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pie;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const ll LINF = 4e18;
const ll delta = 10289;

const int N = 1e5 + 20;
int n, m, deg[N];

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0, v, u; i < m; i++) {
		cin >> v >> u;
		deg[v]++, deg[u]++;
	}
	for (int i = 1; i <= n; i++)
		if (deg[i] % 2)
			return cout << "NO" << endl, 0;
	cout << "YES" << endl;
}



Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int main() {
 
  int64_t d,t,s;
  cin>>d>>t>>s;
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){
  //   for(int j=0; j<M; j++){
  //       cin>>A[i][j];
  //   }
  // }
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  if(d>s*t)cout << "No" << endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <time.h> //for clock
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
using ll = long long;

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

    cout << min(b/a, c) << endl;
}

Measured memory_bytes: 256
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

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

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;
mii mp, mp1;

void solve()
{
     int i, j = 0;
     cin >> n >> k;
     for (i = 1; i <= n; i++)
     {
          cin >> a[i];
          a[i] += a[i - 1];
          a[i] %= k;
     }

     // print2(a, 0, n + 1);

     int ans = 0;
     mp[0]++;
     for (i = 1; i <= n; i++)
     {
          int d = (i - a[i] + k) % k;
          if (i >= k)
          {
               mp[(j - a[j] + k) % k]--;
               j++;
          }
          if (mp.count(d))
               ans += mp[d];
          mp[d]++;
          // bug(ans);
     }

     cout << ans;

}

int32_t main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   int h, w;
   cin >> h >> w;
   int cnt = 0;
   rep (i, h) {
      rep (j, w) {
         char c;
         cin >> c;
         if (c == '#') cnt++;
      }
   }

   if (cnt > h+w-1) {
      puts("Impossible");
   } else {
      puts("Possible");
   }

   return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{

     public static void main(String []args) throws Exception {
        BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
        String s = inp.readLine().trim();
        int len = s.length();
        if(len==0 || len>6){
            System.out.println("No");
        }else{
            if(s.charAt(2) == s.charAt(3)  && s.charAt(4)==s.charAt(5)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
        
        
     }
}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)

int main() {
#ifdef _WIN32
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0); // cin??¨cout?????£????????????
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	while (true) {
		ll n; cin >> n;
		if (n == 0) break;
		vector<pair<ll, ll>> rw(n);
		REP(i, n) cin >> rw[i].first >> rw[i].second;
		sort(ALL(rw)); reverse(ALL(rw));
		ll sum = 0; FOR(i, 1, n) sum += rw[i].first;
		if (rw[0].first <= sum) {
			ll sum2 = 0; REP(i, n) sum2 += rw[i].second;
			cout << sum + rw[0].first + sum2 << endl;
		} else {
			ll rest = rw[0].first - sum;

			vvb dp(n+1, vb(rest + 1, false)); dp[0][0] = true;
			FOR(i, 1, n) REP(j, rest + 1) {
				if (j + rw[i].second < rest + 1) {
					dp[i][j + rw[i].second] = dp[i][j + rw[i].second] | dp[i - 1][j];
				}
				dp[i][j] = dp[i][j] | dp[i - 1][j];
			}
			for (ll i = rest; i >= 0; --i) if (dp[n-1][i]) {
				ll sum2 = 0; REP(i, n) sum2 += rw[i].second;
				cout << sum + rw[0].first + sum2 + (rest - i) << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3236
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int a,b,ans=0;
  cin>>a>>b;
  if(a>=b){
    ans+=a;
    a--;
  }else{
    ans+=b;
    b--;
  }
  if(a>=b){
    ans+=a;
    a--;
  }else{
    ans+=b;
    b--;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
program main
implicit None
	character(len = 100000)::s
	integer(8)::n,q,i
	integer(8),allocatable::l(:),r(:),a(:)
	
	read*,n,q
	read*,s
	
	allocate(l(q),r(q),a(n))
	
	a =0
	do i = 2,n
		if(s(i:i) == "C")then
			if(s(i-1:i-1) == "A")then
				a(i) = 1
			endif
		endif
	enddo
	
	do i = 2,n
		a(i) = a(i-1)+a(i)
	enddo
	
	do i = 1,q
		read*,l(i),r(i)
	enddo
	
	do i = 1,q
		print"(i0)",a(r(i))-a(l(i))
	enddo
end program main

Measured memory_bytes: 3492
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n, k;
int x[100000];
vector<int> po, ne;

int main() {
    cin >> n >> k;
    rep(i,n) cin >> x[i];
    rep(i,n) {
        if (x[i] >= 0) po.push_back(x[i]);
        else ne.push_back(x[i]);
    }
    sort(ne.begin(), ne.end(), greater<int>());
    int ans = MOD;
    rep(i,po.size()) {
        int j = k-i-2;
        if (j < -1) continue;
        if (j >= (int)ne.size()) continue;
        if (j == -1) {
            ans = min(ans,po[i]);
        } else {
            int tmp = po[i];
            tmp += -1*ne[j];
            if (po[i] > -1*ne[j]) tmp += -1*ne[j];
            else tmp += po[i];
            ans = min(ans,tmp);
        }
    }
    if (ne.size() >= k) {
        ans = min(ans,-1*ne[k-1]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 1404
N = int(input())
c = (N+1)*[0]

for i in range(2,N+1):
  j = 2
  while j*j<=i:
    while i%j==0:
      c[j]+=1
      i//=j
    j+=1
  if 1<i:
    c[i]+=1

f = lambda x:sum(y+1>=x for y in c)
print(f(75)+f(25)*(f(3)-1)+f(15)*(f(5)-1)+f(5)*(f(5)-1)//2*(f(3)-2))

Measured memory_bytes: 9112
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class M>
struct SegmentTree{
    using T = typename M::T;
    int sz;
    vector<T> seg;
    explicit SegmentTree(int n) {
        sz = 1;
        while(sz < n) sz <<= 1;
        seg.assign(2*sz, M::e());
    }

    void set(int k, const T &x){ seg[k + sz] = x; }

    void build(){
        for (int i = sz-1; i > 0; --i) seg[i] = M::f(seg[2*i], seg[2*i+1]);
    }

    void update(int k, const T &x){
        k += sz;
        seg[k] = x;
        while (k >>= 1) seg[k] = M::f(seg[2*k], seg[2*k+1]);
    }

    T query(int a, int b){
        T l = M::e(), r = M::e();
        for(a += sz, b += sz; a < b; a >>=1, b>>=1){
            if(a & 1) l = M::f(l, seg[a++]);
            if(b & 1) r = M::f(seg[--b], r);
        }
        return M::f(l, r);
    }

    template<typename C>
    int find(int t, C &c, T &val, int k, int l, int r){
        if(r-l == 1){
            val = f(val, seg[k]);
            return c(val) ? k-sz : -1;
        }
        int m = (l+r) >> 1;
        if(m <= t) return find(t, c, val, (k << 1) | 1, m, r);
        if(t <= l && !c(val = f(val, seg[k]))) return -1;
        int lv = find(t, c, val, (k << 1) | 0 , l, m);
        if(~lv) return lv;
        return find(t, c, val, (k << 1) | 1, m, r);
    }

    template<typename C>
    int find(int t, C &c){
        T val = M::e();
        return find(t, c, val, 1, 0, sz);
    }
    T operator[](const int &k) const { return seg[k + sz]; }
};


struct Monoid{
    using T = double;
    static T f(T a, T b) { return a*b; }
    static T e() { return 1.0; }
};

int main() {
    int n;
    cin >> n;
    vector<int> z(n);
    vector<pair<int, int>> p;
    for (int i = 0; i < n; ++i) {
        int t, a;
        scanf("%d %d", &t, &a);
        z[i] = t;
        p.emplace_back(t, a);
    }
    SegmentTree<Monoid> seg(n);
    for (int i = 0; i < n; ++i) {
        seg.set(i, 1.0-0.1*p[i].second);
    }
    seg.build();
    int q;
    cin >> q;
    while(q--){
        int l, r;
        scanf("%d %d", &l, &r);
        l = lower_bound(z.begin(),z.end(), l) - z.begin();
        r = lower_bound(z.begin(),z.end(), r) - z.begin();
        printf("%.10lf\n", 1e9*seg.query(l, r));
    }
    return 0;
}


Measured memory_bytes: 6168
chomp($_=<>);
($a,$b,$c) = split(' ');
if ((substr($a, -1, 1) eq substr($b, 0, 1)) and
    (substr($b, -1, 1) eq substr($c, 0, 1))) {
    print "YES\n";
} else {
    print "NO\n";
}


Measured memory_bytes: 640
D = {}
N = int(input())
A = list(map(int, input().split()))
Rec = []
Sq = []
for i in A:
  if i in D:
    D[i] += 1
  else:
    D[i] = 1
for i in D:
  if D[i] >= 4:
    Sq.append(i)
  if D[i] >= 2:
    Rec.append(i)
Rec.sort(reverse=True)
if len(Rec) <= 1 and len(Sq) == 0:
  print(0)
elif len(Sq) != 0 and len(Rec) >= 2:
  print(max(Rec[0] * Rec[1], max(Sq) * max(Sq)))
elif len(Sq) == 0 and len(Rec) >= 2:
  print(Rec[0] * Rec[1])


Measured memory_bytes: 18316
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-7
#define inf 0x3f3f3f3f
#define mod 1000000007ll
using namespace std;

int main() {
	speed;
	char c;
	cin >> c;
	map<char, char>a = { {'A', 'T'},{'T', 'A'},{'C', 'G'},{'G', 'C'} };
	cout << a[c];
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int W,H,N;

  
    scanf("%d",&W);
    scanf("%d",&H);
    scanf("%d",&N);

    int x1=0,x2=W,y1=0,y2=H;
    
    int x[N],y[N],a[N];
    
    for(int i=0;i<N;i++){
  scanf("%d",&x[i]);
  scanf("%d",&y[i]);
  scanf("%d",&a[i]);
  if(a[i]==1){
    if(x1<x[i])x1=x[i];
    }
    else if(a[i]==2){
       if(x2>x[i])x2=x[i];
    }
      else if(a[i]==3){
	 if(y1<y[i])y1=y[i];
      }
	else if(a[i]==4){
	   if(y2>y[i])y2=y[i];
	}
    }
    if(x1>=x2||y1>=y2)printf("0\n");
    else{
      printf("%d\n",(x2-x1)*(y2-y1));
    }
 
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
const int INF=1<<21;
int p[105];
int m[105][105];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>p[i-1]>>p[i];
    for(int i=1;i<=n;i++)m[i][i]=0;

        /* l==1时，是每两个相乘，l=3个时，是三个与剩下的几个相乘，l=4，是四个矩阵与剩下的
        相乘的最小*/
    for(int l=2;l<=n;l++)       //对于每个l都是用来变更  矩阵相乘大小的
    {
        for(int i=1;i<=n-l+1;i++)
        {
            int j=i+l-1;
            m[i][j]=INF;
            for(int k=i;k<=j-1;k++)
            {
                m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
            }
        }
    }
    cout<<m[1][n]<<endl;
    return 0;
}



Measured memory_bytes: 3160
m,p,i,x,s,w;main(n){for(;scanf("%d%d%d",&n,&m,&p),n; printf("%d\n",w?(int)(s*((100-p)/100.0))/w:0))for(s=i=0;i++<n;s+=x*100)scanf("%d",&x),w=i-m?w:x;exit(0);}

Measured memory_bytes: 0
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <cctype>

using namespace std;

const int64_t INF=10000000000000000;
int main(){
    int32_t n,m;
    cin>>n>>m;
    int32_t *imos = new int32_t[n+1];
    for(int32_t i1=0;i1<n+1;i1++){
        imos[i1]=0;
    }
    for(int32_t i1=0;i1<m;i1++){
        int32_t l,r;
        cin>>l>>r;
        imos[l-1]++;
        imos[r]--;
    }
    int32_t ans=0;
    int32_t c_sum=0;
    for(int32_t i1=0;i1<n;i1++){
        c_sum+=imos[i1];
        if(c_sum==m){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
int N,T,A;
   cin>>N>>T>>A;
  vector<int>H(N);
  vector<double>kion(N);
  for(int i=0; i<N; i++){
    cin>>H[i];
    kion[i]=abs(A-(T-H[i]*0.006));
  }
  
  int m=0;
  for(int i=0; i<N; i++){
   if(kion[m]>kion[i]){m=i;} 
  }
  
  cout<<m+1;
}


Measured memory_bytes: 256
a = input().split()
x, k, d = abs(int(a[0])), int(a[1]), int(a[2])
a, b = x // d, x % d
c = d - b
if a > k:
    print(x - k * d)
elif a == k:
    print(b)
else:
    t = k - a
    if t % 2:
        print(c)
    else:
        print(b)


Measured memory_bytes: 9112
<?php
    // get input from stdin
    // $input = readline("Please input the number N: ");
    $input = readline();
    // Validate the input. 
    // if(!is_numeric($input) || (int)$input < 1 || 100 < (int)$input) {
    //     throw new \Exception("Invalid input, please input between 1 and 100.", 1);
    // }
    
    // Counting odd numbers between 1 and N
    
    // when value is odd <= please write. @dungnq-0076 
    if (($input % 2) != 0) {
        $prob = round((ceil($input / 2) / $input), 9); // <= don't need * 100
        // echo("The probability of A being odd number is : " . $prob); // <=== this work
        // print_r($prob);
        echo(floatval($prob));
    }
 
    // // when value is even
    if(($input % 2) == 0) {
        print_r(floatval(0.5));
    }
?>

Measured memory_bytes: 4604
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;

int main(void)
{
	map<int, int>prm;
	int n;
	cin >> n;
	if (n == 1)return 0 * printf("1\n");
	for (int i = 2; i <= n; ++i)
	{
		int num = i;
		int a = 2;
		while (num >= a * a)
		{
			if (num % a == 0)
			{
				num /= a;
				prm[a]++;
				continue;
			}
			++a;
		}
		if (num != 1)
		{
			prm[num]++;
		}
	}
	long long ans = 1;
	for (auto& p : prm)
	{
		ans *= (long long)(p.second + 1);
		ans %= 1000000007;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
lst = list(map(int, input().split()))

roots = [list(map(int, input().split())) for _ in range(m)]

ans = [True]*n
for j, k in roots:
    hj = lst[j-1]
    hk = lst[k-1]
    if hj == hk:
        ans[k-1] = False
        ans[j-1] = False

    elif hj > hk:
        ans[k-1] = False
    else:
        ans[j-1] = False

print(ans.count(True))


Measured memory_bytes: 31900
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
using ll = long long;
int main(void){
    string s;
    cin >> s;
    string ans="";
    for(int i=0;i<s.length();i++){
        if(s.substr(i,1)=="B"){
            if(ans!=""){
                ans.erase(ans.length()-1,1);
            }
        }else{
            ans+=s.substr(i,1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int x[100001],y[100001],a[100001],b[100001],c[100001];
int na,nb,m;
int main(){
	ios::sync_with_stdio(0);
	cin>>na>>nb>>m;
	rep(i,na)
	cin>>a[i];
	rep(i,nb)
	cin>>b[i];
	rep(i,m){
		cin>>x[i]>>y[i]>>c[i];
		x[i]--;
		y[i]--;
	}
	int ma=a[0],mb=b[0];
	rep(i,na)
	ma=min(ma,a[i]);
	rep(i,nb)
	mb=min(mb,b[i]);
	int ans=a[x[0]]+b[y[0]]-c[0];
	ans=min(ans,ma+mb);
	rep(i,m){
		ans=min(ans,a[x[i]]+b[y[i]]-c[i]);
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 2176
# N,Mの把握
l = list(map(int, input().split()))
N = l[0]
M = l[1]

#list(map(str, input().split()))をM回くりかえし、１つのリストにまとめる。

c = []
for i in range(M):
	c = c + list(map(int, input().split()))

# リストを指定の番号で検索して、項目数を返す関数
def r(x):
	y = str(c.count(x))
	return y

#都市番号1からNまでリストを検索し、出力
dic = {}
for i in range(1,N+1):
	print(r(i))

Measured memory_bytes: 3064
#include <cstdio>
#include <utility>
#include <vector>

int main() {
    std::vector<int> v;
    
    int m;
    scanf("%d", &m);
    for (int i = 0; i < m; ++i) {
        v.push_back(i);
    }
    
    int n;
    scanf("%d", &n);
    
    int a, b;
    while (~scanf("%d,%d", &a, &b)) {
        std::swap(v[a - 1], v[b - 1]);
    };
    
    for (const auto& i : v) {
        printf("%d\n", i + 1);
    }
}

Measured memory_bytes: 1032
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  double B = 0.0;
  cin >> N;
  if ((N<=100) && (N>=1)) {
    int a[N];
    double b[N];
    for (int i = 0; i < N; i++) {
      cin >> a[i];
      if ((a[i] >=1) && (a[i] <=1000)) {
        b[i] = 1/double(a[i]);
        B = B + b[i];
      } else {return 0;}
    }
    cout << 1/B << "\n";
  }
  
    return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl;
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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


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

    int turn=0, ans;
    while(true)
    {
        if(s[turn].size()==0){ans=turn; break;}
        int n=s[turn][0]-'a'; 
        s[turn]=s[turn].substr(1, s[turn].size()-1); //微妙にわからん
        turn=n;                    
    }            
    if(ans==0){cout<<"A";}
    else if(ans==1){cout<<"B";}
    else{cout<<"C";}
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int l, a, b, c, d, japanese, math, homework, play;
	scanf("%d %d %d %d %d",&l,&a,&b,&c,&d);
	if(a % c == 0)
		japanese = a / c;
	else
		japanese = a / c + 1;
		
	if(b % d == 0)
		math = b / d;
	else
		math = b / d + 1;
		
	if(japanese <= math)
		homework = math;
	else
		homework = japanese;
		
	play = l - homework;
	printf("%d\n",play);
	
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,k,c;
    cin>>a>>b>>k;
    c=a-k;
    if(c<0&&b+c>=0)
        cout<<0<<" "<<b+c<<endl;
    else if(c<0&&b+c<0)
        cout<<0<<" "<<0<<endl;
    else
        cout<<a-k<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN = 1e5 + 10;
int nums[MAXN];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
    }
    sort(nums, nums+n);
    int b = nums[n-1];
    int a = nums[0];
    for (int i = 1; i < n-1; i++) {
        if (abs(2*nums[i]-b) < abs(2*a-b)) {
            a = nums[i];
        }
    }
    cout << b << ' ' << a << endl;
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);

  string o, e;
  cin >> o >> e;

  for (unsigned int i = 0; i < e.size(); ++i) {
    cout << o[i] << e[i];
  }
  if (o.size() != e.size()) {
    cout << o[o.size() - 1] << '\n';
  } else {
    cout << '\n';
  }

  return 0;
}


Measured memory_bytes: 3508
#include<cstdio>
#include<list>
#include<algorithm>
 
using namespace std;
 
int main(){
  int q, x;
  char com[20];
 
  list<int> v;
  scanf("%d", &q);
  for ( int i = 0; i < q; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ) {
      scanf("%d", &x);
      v.push_front(x);
    } else if ( com[6] == 'L' ) {
      v.pop_back();
    } else if ( com[6] == 'F' ) {
      v.pop_front();
    } else if ( com[0] == 'd') {
      scanf("%d", &x);
      for ( list<int>::iterator it = v.begin(); it != v.end(); it++ ) {
        if ( *it == x ) {
          v.erase(it);
          break;
        }
      }
    }
  }
  int i = 0;
  for ( list<int>::iterator it = v.begin(); it != v.end(); it++ ) {
    if ( i++ ) printf(" ");
    printf("%d", *it);
  }
  printf("\n");
 
  return 0;
}


Measured memory_bytes: 33904
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		if(x >= a && x <= (a+b)) System.out.println("YES");
		else System.out.println("NO");
	}
}

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

#define Ff(i,j,n)  for (i = j ; i < n; i++)
#define Fb(i,j,n)    for (i = (n - 1); i >= j; i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pll pair<long, long>
#define pi 3.14159265358979323846
#define fill(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(), x.end()
#define trav(i,x) for(auto& i:x)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

typedef vector < long long > vll;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;

// const ll mod = 998244353;
// const ll N = 1000000007;
// ll binpow(ll b, ll p) { ll ans = 1; while (p > 0) {if (p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;} return ans;}
// ll inv(ll x) {return binpow(x, mod - 2);}
// ll divide(ll x, ll y) {return ((x % mod) * (inv(y))) % mod;}


int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	IOS
	int t = 1;
	// cin >> t;
	while (t--) {
		int n, i, x, t;
		cin >> n >> x >> t;
		int e = n / x ;
		if (n % x == 0)
			cout << e*t << endl;
		else cout << (e + 1)*t << endl;

	}


	return 0;
}

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

int main(void){
  double num,b;
  int a,c,d;
  int i,j;
  int abin[8],bbin[4];
  while(scanf("%lf",&num)&&num>=0){
    a=(int)num;
    b=num-a;
    //printf("%d %g %g\n",a,b,num);
    if(a>=(1<<8)){
      puts("NA");
      continue;
    }
    for(i=7;i>=0;i--){
      c=1<<i;
      d=a&c;
      //printf("%d\n",c);
      if(d==0) abin[i]=0;
      else abin[i]=1;
      //printf("%d %d\n",i,abin[i]);
    }
    for(i=0;i<4;i++){
      b*=2;
      if(b>=1){
	bbin[i]=1;
	b-=1;
      }else{
	bbin[i]=0;
      }
    }
    if(b!=0){
      puts("NA");
      continue;
    }
    for(i=7;i>=0;i--){
      printf("%d",abin[i]);
    }
    putchar('.');
    for(i=0;i<4;i++){
      printf("%d",bbin[i]);
    }
    putchar('\n');
  }
  return 0;
} 

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long a[n];
	for(int i=0;i<n;++i)
		cin>>a[i];
	sort(a,a+n);
	long long sum=0;
	for(int i=0;i<n-1;++i)
		sum+=a[i];
	if(sum<=a[n-1])
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,M;
    cin >> N >> M;
    ll A[M];
    rep(i,M) A[i] = 0;
    rep(i,N){
        ll K;
        cin >> K;
        rep(j,K){
            ll a;
            cin >> a;
            A[a-1]++;
        }
    }
    ll out = 0;
    rep(i,M){
        if(A[i]==N) out++;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Integer[] len = new Integer[n];
		for ( int i = 0; i < n; i++ ) {
			len[i] = in.nextInt();
		}
		Arrays.sort(len, Comparator.reverseOrder());

		int cnt = 0;
		for ( int e1 = 0; e1 < n; e1++ ) {
			for ( int e2 = e1 + 1; e2 < n; e2++ ) {
				
				int d = len[e1] - len[e2];
				
				for ( int e3 = e2 + 1; e3 < n; e3++, cnt++ ) {
					if ( len[e3] <= d ) break;
				}
			}
		}
		System.out.println(cnt);
		in.close();
	}
}

Measured memory_bytes: 26128
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll  INFL = 1e18;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll H, W; cin >> H >> W;
    if(H == 1 || W == 1) cout << 1 << endl;
    else if(H % 2 == 0 || W % 2 == 0) cout << H*W/2 << endl;
    else cout << (H*W+1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
    int N,K;
    cin >> N >> K;
    bool ok[10];rep(i,10)ok[i]=true;
    for(int i=0;i<K;i++){
        int d;cin >> d;
        ok[d]=false;
    }
    for(int i=N;i<=99999;i++){
        int s=i;
        bool f=true;
        while (s>0)
        {
            f&=(ok[s%10]);
            s/=10;
        }
        if(f){
            cout << i << endl;
            return 0;
        }
    }
    
    return 0;
}

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

int T, N, M, K;
int A, B, C, D;

int main()
{
	scanf("%d", &N);
	if (N%10==3) printf("bon");
	else if (N%10==0||N%10==1||N%10==6||N%10==8) printf("pon");
	else printf("hon");
	return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const double PI = 3.1415926535898;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int R;cin>>R;
	cout<<2*PI*R<<'\n';
	return 0;
}

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

#define ll long long int
#define ld long double
#define pb push_back
#define pq priority_queue
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vvll vector<vector<ll>>
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<ll>
#define MODNUM 1000000007
#define lp(i,a,b) for(ll i=a; i<b; i++)

using namespace std;

ll mex(ll a, ll b, ll m) {
	if(b==0) return 1;
	if(b%2) return a*mex((a*a)%m,(b-1)/2,m)%m;
	else return mex((a*a)%m,b/2,m);
}

int x,y;
void exteu(ll a, ll m) {
	if(m==0) { x=1;y=0; }
	else {
		exteu(m,a%m);
		ll temp = x;
		x=y;
		y=temp-(a/m)*y;
	}
}

ll fact(ll n) 
{	ll prod=1;
	for(ll i=2; i<=n; i++) {
		prod*=i;
	}
	return prod;
}

ll gcd(ll a, ll b) {
	if(b==0) return a;
	return gcd(b, a%b);
}
// 2 2 2 7
// 2 2 2 3 3
// 3 3 7

// 3
// 2 
// 3 3
bool isprime[200001];
void makesieve() {
	memset(isprime, true, sizeof(isprime));
	for (int i = 2; i <= sqrt(200000); ++i)
	{
		/* code */
		if(isprime[i]) {
			for (int j = i*i; j <= 200000; j+=i)
			{
				/* code */
				isprime[j]=false;
			}
		}
	}
}
// 3 - (1+1)*4
// 5 - (2+2+2+2+1+1+1)
void solve() {
	int n; cin>>n;
	if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9) {
		cout << "hon";
	} 	
	else if(n%10==0 || n%10==1 || n%10==6 || n%10==8) {
		cout << "pon";
	}
	else cout << "bon";
 }
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll TESTS=1;
	// cin >> TESTS;
	// makesieve();
	while(TESTS--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
 
using namespace std;
 
 int main()
 {
     int N, M, tmp, diff;
     int value, accum = 0;
     vector<int> vec;
     vector<int> vec_diff;

     cin >> N >> M;
     
     if (N > M) {
        cout << 0 << endl;
        return 0;
        }

     for(int i = 0; i < M; i++) {
         cin >> tmp;
         vec.push_back(tmp);
     }

    sort(vec.begin(), vec.end());

    for (int i = 0; i < M - 1; i++) {
        diff = vec[i+1] - vec[i] - 1;
        vec_diff.push_back(diff);
    }
    sort(vec_diff.begin(), vec_diff.end(), greater<int>());

    for (int i = 0; i < N-1; i++) {
        accum += vec_diff[i];
    }

    value = (vec[M-1] - vec[0] + 1) - accum - N;

    cout << value << endl;

    return 0;
 }


Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <string>
using namespace std;

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

int main() {
  string s;
  int ans = 0;
  while(cin>>s) {
    string a(s);
    reverse(ALL(s));
    if (a == s)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int a[1000][5];
int main() {
	int n;
	while (cin >> n&&n != 0) {
		for (int i = 0; i < n; i++) {
			cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
			a[i][4] = a[i][1] * 4 + a[i][2] * 9 + a[i][3] * 4;
		}
		int p[4];
		cin >> p[0] >> p[1] >> p[2] >> p[3];
		bool sum = false;
		for (int i = 0; i < n; i++) {
			bool b = false;
			for (int j = 1; j < 5; j++) {
				if (a[i][j] > p[j - 1])
					b = true;
			}
			if (!b) {
				cout << a[i][0] << endl;
				sum = true;
			}
		}
		if (!sum)
			cout << "NA" << endl;
	}
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll A,B,M; cin>>A>>B>>M;
    ll ans=INF2;
    vector<ll> a(A);
    vector<ll> b(B);
    rep(i,A) cin>>a[i];
    rep(i,B) cin>>b[i];
    rep(i,M){
        ll x,y,c; cin>>x>>y>>c; --x,--y;
        mini(ans,a[x]+b[y]-c);
    }
    SORT(a);
    SORT(b);
    mini(ans,a[0]+b[0]);
    cout<< ans <<"\n";


}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1792
class Array
  def warshall_floyd
    v = size

    dist = map(&:dup)

    v.times do |k|
      v.times do |i|
        v.times do |j|
          cost = dist[i][k] + dist[k][j]
          dist[i][j] = cost if dist[i][j] > cost
        end
      end
    end

    dist
  end
end

N = gets.to_i
S = N.times.map { gets.chomp.chars.map(&:to_i) }


module Graph
  class Tree
    def initialize(edges)
      @edges = edges
    end

    def diameter
      r = @edges.keys.first
      v, _ = farthest_vertex(r)
      u, d = farthest_vertex(v)
      [v, u, d]
    end

    private

    def farthest_vertex(s)
      queue = [[s, 0]]
      dist = -1
      fv = -1
      visited = Hash.new(false)

      until queue.empty?
        v, d = queue.shift

        next if visited[v]
        visited[v] = true

        if dist < d
          dist = d
          fv = v
        end

        @edges[v].each do |u|
          queue.push([u, d + 1])
        end
      end

      [fv, dist]
    end
  end
end

edges = Hash.new { |h, k| h[k] = [] }
e = Array.new(N) { Array.new(N, Float::INFINITY) }

S.each_with_index do |row, i|
  row.each_with_index do |t, j|
    if i == j
      e[i][j] = 0
    end

    next if t.zero?

    e[i][j] = 1
    edges[i] << j
  end
end

e = e.warshall_floyd
tree = Graph::Tree.new(edges)

md = 0
s = -1

e.each_with_index do |row, i|
  row.each do |d, j|
    if md < d
      md = d
      s = i
    end
  end
end

# root, _, dist = tree.diameter

queue = [[s]]
visited = Hash.new(false)

until queue.empty?
  list = queue.shift

  next if list.empty?

  vs = []

  list.each do |v|
    visited[v] = true

    edges[v].each do |u|
      next if visited[u]

      vs << u
    end
  end

  vs.uniq!

  vs.each do |i|
    vs.each do |j|
      next if i == j

      if S[i][j] == 1
        puts -1
        exit
      end
    end
  end

  queue.push(vs)
end

puts md + 1


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

ll topVal(ll n){
    if(n < 10) return n;
    else return topVal(n/10);
}

ll cntDigit(ll n){
    if(n<10) return 1;
    else return 1 + cntDigit(n/10);
}

int main(){
    ll N;  cin >> N;
    ll ans = 0;
    for(int a=1; a<=N; a++){
        ll bot = topVal(a);
        ll top = a%10;
        if(top == 0 || bot == 0) continue;
        if(top == bot && top > N) continue;
        if(top != bot && top*10 + bot > N) continue;

        ll d = cntDigit(N);
        if(top < topVal(N)){
            if(top == bot){
                if(d == 1) ans += 1;
                else if(d == 2) ans += 2;
                else{
                    ans += 1;
                    for(int i=0; i<=d-2; i++){
                        ans += pow(10, i);
                    }
                }
            }else{
                for(int i=0; i<=d-2; i++){
                    ans += pow(10, i);
                }
            }
        }else if(top > topVal(N)){
            if(top == bot){
                if(d==1) ans += 1;
                else if(d==2) ans += 1;
                else{
                    ans += 1;
                    for(int i=0; i<d-2; i++){
                        ans += pow(10, i);
                    }
                }
            }else{
                for(int i=0; i<d-2; i++){
                    ans += pow(10, i);
                }
            }
        }else{
            if(top == bot){
                if(d==1) ans += 1;
                else if(d==2) ans += (10*top+bot>N)? 1 : 2;
                else {
                    ans += 1;
                    for(int i=0; i<d-2; i++){
                        ans += pow(10, i);
                    }
                    if(N%10 >= bot){
                        ll temp = pow(10, d-1);
                        ans += (N%temp)/10 + 1;
                    }else{
                        ll temp = pow(10, d-1);
                        ans += (N%temp)/10;
                    }
                }
            }else{
                for(int i=0; i<d-2; i++){
                    ans += pow(10, i);
                }
                if(N%10 >= bot){
                    ll temp = pow(10, d-1);
                    ans += (N%temp)/10 + 1;
                }else{
                    ll temp = pow(10, d-1);
                    ans += (N%temp)/10;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, K: int, h: "List[int]"):
    ret = 0
    for i in range(N):
        if h[i] >= K:
            ret += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12016
#include <bits/stdc++.h>
using  namespace  std;
using ll=long long;
int main(){
  int x,a,b;
  cin>>x>>a>>b;
  if(a>=b)cout<<"delicious"<<endl;
  else {
    if(x>=b-a)cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	string s; cin >> s;
	int ans=0;
	for(int i=0;i<n-2;i++){
		if(s.substr(i,3)=="ABC")ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  vector<long> data(7);
  for (int i = 0;i < 7; i++){
    cin >> data.at(i);
  }
  vector<int> n{0, 3, 4};
  int count = 0;
  for(int a: n) {
    if (data.at(a) % 2 == 1) count++;
  }
  long sub = 0;
  if(data.at(0) > 0 && data.at(3) > 0 && data.at(4) > 0) {
    if (count > 1) {
      for(int a: n) {
        data.at(a)--;
      }
      sub = 3;
    }
  }
  cout <<(long) sub + (data.at(0) / 2) * 2 + data.at(1) + (data.at(3)/ 2 + data.at(4) / 2) * 2 << endl;
}


Measured memory_bytes: 256
import itertools
N=int(input())
L=list(map(int,input().split()))

ans=0
for lines in itertools.combinations(L, 3):
  if lines[0]!=lines[1] and lines[0]!=lines[2] and lines[1]!=lines[2]:
    lines=sorted(list(lines))
    if lines[0]+lines[1]<=lines[2]:
      continue
    ans+=1
print(ans)

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

int main(){
	string s;
	cin >> s;
	int z = -1, a = -1, size = 0;
	size = s.size();
	for(int i = 0;i < size;i++){
		if (s[i] == 'A' && a == -1){
			a = i;
		}else if (s[i] == 'Z'){
			z = i;
		}
	}
	cout << z - a + 1;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
int main(){
int n,m,b,c;
std::cin>>n>>m>>b;c=b;
for(int i=0;i<99;i++){
if(c%(n+m)<=n){goto a;}
c+=60;
}
c=-1;
a:
for(int i=0;i<20000;i++){
for(int j=0;j<20000;j++){
b+=1;
}
}
std::cout<<c<<"\n";return 0;}

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cmath>
#include <list>
#include <functional>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) (v).erase( unique(all(v), (v).end() );
#define SZ(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define INF 1000000000000
#define MOD 1000000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

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

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

const char newl = '\n';

ll qp(ll a,ull b){ll ans=1;do{if(b&1u)ans*=a;a*=a;}while(b>>=1u);return ans;}
ll qp(ll a,ull b,ll mod){ll ans=1;do{if(b&1u)ans=ans*a%mod;a=a*a%mod;}while(b>>=1u);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


int main() {
    ll x, k, d; cin >> x >> k >> d;

    ll div = x / d;
    ll kk;
    if (div % 2 == k % 2) {
        kk = -div;
    } else {
        if (x < 0) {
            kk = -(div - 1);
        } else {
            kk = -(div + 1);
        }
    }

    ll kp = (kk + k) / 2;
    kp = max(kp, (ll)0);
    kp = min(kp, k);

    div = kp * 2 - k;

    cout << abs(x + div * d) << newl;

    return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vec A(n);
    rep(i,n) cin>>A[i];
    ll ans=0;
    rep(i,n-1) if(A[i]>A[i+1]) ans+=A[i]-A[i+1],A[i+1]=A[i];
    cout<<ans;
}

Measured memory_bytes: 4700
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int n,a[105],ans;
int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",a+i);
    sort(a,a+n,greater<int>());
    for(int i=0;i<n;i++){
        if(i%2==0)ans+=a[i];
        else ans-=a[i];
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256