akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <ostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
typedef unsigned long long ll;
using namespace std;
const int maxn = 100000 + 7;
ll num[maxn];
ll stu[maxn];
ll sum[maxn];
int main()
{
    int n;
    ll t;
    memset(sum,0,sizeof(sum));
    scanf("%d%lld",&n,&t);
    ll maxx = 0;
    sum[0] = 0;
    ll pos;
    for(int i = 1;i<=n;i++){
        scanf("%lld",&stu[i]);
        sum[i] = sum[i-1] + stu[i];
        maxx = max(maxx,stu[i]);
        if(i==1){num[i] = (t - sum[i-1])/stu[i] + 1;continue;}
        if(t>=sum[i]){
            ll time = t-sum[i];
            num[i] = time/maxx + 2;
        }
        else {num[i] = 1;continue;}
    }
    for(int i = 1;i<=n;i++){
        printf("%lld\n",num[i]);
    }
    return 0;
}



Measured memory_bytes: 5560
#include <bits/stdc++.h>
int N,M,a;
int main(){
    std::cin>>N>>M;
    int k[++N]={},s[N]={1};
    while(M--)std::cin>>a,k[a]=1;
    s[a=1]=!k[1];
    for(;a<N;)s[++a]=!k[a]*(s[a-1]+s[a-2])%1000000007;
    printf("%d",s[N-1]);
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int point = 0;
            for (int i = 0; i < 2; ++i)
            {
                if (a < b)
                {
                    point += b;
                    b = b - 1;
                }
                else
                {
                    point += a;
                    a = a - 1;
                }
            }
            Console.WriteLine(point);

        }
    }
}


Measured memory_bytes: 11092
import sys

input()
numbers = map(int, input().split())
evens = [number for number in numbers if number % 2 == 0]

if len(evens) == 0:
    print('APPROVED')
    sys.exit()
    
for even in evens:
    if even % 3 != 0 and even % 5 != 0:
        print('DENIED')
        sys.exit()

print('APPROVED')


Measured memory_bytes: 9048
use std::cmp;

const INF: i64 = 1e17 as i64;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let n: usize = sc.read();
    let a: Vec<i64> = sc.read_vec(n);
    let mut graph = vec![vec![]; n];
    for _ in 0..(n - 1) {
        let v = sc.read::<usize>() - 1;
        let u = sc.read::<usize>() - 1;
        graph[v].push(u);
        graph[u].push(v);
    }

    let mut dp1 = vec![vec![]; n];
    let mut dp2 = vec![vec![]; n];
    dfs(0, 0, &graph, &a, &mut dp1, &mut dp2);

    for i in 1..(n + 1) {
        if dp1[0][i] < INF {
            println!("{}", i - 1);
            return;
        }
        if dp2[0][i] < 0 {
            println!("{}", i - 1);
            return;
        }
    }
}

fn dfs(
    v: usize,
    p: usize,
    graph: &Vec<Vec<usize>>,
    a: &Vec<i64>,
    dp1: &mut Vec<Vec<i64>>,
    dp2: &mut Vec<Vec<i64>>,
) {
    dp1[v].push(INF);
    dp1[v].push(if a[v] > 0 { a[v] } else { INF });
    dp2[v].push(INF);
    dp2[v].push(a[v]);
    for &next in graph[v].iter() {
        if next == p { continue; }
        dfs(next, v, graph, a, dp1, dp2);

        dp1[v] = connect(&dp1[v], &dp1[next], &dp2[next], true);
        dp2[v] = connect(&dp2[v], &dp1[next], &dp2[next], false);
    }
}

fn connect(dp: &Vec<i64>, child1: &Vec<i64>, child2: &Vec<i64>, power_only: bool) -> Vec<i64> {
    assert_eq!(child1.len(), child2.len());
    let mut ans = vec![INF; dp.len() + child1.len() - 1];
    for cut_num in 0..dp.len() {
        if dp[cut_num] == INF { continue; }
        for child_cut_num in 0..child1.len() {
            let child_power = child1[child_cut_num];
            let child_group = child2[child_cut_num];

            let group_num = cut_num + child_cut_num;

            if group_num >= 1 {
                if child_power != INF {
                    ch_min(&mut ans[group_num - 1], dp[cut_num] + child_power);
                }
                if child_group != INF && !power_only {
                    ch_min(&mut ans[group_num - 1], dp[cut_num] + child_group);
                }
            }
            if child_power != INF || child_group < 0 {
                ch_min(&mut ans[group_num], dp[cut_num]);
            }
        }
    }
    ans
}

