akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template <class T> inline T gcd(T a, T b) {if(a==0) return b; return gcd(b%a,a);}
template <class T> inline T lcm(T a, T b) {return a * b / gcd(a,b);}
template <class T> inline T sum(vector<T> &vec) {T res=0; for (int i = 0; i < vec.size(); i++) res += vec[i]; return res;}
template <class T> inline T mpow(T a, T b) {if(b==0)return 1; T c = mpow(a,b/2);if(b%2==1)return c*c*a; return c*c;}
const int INF = 1 << 30;
const long long INFLL = 1LL << 60;
typedef pair<int, int> P;

#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define FOR(i,n) for (int (i)=0;(i)<(n);(i)++)
#define REPB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define FORB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define SORT(A) sort((A).begin(),(A).end())


ll bit[200001], N, D, A;
ll sum(ll i) {
    ll s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    } return s;
}
void add(ll i, ll x) {
    while (i <= 200000) {
        bit[i] += x;
        i += i & -i;
    }
}

int main() {
    
    cin >> N >> D >> A;
    vll X(N), H(N);
    vector<pair<ll,ll>> G(N);
    FOR(i,N) {
        cin >> X[i] >> H[i];
        G[i] = make_pair(X[i],H[i]);
    }
    SORT(G);

    ll res = 0;

    ll idx = 0;
    vll idxs(N);
    FOR(i,N) {
        chmax(idx,(ll)i);
        while (idx+1 < N && G[idx+1].first <= G[i].first + 2*D) idx++;
        idxs[i] = idx;
        //cout << idx << " " << endl;
    }
    //FOR(i,N) cout << idxs[i] << " ";
    //cout << endl;

    FOR(i,N) {
        G[i].second -= sum(i+1);
        //cout << G[i].second << " ";
        if (G[i].second > 0) {
            ll d = (G[i].second+A-1)/A;
            add(i+1,A*d);
            add(idxs[i]+2,-A*d);
            res += d;
        }
    }
    cout << res << endl;

}


Measured memory_bytes: 9600
from collections import deque
from functools import reduce
from itertools import zip_longest
from operator import mul


def dfs(links):
    q = deque([(v, 0) for v in links[0]])
    v = 0
    while q:
        v, a = q.popleft()
        q.extend((u, v) for u in links[v] if u != a)

    anc = [-1] * len(links)
    q = deque([(u, v) for u in links[v]])
    u = 0, 0
    while q:
        u, a = q.popleft()
        anc[u] = a
        q.extend((w, u) for w in links[u] if w != a)

    path = [u]
    a = u
    while a != v:
        a = anc[a]
        path.append(a)
    return path


def calc(links, v, a, l):
    ans = [1] * l
    q = deque([(u, v, 1) for u in links[v] if u != a])
    ans[0] = len(q)
    while q:
        u, a, c = q.popleft()
        ans[c] = max(ans[c], len(links[u]) - 1)
        q.extend((w, u, c + 1) for w in links[u] if w != a)
    return ans


