akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

struct Combination {
    static ll mpow(ll x, ll n) { ll y = 1; for (; n > 0; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }
    vector<ll> fact, ifact;
    Combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1; for (int i = 0; i < n; ++i) fact[i + 1] = fact[i] * (i + 1) % MOD;
        ifact[n] = mpow(fact[n], MOD - 2); for (int i = n; i > 0; --i) ifact[i - 1] = ifact[i] * i % MOD;
    }
    ll operator ()(int n, int k) { return k < 0 || k > n ? 0 : fact[n] * ifact[n - k] % MOD * ifact[k] % MOD; }
} C(3e3);

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

    vv<ll> dp = vvec(N, N, 0LL);
    rep(j, 0, N) dp[0][j] = 1;

    rep(i, 1, N) {
        ll sum = 0;
        if (s[i - 1] == '<') {
            for (int j = 0; j <= N - i - 1; ++j) {
                sum = (sum + dp[i - 1][j]) % MOD;
                dp[i][j] = (dp[i][j] + sum) % MOD;
            }
        }
        else {
            for (int j = N - i - 1; j >= 0; --j) {
                sum = (sum + dp[i - 1][j + 1]) % MOD;
                dp[i][j] = (dp[i][j] + sum) % MOD;
            }
        }
    }

    ll ans = 0;
    rep(j, N) ans = (ans + dp[N - 1][j]) % MOD;
    write(ans);
}

Measured memory_bytes: 70784
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const int N = 4e3 + 10;
char s[N];

int64 solve(const string& p) {
  int n = strlen(s);
  vector<int> pre(n + 1);
  for (int i = 0; i < n; ++i) pre[i + 1] = pre[i] + (s[i] == p[0]);
  int64 ret = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] != p[1]) continue;
    for (int j = i + 1; j < n; ++j) {
      if (s[j] != p[2]) continue;
      int k = 2 * i - j;
      // trace(i, j, k);
      ret += pre[i];
      if (k >= 0 && s[k] == p[0]) --ret;
    }
  }
  return ret;
}

int main() {
  int n;
  scanf("%d%s", &n, s);
  string p = "BGR";
  int64 ret = 0;
  do {
    ret += solve(p);
  } while (next_permutation(p.begin(), p.end()));
  printf("%lld\n", ret);
  return 0;
}


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

int main() {
	long long int N; cin >> N;
	vector<string> s(N);
	for (int i = 0; i < N; i++) cin >> s[i];

	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < s[i].size() - 1; j++) {
			if (s[i][j] == 'A' && s[i][j + 1] == 'B') {
				ans++;
			}
		}
	}

	long long int a = 0, b = 0, ba = 0;

	for (int i = 0; i < N; i++) {
		if (s[i][0] == 'B' && s[i][s[i].size() - 1] != 'A') {
			b++;
		}

		if (s[i][s[i].size() - 1] == 'A' && s[i][0] != 'B') {
			a++;
		}

		if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') {
			ba++;
		}
	}

	if (ba == 0) cout << ans + min(a, b) << endl;
	else if (ba != 0 && a + b > 0) cout << ans + ba + min(a, b) << endl;
	else if (a + b == 0) cout << ans + ba - 1 << endl;
}

Measured memory_bytes: 768
a, b, c, x = [int(input()) for _ in range(4)]
count=0
a2 = x // 500 #500円玉は何枚必要か
if a < a2: #足りない時
    a3 = a
else: #足りてる時
    a3 = a2
for i in range(a3+1):
    y = x -500*i
    b2 = y//100
    if b < b2:
        b3 = b
    else:
        b3 = b2
    for j in range(b3 + 1):
        z = y - 100 * j
        if z // 50 <= c:
            count += 1
print(count)


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

using namespace std;
typedef long long ll;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;

const int mn = 2e5 + 5;
const int mod = 2019;

int n;
int a[mn];
int delta[mn]; // b_1 - b_i
int b[mn];