fn ch_min<T: PartialOrd>(a: &mut T, b: T) {
    if *a > b {
        *a = b;
    }
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 211836
N = int(raw_input())
T, A = map(int, raw_input().split())
H = list(map(int, raw_input().split()))
difH = 10**5
ai = 0
for i, h in enumerate(H):
    d = abs(A - (T - h * 0.006))
    if d < difH:
        difH = d
        ai = i+1
print(ai)

Measured memory_bytes: 2692
A = []
b = []

for i in range(3):
    A.append(list(map(int,input().split())))

N = int(input())

for i in range(N):
    b.append(int(input()))

for c in b:
    for i in range(3):
        for j in range(3):
            if A[i][j] == c:
                A[i][j] = 0

# 横チェック
for i in range(3):
    if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
        print('Yes')
        exit()

# 縦チェック
for i in range(3):
    if A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0:
        print('Yes')
        exit()

#斜めチェック
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    print('Yes')
    exit()

if A[2][0] == 0 and A[1][1] == 0 and A[0][2] == 0:
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 38256
#include <iostream>

using namespace std;

int x1, y1, x2, y2;

int main()
{
    cin >> x1 >> y1 >> x2 >> y2;

    int x3, y3, x4, y4;
    x3 = x2 - (y2 - y1);
    y3 = y2 + (x2 - x1);
    x4 = x3 - (x2 - x1);
    y4 = y3 - (y2 - y1);

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
  
int main(int argc, char *argv[]) {
    int n;
    int d[100];

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &d[i]);
    }

    for (int j = 1; j < n; j++) {
        for (int i = 1; i < n; i++) {
            if (d[i - 1] > d[i]) {
                int tmp = d[i - 1];
                d[i - 1] = d[i];
                d[i] = tmp;
            }
        }
    }

    int max = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (d[i] > max) {
            max = d[i];
            cnt++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, A, B;
  cin >> N >> A >> B;
  int a, b, c;
  a = b = c = 0;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    if (tmp <= A) {
      a++;
    } else if (tmp <= B) {
      b++;
    } else {
      c++;
    }
  }

  int ans = min({a, b, c});
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    int[,] dist;
    int N;
    int M;
    const int INF = int.MaxValue / 2;


    public void calc()
    {
        cin = new Scanner();
        N = cin.nextInt();
        M = cin.nextInt();

        int[] a = new int[M];
        int[] b = new int[M];
        int[] c = new int[M];

        for(int i = 0;i<M;i++)
        {
            a[i] = cin.nextInt();
            b[i] = cin.nextInt();
            c[i] = cin.nextInt();
        }

        dist = new int[N + 1, N + 1];

        for (int i = 0; i < N + 1; i++)
        {
            for (int j = 0; j < N + 1; j++)
            {
                dist[i, j] = i == j ? 0 : INF;
            }
        }

        for(int i = 0;i<M;i++)
        {
            dist[a[i], b[i]] = c[i];
            dist[b[i], a[i]] = c[i];
        }

        //ワーシャルフロイドで全点間最短距離を求める
        for (int k = 1; k <= N; k++)
        {
            for (int i = 1; i <= N; i++)
            {
                for (int j = 1; j <= N; j++)
                {
                    dist[i, j] = Math.Min(dist[i, j], dist[i, k] + dist[k, j]);
                }
            }
        }

        int ans = 0;
        for(int i = 0;i<M;i++)
        {
            //ある辺の長さがその両端の頂点間の最短距離より長いなら、
            //その辺は（ほかの頂点間の最短経路としても）使われない
            if (dist[a[i], b[i]] < c[i]) ans++;
        }

        Console.WriteLine(ans);
    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int solve(int N, int M) {
    int ret = 0;
    vint h(N), w(M);
    vint hcc(N + 1), wcc(M + 1);
    rep(i, N) {
        cin >> h[i];
        hcc[i + 1] = hcc[i] + h[i];
    }
    rep(i, M) {
        cin >> w[i];
        wcc[i + 1] = wcc[i] + w[i];
    }
    vint v(1600000);
    rep(i, N + 1) {
        rep(j, i) {
            v[hcc[i] - hcc[j]]++;
        }
    }
    rep(i, M + 1) {
        rep(j, i) {
            ret += v[wcc[i] - wcc[j]];
        }
    }
    return ret;
}

signed main() {
    while (true) {
        int N, M;
        cin >> N >> M;
        if (N == 0 && M == 0) { break; }
        cout << solve(N, M) << endl;
    }
}


Measured memory_bytes: 15640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define de(x) cout << #x << " = " << x << endl
#define rep(i, a, b) for(int i=(a); i<(b); i++)
//-----
const int N=100010;
int n;
vector<pii> G[N];
ll dis[N];
void dfs(int u, int fa){
	rep(i, 0, sz(G[u])){
		int v=G[u][i].fi, w=G[u][i].se;
		if(v==fa)continue;
		dis[v]=dis[u]+w;
		dfs(v, u);
	}
}
int main() {
	scanf("%d", &n);
	rep(i, 1, n){
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		G[u].pb(mp(v, w));
		G[v].pb(mp(u, w));
	}
	int m, k;
	scanf("%d%d", &m, &k);
	dfs(k, 0);
	rep(i, 0, m){
		int u, v, lca;
		scanf("%d%d", &u, &v);
		cout<<dis[u]+dis[v]<<endl;
	}
	return 0;
}


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

bool comp(pair<pair<string, ll>, ll> lhs, pair<pair<string, ll>, ll> rhs) {
    if (lhs.first.first != rhs.first.first) {
        return lhs.first.first < rhs.first.first;
    }
    return lhs.first.second > rhs.first.second;
}

int main() {
    ll n, p;
    string s;

    cin >> n;
    vector<pair<pair<string, ll>, ll>> sps;

    for (int i = 0; i < n; ++i) {
        cin >> s >> p;
        sps.push_back(make_pair(make_pair(s, p), i+1));
    }

    sort(sps.begin(), sps.end(), comp);

    for (int i = 0; i < n; ++i) {
        cout << sps[i].second << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){

    int a, b, h, area;

    scanf("%d %d %d", &a, &b, &h);

    area = ((a * 1.0 + b * 1.0) / 2.0) * h * 1.0;

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

    return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	SORT(a);
	cout << a.back() - a.front() << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    ll ans=0;
    int n;
    in>>n;
    vector<int> l(n),r(n),p(n);
    multiset<int> L,R;
    fr(i,n) in>>l[i]>>r[i],p[i]=i,L.emplace(l[i]),R.emplace(r[i]);
    fr(i,n){
        L.erase(L.find(l[i]));
        R.erase(R.find(r[i]));
        ans=max(ans,r[i]-l[i]+1ll+max(0,*R.begin()-*L.rbegin()+1));
        //cout<<i<<" "<<ans<<endl;
        L.emplace(l[i]),R.emplace(r[i]);
    }
    sort(p.begin(),p.end(),[&](int i,int j){
        return l[i]<l[j];
    });
    vector<pair<int,int>> lr;
    fr(i,n){
        //cout<<p[i]<<endl;
        if(i<n-1&&r[p[i]]>=r[p[i+1]]){
            while(!lr.empty()){
                int ri;
                tie(ignore,ri)=*lr.rbegin();
                if(ri>=r[p[i+1]]) lr.pop_back();
                else break;
            }
            continue;
        }
        lr.emplace_back(l[p[i]],r[p[i]]);
    }
    //for(auto P:lr) cout<<P.first<<" "<<P.second<<endl;
    n=lr.size();
    fr(i,n-1){
        ans=max(ans,(ll)max(0,lr[0].second-lr[i].first+1)+max(0,lr[i+1].second-lr[n-1].first+1));
        //cout<<i<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
}

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

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

vector<int> a, b, c, d;


int dfs(vector<int> A, int ret, int N, int M, int Q){
    if(A.size() == N){
        int s = 0;
        REP(i, Q){
            if(A[b[i]] - A[a[i]] == c[i]) s += d[i];
        }
        return max(s, ret);
    }

    if(A.size() == 0) A.push_back(1);
    FOR(i, A.back(), M+1){
        A.push_back(i);
        ret = max(ret, dfs(A, ret, N, M, Q));
        A.pop_back();
    }

    return ret;
}

int main()
{
    int N, M, Q;
    cin >> N >> M >> Q;
    a = b = c= d= vector<int>(Q);
    REP(i, Q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i], --b[i];
    }

    // あり得る数列を全探索
    cout << dfs(vector<int>(0), 0, N, M, Q) << endl;

    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define MAXN 2550
#define pii pair<int, int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x < n and y >= 0 and y < n)
using namespace std;
const ll mod = 1e9 + 7;


int main() {
    ios_base::sync_with_stdio(false);
    int n, ans = 0;
    string s;
    cin >> n >> s;

    for (int i=0; i<n-1; i++){
        if (s[i] != s[i+1]) ans++;
    }

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

Measured memory_bytes: 3764
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
 
  int A = sc.nextInt();
  int B = sc.nextInt();
  int C = sc.nextInt();
   if(C>=A && C<=B ) {
	   System.out.print("Yes");
   }
   else {
	   System.out.print("No");
   }
   }
}

Measured memory_bytes: 21844
//_nebula_
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t;
const int M=1e9+7;
const int inf=INT64_MAX;
int dp[100005][3];
int factt(int n)
{
    int ans=1;
    for(int i=1;i<=n;i++)
    {
        ans*=i;
        ans=ans%M;
    }
    return ans;
}
int max(int a,int b,int c)
{
    return max(a,max(b,c));
}
int min(int a,int b,int c)
{
    return min(a,min(b,c));
}
int fspow(int x,int y)
{
    int ans;
    if(y==0) return 1;
    ans=fspow(x, y/2);
    if(y%2==0)
    {
        if((double)ans>=sqrt((double)inf)) return 0;
        return (ans*ans);
    }
    if((double)ans>=sqrt((double)(inf/x))) return 0;
    return x*ans*ans;
}
int gcd(int x,int y)
{
    if(x<y) swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int p2(int x)
{
    int ans=0;
    while(x>=1)
    {
        ans++;
        x/=2;
    }
    return ans;
}
int happy(int st,char ca,int n,vector<tuple<int,int,int> > &chk)
{
    int a,b,c;
    a=get<0>(chk[st]);
    b=get<1>(chk[st]);
    c=get<2>(chk[st]);
    if(st==n-1)
    {
        if(ca=='a') return a;
        if(ca=='b') return b;
        return c;
    }
    if(ca=='a')
    {
        if(!dp[st+1][1]) dp[st+1][1]=happy(st+1,'b',n,chk);
        if(!dp[st+1][2]) dp[st+1][2]=happy(st+1,'c',n,chk);
        return a+max(dp[st+1][1],dp[st+1][2]);
    }
    if(ca=='b')
    {
        if(!dp[st+1][0]) dp[st+1][0]=happy(st+1,'a',n,chk);
        if(!dp[st+1][2]) dp[st+1][2]=happy(st+1,'c',n,chk);
        return b+max(dp[st+1][0],dp[st+1][2]);
    }
    if(!dp[st+1][0]) dp[st+1][0]=happy(st+1,'a',n,chk);
    if(!dp[st+1][1]) dp[st+1][1]=happy(st+1,'b',n,chk);
    return c+max(dp[st+1][0],dp[st+1][1]);
}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
    // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    // cin>>t;
    // int tmp=t;
    while(t--)
    {
        int n;
        cin>>n;
        vector<tuple<int,int,int> >chk(n);
        for(int i=0;i<n;i++)
        {
            int x,y,z;
            cin>>x>>y>>z;
            chk[i]={x,y,z};
        }
        cout<<max(happy(0,'a',n,chk),happy(0,'b',n,chk),happy(0,'c',n,chk))<<"\n";
    }
}


Measured memory_bytes: 15644
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	ll N;
	cin >> N;
	ll sN = 0;
	ll v = N;
	while(v > 0){
		sN += v % 10;
		v /= 10;
	}
	cout << (N % sN == 0 ? "Yes" : "No") << endl;
	
	
	
	
    return 0;
}

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

int main()
{
  int A, B, C, K, *mx;

  cin >> A >> B >> C >> K;
  if (A > B) mx = &A;
  if (B > A) mx = &B;
  if (C > *mx) mx = &C;
  for (int i = 1; i <= K; i++)
    *mx *= 2;
  cout << A + B + C << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <climits>
using namespace std;

int main() {
    long long int n,med,med2,ans=0,ans2=0;
    cin >> n;
    vector<long long int>a(n);
    for(long long int i=0;i<n;i++){
        cin >> a[i];
        a[i]-=(i+1);
    }
    sort(a.begin(),a.end());
    if(n%2==1){
        med=n/2;
        for(long long int i=0;i<n;i++){
            ans+=abs(a[i]-a[med]);
        }
    }else{
        med=n/2-1;
        med2=n/2;
        for(long long int i=0;i<n;i++){
            ans+=abs(a[i]-a[med]);
        }
        for(long long int i=0;i<n;i++){
            ans2+=abs(a[i]-a[med2]);
        }
    }
    if(n%2==1){
        cout << ans;
    }else{
        cout << min(ans,ans2);
    }
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

struct edge {
  int to;
  int cost;
};

int n;
vector<vector<edge>> vec;
vector<i64> dist;

void dfs(int v, int i, i64 d) {
  dist[v] = d;
  for(auto &ite : vec[v]) {
    if(ite.to != i) dfs(ite.to, v, d + ite.cost);
  }
}

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

  int n;
  cin >> n;
  vec.resize(n + 1, vector<edge>(0));
  rep(i, 0, n - 1) {
    int a, b, c;
    cin >> a >> b >> c;
    vec[a].push_back({b, c});
    vec[b].push_back({a, c});
  }

  int q, k;
  cin >> q >> k;
  dist.resize(n + 1);
  dfs(k, 0, 0ll);
  rep(i, 0, q) {
    int x, y;
    cin >> x >> y;
    cout << dist[x] + dist[y] << endl;
  }
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, t;
    cin >> n >> t;
    vint a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    vvint dp1(n+1, vint(t, 0)); 
    vvint dp2(n+1, vint(t, 0)); 
    rep(i, n) {
        rep(j, t) {
            dp1[i+1][j] = dp1[i][j];
            if (j-a[i] >= 0) dp1[i+1][j] = max(dp1[i][j], dp1[i][j-a[i]]+b[i]);
        }
    }

    rrep(i, n) {
        rep(j, t) {
            dp2[i][j] = dp2[i+1][j];
            if (j-a[i] >= 0) dp2[i][j] = max(dp2[i+1][j], dp2[i+1][j-a[i]]+b[i]);
        }
    }

    int ans = 0;
    rep(i, n) {
        rep(j, t) {
            int tmp = b[i];
            tmp += dp1[i][j];
            tmp += dp2[i+1][t-j-1];
            ans = max(ans, tmp);
        }
    }

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

Measured memory_bytes: 70912
import sys

input = sys.stdin.readline


N = int(input())

S = input()

color =list("RGB")

#色がRGBの３色ないとき
for x in color:
    if x not in S:
        print(0)
        exit()

r = 0
g = 0
b = 0
for i in range(len(S)):
    if S[i] == color[0]:
        r+=1
    elif S[i] == color[1]:
        g+=1
    elif S[i] == color[2]:
        b+=1

all = r*g*b

sub = 0
for i in range(N):
    for j in range(i+1,N):
        k = 2*j - i
        #kがN以上の位置にある
        if k >= N:
            continue

        #同じ色がある
        if S[i] == S[j] or S[j] == S[k] or S[k] == S[i] :
            continue
        sub+=1

print(all - sub)
        




Measured memory_bytes: 68388
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")

#define MAX 110000

int h[MAX];
signed main(){
	cout<<fixed<<setprecision(7);
	int N, K, ans = INF;
	
	cin>>N>>K;
	
	for(int i = 0; i < N; i++){
		cin>>h[i];
	}
	
	sort(h, h+N);
	
	for(int i = 0; i + K - 1< N; i++){
		ans = min(ans, h[i+K-1]-h[i]);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string T; std::cin >> T;
  rep(i,sz(T)) {
    if ( T[i] == '?' ) T[i] = 'D';
  }
  std::cout << T << std::endl;
  return 0;
}



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

using namespace std;

int n;

const int M = 303;

double dp[M][M][M];


double f(int i, int j, int k){
	if(i+j+k==0){
		return 0;
	}
	if(i < 0 || i > n || j < 0 || j > n || k < 0 || k > n ){
		return 0;
	}
	if(dp[i][j][k] > 0.00001) return dp[i][j][k];
	double total = i+j+k;
	return dp[i][j][k] = i/total * f(i-1,j,k) + (j/total) * f(i+1,j-1,k) + (k / total) * f(i,j+1,k-1) + n / total;
}

int main(){
	cin >> n;
	vector<int> a(4,0);
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		a[x]++;
	}
	cout << fixed << setprecision(16) << f(a[1],a[2],a[3]) << "\n";
	return 0;
}


Measured memory_bytes: 217344
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define REP(i,n) for (int i = 0; i < n; ++ i)
#define FOR(i,a,b) for (int i = a; i <= b; ++ i)
#define FORD(i,b,a) for (int i = b; i >= a; -- i)
#define debug(x) cerr << #x << ": " << x << "\n"
#define task "0"
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> li;
typedef vector<int> vi;

const int N = 15;
int h, w;
string s[N];
bool vis[N];
vi half1, half2, id;

bool same(int u, int v) {
	REP(i, h) if (s[id[i]][u] != s[id[i]][v]) return false;
	return true;
}
bool rev(int u, int v) {
	REP(i, h) if (s[id[i]][u] != s[id[h-1-i]][v]) return false;
	return true;
}
bool palin(int u) {
	REP(i, h/2) if (s[id[i]][u] != s[id[h-1-i]][u]) return false;
	return true;
}
void check() {
	id.clear();
	REP(i, half1.size()) id.pb(half1[i]);
	REP(i, half2.size()) id.pb(half2[i]);
	//REP(i, (int) id.size()) cerr << id[i] << " "; cerr << "\n";
	memset(vis, 0, sizeof vis);
	bool flagPalin = 0;
	REP(i, w) if (!vis[i]) {
		int cntSame = 1, cntRev = 0;
		FOR(j, i+1, w-1) if (!vis[j]) {
			if (same(i, j)) cntSame ++, vis[j] = 1;
			else if (rev(i, j)) cntRev ++, vis[j] = 1;
		}
		if (palin(i)) {
			if (cntSame % 2) {
				if (!flagPalin) flagPalin = 1;
				else return;
			}
		} else {
			if (cntSame != cntRev) return;
		}
	}	
	cout << "YES";
	exit(0);
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	//freopen(task".inp", "r", stdin);
	//freopen(task".out", "w", stdout);
	cin >> h >> w;
	REP(i, h) cin >> s[i];
	//cerr << "ok\n";
	REP(mask, (1 << h)) if (__builtin_popcount(mask) == h/2) {
		half1.clear(); half2.clear();
		REP(i, h) {
			if ((mask & (1 << i)) > 0) 
				half1.pb(i);
			else half2.pb(i);
		}
		do check();
		while (next_permutation(half2.begin(), half2.end()));
	}
	cout << "NO";
}


Measured memory_bytes: 384
import java.util.Scanner;

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

        int change = n % 500;
        if(change - a <= 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}


Measured memory_bytes: 21204
#include<iostream>
using namespace std;
int main() {
    int A[3];
  	A[0] = -1;
  	A[1] = -1;
    A[2] = -1;
	int N, Y;
  	cin >> N >> Y;
  	Y /= 1000;
  	for(int i = 0; 10 * i <= Y; i++) {
      	for(int j = 0; (10 * i + 5 * j) <= Y; j++) {
          	if((N + 9 * i + 4 * j) == Y) {
              	A[0] = i;
              	A[1] = j;
              	A[2] = N - i - j;
            }
        }
    }
  	
    cout << A[0] <<' '<< A[1] <<' ' << A[2] << endl;
  	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a > b) {
			System.out.println("a > b");
		}else if(a < b) {
			System.out.println("a < b");
		}else {
			System.out.println("a == b");
		}
	}
}


Measured memory_bytes: 26232
import sys 
from collections import Counter
 
N = int(sys.stdin.readline().strip())
C = sys.stdin.readline().strip()

counter = Counter(C)
if len(counter) == 1:
    print(0)
    sys.exit()

limit = counter["R"]
ok = 0
for i in range(limit):
    if C[i] == "R":
        ok += 1

print(limit - ok)

Measured memory_bytes: 9764
//package test;

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

public class Main {

	public static int MIN_VALUE = -1000000000;
	public static int MAX_VALUE =  1000000000;
	public static int MAX_COMMAND = 400000;
	public static int MIN_COMMAND = 1;
	public static void main(String[] args) throws Exception {
		String[] commandList = initCommand();
		doCommnand(commandList);
	}

	private static void doCommnand(String[] commandList) {
		int startIndex = commandList.length;
		int endIndex = commandList.length;
		
		int[] valueList = new int[commandList.length*2+1];
		
		for (int i=0; i< commandList.length; i++) {
			String command = commandList[i];
			String[] commandDetail = command.split(" ", -1);
			if (commandDetail[0].equals("0")) {
				int direction = Integer.parseInt(commandDetail[1]);
				if (direction != 0 && direction != 1) {
					throw new IllegalArgumentException("command is illegal:" + direction);
				}
				int value = Integer.parseInt(commandDetail[2]);
				if (value < MIN_VALUE || value > MAX_VALUE) {
					throw new IllegalArgumentException("command is illegal");
				}
				int valueIndex = -1;
				if (direction == 0) {
					valueIndex = startIndex - 1; 
					valueList[valueIndex] = value;
					startIndex = valueIndex;
				} else if (direction == 1) {
					valueIndex = endIndex;
					valueList[valueIndex] = value;
					endIndex = valueIndex + 1;
				}
			} else if (commandDetail[0].equals("1")) {
				int index = Integer.parseInt(commandDetail[1]);
				if (0 <= index && index < endIndex - startIndex) {
					int value = valueList[startIndex+index];
					System.out.println(value);
				}
			} else if (commandDetail[0].equals("2")) {
				int direction = Integer.parseInt(commandDetail[1]);
				if (direction != 0 && direction != 1) {
					throw new IllegalArgumentException("command is illegal:" + direction);
				}
				if (direction == 0) {
					startIndex++;
				} else if (direction == 1) {
					endIndex--;
				}
			}
			//System.out.println(Arrays.toString(valueList));
		}
	}

	private static String[] initCommand() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String numCommandStr = br.readLine();
		int commandNum = Integer.parseInt(numCommandStr);
		if (commandNum < MIN_COMMAND || commandNum > MAX_COMMAND) {
			throw new IllegalArgumentException(MIN_COMMAND + " <= commandNum <= " + MAX_COMMAND);
		}

		String[] commandList = new String[commandNum];

		for (int i=0; i< commandNum; i++) {
			String command = br.readLine();
			if (command == null || command.isEmpty()) {
				throw new IllegalArgumentException("command is empty");
			}
			commandList[i] = command; 
		}
		return commandList;
	}
}



Measured memory_bytes: 131656
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  vector<ll> a(n);
  for(auto&& e: a) 
  {
    cin>>e;
  }
  ll lim=a[0];
  ll ans=0;
  for (int i = 1; i < a.size(); ++i)
  {
    if(a[i]>=lim)
    {
      lim=a[i];
    }
    else
    {
      ans+=abs(lim-a[i]);
      a[i]=lim;
      lim=a[i];
    }
  } 
  cout<<ans<<endl;
}

