akhauriyash/Code-Regression huggingface dataset:
def examA():
    N = I()
    A = LI()
    ans = 1
    flag = None
    for i in range(N-1):
        cur = A[i+1] - A[i]
        if not flag:
            if cur<0:
                flag = "d"
            elif cur>0:
                flag = "u"
        else:
            if cur<0 and flag=="u":
                flag = None
                ans += 1
            elif cur>0 and flag=="d":
                flag = None
                ans += 1
    print(ans)
    return

def examB():
    def bfs(n,V):
        W = [inf] * n
        W[0] = 0
        que = deque()
        que.append(0)
        while (que):
            now = que.popleft()
            nowW = W[now]
            if nowW==0:
                judge = 0
            elif nowW>0:
                judge = 1
            else:
                judge = -1
            if judge<0:
                cur = -1
            else:
                cur = 1

            for ne in V[now]:
                #print(now,ne)
                if cur+1<judge:
                    break
                if W[ne]!=inf:
                    continue
                W[ne] = nowW + cur
                que.append(ne)
                cur -= 2
        return W
    N, M = LI()
    V = [[]for _ in range(N)]
    for _ in range(M):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)

    L = bfs(N,V)
    D = defaultdict(int)
    minA = 0; maxA = 0
    for i,a in enumerate(L,start=1):
        if a!=inf:
            D[a] = i
            if a<minA:
                minA = a
            if a>maxA:
                maxA = a
    ans = []
    for i in range(minA,maxA+1):
        ans.append(D[i])
    print(len(ans))
    print(" ".join(map(str,ans)))
    return

def examC():
    N, L, T = LI()
    X = [LI()for _ in range(N)]
    ans = []
    for i in range(N):
        now = T if X[i][1]==1 else -T
        cur = (X[i][0] + now)%L
        cur = (cur+L)%L
        ans.append(cur)
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""

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

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

const long INF = 1000000000005;

int main(){
    int N, M, R;
    cin >> N >> M >> R;

    int r[R];
    for(int i=0; i<R; i++){
        cin >> r[i];
        r[i]--;
    }

    long dp[N][N];
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            dp[i][j] = INF;
        }
        dp[i][i] = 0;
    }

    for(int i=0; i<M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        dp[a][b] = c;
        dp[b][a] = c;
    }

    for(int k=0; k<N; k++){
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
            }
        }
    }

    sort(r, r+R);
    long ans = INF;
    do{
        long tans = 0;
        for(int i=1; i<R; i++){
            tans = tans + dp[r[i-1]][r[i]];
        }
        ans = min(ans, tans);
    }while(next_permutation(r, r+R));

    printf("%ld\n", ans);

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    int64_t tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (int64_t)value;
    return output;
}

int64_t imax(const int64_t a, const int64_t b) { return std::max(a, b); } // std::max, std::min は型が違うとエラーになるため、ラッパーを作る。
int64_t imin(const int64_t a, const int64_t b) { return std::min(a, b); }

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

#define input1(begin, end, v1) v1.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i]; }
#define input2(begin, end, v1, v2) v1.resize((end)+1); v2.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i]; } 
#define input3(begin, end, v1, v2, v3) v1.resize((end)+1); v2.resize((end)+1); v3.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i] >> v3[i]; } 

std::vector<int> irange(const int begin, const int end) {
    std::vector<int> ret; for (int i = begin; i <= end; i++) { ret.push_back(i); }
    return ret;
}

template <typename T>
void printvec(const std::vector<T>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

//int ;
int128_t X, Y;
//std::vector<int> ;
//std::vector<int128_t> ;
//std::string ;
//std::vector<std::string> ;
//double ;
//std::vector<double> ;

int main(int argc, char **argv) {
    std::cin >> X >> Y;
    
    std::vector<int128_t> ret;
    ret.push_back(X);

    while(ret.back() * 2 <= Y) {
        ret.push_back(ret.back() * 2);
    }

    std::cout << ret.size() << std::endl;
    
    return 0;
}

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

int main(){
  int a[20001],b[20001];
  char op[20001];
  for(int i=0;i<20001;++i){
    cin >> a[i] >> op[i] >> b[i];
    if(a[i] == 0&&b[i] == 0&&op[i] == '?')break;
  }
  for(int i=0;i<20001;++i){
    if(op[i] == '+')cout << a[i] + b[i] << endl;
    else if(op[i] == '-')cout << a[i] - b[i] << endl;
    else if(op[i] == '*')cout << a[i] * b[i] << endl;
    else if(op[i] == '/')cout << a[i] / b[i] << endl;
    else break;
  }
  return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;

int lcs(char X[], char Y[]) {
    int m = strlen(X);
    int n = strlen(Y);
    int C[1001][1001];
    int maxl = 0;
    
    for (int i = 0; i <= m; i++) { C[i][0] = 0; }
    for (int i = 1; i <= n; i++) { C[0][i] = 0; }
    
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (X[i-1] == Y[j-1]) {
                C[i][j] = C[i - 1][j - 1] + 1;
            } else if (C[i - 1][j] >= C[i][j - 1]) {
                C[i][j] = C[i - 1][j];
            } else {
                C[i][j] = C[i][j - 1];
            }
            
            maxl = max(maxl, C[i][j]);
        }
    }
    
    return maxl;
}

