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

long long dp[100009][2];

long long m=1e9+7;

long long solve(int root, int color, int parent, vector<vector<int>>& g){
   // cout<<dp[root][color];
   if(dp[root][color]!=0)return dp[root][color];
    long long ans =1;
    //cout<<g[root][0];
   for(auto x: g[root]){
      //  cout<<x;
        if(x != parent){
            if(color==0)
            ans=(ans%m*((solve(x,0,root,g)%m+solve(x,1,root,g)%m)%m))%m;
           else
            ans=(ans%m*solve(x,0,root,g)%m)%m;
        }
    }
    return dp[root][color] = ans;
    
}


int main(){
    int n;
    cin>>n;
    vector<vector<int>>g(n+1);
    long long dp[n+1][2];

    
    
    for(int i=1;i<=n-1;i++){
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    cout<<(solve(1,0,-1,g)+solve(1,1,-1,g))%m;
    
}

Measured memory_bytes: 15616
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

bool a[300000];
vector<int> A;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    rep(i,300000) a[i] = true;
    a[0] = a[1] = false;
    for (int i = 2; i < 300000; i++) {
        if (i % 7 != 1 && i % 7 != 6) a[i] = false;
        if (a[i]) {
            for (int j = 2; j*i < 300000; j++) a[i*j] = false;
        }
    }
    rep(i,300000) if (a[i]) A.emplace_back(i);

    while (true) {
        int N; cin >> N;
        if (N == 1) break;
        int M = N;
        vector<int> ans;
        rep(i,A.size()) {
            if (M % A[i] == 0) ans.emplace_back(A[i]);
        }

        cout << N << ":";
        rep(i,ans.size()) cout << " " << ans[i];
        cout << endl; 
    }
}


Measured memory_bytes: 3460
#include <stdio.h>
int main(void){
    int a,b,ans[750],i,j=0,p;
    while (1) {
        ans[0]=0;
        p=0;
        scanf("%d %d",&a,&b);
        if (a==0&&b==0) break;
        for(i=a;i<=b;){
            if(i%4==0){
                if(i%100!=0||i%400==0) {
                	ans[p]=i;
                	p++;
                }
                i+=4;
            } else {
                i++;
            }
        }
        if (j!=0) printf("\n");
        if (ans[0]==0) {
            printf("NA\n");
        } else {
            for(i=0;i<p;i++) printf("%d\n",ans[i]);
        }
        j++;
    }
    return 0;
}

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

int main(){
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;

    ll minn = min({a,b,c,d,e});

    if(minn == n) put(5);
    else if(n % minn == 0) put(4 + n / minn);
    else put(5 + n / minn);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int    x1, x2, x3, x4, x5;

    scanf("%d %d %d %d %d", &x1, &x2, &x3, &x4, &x5);
    printf("%d\n", 15-x1-x2-x3-x4-x5);
    
    return 0;
}