Measured memory_bytes: 4832
#include<stdio.h>

int main(){
  char S[101],T[101];
  int S_length=0,T_length=0,ans=0;
  scanf("%s",S);
  for (int i = 0; i < 101; i++){
    if(S[i]!='\000'){
      S_length++;
    }else{
      break;
    }
  }
  scanf("%s",T);
  for (int i = 0; i < 101; i++){
    if(T[i]!='\000'){ 
      T_length++;
    }else{
      break;
    }
  }

  for (int i = 0; i < S_length-1; i++){
    int min=S[i];
    int t,s=i;
    for (int j = i+1; j < S_length; j++){
      if (min>S[j]){
        min=S[j];
        s=j;
      }
    }
    t=S[i]; S[i]=S[s]; S[s]=t;
  }
  
  for (int i = 0; i < T_length-1; i++){
    int max=S[i];
    int t,l=i;
    for (int j = i+1; j < T_length; j++){
      if (max<T[j]){
        max=T[j];
        l=j;
      }
    }
    t=T[i]; T[i]=T[l]; T[l]=t;
  }

  for (int i = 0; i < S_length; i++)
  {
    if(S[i]==T[i]){
      ans=0;
    }else if(S[i]<T[i]){
      ans=1;
      break;
    }else{
      ans=-1;
      break;
    }
  }

  if (ans==1){
    puts("Yes");
  }else if (ans==0&&S_length<T_length){
    puts("Yes");
  }else{
    puts("No");
  }

  return 0;
}