int main() {
    int N;
    scanf("%d", &N);
    
    for (int i = 0; i < N; i++) {
        char X[1000], Y[1000];
        scanf("%s", X);
        scanf("%s", Y);
        cout << lcs(X, Y) << endl;
    }

    return 0;
}



Measured memory_bytes: 7032
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;
ll N;
#define MAX_N 100000
#define MAX_DP 1000000000 // これで初期化しよう?
int dp[MAX_N + 2];
ll h[MAX_N];
ll solve(ll i);
int main() {
	
	cin >> N;
	
	for (ll i = 0; i < N; i++)
	{
		cin >> h[i];
	}
	for (ll i = 0; i < N + 2; i++)
	{
		dp[i] = MAX_DP;
	}

	cout << solve(N-1) << endl;
}

ll solve(ll i) {
	if (i < 0) return MAX_DP;
	if (i == 0) return 0;
	if (dp[i] != MAX_DP) return dp[i];
	return dp[i] = min(solve(i - 1) + abs(h[i] - h[i - 1]),
			        solve(i - 2) + abs(h[i] - h[i - 2]));
} // 結果はdp[N-1]

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()



int main(void) {
	int d, n; cin >> d >> n;
	int x = pow(100, d);
	if (n <= 99)cout << n * x << endl;
	else cout << 101 * x << endl;
	return 0;
}

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

bool revp2(const pair<ll,ll>&a,const pair<ll,ll>&b){return a.first>b.first;}
bool revp3(const pair<ll,ll>&a,const pair<ll,ll>&b){if(a.first==b.first)return a.second<b.second;
return a.first>b.first;}

int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    ll a[4],b,c,x,y=1,s=0;
    cin>>a[1]>>a[2]>>a[3]>>x;
    //s=max({a,b,c});
    for(int i=1;i<=x;i++)y*=2;
    sort(a+1,a+3+1);
    for(int i=1;i<=2;i++){
        s+=a[i];
    }
    s+=(ll)(a[3]*y);
    cout<<s;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	auto A=vecin<ll>(N);
	auto B=vecin<ll>(N);
	ll SA = accumulate(ALL(A),0LL);
	ll SB = accumulate(ALL(B),0LL);
	ll M = SB-SA;
	if(M<0){
		out("No");
		return 0;
	}
	
	ll sum=0;
	REP(i,N){
		sum += max(0LL,(ll)ceil((B[i]-A[i])/2.0));
	}
	out(sum<=M?"Yes":"No");
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>






int w[60];
int v[60];


int s[60];

int main()
{

    int n;
    std::cin >> n;

    for(int i = 0; i < n; i++){
        std::cin >> v[i];
    }
    for(int i = 0; i < n; i++){
        std::cin >> w[i];
    }

    for(int i = 0; i < n; i++){
        s[i] = v[i] - w[i];
    }


    int maxv = 0;
    for(int i = 0; i < n; i++){
        if(s[i] >= 0){
            maxv += s[i];
        }
    }

    std::cout << maxv;
    return 0;
}


Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  char n[3];
  scanf("%s", n);
  puts(n[0] == '7' || n[1] == '7' || n[2] == '7' ? "Yes" : "No");
}

Measured memory_bytes: 1624
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define srep(i) for (int i = 0; i < s.size(); i++)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
    using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int n, w;
int weight[105] = {}, value[105] = {};

int dp[105][10005] = {};