Measured memory_bytes: 1700
from math import sqrt
inpl = lambda: list(map(int,input().split()))
N = int(input())
xy = [inpl() for _ in range(N)]
def distance(i,j): return sqrt(sum((xy[i][k]-xy[j][k])**2 for k in range(2)))
S = sum(distance(i,j) for i in range(N-1) for j in range(i,N))
print(2*S/N)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define INF 1e18
typedef pair<int,int> pr;
signed main()
{
    SPEED;
    int n,m,i,flag=0;
    cin>>n>>m;
    vector<int> adj[n+1];
    for(i=0;i<m;++i)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    int cost[n+1],visited[n+1]={0},final[n+1]={0};
    for(i=0;i<=n;++i)
        cost[i]=INF;
    queue<int> q;
    q.push(1);
    cost[1]=0;
    while(q.size())
    {
        int p=q.front();
        q.pop();
        for(int i=0;i<adj[p].size();++i)
        {
            if(cost[adj[p][i]]>cost[p]+1)
            {
                final[adj[p][i]]=p;
                cost[adj[p][i]]=cost[p]+1;
                q.push(adj[p][i]);
            }    
        }
    }
    for(i=2;i<=n;++i)
    {
        if(final[i]==0)
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
        cout<<"No";
    else
    {
        cout<<"Yes"<<endl;
        for(i=2;i<=n;++i)
            cout<<final[i]<<endl;
    }
}

Measured memory_bytes: 14628
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main () {
    int A, B;
    cin >> A;
    map<string, int> mp;
    map<string,ll>:: iterator it;

    for(int i = 0; i < A; i++) {
        string tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    cin >> B;
    for(int i = 0; i < B; i++) {
        string tmp;
        cin >> tmp;
        mp[tmp]--;
    }
    int ans = 0;
    for (auto i : mp) {
        ans = max(ans, i.second);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N;
MII m;


int solve(){
	if((N-SIZE(m))%2 == 0) return SIZE(m);
	return SIZE(m)-1;
}


signed main(){
	cin >> N;
	rep(i, 0, N){
		int A;
		cin >> A;
		m[A]++;
	}

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 4992
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    String s=sc.next();
    String t=sc.next();
    for (int i=0;i<n;i++) {
      System.out.print(s.charAt(i));
      System.out.print(t.charAt(i));
    }
    System.out.println();
  }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             (1<<17)
#define vv(type)		vector<vector<type>>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define db(x) 			cout<<x<<" "
#define db1(x) 			cout<<x<<'\n'
#define db2(x,y) 		cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) 		cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) 		for(int i=0;i<(n);++i)
#define repA(i,a,n) 	for(int i=a;i<=(n);++i)
#define repD(i,a,n) 	for(int i=a;i>=(n);--i)
#define so(a) 			sort(a.begin(),a.end())
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
// to find all local maximaa and minima in O(n)
//	 for (int i=1;i<=n;i++)
//        {
//            if (i==1 || i==n || (p[i-1]<p[i])!=(p[i]<p[i+1]))
//           ans.push_back(p[i]);
//        }

int dp[(1 << 16)];
int sums[(1 << 16)];
int preparesums(vector<vi>&score, int mask)
{
	int ans = 0;
	rep(i, 17)
	repA(j, i + 1, 16)
	{
		if ((mask & (1 << i)) && (mask & (1 << j)))
			ans += score[i][j];
	}
	return ans;
}
int solve(vector<vi>&score, int mask)
{
	if (mask == 0) return 0;
	if (dp[mask] != inf)
		return dp[mask];
	int ans = 0;
	for (int submask = mask; submask != 0; submask = (submask - 1)&mask)
		ans = max(ans, sums[submask] + solve(score, mask ^ submask));
	return dp[mask] = ans;
}
void solve()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<vi>score(n, vi(n));
	rep(i, n)
	rep(j, n)
	cin >> score[i][j];
	sums[0] = 0;
	repA(subset, 1, (1 << n) - 1)
	dp[subset] = inf;
	repA(subset, 1, (1 << n) - 1)
	sums[subset] = preparesums(score, subset);
	db1(solve(score, (1 << n) - 1));
}
int32_t main()
{
	solve();
	return 0;
}


Measured memory_bytes: 4632
Module Module1

    Sub main()
        Dim user1 = Console.ReadLine()
        Dim kujiMax As Long = user1
        Dim getItems As New List(Of String)

        For i = 0 To kujiMax - 1
            'Dim user2 = Console.ReadLine()
            'If Not getItems.Contains(user2) Then
            '    getItems.Add(user2)
            'End If
            getItems.Add(Console.ReadLine())
        Next

        'Console.WriteLine(getItems.Count)
        Console.WriteLine(getItems.GroupBy(Function(x) x).Count)
    End Sub
end module

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

typedef long long i64;

int main()
{
    i64 a, b, c, d;
    i64 n;
    cin >> n >> a >> b >> c >> d;
    i64 dif = abs(a - b);

    n--;

    for (int k(0); k <= n; k++) {
        i64 difmax = k * d - (n - k) * c;
        i64 difmin = k * c - (n - k) * d;
        if (difmax >= dif && difmin <= dif) {
            cout << "YES";
            return 0;
        }
    }

    cout << "NO";
    return 0;
}


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

int main() {
  double a,b,x;
  cin >> a >> b >> x;
  
  double theta;
  if (x >= a*b*a/2.0){
    //theta = atan(2*(b-x/(a*a))/a) *180.0 / M_PI;
    theta = atan(2 * (b / a - x / (a * a * a))) * 180.0 / M_PI;
  }
  else {
    theta = atan(a*b*b/(2.0*x))*180.0 / M_PI;
  }
  
  cout << fixed << setprecision(6) << theta << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

#include <atcoder/convolution>
#include <atcoder/dsu>
#include <atcoder/fenwicktree>
#include <atcoder/lazysegtree>
#include <atcoder/math>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/modint>
#include <atcoder/scc>
#include <atcoder/segtree>
#include <atcoder/string>
#include <atcoder/twosat>
using namespace atcoder;

int main(){
  int N,Q;
  cin>>N>>Q;
  VL A(N);
  rep(i,N) cin>>A[i];
  VL B(Q),C(Q),D(Q);
  rep(i,Q) cin>>B[i]>>C[i]>>D[i];
  fenwick_tree<ll> fw(N);
  rep(i,N) fw.add(i,A[i]);
  rep(i,Q){
    if(!B[i]) fw.add(C[i],D[i]);
    else cout<<fw.sum(C[i],D[i])<<endl;
  }
}



Measured memory_bytes: 23820
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)


ll n;
P a[300000];
priority_queue<P,vector<P> , greater<P> > q; //????????????id
priority_queue<ll,vector<ll>, greater<ll> > list; //?????\??£???????????????id
bool ok(ll X){//X???????????????
	//cout<<"start "<<X<<endl;
	ll jud;//????????\???????????£??????return 1
	ll val=0;
	while(!list.empty()) list.pop();
	while(!q.empty()) q.pop();
	rep(i,n) q.push(P(a[i].fr,i));
	rep(i,X){
		P p=q.top();
		q.pop();
		val+=p.fr;
		list.push(p.sc);
	}
	rep(i,n-X+1){
		jud=a[i].sc*X;
		//cout<<i<<"i    jud"<<jud<<"   val"<<val<<endl;
		if(val<=jud){
			return 1;
		}
		ll m=list.top();
		if(m==i){
			list.pop();
			val-=a[m].fr;
			while(!q.empty()&&q.top().second<=i) q.pop();
			if(q.size()){
				P p=q.top();
				q.pop();
				val+=p.fr;
				list.push(p.sc);
			}
		}
		
	}
	//cout<<endl;
	return 0;
}


int main()
{
	cin>>n;
	rep(i,n) cin>>a[i].fr>>a[i].sc;
	sort(a,a+n,[](P a,P b){
		return a.sc<b.sc;
	});
	//cout<<endl;
	//rep(i,n) cout<<i<<"]="<<a[i].fr<<" "<<a[i].sc<<endl;
	ll ub=n+1;
	ll lb=0;
	while(ub-lb>1){
		ll mid=(ub+lb)/2;
		if(ok(mid)){
			lb=mid;
		}
		else ub=mid;
	}
	cout<<lb<<endl;
}

Measured memory_bytes: 18652
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    const A = parseInt(input[0].split(" ")[0]);
    const B = parseInt(input[0].split(" ")[1]);
    for(let i = 0; i<=1000; i++){
        if(Math.floor(i*0.08) == A && Math.floor(i*0.1) == B){
            console.log(i)
            return
        }
    }
    console.log('-1')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

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

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

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

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

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

    var(string, s);

    vector<size_t> cnt(2);
    for (const auto e: s) {
        cnt[e & 1]++;
    }

    output(min(cnt[0], cnt[1]) * 2);

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m), d;
    rep(i, m)cin >> x[i];
    sort(x.begin(), x.end());
    rep(i, m - 1)d.push_back(x[i+1]-x[i]);
    sort(d.begin(), d.end());

    int ans = 0;
    rep(i, max(0, m - n))ans += d[i];
    cout << ans << endl;
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N;
    string c;
    cin >> N >> c;

    vec cnt(N, 0);
    ll tmp = 0;
    for (ll i = N-1; i >= 0; i--) {
        if (c[i] == 'R') tmp++;
        else if (c[i] == 'W') cnt[i] = tmp;
    }

    // printvec(cnt);

    ll ans = 0;
    Rep (l, N) {
        if (c[l] == 'R') continue;
        else if (c[l] == 'W' and cnt[l] > ans) ans++;
    }

    cout << ans << "\n";
}

Measured memory_bytes: 5192
#include <iostream>
using namespace std;
int main(void){

 int N;
 cin >> N;
 
 int C0 = 0;
 int C1 = 0;
 int C2 = 0;
 int C3 = 0;
 
 for(int i = 0; i < N; i++){
     string S;
     cin >> S;
     if(S == "AC"){
         C0++;
     }
     else if(S == "WA"){
         C1++;
     }
     else if(S == "TLE"){
         C2++;
     }
     else if(S == "RE"){
         C3++;
     }
}

cout <<"AC x " << C0 <<endl;
cout <<"WA x " << C1 <<endl;
cout <<"TLE x " << C2 <<endl;
cout <<"RE x " << C3 <<endl;

}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int x;

	cin >> x;

	if( x == 7 || x == 5 || x == 3 ) YES;
	else NO;

	ret 0;
}