def solve(n, links):
    if n == 2:
        return 1, 2

    path = dfs(links)
    c = len(path)
    l = (len(path) + 1) // 2
    # print('path', path)

    if c % 2 == 0:
        u, v = path[c // 2 - 1], path[c // 2]
        ans1 = calc(links, u, v, l)
        ans2 = calc(links, v, u, l)
        # print('ans12', ans1, ans2)
        leaves = 1
        for a1, a2 in zip(ans1, ans2):
            leaves *= max(a1, a2)
        return len(ans1), leaves * 2
    v = path[c // 2]
    ans0 = calc(links, v, None, l)
    leaves = reduce(mul, ans0, 1)
    # print('ans0', ans0, leaves)
    for u in links[v]:
        ans1 = calc(links, u, v, l)
        ans2 = calc(links, v, u, l)
        tmp = 1
        for a1, a2 in zip_longest(ans1, ans2):
            tmp *= max(a1, a2)
        # print('ans12', ans1, ans2, tmp)
        leaves = min(leaves, tmp * 2)
    return len(ans0), leaves


n = int(input())
links = [set() for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)
print(*solve(n, links))


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

int main(){
  string S;
  cin >> S;
  for(int i=0; i<S.size(); i++){
    if(i==5 || i==13){
      cout << " " ;
    }
    else{
      cout << S.at(i) ;
    }
  }
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;
using p = pair<int, int>;

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

    std::cout << ((S == "ABC") ? "ARC" : "ABC") << endl;

    return 0;
}


Measured memory_bytes: 3628
N = int(input())
h = list(map(int, input().split()))

cost = [0]*N+[10000]

for i in range(1,N):
    cost[i] = min(cost[i-1]+abs(h[i-1]-h[i]),cost[i-2]+abs(h[i-2]-h[i]))

print(cost[N-1])

Measured memory_bytes: 13976
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    D = LI()
    D.sort()
    print(D[N//2] - D[N//2 -1])
if __name__ == '__main__':
    main()

Measured memory_bytes: 52624
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 100000000000000;
const double PI = acos(-1);

int a[100100];

int main() {
	int n;
	cin >> n;
	LL ans = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		ans += a[i] / 2;
		a[i] %= 2;
		if (i != n&&a[i] == 1 && a[i + 1] != 0) {
			ans++;
			a[i + 1]--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

bool next_combination(std::vector<int>& sequence, int m)
{
    int index = static_cast<int>(sequence.size()) - 1;
    while (0 <= index && sequence[index] == m)
    {
        --index;
    }

    if (index == -1)
    {
        return false;
    }

    ++sequence[index];
    int n = sequence[index];
    for (++index; index < static_cast<int>(sequence.size()); ++index)
    {
        sequence[index] = n;
    }

    return true;
}

int aggregate_score(const std::vector<std::tuple<int, int, int, int>>& qs, const std::vector<int>& sequence)
{
    int score = 0;
    for (const auto [a, b, c, d] : qs)
    {
        if (sequence[b-1] - sequence[a-1] == c)
        {
            score += d;
        }
    }

    return score;
}

int main()
{
    int n, m, q;
    std::cin >> n >> m >> q;
    std::vector<std::tuple<int, int, int, int>> qs = {};
    qs.reserve(q);
    
    int a, b, c, d;
    while (std::cin >> a >> b >> c >> d)
    {
        qs.emplace_back(a, b, c, d);
    }

    std::vector<int> sequence(n, 1);

    int max_score = 0;
    do
    {
        max_score = std::max(max_score, aggregate_score(qs, sequence));
    } while (next_combination(sequence, m));
    
    std::cout << max_score << std::endl;
}


Measured memory_bytes: 3628
while(1):
    H,W=map(int,input().split(" "))

    if(not H and not W):
        break

    turn_H=1
    turn_W=1
    for i in range(H):
        turn_W=turn_H
        for j in range(W):
            if(turn_W):
                print("#",end="")
            else:
                print(".",end="")
            turn_W=abs(turn_W-1)
        print()
        turn_H=abs(turn_H-1)
    print()


Measured memory_bytes: 7004
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf=1e9+7;
ll x[1000000];
ll sum[10];
int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    ll h,w,n;
    cin>>h>>w>>n;
    ll ans=(h-2)*(w-2);
    //cout<<ans<<endl;
    ll k=0;
    ll a,b;
    for(ll u=0; u<n; u++)
    {
        cin>>a>>b;
        for(ll i=0; i<=2; i++)
            for(ll j=0; j<=2; j++)
            {
                if(a-i>=1&&a-i<=h-2&&b-j>=1&&b-j<=w-2)
                {
                    x[k]=inf*(a-i)+(b-j);k++;
                }
            }
    }
    sort(x,x+k);
    ll t=1;
    for(ll i=0;i<k;i++)
    {
        if(x[i]==x[i+1])t++;
        else
        {
            sum[t]++;
            t=1;
            ans--;
        }
    }
    cout<<ans<<endl;
    for(ll i=1;i<=9;i++)
        cout<<sum[i]<<endl;
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

int X;

signed main()
{
	X=read();
	for ( int i=-200;i<=200;i++ ) 
		for ( int j=-200;j<=200;j++ ) 
		{
			int A=i*i*i*i*i;
			int B=j*j*j*j*j;
			if(A-B==X) 
				return printf("%lld %lld\n",i,j),0;
		}
	return 0;
}
			 

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

using namespace std;

// input
map<ll, ll> memo;
ll h;

ll dfs(ll x) {
  if(x == 1) return 1;
  else if(memo.find(x) != memo.end()) return memo[x];
  else {
    ll tmp = dfs(x/2);
    memo[x] = tmp;
    return memo[x] + memo[x] + 1;
  }
}


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

  cin >> h;

  cout << dfs(h);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var a = ReadSplitInt();
            var ans = 0;
            for (int i = 0; i < N; i++)
            {
                var tmp = a[i];
                while (tmp % 2 == 0)
                {
                    ans++;
                    tmp /= 2;
                }
            }
            Println(ans);
        }

        static List<int> ReadLines(int n)
        {
            var l = new List<int>();
            for (int i = 0; i < n; i++)
            {
                l.Add(ReadInt());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

Measured memory_bytes: 12000
import sys
readline = sys.stdin.readline
from collections import Counter
MOD = 2019

def main():
    S = list(map(int, list(readline().rstrip())))
    N = len(S)
    T = [0] * (N+1)
    e = 1
    for i in range(N-1, -1, -1):
        T[i] = (T[i+1] + int(S[i]) * e) % MOD
        e = e * 10 % MOD
    
    T = [t % MOD for t in T]
    c = Counter(T)
    ans = 0
    for k, v in c.items():
        ans += (v * (v-1)) // 2
    print(ans)


if __name__ == '__main__':
    main()

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

int main()
{
	int N;
	cin >> N;
	map<string, int> cnt;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		cnt[s]++;
	}
	int M;
	cin >> M;
	for (int i = 0; i < M; i++) {
		string t;
		cin >> t;
		cnt[t]--;
	}
	int res = 0;
	for (auto& p : cnt) {
		res = max(res, p.second);
	}
	cout << res << endl;
	return 0;
}


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

 int main() {

	 std::string vec;
	 
	 std::cin >> vec;

	 if (vec[0] == vec[2]) {
		 std::cout << "Yes" << std::endl;
	 }
	 else {
		 std::cout << "No" << std::endl;
	 }

} 

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

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong n;
  cin >> n;

  queue<llong> que;
  REP(i,9){
    que.push(i+1);
  }
  llong cnt = 1;
  while(true){
    llong num = que.front();
    que.pop();
    if(cnt == n){
      cout << num << endl;
      break;
    }
    if(num % 10 != 9 && num % 10 != 0){
      que.push(num * 10 + (num % 10) - 1);
      que.push(num * 10 + (num % 10));
      que.push(num * 10 + (num % 10) + 1);
    }else if(num % 10 == 0){
      que.push(num * 10);
      que.push(num * 10 + 1);
    }else{
      que.push(num * 10 + 8);
      que.push(num * 10 + 9);
    }
    cnt++;
  }
  return 0;
}



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

typedef pair<int, int> P;

P f(int x)
{
	int a = x % 10;
	int b = 0;
	while (x)
	{
		b = x;
		x /= 10;
	}
	return P(a, b);
}
signed main(void)
{
	int n;
	map<P, int> freq;
	long long ans;

	cin >> n;
	For(i, 1, n + 1)
	{
		P p = f(i);
		freq[p]++;
	}
	ans = 0;
	For (i, 1, n + 1)
	{
		P p = f(i);
		P q(p.second, p.first);
		ans += freq[q];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)

int main(){

    fast;
    int T;
    T=1;
    //cin>>T;
    while(T--){
    	int l,r,d;
    	
    	cin>>l>>r>>d;
    	int x=(l-1)/d;
    	int y=r/d;
    	cout<<y-x;
    	
    	
    	

    }

}

Measured memory_bytes: 3576
N, M = [int(x) for x in input().strip().split(" ")]

def dfs(v):
    pvs = set([v])
    path = [v]
    def _dfs(v, path):
        for u in d[v]:
            if u in pvs:
                for i, c in enumerate(path):
                    if c == u:
                        break
                return path[i+1:]  + [u]
            if u in vs:
                continue
            pvs.add(u)
            vs.add(u)
            loop = _dfs(u, path + [u])
            pvs.remove(u)
            if loop:
                return loop
        return False
    return _dfs(v, path)

vs = set()
def dfs_w(v, d):
    # dfs while版 
    vs.add(v)
    pvs = set()
    stack = [v]
    path = []
    while True:
        if len(stack) == 0:
            break
        v = stack.pop()
        if v < 0:
            pvs.remove(path[-1])
            path.pop()
        else:
            pvs.add(v)
            path.append(v)
            for u in d[v]:
                if u in pvs:
                    for i, c in enumerate(path):
                        if c == u:
                            break
                    return path[i+1:]  + [u]
                if u in vs:
                    continue
                vs.add(u)
                stack += [-v, u]
    return False

d = [set() for _ in range(N+1)]
for _ in range(M):
    a, b = [int(x) for x in input().strip().split(" ")]
    d[a].add(b)

for i in range(N):
    i += 1
    if i in vs:
        continue
    loop = dfs_w(i, d)
    if loop:
        break

if not loop:
    print(-1)
    import sys
    sys.exit()

v2i = [-1 for _ in range(N+1)]
for i, v in enumerate(loop):
    v2i[v] = i

nloop, pvs = [], set()
v = loop[0]
f = False
while True:
    nloop.append(v)
    pvs.add(v)
    max_i = max_i_l = -1
    for u in d[v]:
        if v2i[u] == -1:
            continue
        if v2i[v] > v2i[u] and u in pvs:
            f = True
            max_i_l = max(max_i_l, v2i[u])
        if v2i[u] > v2i[v]:
            max_i = max(max_i, v2i[u])
    if f:
        nloop.append(loop[max_i_l])
        break
    v = loop[max_i]

for i, x in enumerate(nloop):
    if x == nloop[-1]:
        break
nloop = nloop[i+1:]
print(len(nloop))
for v in nloop:
    print(v)



Measured memory_bytes: 43884
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double EPS = 1e-8;

int main(){
  int N;
  while(~scanf("%d",&N)){
    if(N == 0) break;

    vector<int> seedlings;
    for(int i=0;i<N+1;i++){
      int height;
      scanf("%d",&height);
      seedlings.push_back(height);
    }

    int res = -1;
    for(int erase_idx=0;erase_idx<seedlings.size();erase_idx++){
      vector<int> selected_seedlings;
      for(int get_idx=0;get_idx<seedlings.size();get_idx++){
	if(erase_idx == get_idx) continue;
	selected_seedlings.push_back(seedlings[get_idx]);
      }

      int diff = selected_seedlings[1] - selected_seedlings[0];      
      bool isok = true;
      for(int i=0;i+1<selected_seedlings.size();i++){
	if(diff != selected_seedlings[i+1] - selected_seedlings[i]){
	  isok = false;
	}
      }

      if(isok){
	res = seedlings[erase_idx];
	goto found;
      }
    }
  found:;
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, A, B;
  cin >> K >> A >> B;
  bool can = false;
  for (int i=A; i<=B; i++){
    if(i%K==0) can = true;
  }
  string ans = "NG";
  if(can) ans = "OK";
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    vector<bool> a(N + 1, true);
    for(int i = 0; i < M; i++){
        int t;
        cin >> t;
        a[t] = false;
    }
    const int MOD = 1e9 + 7;
    vector<long long> dp(N + 1);
    dp[0] = 1;
    for(int i = 0; i < N; i++){
        if(!a[i]) continue;
        if(i + 1 <= N){
            dp[i + 1] += dp[i];
            dp[i + 1] %= MOD;
        }
        if(i + 2 <= N){
            dp[i + 2] += dp[i];
            dp[i + 2] %= MOD;
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 3956
void main(){
	int a, b, c;
	readf("%d %d %d", &a, &b, &c);
	( a<=c&&c<=b?"Yes":"No" ).writeln();
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2784
#!/usr/bin/env python3


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, typ=int):
    return [typ(input()) for _ in range(n)]


def main():
    n, = read_h()
    a = sorted(read_h(), reverse=True)

    print(sum([ai for i, ai in enumerate(a[:2 * n]) if i % 2 == 1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 37084
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
#define inf 1000000007

int main(void){
    int x;
    cin >> x;
    int check[x+1];
    for(int i = 0; i <= x; i++)
        check[i]=0;
    long long int ans = 1;
    int aa;
    for(int i = 2; i <= x; i++){
        aa=i;
        int j = 2;
        while(aa!=1){
            if(aa%j==0){
               check[j]++;
               aa/=j;     
            }
            if(aa%j!=0)
                j++;
        }
    }
    for(int j = 2; j <= x; j++){
        ans = (ans*(check[j]+1))%inf;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	char str[128];
 
	cin >> str;
 
	bool c = false;
	bool f = false;
 
	for(int i = 0; str[i] != '\0'; i++){
		if(str[i] == 'C')
			c = true;
		if(c)
			if(str[i] == 'F')
				f = true;
	}
 
	if(f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
 
	return 0;
}

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

#define eb emplace_back
#define ld long double
#define ll long long

using namespace std;

const int nm = 1000002;

int n, a[nm];
int np;
ll p[nm];
bool mark[nm];
int used[nm];

void get_primes() {
	np = 1;
	p[1] = 2;
	for (ll i = 3; i < nm; i += 2) {
		if (!mark[i]) {
			p[++np] = i;
			for (ll j = i * i; j < nm; j += 2ll * i) {
				mark[j] = 1;
			}
		}
	}
}

void factorize(int n) {
	for (int j = 1; j <= np && p[j] * p[j] <= n; ++j) {
		ll i = p[j];
		if (n % i == 0) {
			used[i]++;
			while (n % i == 0) {
				n /= i;
			}
		}
	}
	if (n > 1) {
		used[n]++;
	}
}

bool check_pairwise() {
	for (int i = 2; i < nm; ++i) {
		if (used[i] > 1) {
			return 0;
		}
	}
	return 1;
}

bool check_setwise() {
	for (int i = 2; i < nm; ++i) {
		if (used[i] == n) {
			return 0;
		}
	}
	return 1;
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	get_primes();
	cin >> n;
//	n = 1000000;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
//		a[i] = 999983;
		factorize(a[i]);
	}

	if (check_pairwise()) {
		cout << "pairwise coprime\n";
		return 0;
	}
	if (check_setwise()) {
		cout << "setwise coprime\n";
		return 0;
	}
	cout << "not coprime\n";
#ifdef LOCAL
	cout << (double) clock() / CLOCKS_PER_SEC << "\n";
#endif
}


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

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
int const MOD = 1000000007;
#define END {cout<<END<<'\n'; return 0;}
#define ALL(vec) vec.begin(),vec.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,s,n) for(int i=s; i<n; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<a<<'\n'
#define pri2(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n';
template<class T> inline bool cmin(T& a, T b) { if (a > b) { return a = b; } return false; }
template<class T> inline bool cmax(T& a, T b) { if (a < b) { return a = b; } return false; }

int n,m,q,_,x,y;
string s,sb;
bool ok;
char ch;

int main(){
  cin.tie(nullptr); ios::sync_with_stdio(false);
  
  cin>>n; list<int>a;
  rep(i,n){
    cin>>s;
    if(s=="insert"){cin>>x; a.emplace_front(x);}
    else if(s=="deleteFirst")a.pop_front();
    else if(s=="deleteLast")a.pop_back();
    else{
      cin>>x;
      for(list<int>::iterator it=a.begin(); it!=a.end(); it++){
        if(*it==x){a.erase(it); break;}
      }
    }
  }
  while(!a.empty()){
    cout<<a.front(); a.pop_front();
    cout<<(a.empty()?'\n':' ');
  }
}


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

int main()
{
    int K, A, B;
    cin >> K >> A >> B;
    for (int i = A; i <= B; i++)
    {
        if (i % K == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(void){
   int n,i;
   scanf("%d",&n);
   char s[n],t[n];

   scanf("%s%s",s,t);

   for(i=0;i<n;i++){
      printf("%c%c",s[i],t[i]);
   }
   printf("\n");
   return 0;
}

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

int main()
{
	int a;
	cin >> a;
	set<int> s;
	int ans = 1;
	s.insert(a);
	while(1)
	{
		ans++;

		if (a % 2 == 0) a /= 2;
		else a = a * 3 + 1;


		if (s.find(a) != s.end()) break;

		s.insert(a);
	}

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

Measured memory_bytes: 256
#include <queue>
#include <map>
#include <iostream>
using namespace std;
int main() {
    int n, d, a; cin >> n >> d >> a;
    map<int, int> xh;
    for (int i = 0; i < n; i++) {
        int x, h; cin >> x >> h;
        xh[x] = h;
    }
    long long ans = 0, sum = 0;
    queue<pair<int, long long> > q;
    while (!xh.empty()) {
        auto it = xh.begin();
        int x = it->first;
        while (!q.empty() && q.front().first < x) {
            sum -= q.front().second;
            q.pop();
        }
        long long h = it->second - sum;
        if (h > 0) {
            ans += (h + a - 1) / a;
            sum += (h + a - 1) / a * a;
            q.push({x + 2 * d, (h + a - 1) / a * a});
        }
        xh.erase(it);
    }
    cout << ans << endl;
}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    static int n;
    static int[] x;
    static int[] y;
    static long[] h;


    public static void main(String[] args) {
        n = sc.nextInt();
        x = new int[n];
        y = new int[n];
        h = new long[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            h[i] = sc.nextLong();
        }

        //solve
        long minH = 0;
        int ansX = 0;
        int ansY = 0;
        for (int xi = 0; xi <= 100; xi++) {
            for (int yi = 0; yi <= 100; yi++) {
                long ans = sameHeight(xi, yi);
                if (ans < 1) {
                    continue;
                }
                if (minH < ans) {
                    minH = ans;
                    ansX = xi;
                    ansY = yi;
                }
            }
        }

        System.out.println(ansX + " " + ansY + " " + minH);
    }

    public static long sameHeight(int xi, int yi) {
        long height = -1;
        for (int j = 0; j < n; j++) {
            if (h[j] > 0) {
                long ans = Math.abs(xi - x[j]) + Math.abs(yi - y[j]) + h[j];
                if (height < 0) {
                    height = ans;
                    continue;
                }
                if (height != ans) {
                    return -1;
                }
            }
        }
        for (int j = 0; j < n; j++) {
            if (h[j] == 0) {
                long dist = Math.abs(xi - x[j]) + Math.abs(yi - y[j]);
                if (height > dist) {
                    return -1;
                }
            }
        }
        return height;
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 100005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, sg[MAXN];

struct Edge {
	int v, nxt;
}e[MAXN<<1];
int first[MAXN], eCnt;

inline void AddEdge(int u, int v) {
	e[++eCnt].v = v;
	e[eCnt].nxt = first[u];
	first[u] = eCnt;
}

void DFS(int u, int fa) {
	for (int i=first[u];i;i=e[i].nxt) {
		int v = e[i].v;
		if (v == fa) continue;
		DFS(v, u);
		sg[u] ^= (sg[v] + 1);
	}
}

void init() {
	read(n);
	for (int i=1,u,v;i<n;++i) {
		read(u); read(v);
		AddEdge(u, v);
		AddEdge(v, u);
	}
}

void solve() {
	DFS(1, 0);
	puts(sg[1]? "Alice" : "Bob");
}

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


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

int main(){

	int n;
	while (std::cin >> n, n){

		int max, before;
		std::cin >> before;

		max = before;

		for (int i = 1, a; i < n; i++){
			std::cin >> a;
			before = std::max(before + a, a);
			max = std::max(max, before);
		}

		std::cout << max << std::endl;
	}

	return 0;
}

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

int main() {
    int K, S; cin >> K >> S;
    int ans = 0;
    for (int i = 0; i <= K; i++)
    {
        for (int j = 0; j <= K; j++)
        {
            int k = S - i - j;
            if(k>=0 && k<=K) ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k, s;
	cin >> n >> k >> s;
	vector<int> ans(n);
	for (int i = 0; i < n; i++) {
		if (k > 0) {
			ans[i] = s;
			k--;
		} else {
			ans[i] = (s == 1 ? 2 : s - 1);
		}
	}
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << ' ';
		cout << ans[i];
	}
	cout << '\n';
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

int main(){
  int p[6];
  for( int i=0; i < 6; ++i ){ std::cin >> p[i]; }
  if ( ( p[4] - p[0] ) <= p[5] ){
    std::cout << "Yay!" << std::endl;
  }
  else{
    std::cout << ":(" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
# n=int(input())
# a,b=map(int, input().split())
# c=list(map(int, input().split()))
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import numpy as np
import math
import copy

N = int(input())

l = [int(input()) for _ in range(5)]

trans_min = min(l)

bottle_neck = math.ceil(N / trans_min)

print(bottle_neck + 4)

Measured memory_bytes: 12444
// spnauT
//
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int _b=(b),i=(a);i<_b;++i)
#define ROF(i,b,a) for(int _a=(a),i=(b);i>_a;--i)
#define REP(n) for(int _n=(n);_n--;)
#define _1 first
#define _2 second
#define PB(x) push_back(x)
#define SZ(x) int((x).size())
#define ALL(x) (x).begin(),(x).end()
#define MSET(m,v) memset(m,v,sizeof(m))
#define MAX_PQ(T) priority_queue<T>
#define MIN_PQ(T) priority_queue<T,vector<T>,greater<T>>
#define IO(){ios_base::sync_with_stdio(0);cin.tie(0);}
#define nl '\n'
#define cint1(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long LL;typedef pair<int,int> PII;
typedef vector<int>VI;typedef vector<LL>VL;typedef vector<PII>VP;
template<class A,class B>inline bool mina(A &x,const B &y){return(y<x)?(x=y,1):0;}
template<class A,class B>inline bool maxa(A &x,const B &y){return(x<y)?(x=y,1):0;}

#define MAXN (100004)

int A[MAXN];

int main()
{
	IO();
	cint1(N);
	FOR(i,0,N) cin >> A[i];
	A[N++] = 0;
	sort(A,A+N,greater<int>());
	int n = 1;
	while(n < A[n]) ++n;
	--n;

	int win = 0;
	if(n < A[n] && (A[n]-n)%2 == 0) win = 1;
	int p = n;
	while(n < A[p]) ++p;
	if((p-n)%2 == 0) win = 1;
	if(win) cout << "First" << nl;
	else cout << "Second" << nl;

	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;


namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var lists = Console.ReadLine()
                .ToArray();
            var count = lists.Length;
            var unkos = new List<string>();
            unkos.Add(lists[0].ToString());
            long ans = 0;
            for (long i = 1; i < count; i++)
            {
                unkos = Unkoman(unkos, long.Parse(lists[i].ToString()));
            }
            foreach (var item in unkos)
            {
                long num = 0;
                var i = item.Split(new[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var item2 in i)
                {
                    num += long.Parse(item2);
                }
                ans += num;
            }
            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static List<string> Unkoman(List<string> vs, long unko)
        {
            var ls = new List<string>();
            foreach (var item in vs)
            {
                ls.Add(item + "+" + unko);
                ls.Add(item +  unko);
            }
            return ls;
        }
    }
    
}


Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

int main(){
    int n; cin >> n;
    int a[1010000];

    for(int i=1; i<=101; i++){
        for(int j=1; j<=101; j++){
            for(int k=1; k<=101; k++){
                ll d;
                d=i*i+j*j+k*k+i*j+j*k+k*i;
                a[d-1]++;
            }
        }
    }

    rep(i, n) out(a[i]);
    
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
 
typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;
 
#define for01(n)  for (ll i=0; i<n; i++)
#define for02(n)  for (ll j=0; j<n; j++)
#define for03(n)  for (ll k=0; k<n; k++)
#define for11(n)  for (ll i=1; i<=n; i++)
#define for12(n)  for (ll j=1; j<=n; j++)
#define for13(n)  for (ll k=1; k<=n; k++)

#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define F first
#define S second
#define pp pair <ll, ll>
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define si size()
#define bk back()
#define deci(n)  fixed<<setprecision(n)

#define p0(a) cout << a << " "
#define p1(a) cout << a << endl

#define MAX LLONG_MAX
#define MIN LLONG_MIN

using namespace std;



int main()
{
  ll n;
  cin >> n;
  
  ll max = n*(n+1)/2;
  p1(max - n);
 
  return 0;
}

Measured memory_bytes: 256
using System;
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 c = int.Parse(input[2]);
        int k = int.Parse(input[3]);

        if (k <= a)
        {
            Console.WriteLine(k);
        }
        else if (k <= a + b)
        {
            Console.WriteLine(a);
        }
        else
        {
            Console.WriteLine(a - (k - a - b));
        }
    }
}

Measured memory_bytes: 27496
class PrimeTool():
    def __init__(self, max=5 * 10 ** 5 + 500, mod=10 ** 9 + 7):
        self.mod = mod
        self.modm2 = self.mod - 2
        self.max = max
        self.fac = [1] * max
        self.inv = [1] * max
        if self.max > 1:
            for i in range(2, self.max):
                self.fac[i] = (self.fac[i - 1] * i) % self.mod
                self.inv[i] = pow(self.fac[i], self.modm2, self.mod)

    def perm(self, n, r):
        if r == 0:
            return 1
        return self.fac[n] * self.inv[n - r] % self.mod

    def cmb(self, n, r):
        r = max(r, n - r)
        if n == r:
            return 1
        return self.fac[n] * self.inv[n - r] * self.inv[r] % self.mod


def resolve():
    N, M = map(int, input().split(' '))
    res = 0
    tool = PrimeTool()

    for k in range(N + 1):
        res += (-1) ** k * tool.cmb(N, k) * tool.perm(M, k) * tool.perm(M - k, N - k) ** 2
        res %= tool.mod

    print(res)


resolve()

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

int main(){
    string s;
    cin >> s;
    if((s[0] == 'a' && s[1] == 'a') || (s[0] == 'a' && s[2]  == 'a') || (s[1] == 'a' && s[2] == 'a')) cout << "No" << endl;
    else if((s[0] == 'b' && s[1] == 'b') || (s[0] == 'b' && s[2]  == 'b') || (s[1] == 'b' && s[2] == 'b')) cout << "No" << endl;
    else if((s[0] == 'c' && s[1] == 'c') || (s[0] == 'c' && s[2]  == 'c') || (s[1] == 'c' && s[2] == 'c')) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	char c;
	cin >> c;
	if(isupper(c))
		cout << 'A';
	else
		cout << 'a';





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
 
int main()
{
    int n,m,a,b;
    cin>>n>>m;
    vector<int> v(n);
    for(int i=0;i++<m;v[a-1]++,v[b-1]++)cin>>a>>b;
    for(auto&& e:v)cout << e << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,A,i,j,k;cin>>N>>A;ll X[N],DP[N+1][4901];
  REP(i,N){cin>>X[i];X[i]-=A;}
  REP(i,4901)DP[0][i]=0;DP[0][2450]=1;
  FOR(i,1,N+1)REP(j,4901){
    DP[i][j]=DP[i-1][j];
    if(j-X[i-1]>=0&&j-X[i-1]<=4900)DP[i][j]+=DP[i-1][j-X[i-1]];
  }
  cout<<DP[N][2450]-1<<endl;
  return 0;
}

Measured memory_bytes: 2176
# -*- coding: utf-8 -*-
 
def main(S):
    sum = 0
    for i in range(1 << (len(S)-1)):
        res = S[0]
        for j in range(len(S)-1):
            if((i >> j) & 1):
                res += "+"
            res += S[j+1]    
        sum += eval(res)
    print(sum)
            
if(__name__ == "__main__"):
    S = list(input())
    
    main(S)

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <queue>
#include <functional>
#define INF 1e15
using namespace std;

typedef long long ll;
typedef pair<ll,int> P;
struct edge{
	int t,id;
	ll d;

	edge(int tt,int ii,ll dd){
		t=tt;
		id=ii;
		d=dd;
	}
};

int n,m,c;
int a[200001],b[200001],d[200001];
ll cost[100001],x_max;
vector<edge> G[100001];
bool flag[200001];
ll costdata[100001];
int index[100001],datasize;


void dijk(){
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,1));
	for(int i=1;i<=n;i++)cost[i]=INF;
	cost[1]=0;
	while(que.size()){
		P q=que.top();
		que.pop();
		if(q.first!=cost[q.second])continue;
		costdata[datasize]=cost[q.second];
		index[datasize++]=q.second;
		x_max=max(x_max,q.first);
		for(int i=0;i<G[q.second].size();i++){
			edge e=G[q.second][i];
			if(e.d+q.first<cost[e.t]){
				cost[e.t]=e.d+q.first;
				que.push(P(cost[e.t],e.t));
			}
		}
	}
	return;
}

int main(void){
	scanf("%d %d %d",&n,&m,&c);
	ll res=INF;
	for(int i=0;i<m;i++){
		scanf("%d %d %d",&a[i],&b[i],&d[i]);
		G[a[i]].push_back(edge(b[i],i,d[i]));
		G[b[i]].push_back(edge(a[i],i,d[i]));
	}
	dijk();
	ll alldist=0;
	for(int i=n-1;i>=0;i--){
		res=min(res,costdata[i]*c+alldist);
		for(int j=0;j<G[index[i]].size();j++){
			edge e=G[index[i]][j];
			if(!flag[e.id]){
				flag[e.id]=true;
				alldist+=e.d;
			}
		}
	}
	res=min(res,alldist);
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 18736
//c++ 10 ** 7 の定数倍は普通に通るので，9 * 10 ** 6 も可能．
#include<iostream>
using namespace std;
int main(){
    int r, g, b, N;
    int a;
    int ans = 0;
    cin >> r >> g >> b>> N;
    for(int i = 0; i < N + 1; i++){
        for(int j = 0; j < N + 1; j++){
            if(N - r * i >= 0){
                a = N - r * i;
                if(a - g * j >= 0){
                    a -= g * j;
                    if(a % b == 0){
                        ans += 1;
                    }
                }
            }
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;

int main(){
    int n, m; cin >> n >> m;
    vector<int> bad_stairs(n+10, 0);
    int a;
    for(int i=0; i<m; i++){
        cin >> a;
        bad_stairs[a] = 1;
    }
    vector<ll> dp(n+10, 0);
    dp[0] = 1;
    for(int i=0; i<n; i++){
        if(bad_stairs[i+1] == 1 && bad_stairs[i+2] == 1){
            cout << "0" << endl;
            return 0;
        }
        else if(bad_stairs[i+1] == 1){
            dp[i+2] += dp[i];
        }
        else if(bad_stairs[i+2] == 1){
            dp[i+1] += dp[i];
        }
        else{
            dp[i+2] += dp[i];
            dp[i+1] += dp[i];
        }
        dp[i+1] %= MOD;
        dp[i+2] %= MOD;
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1536
n = int(input())
p = [list(map(int, input().split())) for _ in range(n)]
for i, v in enumerate(p):
    x, y = v
    p[i] = x-y, x+y

xm, ym = -10**9, -10**9
xw, yw = 10**9, 10**9
for x, y in p:
    xm = max(xm, x)
    xw = min(xw, x)
    ym = max(ym, y)
    yw = min(yw, y)

# print(p)
ans = max(abs(xm - xw), abs(ym - yw))
print(ans)






Measured memory_bytes: 106396
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INF = 1LL << 60;

 int main() {
   int N;
   bool ok = false;

   cin >> N;

   if (N / 100 == 7) ok = true;
   else if (N % 10 == 7) ok = true;
   else if (N / 10 % 10 == 7) ok = true;

   if (ok) cout << "Yes" << endl;
   else cout << "No" << endl;
 }


Measured memory_bytes: 3596
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int q = Integer.parseInt(sc.next());
        int a, b, p, x;
        
        HashMap<Integer, ArrayList> map = new HashMap<>();
        for(int i = 0; i < n-1; i++){
            a = Integer.parseInt(sc.next());
            b = Integer.parseInt(sc.next());
            
            if(!map.containsKey(a)){
                ArrayList<Integer> list = new ArrayList<>();
                map.put(a, list);
            }
            map.get(a).add(b);
            
            if(!map.containsKey(b)){
                ArrayList<Integer> list = new ArrayList<>();
                map.put(b, list);
            }
            map.get(b).add(a);
        }
        
        int[] count = new int[n];
        for(int i = 0; i < q; i++){
            p = Integer.parseInt(sc.next());
            x = Integer.parseInt(sc.next());
            count[p-1] += x;
        }
        
        ArrayDeque<Integer> que = new ArrayDeque();
        que.offer(1);
        boolean[] visited = new boolean[n];
        
        while(!que.isEmpty()){
            int i = que.poll();
            ArrayList<Integer> list = map.get(i);
            visited[i-1] = true;
            
            list.forEach((v) -> {
                if(!visited[v-1]){
                    count[v-1] += count[i-1];
                    que.offer(v);
                }
            });
        }
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            sb.append(count[i]).append(" ");
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 164324
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),* $(,)*) => {
        #[cfg(debug_assertions)]
        eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
    };
}

fn main() {
    input! {
        x: usize,
    }
    if x == 0 {
        println!("1");
    } else {
        println!("0");
    }
}


Measured memory_bytes: 2128
let readIntArray () =
    stdin.ReadLine().Split(" ") |> Array.map int

let choice ok ng bool = if bool then ok else ng

readIntArray ()
|> fun [| h; n |] ->
    readIntArray ()
    |> Array.sortDescending
    |> Array.take n
    |> Array.reduce (+)
    |> (<=) h
    |> choice "Yes" "No"
    |> printfn "%s"


Measured memory_bytes: 37780