int main()
{
    int n,m,x,a;
    int sum1=0,sum2=0,ans=0;
    cin>>n>>m>>x;
    rep(i,0,m){
        cin>>a;
        if(x>a){
            sum1++;
        }else{
            sum2++;
        }
    }
    ans=min(sum1,sum2);
    cout<<ans<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

int n, m, q;
int a[55], b[55], c[55], d[55];
ll ans;
int v[15];
void dfs(int pos) {
    if (pos >= n) {
        ll res = 0;
        rep(i, q) {
            if (v[b[i]] - v[a[i]] == c[i])
                res += d[i];
        }
        maxs(ans, res);
        return;
    }

    loops(j, v[pos], m) {
        v[pos + 1] = j;
        dfs(pos + 1);
    }
}
void solve() {
    cin >> n >> m >> q;
    rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    reps(i, m) {
        v[0] = i;
        dfs(0);
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}


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

int main(){
  int A,B,count=0;
  cin >> A >> B;
  for(int i=A;i<B+1;i++){
    int C=i;
    int C1=C%10;
    C/=10;
    int C2=C%10;
    C/=10;
    int C3=C%10;
    C/=10;
    int C4=C%10;
    C/=10;
    int C5=C%10;
    if(C1==C5 && C2==C4){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
h_list = []

for i in range(N):
    h = int(input())
    h_list.append(h)

list.sort(h_list)

ans = 1000000000
for i in range(0, N-K+1):
    if h_list[i+K-1] - h_list[i] < ans:
        ans = h_list[i+K-1] - h_list[i]
        
print(ans)

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

int c[10][10];

void floid() {
  for (int k = 0; k < 10; k++)
     for (int i = 0; i < 10; i++) 
      for (int j = 0; j < 10; j++) 
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
}

int main(void) {
  int h, w;
  cin >> h >> w;
  rep (i, 10) rep (j, 10) cin >> c[i][j];

  floid();

  ll ans = 0;
  rep (i, h * w) {
    int a;
    cin >> a;
    if (a == -1 || a == 1) continue;
    ans += c[a][1];
  }

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

Measured memory_bytes: 256
fun main(args:Array<String>) {
	val n = readLine()!!.toInt()
	val (d,x) = readLine()!!.split(" ").map{ it.toInt() }
	val a = (1..n).map{ readLine()!!.toInt() }
	println( x + a.flatMap { (1..d step it).toList() }.size )
}

Measured memory_bytes: 37872
# import math
# import bisect
# import heapq
# from collections import deque
# import numpy as np

# a,b,c = map(int, input().split())
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 'YES'
for i in range(n-1):
    if a[i] == a[i+1]: ans = 'NO'

print(ans)

Measured memory_bytes: 25932
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define DUMP(v) for(auto& x : v) cerr << x << " "; cerr << endl;
using namespace std;

using ll = long long;

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; }
constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

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

  int n, c;
  cin >> n >> c;

  vector<pair<int, int>> recorders(30, {0, -1});

  vector<vector<int>> programs(n);
  rep(i, n) {
    int s, t, c;
    cin >> s >> t >> c;
    programs[i] = {s, t, c};
  }

  sort(ALL(programs));

  for (auto& v : programs) {
    int s = v[0], t = v[1], c = v[2];
    for (auto& p : recorders) {
      if (p.first < s || p.first == s && p.second == c) {
        p.first = t;
        p.second = c;
        break;
      }
    }
  }

  ll ans = 0;
  for (auto& p : recorders) {
    if (p.first != 0) ans++;
  }

  cout << ans << endl;

  return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ////string[] inputData = Console.ReadLine().Split(' ');
            ////Int32 inputData = Int32.Parse(Console.ReadLine());
            //string inputData = Console.ReadLine();

            //if (inputData.Contains("7"))
            //{
            //    Console.WriteLine("Yes");

            //} else
            //{ 
            //    Console.WriteLine("No");
            //}
            Int64 ans = 0;
            Int64 inputData = Int64.Parse(Console.ReadLine());
            for (Int64 loop = 1; loop <= inputData; loop++) {
                if (loop % 3 != 0 && loop % 5 != 0) {
                    ans += loop;
                }
            }


            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 27540
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
typedef long long ll;
int main(){
	int n,h;
	int count = 0;
	cin >> n>>h;
	vector<int> a(n);
	
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] >= h) count++;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t h,w;
  cin >> h >> w;
  int64_t ans;
  if(h==1||w==1) ans=1;
  else if(h%2==0||w%2==0) ans =(h*w)/2;
  else ans =(h*w)/2+1;
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class AC>void r(AC &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int a,b,c;
int main(){
    r(a);r(b);r(c);
    if(a==b+c||b==a+c||c==a+b)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;
using ld=long double;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int mod = TEN(9)+7;

signed main()
{
	int N, M; cin >> N >> M;
	swap(N, M);
	int ans = 0;
	int a = min(M, N / 2);
	ans += a;
	N -= a * 2, M -= a;
	ans += N / 4;

	cout << ans << endl;
}




Measured memory_bytes: 256
from pprint import pprint
from collections import deque, defaultdict

n, q = list(map(int, input().strip().split(" ")))
# edges = defaultdict(set)
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a_i, b_i = list(map(int, input().strip().split(" ")))
    edges[a_i-1].append(b_i-1)
    edges[b_i-1].append(a_i-1)
    # edges[a_i-1].add(b_i-1)
    # edges[b_i-1].add(a_i-1)

# p = defaultdict(int)
# counter = defaultdict(int)
counter = [0] * n
p = [0] * n
x = []
for _ in range(q):
    p_i, x_i = list(map(int, input().strip().split(" ")))
    # p[p_i-1] += x_i
    counter[p_i-1] += x_i


parents = deque()
# parents.append(0)
# parents = []
parents.append(0)
visited = set()
while parents:
    parent = parents.popleft()
    # parent = parents.pop()
    if parent in visited:
        continue
    visited.add(parent)
    # counter[parent] += p[parent]
    # print("parent")
    # print(parent, counter[parent])
    for child in edges[parent]:
        if child in visited:
            continue
        # if counter[child] != 0:
        #    continue
        counter[child] += counter[parent]
        # print("child")
        # print(child, counter[child])
        parents.append(child)
        # parents.add(child)

#print(" ".join(list(map(str, counter.values()))))
print(" ".join(list(map(str, counter))))

Measured memory_bytes: 129264
using System;
using System.IO;
using System.Text;

namespace MinPro2019D
{
    public class Program
    {
        void Solve(SimpleScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var L = ss.Next(int.Parse);
            var dp = new long[5];

            for (var i = 0; i < L; i++)
            {
                var A = ss.Next(long.Parse);
                var x = A == 0 ? 2 : A & 1;

                dp[0] += A;
                dp[1] += x;
                dp[2] += (x & 1) ^ 1;
                dp[3] += x;
                dp[4] += A;

                for (var t = 1; t < 5; t++)
                {
                    dp[t] = Math.Min(dp[t], dp[t - 1]);
                }
            }

            sw.WriteLine(dp[4]);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new SimpleScanner(Console.OpenStandardInput());
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }
    }

    //ref: https://qiita.com/Camypaper/items/de6d576fe5513743a50e#%E5%85%A5%E5%8A%9B%E3%81%AE%E9%AB%98%E9%80%9F%E5%8C%96
    //by Camypaperさん 
    public class SimpleScanner
    {
        const int DefaultCapacity = 1024;

        readonly Stream stream;
        readonly int capacity;
        readonly byte[] buffer;

        int index = 0;
        int length = 0;
        bool isEof = false;

        public SimpleScanner(Stream stream, int capacity = DefaultCapacity)
        {
            this.stream = stream;
            this.capacity = capacity;
            this.buffer = new byte[capacity];
        }

        void Reload()
        {
            if (isEof) throw new EndOfStreamException();
            index = 0;
            length = stream.Read(buffer, 0, capacity);
            isEof = length <= 0;
        }

        int Peek()
        {
            if (index < length) return buffer[index];
            Reload();
            return Peek();
        }

        int Read()
        {
            var ret = Peek();
            index++;
            return ret;
        }

        bool IsInputable(int b)
        {
            return 33 <= b && b <= 126;
        }

        public T Next<T>(Func<string, T> parser)
        {
            var sb = new StringBuilder();
            while (!IsInputable(Peek())) Read();
            while (IsInputable(Peek())) sb.Append((char)Read());
            return parser(sb.ToString());
        }
    }
}


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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = (c + b - 1) / b;
  int y = (a + d - 1) / d;
  cout << (x <= y ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>

int main()
{
    int i;
    char ch, ch_i[3], ch_o[3];
    scanf("%s", ch_i);
    ch_o[0] = ch_i[0];;

    scanf("%s", ch_i);
    ch_o[1] = ch_i[1];

    scanf("%s", ch_i);
    ch_o[2] = ch_i[2];

    for(i=0; i<3; i++)
        printf("%c", ch_o[i]);

    return 0;
}


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

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];

    // int one = 0;
    // int two = 0;
    // int gcd = 0;
    // int ans;

    // for (int dumy:a){
    //     if (dumy % 2 == 0)two++;
    //     if (dumy % 2 != 0)one++;
    //     if (dumy % a[0] == 0)gcd++;
    // }
    // if (gcd == a.size())ans = a[0];
    // else if (one == a.size())ans = 2;
    // else if (two == a.size())ans = 2;
    // else ans = 1;

    vector<int> ans(n);
    ans[0] = gcd(a[0],a[1]);
    rep(i,n-2){
       ans[i+1] =  gcd(ans[i],a[i+2]);
    }

    cout << ans[n-2] << endl;
    return 0;
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
  input! {
    mut x: usize
  };

  let mut cur = 100;
  let mut res = 0;
  while cur < x {
    res += 1;
    cur += cur / 100;
  }
  println!("{}", res);
}


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

using namespace std;

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

 vector<int> V(N);
 vector<int> C(N);
 for(int i = 0; i < N; i++){ cin >> V[i]; }
 for(int i = 0; i < N; i++){ cin >> C[i]; }

  int sum = 0;

 for(int i = 0; i < N; i++){
   sum += V[i];
   sum -= C[i];
 }

 for(int i = 0; i < N; i++){
   if(sum < sum - V[i] + C[i]){ sum = sum - V[i] + C[i]; }
 }

 cout << sum;




  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LiangJiaJun main
#define ll long long
using namespace std;
int pr[104],n;
set<ll>tr;
int LiangJiaJun(){
    tr.clear();
    memset(pr,0,sizeof(pr));
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int k=i,p=2;
        while(k>=p){
            if(k%p==0){
                while(k%p==0){
                    ++pr[p];
                    k/=p;
                }
            }
            p++;
        }
        if(k!=1)pr[k]++;
    }
    int r3=0,r21=0,r22=0,r1=0;
    for(int i=2;i<=100;i++){
        for(int j=2;j<=100;j++){
            for(int k=2;k<=100;k++){
                if(pr[i]>=2&&pr[j]>=4&&pr[k]>=4&&i!=j&&i!=k&&j!=k){
                    ++r3;
                }
            }
        }
    }
    for(int i=2;i<=100;i++){
        for(int j=2;j<=100;j++){
            if(pr[i]>=4&&pr[j]>=14&&i!=j)r21++;
            if(pr[i]>=2&&pr[j]>=24&&i!=j)r22++;
        }
    }
    for(int i=2;i<=100;i++)if(pr[i]>=74)r1++;
    printf("%d\n",r3/2+r21+r22+r1);
    return 0;
}


Measured memory_bytes: 256
from collections import deque

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

edge = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

score = [0]*n

for i in range(q):
    p, x = map(int,input().split())
    score[p-1] += x

visited = [0]*n
visited[0] = 1

s = deque([0])
while s:
    now = s.pop()
    for v in edge[now]:
        if visited[v]:
            continue
        score[v] += score[now]
        visited[v] = 1
        s.append(v)

print(*score)

Measured memory_bytes: 56580
from itertools import accumulate

mod = 10 ** 9 + 7

N, K = map(int, input().split())
A = sorted([int(x) for x in input().split()])

f = [1 for _ in range(N + 1)]
inv = [1 for _ in range(N + 1)]
finv = [1 for _ in range(N + 1)]

for i in range(2, N + 1):
    f[i] = f[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod
comb = [f[n] * (finv[K - 1] * finv[n - (K - 1)] % mod) % mod for n in range(K - 1, N)]

ans = 0
for i in range(N - K + 1):
    ans += comb[i] * (A[i + K - 1] - A[N - i - K])
    ans %= mod
print(ans)


Measured memory_bytes: 20988
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}

fn main() {
    let r: i32 = read_line().trim().parse().unwrap();
    println!("{}", 3*r*r);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main()
{
  int k, s;
  int x, y, z;
  int answer = 0;
  scanf("%d%d", &k, &s);
  //   printf("k%d,s %d\n", k, s); 
  //      printf("until k : %d\n", k); 

  for (x = 0; x <= k; x++) {
    for (y = 0; y <= k; y++) {
      z = s - x - y;
      if ((z < 0) || (z > k))
	continue;
      //            printf("x%d, %d, %d, %d\n", x, y, z, s);
      answer++;
      
    }
  }

  printf("%d", answer);
}

	


Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>

using namespace std;

#define rep(i, n) for (size_t i = 0; i < (n); i++)

int main() {
  size_t N, M;
  scanf("%ld%ld", &N, &M);
  bool es[N][N];
  rep(i, N) rep(j, N) es[i][j] = false;
  rep(j, M) {
    size_t a, b;
    scanf("%ld%ld", &a, &b);
    a--; b--;
    es[a][b] = es[b][a] = true;
  }
  size_t xs[N];
  rep(i, N) xs[i] = i;
  size_t c = 0;
  do {
    rep(i, N - 1)
      if (!es[xs[i]][xs[i+1]])
        goto escape;
    c++;
escape:
    ;
  } while (next_permutation(xs + 1, xs + N));
  printf("%ld\n", c);
  return 0;
}


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

using namespace std;

#define ll long long
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define all(c) (c).begin(), (c).end()
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if(s[0]==s[1] and s[0]==s[2]) cout << "Yes" << endl;
  else if(s[1]==s[2] and s[2]==s[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}  


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<string> line(100);
  int l,k;
  char cc;
  stringstream ss;
  for(l=0;getline(cin,line[l],'\n');l++);
  int path[(l+1)/2+2][l];
  for(int i=0;i<(l+1)/2+2;i++)path[i][0] = 0;
  for(int i=0;i<l;i++)path[0][i] = 0,path[(l+1)/2+1][i] = 0;
  ss<<line[0];
  ss>>path[1][0];
  for(int i=1;i<l;i++){
    ss.str("");
    ss.clear(stringstream::goodbit);
    ss<<line[i];
    for(int j=0;j<(l+1)/2;j++){
      k=0;
      ss>>k>>cc;
      if(i<=l/2)
	path[j+1][i]=max(path[j][i-1],path[j+1][i-1])+k;
      else
	path[j+1][i]=max(path[j+1][i-1],path[j+2][i-1])+k;
    }
  }
  cout<<path[1][l-1]<<endl;
  return 0;
}

Measured memory_bytes: 0
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>

typedef uint64_t ull;
typedef  int64_t sll;

ull n, q;
char s[1050000];

int nextdp[1050000][27];
int doub[20][1050000];

ull solve () {
	sll i, j, ki, li;
	sll result = 0;
	double dresult = 0;
	sll maybe = 0;
	sll sum = 0;
	sll item;
	sll *dpcell;

	n = strlen(s);

	for (j = 0; j < 27; j++) {
		nextdp[n + 1][j] = n + 1;
		nextdp[n][j] = n + 1;
	}
	nextdp[n][26] = n;

	for (i = n - 1; i >= 0; i--) {
		sll ch = s[i] - 'a';

		nextdp[i][ch] = i + 1;
		for (j = ch + 1; j < 27; j++) {
			nextdp[i][j] = nextdp[nextdp[i][j - 1]][j - 1];
		}
		if (ch) {
			for (j = 0; j < ch; j++) {
				nextdp[i][j] = nextdp[nextdp[i][26]][j];
			}
		}
	}
	for (j = 0; j <= n + 1; j++) {
		doub[0][j] = nextdp[j][26];
	}
	for (i = 1; i < 20; i++) {
		for (j = 0; j <= n + 1; j++) {
			doub[i][j] = doub[i - 1][doub[i - 1][j]];
		}
	}

	while (q--) {
		int l, r;
		scanf("%d%d", &l, &r);
		l--;

		for (i = 19; i >= 0; i--) {
			if (doub[i][l] <= r) {
				l = doub[i][l];
			}
		}
		if (l == r) {
			puts("Yes");
		} else {
			puts("No");
		}
	}
	return 0;
}

int32_t main (int argc, char *argv[]) {
	scanf("%s", s);
	scanf("%llu", &q);

	solve();

	return 0;
}


Measured memory_bytes: 102912
from itertools import permutations
x = (int(input()) for _ in range(5))
ans = 650
for p in permutations(x, 5):
  tmp = 0
  for i, v in enumerate(p):
    if i != len(p) - 1:
      tmp += (v // 10 + 1) * 10 if v % 10 else v
    else:
      tmp += v
  ans = min(ans, tmp)
  
print(ans)

Measured memory_bytes: 3316
# 桁DP

n = gets.chomp.split("").map(&:to_i)
k = gets.to_i
length = n.length
# dp[上から i 桁まで][smaller][0 でない数字を使った回数]の出現回数
dp = (length + 1).times.map { 2.times.map { Array.new([length + 1, k + 1].max, 0) } }
# 初期化
# dp[0 桁目まで][桁は不自由][0 でない数字 を 0 回使った]の出現回数は 1
dp[0][0][0] = 1

# 桁数分ループする（i は遷移元の桁）
length.times do |i|
  dp_current = dp[i]
  # 最適化のため、事前に 1 行分だけ参照渡しをする
  # dp_next と dp[i + 1] の object_id は同じ
  dp_next = dp[i + 1]
  # smaller == 1 の場合、以下の桁は自由
  2.times do |smaller|
    # 1 を使った回数ごとに確認する
    length.times do |count|
      # smaller が既に 1 の場合は 10 回ループ、0 の場合は(その桁の数字 + 1）回ループ
      limit = smaller == 1 ? 9 : n[i]
      (limit + 1).times do |d|
        # smaller == 0 且つ d == limit（上限）の時のみ、0 のまま遷移する
        next_smaller = smaller == 0 && d == limit ? 0 : 1
        # d == 0 でない場合は回数を足す
        addition = d == 0 ? 0 : 1
        # 次の桁に遷移する
        dp_next[next_smaller][count + addition] += dp_current[smaller][count]
      end
    end
  end
end

ans = 0
# 桁が自由、不自由ともに、(0 以外を k 回使った出現回数)を ans に足す
2.times do |i|
  ans += dp[length][i][k]
end
puts ans


Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
int main()
{ 
    int n,a,b,c;
    cin>>n;
    
    a=n%10;
    b=n/10%10;
    c=n/100;
    
    if(a==7||b==7||c==7) 
        cout<<"Yes";
    else
        cout<<"No";
    
    return 0;
}

Measured memory_bytes: 3624
INF=10**50

def Bellman_Ford(s,N,Edge):
    dist=[INF]*N
    dist[s]=0
    cnt=0
    while True:
        update=False
        for f,t,c in Edge:
            if dist[t]>dist[f]+c:
                if dist[f]!=INF:
                    dist[t]=min(dist[t],dist[f]+c)
                    update=True
                    if cnt==N-1 and t==N-1:
                        print('inf')
                        exit()
        if not update or cnt==N-1:
            break
        cnt+=1
    return -dist[N-1]
N,M=map(int,input().split())
Edge=[]
for i in range(M):
    a,b,c=map(int,input().split())
    a,b,c=a-1,b-1,-c
    Edge.append([a,b,c])
print(Bellman_Ford(0,N,Edge))

Measured memory_bytes: 46568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll P = 1e9 + 7;


int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  double pi = 3.14159265359, r;
  cin >> r;
  cout << pi * 2 * r;
  return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr ll INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);int X;
    cin >> X;
    if(X == 7 || X == 5 || X == 3){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;



int main()
{
    int a[10];char b[10][10];char x;
    b[1][1]='+';b[1][2]='+';b[1][3]='+';
    b[2][1]='+';b[2][2]='+';b[2][3]='-';
    b[3][1]='+';b[3][2]='-';b[3][3]='+';
    b[4][1]='+';b[4][2]='-';b[4][3]='-';
    b[5][1]='-';b[5][2]='+';b[5][3]='+';
    b[6][1]='-';b[6][2]='+';b[6][3]='-';
    b[7][1]='-';b[7][2]='-';b[7][3]='+';
    b[8][1]='-';b[8][2]='-';b[8][3]='-';
    for (int i=1;i<=4;i++) {cin>>x;a[i]=x-'0';}
    int ans;
    for (int i=1;i<=8;i++)
        {
            ans=a[1];
            for (int j=1;j<=3;j++)
                {
                    if (b[i][j]=='+') ans+=a[j+1];
                    if (b[i][j]=='-') ans-=a[j+1];
                }
            if (ans==7)
                {
                    printf("%d",a[1]);
                    for (int k=1;k<=3;k++) cout<<b[i][k]<<a[k+1];
                    cout<<"=7";
                    return 0;
                }
        }

    return 0;
}


Measured memory_bytes: 256
import sys;

def init(n_):
    length = 1;
    while(length < n_):
        length*=2
    element = [0]*(2*length-1)
    for i in range(2*length-1):
        element[i] = 0
    return element,length

def update(k,a,element):
    k+=n-1
    element[k]+=a
    while(k > 0):
        k = (int)((k-1)/2)
        element[k] = element[k*2+1]+element[k*2+2]

def findmin(a, b):
    return findquery(a,b+1,0,0,n)

def findquery(a, b, k, l, r):
    if(r <= a or b <= l):
        return 0
    if(a <= l and r <= b):
        return element[k]

    vl = findquery(a,b,k*2+1,l,(int)((l+r)/2+0.5))
    vr = findquery(a,b,k*2+2,(int)((l+r)/2),r)
    return vl+vr

n,q = map(int, input().split());

element,n = init(n)

for i in range(q):
    query,key,value = map(int, input().split());
    if(query == 0):
        update(key-1,value,element)
    else :
        print(findmin(key-1,value-1))


Measured memory_bytes: 10760
#include<stdio.h>
int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int *higher = &a;
    if(b>*higher)higher = &b;
    if(c>*higher)higher= &c;
    *higher = 0;
    printf("%d\n", a+b+c);
    return 0;
} 

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

#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = (b ? b / x : 0) - (max(a - 1, 0ll) / x);
    if (b && !a) ans++;
    if (!a && !b) ans++;
    cout << ans << '\n';
    return 0;
}

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

const long long md = 1e9 + 7;

long long power(long long b, long long exp, long long m) {
  long long res = 1;
  b = b % m;
  while (exp > 0)
  {
    if (exp & 1) {
      res = (res * b) % m;
    }
    exp = exp >> 1;
    b = (b * b) % m;
  }
  return res;
}

void solve() {
  string s;
  cin >> s;
  int N = s.size();

  vector<vector<long long>> dpv(N + 1, vector<long long>(3, 0));
  int num_question_marks = 0;
  for (int i = N - 1; i >= 0; --i) {
    if (s[i] == 'A') {
      dpv[i][2] = dpv[i + 1][2] + dpv[i + 1][1];
      dpv[i][1] = dpv[i + 1][1];
      dpv[i][0] = dpv[i + 1][0];
    } else if (s[i] == 'B') {
      dpv[i][2] = dpv[i + 1][2];
      dpv[i][1] = dpv[i + 1][1] + dpv[i + 1][0];
      dpv[i][0] = dpv[i + 1][0];
    } else if (s[i] == 'C') {
      dpv[i][2] = dpv[i + 1][2];
      dpv[i][1] = dpv[i + 1][1];
      // TODO: Change this to be modulo compatible.
      dpv[i][0] = dpv[i + 1][0] + power(3, num_question_marks, md);
    } else if (s[i] == '?') {
      dpv[i][2] = dpv[i + 1][2] + dpv[i + 1][1] + 2 * dpv[i + 1][2];
      dpv[i][1] = dpv[i + 1][1] + dpv[i + 1][0] + 2 * dpv[i + 1][1];
      dpv[i][0] = 3 * dpv[i + 1][0] + power(3, num_question_marks, md);
      ++num_question_marks;
    } else {
      assert(false);
    }
    dpv[i][2] %= md;
    dpv[i][1] %= md;
    dpv[i][0] %= md;
  }
  cout << dpv[0][2] << endl;
}

int main() {
  solve();
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    int d[n];
    
    rep(i, n){
        cin >> d[i];
    }
    
    int duplication = 0;
    
    sort(d, d + n);
    
    int tmp = d[0];
    FOR(i, 1, n){
        if(d[i - 1] == d[i]){
            duplication++;
        }
    }
    cout << n - duplication << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, x, N) for (long long i = x; i < (N); i++)
using namespace std;
int main()
{
	string a, b, ans_a, ans_b;
	vector<string> ans(2);
	cin >> a >> b;
	int c, d;
	c = atoi(a.c_str());
	d = atoi(b.c_str());
	rep(i, 0, d)
	{
		ans_a += a;
	}
	rep(i, 0, c)
	{
		ans_b += b;
	}
	ans[0] = ans_a;
	ans[1] = ans_b;
	sort(ans.begin(), ans.end());
	cout << ans[0] << endl;
}


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

int main() {
	long long int a,b;
	cin>>a>>b;
	long long int arr[a+1];
	for(int i=1;i<=a;i++)
	arr[i]=1;
	long long int r[a+1]={0};
	long long int sum=0;
	r[1]=1;
	long long int x,y;
	for(int i=0;i<b;i++)
	{
	    cin>>x>>y;
	    if(r[x]==1 && arr[x]==1)
	    {
	        r[x]=0;
	        r[y]=1;
	        arr[x]--;
	        arr[y]++;
	    }
	    else if(r[x]==1 && arr[x]>1)
	    {
	        r[y]=1;
	        arr[x]--;
	        arr[y]++;
	    }
	    else
	    {
	        arr[x]--;
	        arr[y]++;
	    }
	}
	for(int i=1;i<=a;i++)
	{
	    sum=sum+r[i];
	}
	cout<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main() {
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ans=max({a*c,a*d,b*c,b*d});
  cout<<ans<<endl;
}

Measured memory_bytes: 3640
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def new(t):
    for r in t:
        tmp = []
        cnt = 0
        for b in [100, 101, 102, 103, 104, 105]:
            nex = r - b
            if nex == 0 or r % b == 0:
                return 1
            elif nex < 100:
                cnt += 1
                if cnt == 6:
                    return 0
            tmp.append(nex)
        t = tmp
    # print(t, tmp)
    return new(t)
        

def main():
    x = ni()

    t = [x]
    return new(t)
    

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
from collections import defaultdict
from heapq import heappop, heappush


class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]


n,m,s = map(int, input().split())
uvab = [list(map(int, input().split())) for i in range(m)]
cd = [list(map(int, input().split())) for i in range(n)]

G = Graph()
for u,v,a,b in uvab:
    u-=1
    v-=1
    u*=2501
    v*=2501
    for i in range(2500,a-1,-1):
        G.add_edge(u+i,v+i-a,b)
        G.add_edge(v+i,u+i-a,b)
for i,(c,d) in enumerate(cd):
    i*=2501
    for j in range(2501-c):
        G.add_edge(i+j,i+j+c,d)

s = min(s,2500)
dist = Dijkstra(G, s)
for i in range(1,n):
    ans = 10 ** 18
    for j in range(2501):
        goal = i * 2501 + j
        D = dist.shortest_distance(goal)
        ans = min(ans, D)
    print(ans)


Measured memory_bytes: 154128