Measured memory_bytes: 256
import math
from collections import Counter

N = int(input())

c = Counter()

ans = 0
for n in range(1, N + 1):
    left = n // (10 ** int(math.log10(n)))
    right = n % 10
    c[(left, right)] += 1

for left, right in c.keys():
    ans += c[(left, right)] * c[(right, left)]

print(ans)


Measured memory_bytes: 9492
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	ll N, K;
	cin >> N >> K;

	//addnum本辺を追加する
	ll addnum = (N - 2) * (N - 1) / 2 - K;
	if(N == 2 && K == 0){
		cout << "1" << endl;
		cout << "1 2" << endl;
		return 0;
	}
	if(addnum < 0 || N == 2){
		cout << "-1" << endl;
		return 0;
	}
	vector<pll> ANS;
	for(ll i = 2; i <= N; i ++){
		ANS.pm(1LL, i);
	}
	ll cnt = 0;
	for(ll i = 2; i <= N && cnt < addnum; i ++){
		for(ll j = i + 1; j <= N && cnt < addnum; j ++){
			ANS.pm(i, j);
			cnt ++;
		}
	}
	cout << ANS.size() << endl;
	for(ll i = 0; i < ANS.size(); i ++){
		cout << ANS[i].first << SPACE << ANS[i].second << endl;
	}

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int N, M;
	cin >> N >> M;
	vector<vector<int>> S(M);
	int k, s;
	for(int i = 0; i < M; i ++){
		cin >> k;
		for(int j = 0; j < k; j ++){
			cin >> s;
			S[i].pb(s - 1);
		}
	}
	vector<int> p(M);
	for(int i = 0; i < M; i ++){
		cin >> p[i];
	}
	bool flag;
	int cnt, ans = 0;
	for(unsigned ll bit = 0; bit < pow(2, N); bit ++){
		//cout << "bit = " << bit << endl;
		flag = true;
		for(int i = 0; i < M; i ++){
			cnt = 0;
			for(int j = 0; j < S[i].size(); j ++){
				if(bit & (1<<S[i][j]))cnt++;
			}
			if(cnt%2 != p[i]){
				//cout << "EEE " << i << endl;
				flag = false;
				break;
			}
		}
		if(flag){
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define rep(i, a) for (int i = 0; i < (a); i++)
#define repd(i, a) for (int i = (a)-1; i >= 0; i--)
#define reps(i, a, j) for (int i = (j); i < (a); i++)
#define deb(x) cout << #x << " " << x << endl;
#define debs(x) cout << #x << " " << x << " ";
#define deba(x) for (auto _i:x) cout << _i << " ";cout << endl;
#define ms(a) memset(a,0,sizeof(a));
#define mp make_pair
#define eb emplace_back
#define pii pair < int , int >
#define all(a) a.begin(),a.end() 

const int mod = 1e9 + 7;
void solve() {
    int n,k; cin >> n >> k;
    int dp[n][k+1];
    ms(dp);
    rep(i,n) {
        int x; cin >> x;
        rep(j,k+1) {
            if (i == 0) {
                if (j <= x) dp[i][j] = 1;
            }else {
                // for (int no = 0; no <= min(j,x); no++) {
                //     dp[i][j] += (dp[i-1][j-no]);
                // }
                 dp[i][j] = (dp[i-1][j]%mod - (j-min(j,x)-1 >=0 ?dp[i-1][j-min(j,x)-1]:0)%mod + mod)%mod;
            }
        }
        if (i != n-1) reps(j,k+1,1) dp[i][j] = (dp[i][j]%mod + dp[i][j-1]%mod)%mod;
    }
    // rep(i,n) {deba(dp[i]); cout << endl;}
    cout << dp[n-1][k] << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t; t=1;
    while (t--) solve();
}





Measured memory_bytes: 81796
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back

using namespace std;

char ch;

int main()
{
    cin >> ch;
    if (ch>='A'&&ch<='Z')cout << "A\n";
    else cout << "a\n";
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(int a, int b) {
	return a > b;
}

int main() {
	llint n, k;
	cin >> n >> k;
	vector<llint>a(n);
	llint max = 0;
	rep(i, n) {
		cin >> a[i];
		if (max < a[i]) {
			max = a[i];
		}
	}
	llint cnt = 0;
	llint tmp = k;
	if (max > tmp) {
		tmp = max;
	}
	if (tmp == 0) {
		cnt = 1;
	}
	while (tmp > 0) {
		cnt++;
		tmp /= 2;
	}
	vector<llint>b(cnt);
	rep(i, n) {
		for (int j = 0;a[i] > 0;j++) {
			b[cnt - 1 - j] += a[i] % 2;
			a[i] /= 2;
		}
	}
	tmp = 0;
	llint ans = 0;
	llint x;
	rep(i, cnt) {
		x = pow(2, cnt - 1 - i);
		if ((double)b[i] < (double)n / 2 && tmp + x <= k) {
			ans += x*(n - b[i]);
			tmp += x;
		}
		else {
			ans += x*b[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  int n;
  cin >> n;
  vi L(n);
  rep(i,n) cin >> L[i];
  SORT(L);
  int ans = 0;
  rep(b,n) {
    int r = b+1;
    rep(a,b) {
      int ab = L[a]+L[b];
      while (r < n && L[r] < ab) ++r;
      int l = b+1;
      // c = [l,r)
      ans += max(0,r-l);
    }
  }
  cout << ans << 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(); //高橋攻撃力
		int c = sc.nextInt(); //青木体力
		int d = sc.nextInt(); //青木攻撃力

		double num1 = Math.ceil((double)a / d) + 1;
		double num2 = Math.ceil((double)c / b) + 1;

		if(num2 <= num1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();

	}

}

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

int main ( ) {
	int N, K;
	int num = 1;

	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		if (num * 2 < num + K) {
			num *= 2;
		} else {
			num += K;
		}
	}
	cout << num << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int n,i,j;
	scanf("%d", &n);
	if (n % 2 == 0) {
		printf("%d\n", (n - 2)*n / 2);
		for (i = 1; i < n; i++) {
			for (j = i + 1; j <= n; j++) {
				if (i + j != n+1) { printf("%d %d\n", i, j); }
			}
		}
	}
	else {
		printf("%d\n", (n - 1)*(n - 1)/2);
		for (i = 1; i < n-1; i++) {
			for (j = i + 1; j < n; j++) {
				if (i + j != n) { printf("%d %d\n", i, j); }
			}
		}
		for (i = 1; i < n; i++) {
			printf("%d %d\n", n, i);
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int ans = -1;
    int a, b, c;
    cin >> a >> b >> c;
    ans = max(ans, a + b * 10 + c);
    ans = max(ans, a + c * 10 + b);
    ans = max(ans, b + a * 10 + c);
    ans = max(ans, b + c * 10 + a);
    ans = max(ans, c + a * 10 + b);
    ans = max(ans, c + b * 10 + a);
    cout << ans << endl;
    system("pause");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, double> pdd;
const double eps = 1e-10;
const double pi = acos(-1);
inline int sgn(double d){if(fabs(d) < eps) return 0;if(d > 0) return 1;return -1;}
inline double rad(double _deg){return _deg / 180.0 * pi;}
inline double deg(double _rad){return _rad / pi * 180.0;}
struct Point{
	double x, y;
	void read(){scanf("%lf%lf", &x, &y);}
	Point():x(0.0), y(0.0){}
	Point(double a, double b = 0.0): x(a), y(b){}
	Point(const Point& p): x(p.x), y(p.y){}
	Point operator + (const Point& a){return {x + a.x, y + a.y};}
	Point operator - (const Point& a){return {x - a.x, y - a.y};}
	double operator * (const Point& a){return x * a.x + y * a.y;}
	double operator ^ (const Point& a){return x * a.y - y * a.x;}
	bool operator == (const Point& p){return sgn(x - p.x) == 0 && sgn(y - p.y) == 0;}
	bool operator < (const Point &p) const{
		if(sgn(x - p.x) == 0) 
			return sgn(y - p.y) == -1;
		return sgn(x - p.x) == -1;
	}
	double length(){return sqrt(x * x + y * y);}
}typedef Vector;
struct Line{
	Point a, b;
	void read(){a.read(); b.read();}
	Line() : a(0.0, 0.0) , b(0.0, 0.0){}
};
struct Segment{
	Point a, b;
	void read(){a.read(); b.read();}
	Segment() : a(0.0, 0.0) , b(0.0, 0.0){}
};
double distance(const Point &a, const Point &b) 
{
	double x = a.x - b.x;
	double y = a.y - b.y;
	return sqrt(x * x + y * y);
}
Point Projection(Point p, Line l)
{ 
	// 点在直线上的投影点
	Vector v1 = l.b - l.a;
	Vector v2 = p - l.a;
	double k1 = v1 * v2;
	double k2 = v1.length();
	k1 /= k2 * k2;
	return {l.a.x + v1.x * k1, l.a.y+ v1.y * k1};
}
Point Reflection(Point p, Line l)
{
	// 点关于直线对称
	Point p0 = Projection(p, l);
	Vector v0 = p0 - p;
	return p0 + v0;
}
int ccw(Point p, Segment sg)
{
	// p 关于(sg.a -> sg.b)的关系
	Vector v0 = sg.b - sg.a;
	Vector v1 = p - sg.a;
	
	int fcross = sgn(v0 ^ v1);
	
	if(fcross == 1) return 1; // 顺时针方向
	if(fcross == -1) return 2; // 逆时针方向
	
	int fdot = sgn(v0 * v1);
	
	if(fdot == -1) return 3; // 反向线段外共线
	if(v0.length() < v1.length()) return 4; //正向线段外共线
	return 5; //点在线段上
}
int main()
{
	Segment sg;
	sg.read();
	int n;
	scanf("%d", &n);
	while(n --)
	{
		Point p;
		p.read();
		int ans = ccw(p, sg);
		if(ans == 1) puts("COUNTER_CLOCKWISE");
		else if(ans == 2) puts("CLOCKWISE");
		else if(ans == 3) puts("ONLINE_BACK");
		else if(ans == 4) puts("ONLINE_FRONT");
		else puts("ON_SEGMENT");
	}
	return 0;
}


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

bool isRow(vector<vector<char>> r, int i)
{
	for (int j = 0; j < r[0].size(); ++j)
	{
		if (r[i][j] != '.')
		{
			return false;
			break;
		}
	}
	return true;
}

bool isColumn(vector<vector<char>> r, int j)
{
	for (int i = 0; i < r.size(); ++i)
	{
		if (r[i][j] != '.')
		{
			return false;
			break;
		}
	}
	return true;
}

int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<char>> T(H, vector<char>(W));
	for (int i = 0; i < H; ++i)
		for (int j = 0; j < W; ++j)
			cin >> T[i][j];

	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			if (isColumn(T, j))
				continue;
			else if (isRow(T, i)) 
				goto skip;	
			else
				cout << T[i][j];
		}
		cout << endl;
        skip:{} 
	}
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
	int a,b;
	sd(a);sd(b);
	pd(6-a-b);
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long n;
	cin >> n;
	if (n % 2) {
		cout << 0;
		return 0;
	}
	long long ans = 0, k = 0;
	long long A = 1, B = 1;
	for (int i = 0; A <= 1e18; i++) {
		A *= 5;
		if (ans < n / 2)
			ans += (n / 2) / A;
	}
	for (int i = 0; B <= 1e18; i++) {
		B *= 2;
		k += n / B;
	}
	ans = min(ans, k);
	cout << ans;
}


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

using namespace std;

int main(void){
	while(1){
		int d, e; cin >> d >> e;
		if(!d && !e) break;
		double cost;
		double ans = 1e9;
		for(int i=0; i<d; i++){
			int sum = 0;
			sum = i*i + (d-i)*(d-i);
			cost = sqrt(sum);
			ans = min(ans, abs((double)e-cost));
		}
		printf("%.10lf\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-9;    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

inline bool is_parallel(pp l1, pp l2) {
  return (l1.second.second-l1.first.second)*(l2.second.first-l2.first.first) == (l1.second.first-l1.first.first)*(l2.second.second-l2.first.second);
}

int n;
pi points[16];
bool used[16];
int ans = 0;
pp vl[8];
int vl_l;

void dfs(int cnt) {
    rep(i,n) {
        if (!used[i]) {
            used[i] = true;
            for (int j = i+1; j < n; j++) {
                if (!used[j]) {
                    used[j] = true;
                    pp l = pp(points[i], points[j]);
                    int now = cnt;
                    rep(k,vl_l) {
                        if (is_parallel(l, vl[k])) now++;
                    }
                    vl[vl_l++] = l;
                    ans = max(ans,now);

                    dfs(now);

                    used[j] = false;
                    vl_l--;
                }
            }
            used[i] = false;
            break;
        }
    }
}

void solve() {
    cin >> n;
    rep(i,n) {
        int x, y; cin >> x >> y;
        points[i] = pi(x,y);
    }
    memset(used,0,sizeof(used));
    dfs(0);
    cout << ans << endl;
}

int main() {
#ifndef LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
    cout.precision(20);
    cerr << fixed;
    cerr.precision(6);
#ifdef LOCAL
    //freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif  
    solve();
    //cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}



Measured memory_bytes: 3216
import collections
import itertools as it
import math
import numpy as np

# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()
H, N = map(int, input().split())
A = list(map(int, input().split()))

if sum(A) >= H:
    print('Yes')
else:
    print('No')

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

int main() {
    int row, column;
    cin >> row >> column;

    vector<vector<char>> mtx(row+2, vector<char>(column+2));
    vector<vector<char>> asw(row+2, vector<char>(column+2, '0'));
    for(int i=1; i<row+1; ++i){
        for(int j=1; j<column+1; ++j){
            cin >> mtx.at(i).at(j);
        }
    }

    vector<int> vec={-1,0,1};
    for(int i=1; i<row+1; ++i){
        for(int j=1; j<column+1; ++j){
            if(mtx.at(i).at(j) == '#'){
                asw.at(i).at(j) = '#';
                for(auto p:vec){
                    for(auto q:vec){
                        if(asw.at(i+p).at(j+q)=='#'){
                            continue;
                        }
                        asw.at(i+p).at(j+q)=char((int)asw.at(i+p).at(j+q)+1);
                    }
                }

            }
        }
    }
    for(int i=1; i<row+1; ++i){
        for(int j=1; j<column+1; ++j){
            cout << asw.at(i).at(j);
        }
        cout << endl;
    }
}

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

struct Edge {
	int from;
	int to;
	int cost;
};

const ll INF = 1LL << 60;

int main() {
  int n, m;
	cin >> n >> m;
	vector<Edge> g(m);
	rep(i, m) {
		cin >> g[i].from >> g[i].to >> g[i].cost;
		g[i].from--, g[i].to--;
	}
	vector<ll> ans(n, -INF);
	ans[0] = 0;
	rep(i, n) rep(j, m) {
		Edge e = g[j];
		if (ans[e.from] == -INF) continue;
		if (ans[e.from] + e.cost > ans[e.to]) {
			ans[e.to] = ans[e.from] + e.cost;
			if (i == n - 1 && e.to == n - 1) {
				cout << "inf" << endl;
				return 0;
			}
		}
	}
	cout << ans[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        boolean[] f = new boolean[100001];
        int[] c = new int[100002];
        int N, L, R;
        for (int i = 2; i < 100000; i++) {
            if (!f[i]) {
                for (int j = i + i; j <= 100000; j += i) {
                    f[j] = true;
                }
            }
        }
        for (int i = 3; i <= 100000; i += 2) {
            if (!f[i] && !f[(i + 1) / 2]) {
                c[i]++;
            }
        }
        for (int i = 3; i <= 100000; i++) {
            c[i] += c[i - 1];
        }
        N = sc.nextInt();
        while (N-- != 0) {
            L = sc.nextInt();
            R = sc.nextInt();
            System.out.println(c[R] - c[L - 1]);
        }
    }
}

Measured memory_bytes: 65116
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int check(int a)
{
	if (11 <= a && a <= 14)
	{
		return(0);
	}
	else if (18 <= a && a <= 20)
	{
		return(1);
	}
	else if (21 <= a || a <= 1)
	{
		return(2);
	}
	return(-1);
}

void solve()
{
	int n;
	while (cin >> n, n)
	{
		vector<int> sumCnt(3);
		vector<int> okCnt(3);
		for (int i = 0; i < n; ++i)
		{
			int hh, mm, MM;
			char c;
			cin >> hh >> c >> mm >> MM;
			int x = check(hh);
			if (x == -1)
			{
				continue;
			}
			MM -= mm;
			if (MM < 0)
			{
				MM += 60;
			}
			if (MM <= 8)
			{
				okCnt[x]++;
			}
			sumCnt[x]++;
		}
		if (sumCnt[0])
		{
			cout << "lunch " << 100 * okCnt[0] / sumCnt[0] << endl;
		}
		else
		{
			cout << "lunch no guest" << endl;
		}
		if (sumCnt[1])
		{
			cout << "dinner " << 100 * okCnt[1] / sumCnt[1] << endl;
		}
		else
		{
			cout << "dinner no guest" << endl;
		}
		if (sumCnt[2])
		{
			cout << "midnight " << 100 * okCnt[2] / sumCnt[2] << endl;
		}
		else
		{
			cout << "midnight no guest" << endl;
		}
	}
}

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

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

using namespace std;

int const nmax = 100;
int v[1 + nmax];

int main() {

  int n, m, sum = 0, p, mint = 1000000;
  cin >> n >> m >> p;
  cout << (n - p) / (m + p);
  return 0;
}


Measured memory_bytes: 3592
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>

using namespace std;

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

	if (N >= K)
	{
		cout << K*X + (N - K)*Y << endl;
	}
	else
	{
		cout << N*X << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+7;

int p[MAXN];
bool done[MAXN];

int parent(int u) {
    if (u==p[u]) return u;
    return p[u] = parent(p[u]);
}

bool unite(int u, int v) {
    u = parent(u);
    v = parent(v);

    if (u==v) {
        if (done[u]) return false;
        done[u] = true;
        return true;
    }

    if (done[u] && done[v]) return false;

    p[v] = u;
    done[u] |= done[v];

    return true;
}

typedef tuple< int , int , int >triple;

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

    int n, h, w;
    cin >> n >> h >> w;

    for (int i = 1; i <= h+w; i++) p[i] = i;

    vector< triple >edges(n);
    for (int i = 0; i < n; i++) {
        cin >> get<1>(edges[i]) >> get<2>(edges[i]) >> get<0>(edges[i]);
    }

    sort(edges.rbegin(), edges.rend());

    long long ans = 0;
    for (triple t : edges) {
        int u = get<1>(t);
        int v = h+get<2>(t);
        if (unite(u, v)) {
            ans += get<0>(t);
//            cout << "taken " << get<0>(t) << endl;
        }
    }

    cout << ans << "\n";


    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= n; i--)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
const int mod = 1e9+7;

const ll INF = 1e14;
const int MAX = 1e4;

struct edge {int to, cost;};
vector<edge> graph[MAX]; // 隣接リスト
ll dist[MAX]; // 始点からの距離

void bellman_ford(int n, int s, bool &flag) {
    fill(dist, dist+MAX, INF);
    dist[s] = 0;
    for (int i = 0; i < n; i++) { // 頂点の数ループ
        rep(from, n) {
            for (edge e : graph[from]) {
                if (dist[e.to] > dist[from] + e.cost) {
                    dist[e.to] = dist[from] + e.cost;
                    if (i == n-1 and e.to == n-1) { // 負の閉路の検出
                        flag = true;
                        return;
                    }
                }
            }
        }
    }
}

int main() {
    // input
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int from, to, cost;
        cin >> from >> to >> cost;
        from--; to--; cost *= -1;
        graph[from].push_back({to, cost});
    }
    // solve
    bool flag = false;
    bellman_ford(n, 0, flag);
    if (not flag) {
        cout << -dist[n-1] << "\n";
    } else {
        cout << "inf" << "\n";
    }
}

Measured memory_bytes: 3932
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void solve()
{
    ll A, B;
    cin >> A >> B;
    ll taps = 0;
    while ((A - 1) * taps + 1 < B)
    {
        taps++;
    }

    cout << taps << endl;
}

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


Measured memory_bytes: 256
nums=list(map(int,input().split()))

if nums[2] >= nums[1]:
	a=nums[1]
	b=nums[2]
else:
	b=nums[1]
	a=nums[2]
	
if nums[0] <= a:
	min=nums[0]
	mid=a
	max=b
elif nums[0] <= b:
	min=a
	mid=nums[0]
	max=b
else:
	min=a
	mid=b
	max=nums[0]

print(min,mid,max)

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

template <typename T> vector<T> readVector(int n) { vector<T> res(n); for (int i = 0 ; i < n ; i++) cin >> res[i]; return res; }

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

    int l, r, d;
    cin >> l >> r >> d;

    int cnt = 0;
    for(int i=l; i<=r; i++) {
        if(i%d == 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3608
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]
    N = int(input())
    if N < 1200:
        print('ABC')
    elif N<2800 and N >= 1200:
        print('ARC')
    else:
        print('AGC')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include <bits/stdc++.h>
 
using namespace std;
 
//conversion
//------------------------------------------
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();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//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 SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const double INF=1e9;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int N,M,K;
double res;
void dfs(int cnt,int sum){
	if(cnt==N){
		res+=max(sum-K,1);
		return;
	}
	REP(i,M)dfs(cnt+1,sum+i+1);
}
int main(){
	
	while(cin>>N>>M>>K,N,M){
		res=0.0;
		dfs(0,0);
		double cmb=pow(M,N);
		cout<<fixed<<setprecision(10)<<res/cmb<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1288