Measured memory_bytes: 1644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

string s, t;

int main() {
	cin >> s >> t;
	bool flag_t = false;
	for (int i = s.size() - t.size(); i >= 0; --i) {
		bool flag = true;
		for (int j = 0; j < t.size(); ++j) {
			flag &= (s[i + j] == '?' || s[i + j] == t[j]);
		}
		if (flag) {
			for (int j = 0; j < t.size(); ++j) {
				s[i + j] = t[j];
			}
			flag_t = true;
			break;
		}
	}
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == '?') s[i] = 'a';
	}
	if (!flag_t) cout << "UNRESTORABLE" << endl;
	else cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;

    int ans = 0;
    rep(i, n+1) {
        rep(j, n+1) {
            int rm = n - r*i - g*j;
            if (rm >= 0 && rm%b == 0) ans++;
        }
    }

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

Measured memory_bytes: 256
import math
A,B,H,M=map(int,input().split())
s=(60*H+M)*60
t=(1/120)*s #長針の角度
u=6*M #短針の角度
v=abs(t-u)
if 0<v<=180:
  k=math.cos(math.radians(v))
  C=math.sqrt(A**2+B**2-2*A*B*k)
  print(C)
elif v>=180:
  w=360-v
  k=math.cos(math.radians(w))
  C=math.sqrt(A**2+B**2-2*A*B*k)
  print(C)    