int main() {
#ifdef trote
    freopen("../1.txt", "r", stdin);
#endif
    scanf("%d", &n);
    ll S = 0;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]), S += a[i];
    int sum = 0;
    for (int i = 1; i < n; i += 2) {
        sum += 2 * (a[i] - a[i + 1]);
        delta[i + 2] = sum;
        //printf("%d %d\n", i + 2, delta[i + 2]);
    }
    sum += 2 * (a[n] - a[1]);
    delta[2] = sum;
    for (int i = 2; i < n - 1; i += 2) {
        sum += 2 * (a[i] - a[i + 1]);
        delta[i + 2] = sum;
    }
    for (int i = 2; i <= n; i++) S += delta[i];
    b[1] = S / n;
    for (int i = 2; i <= n; i++) b[i] = b[1] - delta[i];
    for (int i = 1; i <= n; i++) {
        //printf("%d ", delta[i]);
        printf("%d ", b[i]);
    //    puts("");
    }

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
int main()
{
	int a, b;
	std::cin >> a >> b;
	int result = 0;
	for (int i = 0; i < 2; i++)
	{
		if (a >= b)
		{
			result += a;
			a = a - 1;
		}
		else
		{
			result += b;
			b = b - 1;
		}
	}
	std::cout << result << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f40;
const long long mod=1e9+7;
const long double PI = acos(0);
template <class T>void UNIQUE(vector<T> &x){
	sort(all(x));
	x.erase(unique(all(x)), x.end());
}

// }}} End Header
int main() {
	ll n, w = 0, r = 0, ans;
	string s;
	cin >> n >> s;

	ll white = count(all(s), 'W');
	ll right = count(all(s), 'R');
	ans = min(white, right);
	r = right;

	rep(i,n-1){
		if(s[i] == 'W') w++;
		else r--;
		ll subans = max(w, r);
		ans = min(subans, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3756
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int rate[9] = {};
    int a;
    for (int i=0; i<n; i++) {
        cin >> a;
        if (a >= 3200) a=3200;
        rate[a/400]++;
    }
    int sum = 0;
    for (int i=0; i<8; i++) {
        if (rate[i] != 0) sum++;
    }
    int min, max;
    max = sum + rate[8];
    if (sum != 0) {
        min = sum;
    } else {
        if (rate[8] != 0) {
            min = 1;
        } else {
            min = 0;
        }
    }
    cout << min << " " << max << endl;
}

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

int cnt;

void Merge(int A[],int left,int mid,int right)
{
    int n1=mid-left;
    int n2=right-mid;
    int L[n1+1],R[n2+1];
    int i,j;
    for(i=0;i<n1;++i)
    {
        L[i]=A[left+i];
    }
    for(i=0;i<n2;++i)
    {
        R[i]=A[mid+i];
    }
    L[n1] = R[n2] =  INT_MAX;
    i=0;j=0;
    for(int k=left;k<right;k++)
    {
        cnt++;
        if(L[i]<=R[j])
        {
            A[k]=L[i++];
        }
        else
        {
            A[k]=R[j++];
        }

    }
}
void mergesort(int A[],int left,int right)
{
    if(left+1<right)
    {
        int mid=(left+right)/2;
        mergesort(A,left,mid);
        mergesort(A,mid,right);
        Merge(A,left,mid,right);
    }
}

int main(){
    int A[500000],n,i;
    cnt=0;
    scanf("%d",&n);
    for(i=0;i<n;++i)
    {
        scanf("%d",&A[i]);
    }
    mergesort(A,0,n);
    for(i=0;i<n;++i)
    {
        if(i)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");

    printf("%d\n",cnt);

    return 0;
}



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

int check(string str,int n)
{
    for(int i=0,j=n/2;i<n/2,j<n;i++,j++)
    {
        if(str[i]!=str[j])
        {
            return 1;
        }
    }
    return 0;
}

int main()
{
    int len;
    cin>>len;
    string str;
    cin>>str;
    if(len%2==0)
    {
        if(check(str,len)==1)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }
}


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

int main()
{
  int n;
  cin>>n;
  int vag=n/100;
  int rem=n%100;
  
  int tot=0;
  for(int i=5;i>=1;i--)
  {
    while(rem>=i)
    {
      tot++;
      rem-=i;
    }
  }
  
  if(tot<=vag) cout<<1;
  else cout<<0;
  
  return 0;
}

Measured memory_bytes: 256
import math
N = int(input())
min_digits = 12
for a in range(1, round(math.sqrt(N))+1):
    if N%a !=0:
        continue
    b = N//a
    digits = max(len(str(a)), len(str(b)))
    if digits < min_digits:
        min_digits = digits
print(min_digits)

Measured memory_bytes: 3188
s = input()

mod = 10**9+7
n = len(s)
res = [1] + [0] * 12
for ss in s:
    dp = [0] * 13
    for i in range(13):
        dp[(10*i)%13] = res[i]
    dp += dp

    if ss == '?':
        for i in range(13):
            res[i] = sum(dp[i+4:i+14])
    else:
        for i in range(13):
            res[i] = dp[i+13-int(ss)]
    res = [v%mod for v in res]
print(res[5])


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long idx=0;
    long N, A, B;
    cin >> N >> A >> B;
    long loop = N / (A + B);
    long residual = N - (A + B) * loop;
    if (A >= residual)
        cout << A * loop + residual << endl;
    else
        cout << A * loop + A << endl;

    return 0;
}

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

int main(){
    int n;
    char s;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=='Y'){
            cout<<"Four"<<endl;
            break;
        }
        if(i==n-1) cout<<"Three"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int func(int n) { return n % 2 == 0 ? n / 2 : 3 * n + 1; }

int main()
{
    const int max = 1000000;
    int s;
    map<int, bool> exists;
    for (int i = 0; i <= max; i++)
    {
        exists[i] = false;
    }
    cin >> s;
    int prev = s;
    for (int i = 2; i <= 1000000; i++)
    {
        exists[prev] = true;
        prev = func(prev);
        if (exists[prev])
        {
            cout << i << endl;
            return 0;
        }
    }
    return -1;
}


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


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

int main() {
    int n;
    cin >> n;
    vector<double> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    double sum;
    for (int i = 0; i < n; i++) {
        sum += a[i];
    }
    double m = round(sum / (double)n);
    
    double ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (a[i] - m) * (a[i] - m);
    }
    
    cout << (int)ans << endl;
}

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

long long mod = 998244353;

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




int main() {
  
  long long N,M,K;
  cin >> N >> M >> K;
  
  vector<long long> ii(300000),iii(300000);
  ii[0] = 1;
  iii[0] = 1;
  for (int i=1; i<300000; i++) {
    ii[i] = ii[i-1] * i;
    ii[i] %= mod;
    iii[i] = pow_kai(ii[i], mod-2);
  }
  
  long long ans = 0;
  long long term;
  
  for (int i=0; i<K+1; i++) {
    term = ii[N-1] * iii[i];
    term %= mod;
    term *= iii[N-1-i];
    term %= mod;
    term *= pow_kai(M-1,N-i-1);
    term %= mod;
    term *= M;
    term %= mod;
    ans += term;
    ans %= mod;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 7992
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    ll N;
    cin >> N;

    string A = to_string(N);

    int K = A.size();
    int f = 0;

    rep(i, K) f += A[i] - '0';

    if (N % f == 0) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define vi vector < int >
#define pii pair < int, int >
#define INF (int)1e9
#define pb push_back
#define fastIO ios::sync_with_stdio(0); cin.tie(0);

int main()
{
    fastIO
    
    int n;
    cin >> n;
    
    vi a(n + 1);
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
        
    unordered_map < int, int > sum, diff;
    for(int i = 1; i <= n; ++i)
    {
        if(sum.count(i + a[i]))
            ++sum[i + a[i]];
        else
            sum[i + a[i]] = 1;
    }
    
    for(int i = 1; i <= n; ++i)
    {
        if(diff.count(i - a[i]))
            ++diff[i - a[i]];
        else
            diff[i - a[i]] = 1;
    }
    
    ll ans = 0;
    for(auto it : sum)
    {
        int no = it.first;
        int count = it.second;
        if(diff.find(no) != diff.end())
            ans += (ll)count * diff[no];
    }
    
    cout << ans;
    
    return 0;
}



Measured memory_bytes: 19536
#include <iostream>
#include <cstdio>

using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	int n;
	while(cin >> n, n) {
		int board[15][15] = {};
		board[n/2+1][n/2] = 1;
		int y = n/2+1, x = n/2;
		rep2(i,2,n*n+1) {
			y = (y+1)%n, x = (x+1)%n;
			if(board[y][x]) {
				do {
					y = (y+1)%n, x = (n+x-1)%n;
				} while(board[y][x]);
			}
			board[y][x] = i;
		}
		rep(i,n) {
			rep(j,n) {
				printf("%4d",board[i][j]);
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n,q,l,r,record[100000]={0};
    string s;
    cin>>n>>q>>s;
    for(int i=1;i<n;i++){
        record[i]=record[i-1];
        if(s[i]=='C'&&s[i-1]=='A'){
            record[i]++;
        }
    }
    for(int i=0;i<q;i++){
        cin>>l>>r;
        cout<<record[r-1]-record[l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1408
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
case = [[], [], []]
for i in p:
    if i <= a:
        case[0].append(i)
    elif i <= b:
        case[1].append(i)
    else:
        case[2].append(i)
print(min(map(lambda x: len(x), case)))


Measured memory_bytes: 3060
num = gets.chomp.to_i
n = num*(num-1)/2
cnt = []
for i in 0..(num-1)
 cnt[i] = 0
end

n.times do |i|
  data = gets.split.map(&:to_i)
  a = data[0]-1
  b = data[1]-1
  if data[2] == data[3]
    cnt[a] += 1
    cnt[b] += 1
  elsif data[2] < data[3]
    cnt[b] += 3
  else
    cnt[a] += 3
  end
end

rank = []
for i in 0..num-1
  rank[i] = 0
end

for i in 0..num-1
  for j in 0..num-1
    if cnt[i] < cnt[j]
       rank[i] += 1
    end
  end
  rank[i] += 1
end
puts rank



Measured memory_bytes: 7104
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

double a, b;

void init() {

}

void input() {
  cin >> a >> b;
}

void solve() {
  cout << a/b << endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>
#include<queue>
#define mod 998244353
#define pb push_back
#define ll long long
using namespace std;
int main(){
	int n=0,w=0,s=0,e=0;
	string str;
	cin>>str;
	for(int i=0;i<str.size();i++){
		if(str[i]=='N')n++;
		if(str[i]=='W')w++;
		if(str[i]=='S')s++;
		if(str[i]=='E')e++;
	}
	if( n * s == 0 && n != s)cout<<"No"<<endl;
	else if( e * w == 0 && e != w)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;	
	return 0;
}

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

int main(){
    while(1){
     int t,n,c=0;
     cin>>t;
     if(t==0)break;
     cin>>n;
     for(int i=0;i<n;++i){
        int s,e;
        cin>>s>>e;
        c+=e-s;
     }
        if(c>=t)cout<<"OK"<<endl;
        else cout<<t-c<<endl;
    }

    return 0;
}

Measured memory_bytes: 1164
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Mehvix
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc168_b solver = new abc168_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc168_b {
        public void solve(int testNumber, Scanner fin, PrintWriter fout) {
            int k = fin.nextInt();
            String s = fin.next();
            if (s.length() <= k) fout.println(s);
            else fout.println(s.substring(0, k) + "...");
        }

    }
}



Measured memory_bytes: 38672
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void split(int out[], char str[]);
int cmp(const void *p, const void *q);

int main(void) {
  int nums;
  char *tmp;
  int *list, *sorted;
  int rmed, lmed;
  tmp = (char *)malloc(sizeof(char) * 2000001);
  list = (int *)malloc(sizeof(int) * 200001);
  sorted = (int *)malloc(sizeof(int) * 200001);
  int i;
  scanf("%d\n", &nums);
  gets(tmp);
  split(list, tmp);
  memcpy(sorted, list, sizeof(int) * nums);
  qsort(sorted, nums, sizeof(int), cmp); // listをソート
  rmed = sorted[nums / 2];
  lmed = sorted[nums / 2 - 1]; // 正しい
  free(sorted);
  for (i = 0; i < nums; ++i) {
    if (list[i] <= lmed) {
      printf("%d\n", rmed);
    } else {
      printf("%d\n", lmed);
    }
  }
  free(tmp);
  free(list);
  return 0;
}

void split(int out[], char str[]) {
  int i;
  int out_i = 0, tmp_i = 0;
  char tmp[11] = {};
  for (i = 0; ; ++i) {
    if (str[i] == ' ') {
      out[out_i++] = atoi(tmp);
      memset(tmp, '\0', sizeof(tmp));
      tmp_i = 0;
    } else if (str[i] == '\0') {
      out[out_i] = atoi(tmp);
      break;
    } else {
      tmp[tmp_i++] = str[i];
    }
  }
}

int cmp(const void *p, const void *q) {
    return *(int*)p - *(int*)q;
}


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

int main() {
  int n;
  cin >> n;
  int four=0, odd=0, even=0;
  rep(i,n) {
    int m;
    cin >> m;
    if(m%4==0) four++;
    else if(m%2==0) even++;
    else odd++;
  }

  if(even%2!=0) cout << (odd<=four? "Yes" : "No") << endl;
  if(even%2==0) cout << (odd<=four+1? "Yes" : "No") << endl;

}


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

int main(){
	
	//use vector
	std::vector<int> height(10); // create height[10]
	
	// input
	for(int i = 0; i < 10; ++i){
		std::cin >> height[i];
	}
	
	//sort
	std::sort(height.begin(), height.end(), std::greater<int>());
	
	//output
	for(int i = 0; i < 3; ++i){
		std::cout << height[i] << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
#define mp make_pair
#define fi first
#define se second
using namespace std;
int i[111111];
vector<int> ii;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0,h,j;
  string s;
  cin >>a>>b;
  for(int n=0;n<a;n++){
    cin >>c;
    d+=min(c*2,(abs(b,c))*2);
  }
  cout <<d<<'\n';
  return (0);
}


Measured memory_bytes: 256
N = gets.to_i
A = Array.new(100001, 0)
sum = 0
line = gets.split(' ').map(&:to_i)

for num in 0..N-1 do
    n = line[num]
    A[n] += 1
    sum += n
end

Q = gets.to_i
q_line = []

for num in 0..Q-1 do
    q_line = gets.chomp.split(' ').map(&:to_i)
    B = q_line[0]
    C = q_line[1]
    b = A[B].to_i
    A[B] = 0
    sum += b * (C - B)
    A[C] += b
    puts sum
end

Measured memory_bytes: 42196
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var N = IO_ShortCut.ReadInt;
            long ans = 1;
            for (int i = 1; i <= N; i++)
            {
                ans = Mod.Multi(i, ans);
            }
            WriteLine(ans);
        }
    }

    public class IO_ShortCut
    {
        #region Input
        public static string ReadString => ReadLine();
        public static int ReadInt => int.Parse(ReadLine());
        public static long ReadLong => long.Parse(ReadLine());
        public static double ReadDouble => double.Parse(ReadLine());

        public static List<string> ReadSplitString => ReadLine().Split().ToList();
        public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
        public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
        public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        #endregion
    }

    /// <summary>
    /// 10^9+7で四則演算するときに使うクラス
    /// 正の数のみ対応
    /// </summary>
    public class Mod
    {
        // 割る数の定義
        private readonly static long M = 1000000007;

        // 足し算
        public static long Add(long a, long b)
        {
            var result = a + b;
            if (a + b < 0)
                return result % M == 0 ? result % M : result % M + M;
            else if (a + b >= M)
                return result % M;
            else
                return result;
        }
        // 引き算
        // 割られる数が負になると余りの定義的にダメなので実装
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        // 掛け算
        public static long Multi(long a, long b) => (a * b) % M;
    }

}

Measured memory_bytes: 11092
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

int main()
{
	stack<int> S1;
	stack<pair<int, int>> S2;
	char ch;
	int sum = 0;
	for (int i = 0; cin >> ch; i++)
	{
		if (ch =='\\' )
		{
			S1.push(i);
		}
		else if (ch == '/' && S1.size() > 0)
		{
			int j = S1.top(); S1.pop();
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j)
			{
				a += S2.top().second; S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}
	
	vector<int> ans;
	int  t = 0;
	while (S2.size() >0)
	{
		ans.push_back(S2.top().second);
		S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (int i = 0; i < ans.size(); i++)
	{
		cout << " ";
		t += ans.at(i);
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
	int N;
  	cin>>N;
  	int kuku[101];
  	
  	rep(i,101){
     	kuku[i] =0;
    }
  	
  	rep(i,9){
     	rep(j,9){
         	int product=(i+1)*(j+1);
          	kuku[product]++;
        }
    }
  	
  	if(kuku[N]) cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
  	
  	
  
  
}

Measured memory_bytes: 3592
/* 
 * Project: AtCoder Beginners Contest 072 B - OddString
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/10
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstring>
using namespace std;

char s[100000];

void solve() {
    
    int length = strlen(s);
    for (int i=0;i<length;i+=2) {
        printf("%c", s[i]);
    }
    printf("\n");

}

int main() {

    scanf("%s", s);

    solve();

}

Measured memory_bytes: 384
#include <stdio.h>


int main(int argc, const char * argv[]) {
    // insert code here...
    
    int accii[26] = {0};
    
    char c;
    while(scanf("%c",&c) != EOF){
        int small = c - 'a';
        int big = c - 'A';
        if(small >= 0 && small <= 25){
            accii[small]++;
        }
        else if(big >= 0 && big <= 25){
            accii[big]++;
        }
        
    }
    
    
    int i;
    for(i=0;i<26;i++){
        printf("%c : %d\n", i + 'a', accii[i]);
    }
    
    return 0;
}

Measured memory_bytes: 540
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

H, W, K = LI()
c = SRL(H)

ans=0
 
for i in range(2**H):
    seen=[]
    for n in range(H):
        if ((i>>n) & 1):
            seen.append(c[n])
    for j in range(2**W):
        count=0
        for m in range(W):
            if ((j>>m) & 1):
                for l in range(len(seen)):
                    if seen[l][m]=="#":
                        count+=1

        if count==K:
            ans+=1
print(ans)

Measured memory_bytes: 9344
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<queue>	

using namespace std;

namespace MyLib {
#define ALL(a) begin(a),end(a)
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
}
using namespace MyLib;


ll t[1000];
int main() {
	t[0] = 1;
	REP(i, 30)
		t[i + 1] = t[i] * 3;

	int n;
	cin >> n;

	int i;
	for (i = 0; i < 30; i++)
		if (t[i] >= n)
			break;
	cout << i << endl;



	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
using namespace std;
int k,a[109],l,m=0;
int main()
{
	cin>>l>>k;
	for(int i=0;i<k;i++)
	{
		cin>>a[i];
		m+=a[i];
	}
	sort(a,a+k);
	m-=a[k-1];
	m=a[k-1]-m-1;
	if(m>0)
		cout<<m;
	else
		cout<<0;
	cout<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

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

signed main(){
  string s; cin>>s;
	int q; cin>>q;
	int omote = 1;
	vector<char> front, back;
	rep(i,q){
		int t; cin>>t;
		if(t==1) omote = 1-omote;
		else{
			int f; cin>>f; char c; cin>>c; f--;
			if(omote!=f) front.PB(c);
			else back.PB(c);
		}
	}
	if(omote){
		REP(i,front.size()) cout<<front[i];
		cout<<s;
		rep(i,back.size()) cout<<back[i];
		cout<<endl;
	}else{
		REP(i,back.size()) cout<<back[i];
		REP(i,s.size()) cout<<s[i];
		rep(i,front.size()) cout<<front[i];
		cout<<endl;
	}
  return 0;
}


Measured memory_bytes: 976
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#endif

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cins(s);
	s[0] = s[0] + 1;
	cout << s << endl;
}

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



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int H,W;

long long dp[1010][1010]={};

long long  search(int h, int w){
if(h<0 || w<0)return 0;
if(dp[h][w]!=-1)return dp[h][w];
long long res;
res=search(h-1,w)+search(h,w-1);
if(res>mod)res%=mod;
return dp[h][w]=res;
}

int main(){
char c;
cin>>H>>W;
rep2(i,H){
    rep2(k,W){
        cin>>c;
        dp[i][k]=-1;
        if(c=='#')dp[i][k]=0;
    }
}
dp[1][1]=1;

long long ans=search(H,W);

cout<<ans<<endl;


 return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

int main(void)
{
  ll n; cin >> n;
  // ll x, y, z; cin >> x >> y >> z;
  // string s; cin >> s;
  vector<ll> a(n+1); REP(i, n+1) cin >> a[i];
  vector<ll> b(n); REP(i, n) cin >> b[i];
  ll ans = 0;
  // bool ok = false;

  REP(i, n) {
    ll r = 0;
    if(b[i] <= a[i]) {
      ans += b[i];
    } else {
      r = b[i] - a[i];
      ans += a[i];
      if(r >= a[i+1]) {
	ans += a[i+1];
	a[i+1] = 0;
      } else {
	ans += r;
	a[i+1] -= r;
      }
    }
  }
  
	   
  
  cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(){
   int x,y,a;
 
   scanf("%d %d",&x,&y);
   if (x==1) a=300000;
   else if (x==2) a=200000;
   else if (x==3) a=100000;
   else a=0;
   if (y==1) a+=300000;
   else if (y==2) a+=200000;
   else if (y==3) a+=100000;
   if (x==1 && y==1) a+=400000;
   printf("%d\n",a);
   return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P;
string S,T;
ll ans;
ll x[1000000];
ll y[1000000];
ll a[1000000];
ll b[1000000];
ll c[1000000];
ll t[1000000];
string s[10000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
int main() {
	cin>>N>>P;
	if(N==1){
		cout<<P<<endl;
	}else{
		ans=1;
		ll num=pow(P,1.0/(double)N);
		ll tmp=num;
		num++;
		for(int i=2;i<=num;i++){
			ll num1=P;
			rep(j,0,N){
				if(num1%i==0){
					num1/=i;
				}else{
					break;
				}
				if(j==N-1){
					ans=i;
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int const inf = 1<<29;
int N, M;
vector<int> a, b, c;
vector<vector<int>> dist;

void input(){
    cin >> N >> M;
    a.resize(M), b.resize(M), c.resize(M);
    dist.resize(N, vector<int>(N, inf));
    rep(i, N) dist[i][i] = 0;
    rep(i, M){
        cin >> a[i] >> b[i] >> c[i];
        --a[i]; --b[i];
        dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
    }
}

void floyd() {
    rep(k, N) {
        rep(i, N) {
            if(dist[i][k] == inf) continue;
            rep(j, N) {
                if(dist[k][j] == inf) continue;
                chmin(dist[i][j], dist[i][k]+dist[k][j]);
            }
        }
    }
}

void calc() {
    int cnt = 0;
    rep(i, M){
        bool shortest = false;
        rep(j, N){
            if(j != b[i] && dist[j][b[i]] == dist[j][a[i]]+c[i]) shortest = true;
            if(j != a[i] && dist[j][a[i]] == dist[j][b[i]]+c[i]) shortest = true;
        }
        if(!shortest) ++cnt; 
    }
    cout << cnt << endl;
}

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

    input();
    floyd();
    calc();


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(int argc, const char * argv[]) {
    int i,n;
    double sum=0,ave,s,sum2=0;
    double a[1000];
    while(1){
    scanf("%d",&n);
        if(n==0){
            break;
        }
    for(i=0;i<n;i++){
        scanf("%lf",&a[i]);
        sum+=a[i];
    }
    ave=sum/n;
    for(i=0;i<n;i++){
        sum2=sum2+(a[i]-ave)*(a[i]-ave);
    }
    sum2=sum2/n;
    s=sqrt(sum2);
    printf("%f\n",s);
        sum=0;
        sum2=0;
    }
    return 0;
}

Measured memory_bytes: 664
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set> 
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define ii pair<int, int>
#define f(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define sz(a) (int)(a).size()
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
int x[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int y[] = { -1, 0, 1, 0, 1, -1, -1, -1 };
const int MOD = 1e9 + 7, N = 2e5 + 5;
const double pi = acos(-1);

ll fact[N], inv[N];
ll fp(ll b, ll p)
{
	if (p == 0)
		return 1;
	ll ans = fp(b, p / 2);
	ans = (ans * ans) % MOD;

	if (p % 2 != 0)
		ans = (ans *(b % MOD)) % MOD;
	return ans;
}

void calc(ll n)
{
	fact[0] = inv[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		fact[i] = (i * fact[i - 1]) % MOD;
		inv[i] = fp(fact[i], MOD - 2);
	}
}

ll ncr(ll n, ll r)
{
	return ((fact[n] * inv[r]) % MOD * inv[n - r]) % MOD;
}

ll gcd(ll a, ll b)
{
	if (!a)return b;
	return gcd(b % a, a);
}

ll lcm(ll a, ll b)
{
	return (a * b) / gcd(a, b);
}

int main()
{
	assem99;

	int arr[N];
	int n, k; cin >> n >> k;
	calc(n);
	ll mn, mx, ans = 0;
	f(i, 0, n) cin >> arr[i];
	sort(arr, arr + n);
	f(i, 0, n)
	{
		if (i >= k - 1) mx = ncr(i, k - 1); else mx = 0;
		if (i <= n - k) mn = ncr((n - i) - 1, k - 1); else mn = 0;
		ll tmp = mx - mn;
		tmp = (tmp * arr[i]) % MOD;
		ans = (ans % MOD + tmp % MOD) % MOD;
	}
	cout << ans;

	return 0;
}

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

int main(){
    
    int zure;
    string str,the,thi,tha;
    
    the = "the";
    thi = "this";
    tha = "that";
    while(getline(cin,str)){
        for(int i=0;i<26;i++){
            
            for(int j=0;j<4;j++){
            
                if(j < 3) the[j] = 'a'+(the[j]-'a'+1)%26;
                thi[j] = 'a'+(thi[j]-'a'+1)%26;
                tha[j] = 'a'+(tha[j]-'a'+1)%26;
            
                if(str.find(the) != string::npos || str.find(thi) != string::npos || str.find(tha) != string::npos){
                    zure = (the[0]-'t'+26)%26;
                }
            
            }
        
        }
    
        for(int i=0;i<str.size();i++){
            if('a' <= str[i] && str[i] <= 'z'){
                str[i] = str[i]-zure;
                if(str[i] < 'a') str[i] += 26;
            }
        }
        cout << str << endl;
    }
    return(0);
}


Measured memory_bytes: 3184
class UF():
  def __init__(self, N):
    self._parent=[n for n in range(0, N)]
    self._size=[1] * N

  def find_root(self, x):
    if self._parent[x]==x:return x
    self._parent[x]=self.find_root(self._parent[x])
    return self._parent[x]

  def unite(self, x, y):
    gx=self.find_root(x)
    gy=self.find_root(y)
    if gx==gy:return

    if self._size[gx]<self._size[gy]:
      self._parent[gx]=gy
      self._size[gy]+=self._size[gx]
    else:
      self._parent[gy]=gx
      self._size[gx]+=self._size[gy]

  def size(self, x):
    return self._size[self.find_root(x)]

  def samegroup(self, x, y):
    return self.find_root(x)==self.find_root(y)

  def groupnum(self):
    N=len(self._parent)
    ans=0
    for i in range(N):
      if self.find_root(i)==i:
        ans+=1
    return ans

n,m=map(int,input().split())
UF=UF(n+m)
for i in range(n):
  l=list(map(int,input().split()))
  for j in range(1,l[0]+1):
    UF.unite(i,n+l[j]-1)
ct=0
for i in range(n,n+m):
  if UF.size(i)==1:
    ct+=1
if UF.groupnum()-ct==1:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 12592
h, w = map(int, input().split())
a = [input() for _ in range(h)]

row = []
column = []

for i in range(h):
    flag = 1
    first = "."
    for j in range(w):
        if a[i][j] != first:
            flag = 0
    if flag == 0:
        row.append(i)

for j in range(w):
    flag = 1
    first = "."
    for i in range(h):
        if a[i][j] != first:
            flag = 0
    if flag == 0:
        column.append(j)


for i in row:
    output = ""
    for j in column:
        output += a[i][j]
    if output != "":
        print(output)

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

using namespace std;

int main()
{
	int n,K;
	cin >> n >> K;
	int h[n+1];
	h[0] = 0;
	for(int i=1; i<=n; i++)  cin >> h[i];
	int dp[n+1];

	dp[0] = 10001;      // if h2 < h1 then it will fail if dp[0]=0.
	dp[1] = 0;
	for(int i=2; i<n+1; i++)
	{
		int min = dp[i-1] + abs(h[i]-h[i-1]);
		for(int k=2; i-k>0 && k<=K; k++)
		{
            int x = dp[i-k] + abs(h[i]-h[i-k]);
            if(x<min)  min = x;
		}

		dp[i] = min;
		

	}

	cout << dp[n] << endl;

}

Measured memory_bytes: 1024
// 054 AGC C - One-stroke Path 2017/02/11

#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

bool Graph[8][8] = {false};

int dfs(int x, int n , bool* visited){
    bool all_visited = true;
    rep(i ,n){
        if(visited[i] == false) all_visited = false;
    }
    if (all_visited) return 1;

    int ret = 0;
    for(int i=1;i<n;++i){
        if( Graph[x][i] == false ) continue;
        if( visited[i] == true ) continue;
        visited[i] = true;
        ret+=dfs(i , n , visited);
        visited[i] = false;
    }
    return ret;
}

int main(){
    int n , m; cin >> n >> m;
    bool visited[8]={false};
    rep(i ,m){
        int a , b;
        cin >> a >> b;
        Graph[a-1][b-1] = true;
        Graph[b-1][a-1] = true;
    }
    visited[0]=true;
    cout << dfs(0,n,visited) << endl;
}

Measured memory_bytes: 256