akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;

int keta(int N, int K) 
{
	int answer = 0;
	while (N > 0) 
	{
		N /= K;
		answer++;
	}
	return answer;
}

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

	cout << keta(N, K) << endl;

	return 0;
}

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

char T[550005];

// Based on editorial solution
int D[13][550005]; // one digit at a time, with digit 0 representing the ones place
int W[13][550005];
int lastUpdated[13][550005];

inline void putInt(int i){
    if(i==0){putchar_unlocked('0');}
    else{
    int x[11];
    int count1=0;
    while(i>0){
        x[count1++]=i%10;
        i/=10;
    }
    for(int j=count1-1;j>=0;j--){
        putchar_unlocked(48+x[j]);
    }
    }
    putchar_unlocked(' ');
}

int N;

void update(int n, int indx, int cntS){
    if((cntS&1) != (lastUpdated[n][indx]&1)){
        // conduct salsa
        if(D[n][indx] == 1){
            D[n][indx] = 2;
        }else if(D[n][indx] == 2){
            D[n][indx] = 1;
        }
    }
    // updated the lastUpdated index
    lastUpdated[n][indx] = cntS;
}

int pow3[16];

int main(){
    scanf("%d", &N);

    scanf(" %s", T);

    int M = strlen(T);

    pow3[0] = 1;
    for(int i = 1; i <= N; i ++){
        pow3[i] = pow3[i-1]*3;
    }

    int pow3N = pow3[N];

    //printf("ok");
    memset(W, 0, sizeof(W));
    for(int n = 1; n <= N; n ++){
        //printf("ok");
        for(int j = 0; j < pow3[N]; j ++){
            D[n][j] = (j%pow3[n])/pow3[n-1];
            //printf("D[%d][%d]=%d\n", n, j, D[n][j]);
        }
        W[n][0] = pow3[n]-1;
    }


    memset(lastUpdated, 0, sizeof(lastUpdated));
    int cntS2 = 0;
    for(int n = 1; n <= N; n ++){
        int cntS = 0;
        for(int i = 0; i < M; i ++){
            int indx0 = W[n-1][i];
            int indx1 = W[n-1][i]+pow3[n-1];
            if(indx1 >= pow3[n]){
                indx1 -= pow3[n];
            }
            int indx2 = W[n-1][i]+(pow3[n-1]<<1);
            if(indx2 >= pow3[n]){
                indx2 -= pow3[n];
            }

            update(n, indx0, cntS+(T[i]=='S'));
            update(n, indx1, cntS+(T[i]=='S'));
            update(n, indx2, cntS+(T[i]=='S'));
            if(D[n][indx0] == 2){
                W[n][i] = indx0;
            }else if(D[n][indx1] == 2){
                W[n][i] = indx1;
            }else{
                W[n][i] = indx2;
            }

            if(T[i] == 'R'){
                D[n][indx0] = (D[n][indx0]+1);
                D[n][indx1] = (D[n][indx1]+1);
                D[n][indx2] = (D[n][indx2]+1);
                if(D[n][indx0] == 3){D[n][indx0] = 0;}
                if(D[n][indx1] == 3){D[n][indx1] = 0;}
                if(D[n][indx2] == 3){D[n][indx2] = 0;}
                lastUpdated[n][indx0] = cntS;
                lastUpdated[n][indx1] = cntS;
                lastUpdated[n][indx2] = cntS;
            }else if(T[i] == 'S'){
                cntS ++;
            }

            //printf("W[%d][%d]=%d\n", n, i+1, W[n][i+1]);
        }

        cntS2 = cntS;
    }

    for(int n = 1; n <= N; n ++){
        for(int i = 0; i < pow3[n]; i ++){
            update(n, i, cntS2);
        }
    }

    for(int i = 0; i < pow3[N]; i ++){
        int temp = 0;
        for(int n = 1; n <= N; n ++){
            temp += D[n][i%pow3[n]]*pow3[n-1];
        }
        putInt(temp);
    }

    return 0;
}


Measured memory_bytes: 85132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

ll dp[100010];