elif v==0:
  print(abs(B-A))

Measured memory_bytes: 9480
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    string S;
    cin >> S;

    int N = S.size();

    int cnt = 0;
    rep(i, N) {
        cnt += S[i] == 'o';
    }

    cnt += 15 - N;

    cout << (cnt >= 8 ? "YES" : "NO") << endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<pair<string,int>>vec(N);
  map<int,int>mp;
  for(int i=0; i<N; i++){
    cin >> vec[i].first >> vec[i].second;
    vec[i].second *= -1;
    mp[vec[i].second] = i+1;
  }
  sort(vec.begin(),vec.end());
  for(int i=0; i<N; i++){
    cout << mp[vec[i].second] << endl;
  }
}


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

int main() {
	
	int a, b, c; cin >> a >> b >> c;
	bool can = false;
	for (int i = 1; i <= b; i++) {
		if (i * a % b == c) {
			can = true;
		}
	}
	if (can) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int SURP = 1000000007;

int main(){
	int N;
	cin >> N;
	int a[N];
	int sum = 0;
	FOR(i,0,N){
		cin >> a[i];
		sum += a[i];
	}

	sort(a,a+N);

	if(sum%10 == 0){
		FOR(i,0,N){
			if(a[i]%10 != 0) {
				sum -= a[i];
				break;
			}
		}
	}
	if(sum%10 == 0) sum = 0;

	cout << sum << endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <cstdint>
#include <set>
#include <deque>
#include <iomanip>
#include <queue>

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

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

#define EPS (1e-7)
#define ALL(x) begin(x), end(x)

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

	struct Node {
		ll num;
		ll cost;
	};
	vector<vector<Node>> Table(N);
	for (size_t i = 0; i < N - 1; i++) {
		ll u, v, w;
		cin >> u >> v >> w;
		u--;
		v--;
		Table[u].push_back({v, w});
		Table[v].push_back({u, w});
	}
	// 木は一本道なので、1から攻めていけばよい。
	// dfsだ。いやダメだbfsだ。
	vector<ll> Ans(N, -1);
	queue<Node> Q;
	Q.push({0,0});
	while (!Q.empty()) {
		const Node now = Q.front();
		Q.pop();
		// コストとVisit更新
		Ans[now.num] = now.cost;

		for (size_t i = 0; i < Table[now.num].size(); i++) {
			if (Ans[Table[now.num][i].num] != -1) { continue; }
			// nowとつながっている先が未訪問であれば、キューに入れる。
			Q.push({Table[now.num][i].num, now.cost + Table[now.num][i].cost});
		}
	}

	for (size_t i = 0; i < N; i++) {
		ll value = Ans[i] % 2;
		cout << value << endl;
	}
	return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
const ll integer = pow(2, 32) - 1; // 4294967295
#define N 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
void AIA() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isprime(ll n) {
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0)return 0;
	}
	return (n!=1);
}

/*
 _____________              __                ___        ___       ___________________________     ____        ____
|             |            /\ \              |   |      |   |     |                           |    \   \      /   /
|   __________|           / /\ \             |   |      |   |     |      _____      _____     |     \   \    /   /
|  |                     / /  \ \            |   |      |   |     |     |     |    |     |    |      \   \  /   /
|  |                    / /    \ \           |   |      |   |     |     |     |    |     |    |       \   \/   /
|  |______             / /      \ \          |   |______|   |     |     |     |    |     |    |        \      /
|         |           / /        \ \         |              |     |     |     |    |     |    |         \    /
|   ______|          / /          \ \        |    ______    |     |     |     |    |     |    |          |  |
|  |                / /============\ \       |   |      |   |     |     |     |    |     |    |          |  |
|  |               / /==============\ \      |   |      |   |     |     |     |    |     |    |          |  |
|  |              / /                \ \     |   |      |   |     |     |     |    |     |    |          |  |
|  |             / /                  \ \    |   |      |   |     |     |     |    |     |    |          |  |
|__|            /_/                    \_\   |___|      |___|     |_____|     |____|     |____|          |__|

										  <<<<<<<<<<< NEVER GIVE UP !! >>>>>>>>>>>
										<<<<<<<< YOU CAN DO IT IF YOU WANT !! >>>>>>>>
										 <<<<<<<<< BELIEVE IN YOURSELF !! >>>>>>>>>

*/
int main() {
	//cout << fixed << setprecision(9);
	//freopen("stand.in","r",stdin);
	//freopen("stand.out","w",stdout);
	AIA();
	int n;
	cin>>n;
	
	map<string,int>mp;
	while(n--){
		string s;
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
	return 0;
}

Measured memory_bytes: 3664