int main(){
    int n,m;
    cin>>n>>m;
    vector<bool> ok(100010,true);
    rep(i,m){
        int a;
        cin>>a;
        ok[a]=false;
    }

    dp[0]=1;
    rep(i,n){
        if(!ok[i]) continue;
        dp[i+1]=(dp[i+1]+dp[i])%MOD;
        dp[i+2]=(dp[i+2]+dp[i])%MOD;
    }

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

Measured memory_bytes: 4400
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define rep(i,j,k) for(int i=j; i<k; ++i)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io 
	string s[]={ "MON", "TUE", "WED", "THU", "FRI", "SAT","SUN"};
	string d; cin>>d;
	int h=-1;
	rep(i,0,6){
		if(d==s[i]){
			h=i;
			break;
		}
	}
	cout<<(6-h);
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main(void) {
    int n, m; cin >> n >> m;
    vector<int> e(m);
    set<int> used;
    for (int i = 0; i < m; i++) cin >> e[i];

    for (int i = m-1; i >= 0; i--) {
        auto r = used.insert(e[i]);
        if (r.second) {
            cout << e[i] << endl;
        }
    }

    for (int i = 1; i <= n; i++) {
        int r = used.count(i);
        if (r == 0) {
            cout << i << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 7832
from math import ceil

li = []

for i in range(5):
    tmp = int(input())
    li.append(tmp)

li_sorted = sorted(li, key=lambda digit: digit % 10)

last_flag = False

ans = 0
for i in li_sorted:
    if i % 10 == 0:
        ans += i
    elif last_flag is False:
        last_flag = True
        ans += i
    else:
        ans += i + 10 - (i % 10)

print(ans)

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

template<typename T> T gcd(T a, T b) {
    if(!b) return a;
    return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned long long uInt;
typedef unsigned uint;

int main(void) {
    int A, B;
    
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B)) << "\n";

    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

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

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

    int n,w;

    while(cin>>n>>w,n)
    {
        int a[11]={0},cnt=0,M=0; //度数、区間の数、度数の最大値
        REP(i,n){
            int b; cin>>b;
            a[b/w]++;
            cnt=max(cnt,b/w+1);
        }
        REP(i,cnt) M=max(M,a[i]);

        int sum=0;
        REP(i,cnt){
            sum+=(cnt-i-1)*a[i];
        }
        cout<<(double)sum/((cnt-1)*M)+0.01<<endl;
    }

}



Measured memory_bytes: 3260
import bisect
import sys
input = sys.stdin.readline

def main():
    a,b,q = map(int,input().split())
    s = []
    t = []
    s1 = []
    t1 = []

    for _ in range(a):
        s.append(int(input()))
    for _ in range(b):
        t.append(int(input()))

    for i in range(a-1):
        s1.append((s[i]+s[i+1])/2)
    for i in range(b-1):
        t1.append((t[i]+t[i+1])/2)

    for _ in range(q):
        x = int(input())
        s_index = bisect.bisect_left(s1, x)
        t_index = bisect.bisect_left(t1, x)
        xs = []
        xt = []
        for i in range(-2, 3):
            if 0 <= s_index + i < a:
                xs.append(s[s_index+i])
            if 0 <= t_index + i < b:
                xt.append(t[t_index+i])
        ans = 10**20
        for i in xs:
            for j in xt:
                ans = min(ans, abs(x-i) + abs(i-j), abs(x-j) + abs(j-i))

        print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 73308
r, c = map(int, input().split())

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

for i in range(r):
    matrix[i].append(sum(matrix[i]))

matrix.append(list(map(sum, zip(*matrix))))
# matrix.append([sum(i) for i in zip(*matrix)])

for row in matrix:
    print(' '.join(str(e) for e in row))


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

int main(){
    int x;
    cin >> x;
    int ans = 1;
    int b = 1800;
    while(true){
        if(x >= b){
            cout << ans << endl;
            return 0;
        }
        b -= 200;
        ans++;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = 555;
const int 
    di[] = {0,1,0,-1},
    dj[] = {1,0,-1,0}; 

int n, dist[N][N];
bool gone[N][N];

void dfs(int i, int j, int d) {
    if (dist[i][j] <= d) return;
    dist[i][j] = d;
    forn(dir,4) {
        int ni = i + di[dir], nj = j + dj[dir];
        if (ni < 0 || ni >= n || nj < 0 || nj >= n) continue;
        dfs(ni, nj, d + !gone[ni][nj]);
    }
}
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    forn(i,n) forn(j,n) 
        dist[i][j] = min(min(i+1,j+1), min(n-i, n-j));

    ll ans = 0;
    forn(_,n*n) {
        int x; cin >> x;
        --x;
        int i = x/n, j = x%n;
        assert(dist[i][j] > 0);
        ans += dist[i][j] - 1;
        dfs(i,j,dist[i][j]-1);
        gone[i][j] = true;
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 20400
def change(hoge):
    if hoge == 'A':
        return 'X'
    if hoge == 'B':
        return 'Y'
    if hoge == 'C':
        return 'Z'
    if hoge == 'D':
        return 'A'
    if hoge == 'E':
        return 'B'
    if hoge == 'F':
        return 'C'
    if hoge == 'G':
        return 'D'
    if hoge == 'H':
        return 'E'
    if hoge == 'I':
        return 'F'
    if hoge == 'J':
        return 'G'
    if hoge == 'K':
        return 'H'
    if hoge == 'L':
        return 'I'
    if hoge == 'M':
        return 'J'
    if hoge == 'N':
        return 'K'
    if hoge == 'O':
        return 'L'
    if hoge == 'P':
        return 'M'
    if hoge == 'Q':
        return 'N'
    if hoge == 'R':
        return 'O'
    if hoge == 'S':
        return 'P'
    if hoge == 'T':
        return 'Q'
    if hoge == 'U':
        return 'R'
    if hoge == 'V':
        return 'S'
    if hoge == 'W':
        return 'T'
    if hoge == 'X':
        return 'U'
    if hoge == 'Y':
        return 'V'
    if hoge == 'Z':
        return 'W' 

before = list(raw_input())
after = []
for i in range(len(before)):
    after.append(change(before[i]))
print ''.join(after)


Measured memory_bytes: 4288
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> l(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> l[i];
    }
    sort(ALL(l));
    ll sum = 0;
    for (ll i = n - 1; i > 1; i--)
    {
        for (ll k = i - 1; k > 0; k--)
        {
            auto itr = l.begin() + k - upper_bound(l.begin(), l.begin() + k, l[i] - l[k]);
            sum += itr;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
// InsertionSort.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <vector>
using namespace std;

int insertionSort(
    vector<int> &list
) {
    for (int i = 0; i < list.size(); ++i) {
        auto tmp = list[i];
        for (int j = i - 1; j >= 0; --j) {
            if (tmp < list[j]) {
                list[j + 1] = list[j];
                list[j] = tmp;
            }
        }
        for (int j = 0; j < list.size(); ++j) {
            cout << list[j];
            if (j != (list.size() - 1)) {
                cout << " ";
            }
            else{
                cout << endl;
            }
        }
    }
    return 0;
}

int main()
{
    int num, a;
    cin >> num;
    vector<int> list;
    for (int i = 0; i < num; ++i) {
        cin >> a;
        list.push_back(a);
    }
    insertionSort(list);
    return 0;
}



Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#define ll long long
const ll mod = 1e+9;
using namespace std;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
int main(){
    string s;   cin >> s;
    int n=s.length();
    if(s[n-2] == 'B') cout << "ARC\n";
    else cout << "ABC\n";
return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using ll = long long;

int main() {
    int n;
    n = 5;
    vi a(n);
    rep(i, n) cin >> a.at(i);

    rep(i, n) {
        if (a.at(i) == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }

    //rep (i, n) {
    //    cout << a.at(i) << endl;
    //}
}

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

int  main()
{
	long a,b,c,d;
	long max = LONG_MIN;
	cin >> a >> b >> c >> d;
	long A, B, C, D;
	A = a * c;
	B = a * d;
	C = b * c;
	D = b * d;
	priority_queue<long> pq;
	pq.push(A);
	pq.push(B);
	pq.push(C);
	pq.push(D);
	cout << pq.top() << endl;
	return (0);
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main(){
  int n, h, w; cin >> n >> h >> w;
  
  int cnt = 0;
  REP(i, n)REP(j, n){
    if(i + h > n || j + w > n) continue;
    cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
//greaterで必要
#include <functional>
//重複チェック
#include <set>


using namespace std;
typedef long long ll;
ll N;
ll M;
ll r;
ll INF = 1<<28;


int main() {
    //頂点数
    cin >> N;
    string S;
    cin >> S;

    int r = 0;
    int b = 0;
    for(int i= 0; i < N; i++){
        if(S.substr(i,1) == "R"){
            r++;
        }else{
            b++;
        }
    }

    if(r > b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

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

using namespace std;

typedef long long ll;

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;
}

const ll MAX_N = 200000LL;
const ll MAX_A = 1000000LL;
const ll MAX_F = 1000000LL;
const ll MAX_SCORE = MAX_A * MAX_F;

vector<ll> A, F, B;

bool check(const ll score, const ll N, const ll K) {
    ll remain = K;
    // printf("score: %lld\n", score);
    for (int i = 0; i < N; i++) {
        ll required = max(0LL, (B[i] - score + F[i] - 1) / F[i]);
        // printf("%d: B = %lld, F = %lld, required = %lld\n", i, B[i], F[i], required);
        remain -= required;
        if (remain < 0) return false;
    }
    return true;
}

ll solve(const ll N, const ll K) {
    ll left = -1LL, right = MAX_SCORE + 1LL, mid;
    while (right - left > 1) {
        mid = left + (right - left) / 2; // (right + left) / 2 may cause overflow
        if (check(mid, N, K)) right = mid;
        else left = mid;
    }
    return right;
}

int main(void) {
    ll N, K;
    cin >> N >> K;

    A.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    F.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> F[i];
    }
    sort(F.begin(), F.end());
    reverse(F.begin(), F.end());

    B.resize(N);
    for (int i = 0; i < N; i++) {
        B[i] = A[i] * F[i];
    }

    cout << solve(N, K) << endl;

    return 0;
}


Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl;
  for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

// const int SIZE = 3e5+1;
// vector<vector<bool>> is_bomb(SIZE, vector<bool>(SIZE, false));//グローバルにしてもREした
// bool is_bomb[300000][300000];
int main(){
  int H, W;
  cin >> H >> W;
  int M;
  cin >> M;

  // vector<vector<bool>> is_bomb(H, vector<bool>(W, false));// 配列がでかすぎるとREになるらしい  かわりにmapでやってみる
  using P = pair<int, int>;
  map<P, int> mp;
  vector<int> num_h(H, 0), num_w(W, 0);
  for(int i=0; i<M; i++){
    int h, w;
    cin >> h >> w;
    h--; w--;
    // is_bomb[h][w] = true;
    mp[P(h, w)]++;
    num_h[h]++;
    num_w[w]++;
  }
  
  int h_num_max = 0, w_num_max = 0;
  for(int i=0; i<H; i++) h_num_max = max(h_num_max, num_h[i]);
  for(int i=0; i<W; i++) w_num_max = max(w_num_max, num_w[i]);

  vector<int> maxs_h, maxs_w;
  for(int i=0; i<H; i++) if(num_h[i] == h_num_max) maxs_h.emplace_back(i);
  for(int i=0; i<W; i++) if(num_w[i] == w_num_max) maxs_w.emplace_back(i);

  int ans = 0;
  for(int i=0; i<(int)maxs_h.size(); i++){
    for(int j=0; j<(int)maxs_w.size(); j++){
        int tmp = num_h[maxs_h[i]] + num_w[maxs_w[j]];
        // if(is_bomb[maxs_h[i]][maxs_w[j]] == true) tmp--;
        if(mp[P(maxs_h[i],maxs_w[j])]) tmp--;
        else{
          cout << tmp << endl;
          return 0;//これいれんとTLEになった
        }
        ans = max(ans, tmp);
    }
  }

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


Measured memory_bytes: 28468
def main():
    N = int(input())
    S = input()
    W = [0] * (N + 1)
    E = [0] * (N + 1)

    for i in range(N):
        if S[i] == 'W':
            W[i + 1] = W[i] + 1
            E[i + 1] = E[i]
        else:
            W[i + 1] = W[i]
            E[i + 1] = E[i] + 1

    ans = float('inf')
    for i in range(N):
        ans = min(ans, W[i] + E[N] - E[i+1])
    
    print(ans)
        

main()

Measured memory_bytes: 45552
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main() {
	int n, t;
	int maxx, minn;
	scanf("%d", &n);
	scanf("%d", &t);
	maxx = -1000000001; minn = t;
	for (int i = 1; i < n; i++) {
		scanf("%d", &t);
		// ?????´??°??????????????§???
		maxx = maxx < t - minn ? t - minn : maxx;
		// ?????´??°??????????°????
		minn = minn > t ? t : minn;
	}
	printf("%d\n", maxx);
}

Measured memory_bytes: 3228
n, y = [int(x) for x in input().split()]
for i in range(n+1):
    for j in range(n - i + 1):
        if 10000*i + 5000*j + 1000*(n - i - j) == y:
            print(i, j, n - i - j)
            exit()
print(-1,-1,-1)

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

keta = len(str(n))
cnt = 0

for i in range(keta):
    if i%2 != 0: #odd
        cnt += 10**i - 10**(i-1)
    if i == keta-1 and keta%2 != 0:
        cnt += n - 10**(keta-1) + 1

print(cnt)

Measured memory_bytes: 9076
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;

int main()
{


   int n,a,b;
   scanf("%d",&n);
  int t=n;
  int cnt = 0;
  while(t)
  {
      cnt+=t%10;
      t/=10;
  }
  if(n%cnt==0)
    printf("Yes\n");
  else printf("No\n");


    return 0;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int n,a,b;
  while(cin >> n >> a >> b){
    int ans = min(b,n*a);
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
public:
  ll *fac,*finv,*inv;
//public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int n;
  string s;
  cin >> n >> s;
  vector<int> red,green,blue;
  for(int i=0;i<n;i++){
    if(s[i] == 'R') red.push_back(i);
    else if(s[i] == 'G') green.push_back(i);
    else blue.push_back(i);
  }
  ll ans = 0;
  for(int i=0;i<red.size();i++){
    for(int j=0;j<green.size();j++){
      if(blue.size() == 0) break;
      ans += blue.size();
      if(red[i] < green[j]){
        auto itr = lower_bound(blue.begin(),blue.end(),green[j]+(green[j]-red[i]));
        if(*itr == green[j]+(green[j]-red[i])) ans--;
        itr = lower_bound(blue.begin(),blue.end(),red[i]-(green[j]-red[i]));
        if(*itr == red[i]-(green[j]-red[i])) ans--;
        if((red[i]+green[j])%2 == 0){
          itr = lower_bound(blue.begin(),blue.end(),(red[i]+green[j])/2);
          if(*itr == (red[i]+green[j])/2) ans--;
        }
      }
      else{
        auto itr = lower_bound(blue.begin(),blue.end(),red[i]+(red[i]-green[j]));
        if(*itr == red[i]+(red[i]-green[j])) ans--;
        itr = lower_bound(blue.begin(),blue.end(),green[j]-(red[i]-green[j]));
        if(*itr == green[j]-(red[i]-green[j])) ans--;
        if((red[i]+green[j])%2 == 0){
          itr = lower_bound(blue.begin(),blue.end(),(red[i]+green[j])/2);
          if(*itr == (red[i]+green[j])/2) ans--;
        }
      }

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


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

int x;

int mySet(int d,int e){
	int a=0;
	if(d==4){
		if(e==x){
			return 1;
		}else{
			return 0;
		}
}
	for(int i=0;i<=9;i++){
		a+=mySet(d+1,e+i);
	}
	return a;
}

int main(void){
	while(scanf("%d",&x)!=EOF){
		cout<<mySet(0,0)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3164
def kai(a):
    x=a
    for i in range(a-1,1,-1):
        x*=i
    return x

n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))

a=[i for i in range(1,n+1)]
b=[i for i in range(1,n+1)]

cnt_1=0
cnt_2=0

for i in range(n-2):
    cnt_1+=kai(n-i-1)*(a.index(p[i]))
    cnt_2+=kai(n-i-1)*(b.index(q[i]))
    a.remove(p[i])
    b.remove(q[i])

if p[-2]>p[-1]:
    cnt_1+=1

if q[-2]>q[-1]:
    cnt_2+=1

print(abs(cnt_1-cnt_2))

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
    int a,b,C;
    double S,L,h,rad;

    cin>>a>>b>>C;
    rad=C*acos(-1)/180.0;
    h=b*sin(rad);
    S=a*h/2.0;
    L=sqrt(a*a+b*b-2*a*b*cos(rad))+a+b;
    cout<<fixed<<setprecision(8)<<S<<'\n';
    cout<<fixed<<setprecision(8)<<L<<'\n';
    cout<<fixed<<setprecision(8)<<h<<'\n';

}


Measured memory_bytes: 3568
import static java.lang.Integer.parseInt;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * A Thief (0-1 Knapsack problem)
 */
public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int c = 0;
		while (!(line = br.readLine()).equals("0")) {
			c++;
			int w = parseInt(line);
			int n = parseInt(br.readLine());

			int[] vs = new int[n + 1];
			int[] ws = new int[n + 1];

			for (int i = 1; i < n + 1; i++) {
				line = br.readLine();
				vs[i] = parseInt(line.substring(0, line.indexOf(',')));
				ws[i] = parseInt(line.substring(line.indexOf(',') + 1));
			}

			int[][] dp = new int[2][w + 1];
			for (int i = 1; i < n + 1; i++) {
				for (int j = 1; j < w + 1; j++) {
					dp[0][j] = dp[1][j];
					if (j >= ws[i]) {
						dp[1][j] = Math.max(dp[0][j - ws[i]] + vs[i], dp[0][j]);
					}
				}
			}

			int maxv = 0;
			int minw = w;
			for (int i = 1; i < w + 1; i++) {
				if (dp[1][i] > maxv) {
					maxv = dp[1][i];
					minw = i;
				}
			}
			System.out.print("Case " + c + ":\n" + maxv + "\n" + minw + "\n");
		}

	}

}

Measured memory_bytes: 22160
import java.util.Scanner;
import java.awt.image.BandedSampleModel;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {


    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int h=sc.nextInt();
        int w=sc.nextInt();
        int m=sc.nextInt();
        Map<String,Integer> map=new HashMap<>();
        int r[]=new int[h];
        int c[]=new int[w];
        int marr[][]=new int[m][2];
        for(int i=0;i<m;i++)
        {
            int x=sc.nextInt()-1;
            int y=sc.nextInt()-1;
            marr[i][0]=x;
            marr[i][1]=y;
            map.put(x+" "+y,1);
            r[x]++;
            c[y]++;
        }
//        Arrays.sort(r);
//        Arrays.sort(c);
        //System.out.println((r[h-1]+c[w-1]));
        int mr=0;
        int mc=0;
        for(int i=0;i<h;i++)
        {
            mr=Math.max(mr,r[i]);
        }
        for(int i=0;i<w;i++)
        {
            mc=Math.max(mc,c[i]);
        }

        int s1=0;
        int s2=0;
        for(int i=0;i<h;i++)
        {
            if(r[i]==mr)
            {
                s1++;
            }
        }
        for(int i=0;i<w;i++)
        {
            if(c[i]==mc)
            {
                s2++;
            }
        }
        int ans=mc+mr;
        long d=0;
        for(int i=0;i<m;i++)
        {
            if(r[marr[i][0]]+c[marr[i][1]]==(mc+mr))
            {
                d++;
            }
        }
        if((long)(d)<((long)s1)*((long)s2))
        {
            System.out.println(ans);
        }
        else
        {
            System.out.println(ans-1);
        }

    }
}


Measured memory_bytes: 103268
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;

const ll MAXN = 1e5 + 100;
ll n, a[MAXN], pref[MAXN];

bool used[MAXN];

int main() {

cin >> n;

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

sort(a + 1, a + 1 + n);

for(int i = 1; i <= n; ++i) {
    
    pref[i] = pref[i - 1] + a[i]; 
    
}

ll ans = 1;
used[n] = 1;

for(int i = n - 1; i >= 1; --i) {
    
    if(pref[i] * 2 >= a[i + 1]) {
        
        used[i] = used[i + 1];
        
        
    }
    
    if(used[i]) {ans++;}
    
}

cout << ans;

return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    vector<pair<int,int>> V(N);

    rep(i,N) {
        int a, b; cin >> a >> b;
        V[i] = {a,b};
    }
    sort(V.begin(), V.end(), [](auto&& a, auto&& b){
        return (a.first + a.second) > (b.first + b.second);
    });
    ll sumA = 0, sumB = 0;
    rep(i,N) {
        if (i % 2 == 0) sumA += V[i].first; else sumB += V[i].second;
    }
    cout << sumA - sumB << endl;
}


Measured memory_bytes: 3980
f = lambda : map(int, input().split())

n, m = f()
ll = [[0]*n for i in range(m)]
for i in range(m):
  k, *t = f()
  for j in range(k):
    ll[i][t[j]-1] = 1
lp = list(f())

import itertools as it
ans = 0

for p in it.product([0,1], repeat=n):
  if lp == [sum(a*b for a, b in zip(p,l))%2 for l in ll]:
    ans += 1

print(ans)

Measured memory_bytes: 3064
#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 uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.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(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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;}
}

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

ll dp[50]; // dp[i]: i段目まで上る方法の数

void init() {
   dp[0] = 1;
   for (int i = 0; i <= 30; i++) {
      dp[i+1] += dp[i];
      dp[i+2] += dp[i];
      dp[i+3] += dp[i];
   }
}

int main() {
   init();
   while (1) {
      int n;
      cin >> n;
      if (!n) break;
      ll day = max(1LL, dp[n] / 10);
      // debug(day)
      cout << day / 365 + (day%365 != 0) << endl;
      // line()
   }

   return 0;
}


Measured memory_bytes: 3000
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,y;
  cin>>x>>y;
  if(y%2==0)
  {
    if(ceil(double(y)/x)<=4&&floor(double(y)/x)>=2)
      cout<<"Yes";
    else
      cout<<"No";
  }
  else
  cout<<"No";
}


Measured memory_bytes: 3716
A,B,C,D = map(str,list(input()))

for op1 in ["+","-"]:
  for op2 in ["+","-"]:
    for op3 in ["+","-"]:
      if eval(A+op1+B+op2+C+op3+D) == 7:
        ans = A+op1+B+op2+C+op3+D+"=7"
        break
print(ans)

Measured memory_bytes: 9100
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

int main() {
    ll x,y;
    cin >> x >> y;
    ll ans=0;
    if(llabs(x)<=llabs(y)){
        ans+=llabs(y)-llabs(x);
        if(x<0 && y<0) ans+=2;
        else if(x<0 || y<0) ans+=1;
    }
    else{
        ans+=llabs(x)-llabs(y);
        if(x>0 && y>0) ans+=2;
        else if(x>0 || y>0) ans+=1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

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

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> myds;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define F first
#define S second
#define vec(x) vector<x> 
#define pi(x,y) pair<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repd(i,x,y,k) for(int i=x;i<y;i+=k)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define rev(x) reverse(all(x))
#define uniq(x) x.resize(distance(x.begin(),unique(all(x))))
#define full(x,a) memset(x,a,sizeof(x))
#define lcm(x,y) ((x*y)/__gcd(x,y))
#define mod 1000000007
#define bitcount __builtin_popcountll
#define pb push_back
#define indexof order_of_key
#define valueat find_by_order

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

int gcdextended(int a,int b,int &x,int &y){if(!a){x=0,y=1;return b;}int x1,y1;int ans=gcdextended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return ans;}
int inv(int a){int x,y;int ans=gcdextended(a,mod,x,y);return(x%mod+mod)%mod;}
int nCr(int n,int k){int res=1;k=(k>n-k)?n-k:k;rep(i,0,k){res*=(n-i);res/=(i+1);}return res;}
int POW(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res%mod*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
//void seive(){prime[0]=0;prime[1]=0;rep(i,2,10002)prime[i]=1;for(int i=2;i*i<=10000;i++){if(prime[i]){for(int j=i*i;j<=10000;j+=i)prime[j]=0;}}} 

const int N=100005;

int n,m,k;
int frnd[N],blck[N];
int par[N],sz[N];

void init(){
	rep(i,0,N){
		par[i]=i;
		sz[i]=1;
	}
}

int find(int x){
	if(par[x]!=x)
		par[x]=find(par[x]);
	return par[x];
}

void merge(int x,int y){
	int xr=find(x),yr=find(y);
	if(xr==yr)
		return;
	if(sz[xr]>=sz[yr]){
		par[yr]=xr;
		sz[xr]+=sz[yr];
	}
	else{
		par[xr]=yr;
		sz[yr]+=sz[xr];
	}
}

void input(){
	cin>>n>>m>>k;
	init();
	rep(i,0,m){
		int x,y;
		cin>>x>>y;
		frnd[x]++;
		frnd[y]++;
		merge(x,y);
	}
	rep(i,0,k){
		int x,y;
		cin>>x>>y;
		if(find(x)==find(y)){
			blck[x]++;
			blck[y]++;
		}
	}
}

void solve(){
	rep(i,1,n+1)
		cout<<sz[find(i)]-1-frnd[i]-blck[i]<<" ";
	cout<<endl;
}

main(){
	fastio;
	int t=1;
	while(t--){
		input();
		solve();
	}
}

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

int main() {
  int A,B,C,D,E; cin >> A >> B >> C >> D >> E;
  int diff = max({(A+9)/10*10 - A, (B+9)/10*10 - B, (C+9)/10*10 - C, (D+9)/10*10 - D, (E+9)/10*10 - E});
  int ans = (A+9)/10*10 + (B+9)/10*10 + (C+9)/10*10 + (D+9)/10*10 + (E+9)/10*10 - diff;
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[0].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int N; cin >> N;
    vec D(N); readv(D);
    SORT(D);

    int cnt[24];
    fill(cnt, cnt + 24, 0);
    cnt[0] = 1;

    REP(i, N){
        if(i % 2 == 0) cnt[D[i]]++;
        else cnt[24 - D[i]]++;
    }
    int ans = INF;
    REP(i, 24) REP(j, i) if(cnt[i] > 0 && cnt[j] > 0) ans = min(ans, llabs(i - j));
    REP(i, 24) if(cnt[i] >= 2) ans = 0;
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 998244353
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,Pll> a,pair<ll,Pll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se.fi>b.se.fi;
}
//----------------------------------------------------------------------
double abtoc(double a,double b,double c){
    //cout<<cos(c)<<endl;
    //cout<<(double)a*a+b*b-2*a*b*cos(c)<<endl;
    return pow(a*a+b*b-2*a*b*cos(c*PI/180.0),0.5);
}
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //-------------------------------
    int a,b,h,m;cin>>a>>b>>h>>m;
    double aa=a;
    double bb=b;
    double enger=0;
    double e1=(double)h*(360.0/12.0)+30.0*((double)m/60.0);
    double e2=360*((double)m/60.0);
    enger = mmax(e1,e2)-mmin(e1,e2);
    if(enger>180.0){
        enger=360.0-enger;
    }

    //cout<<aa<<" "<<bb<<endl;
    printf("%.11lf\n",abtoc(aa,bb,enger));
    //-------------------------------  
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------






















































Measured memory_bytes: 4312
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int x; cin >> x;

    int ans = x / 11 * 2;
    if(x % 11 != 0) {
        if(x % 11 > 6) ans += 2;
        else ans++;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

int main() {
    int N, M; string S, T; cin >> N >> M >> S >> T;
    ll L = lcm(N, M);

    map<ll, char> m;
    REP(i, 0, N) m[L / N * i + 1] = S[i];
    REP(i, 0, M) {
        if (m[L / M * i + 1] != 0 && m[L / M * i + 1] != T[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << L << endl;
    return 0;
}

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

const int MAX_STRING = 1000000+1;

string s;

string p_expr(int &p);

int p_number(int &p)
{
  int res = 0;
  while (isdigit(s[p])) {
    res *= 10;
    res += s[p++] - '0';
  }
  return res;
}

string p_character(int &p)
{
  string res = "";
  while (isalpha(s[p]))
    res += s[p++];
  return res;
}

string p_term(int &p)
{
  if (isalpha(s[p])) {
    return p_character(p);
  } else {
    int num = p_number(p);
    string t = "";
    if (s[p] == '(') {
      ++p;
      t = p_expr(p);
      ++p;
    } else {
      t = p_character(p);
    }
    string res = "";
    for (int i = 0; i < num && res.size() < MAX_STRING; ++i)
      res += t;
    return res;
  }
}

string p_expr(int &p)
{
  string res = p_term(p);
  while (p < s.size() && s[p] != ')')
    res += p_term(p);
  return res;
}

int main()
{
  int i;
  while (cin >> s >> i) {
    if (s == "0" && i == 0)
      break;

    int p = 0;
    string ans = p_expr(p);
    if (i < ans.size())
      cout << ans[i] << endl;
    else
      cout << "0" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
h, w = map(int, input().split())
list_C = [ list(map(int,input().split(" "))) for i in range(10)]
list_A = [ list(map(int,input().split(" "))) for i in range(h)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            list_C[i][j] = min(list_C[i][j], list_C[i][k]+list_C[k][j])
ans = 0
for i in range(h):
    for j in range(w):
        num = list_A[i][j]
        if num != -1:
            ans += list_C[num][1]
print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const ll INF = 1ll << 60;
const int MAXN = 2e6 + 10;

int n, m;
int q;
ll mn, mx;

vector<PII> E[MAXN], F[MAXN];

void read(){
	scanf("%d%d", &n, &m);
	scanf("%d", &q);
	for(int i = 1; i <= n; i++)
		E[i].clear();
	for(int i = 1; i <= m; i++)
		F[i].clear();//, deg[i] = 0;
	for(int i = 1; i <= q; i++){
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z);
		E[x].push_back(PII(y, z));
	}
	for(int i = 1; i <= n; i++)
		sort(E[i].begin(), E[i].end());
	for(int i = 1; i <= n; i++){
		for(int j = 1; j < E[i].size(); j++){
			F[E[i][j-1].first].push_back(PII(E[i][j].first, E[i][j].second - E[i][j-1].second));
			F[E[i][j].first].push_back(PII(E[i][j-1].first, E[i][j-1].second - E[i][j].second));
		//	deg[E[i][j].first]++;
		}	
	}
//	puts("=-=");
}

ll dis[MAXN];
int FG[MAXN];
ll _mn[MAXN], _mx[MAXN];

int dfs(int u, int cnt){
	for(int i = 0; i < F[u].size(); i++){
		int v = F[u][i].first;
		if (dis[v] == INF){
			dis[v] = dis[u] + F[u][i].second;
			FG[v] = cnt;
			mn = min(mn, dis[v]);
			mx = max(mx, dis[v]);
			if (!dfs(v, cnt)) return 0;
		}
		else{
			if (dis[v] != dis[u] + F[u][i].second)
				return 0;
		}
	}
	return 1;
}

int solve(){
	for(int i = 1; i <= m; i++)
		dis[i] = INF, FG[i] = 0;
	int cnt = 0;
	for(int i = 1; i <= m; i++)
		if (dis[i] == INF){
			dis[i] = 0;
			FG[i] = ++cnt;
			mn = 0, mx = 0;
			if (!dfs(i, cnt))
				return 0;
			if (mx - mn > 1000000000)
				return 0;
			_mn[cnt] = mn, _mx[cnt] = mx;
		}
	for(int i = 1; i <= n; i++){
		int x = i;
		for(int j = 0; j < E[i].size(); j++){
			int y = E[i][j].first, z = E[i][j].second;
			if (z - dis[y] + _mn[FG[y]] < 0) return 0;
			if (z - dis[y] + _mx[FG[y]] > 1000000000) return 0;
		}
	}
	return 1;
	/*
	for(int i = 1; i <= m; i++){
		int flag = -1;
		ll Nico = 0;
		for(int j = 0; j < F[i].size(); j++){
			int x = F[i][j].first, y = F[i][j].second;
			if (dis[x] != -1) {
				if (flag == -1)
					Nico = dis[x] - y;
				else{
					if (Nico != dis[x] - y) return 0;
				}
				if (dis[i] + y != dis[x]) return 0;
			}
		}
	}
	*/
}

void printans(int flag){
	puts(flag ? "Yes" : "No");
}
	

int main(){
	int T = 1;
//	cin>>T;
	while(T--){
		read();
		printans(solve());
	}
	return 0;
} 


Measured memory_bytes: 103424
#include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
#define LEN 100005
using namespace std;
int A[1000000],n;

int binarySearch(int key){
    int left = 0,right = n,mid;
    while( left < right){
        mid = (left + right)/2;
        if(key == A[mid])return 1;
        if(key > A[mid])left = mid + 1;
        else if(key < A[mid])right = mid;
    }
    return 0;
}
int main(){
    int q,key,sum = 0;
    cin >> n;
    for(int i = 0; i < n; i++)cin >> A[i];
    
    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> key;
        if(binarySearch(key))sum++;
    }
    cout << sum << endl;
    return 0;
}




Measured memory_bytes: 3476