akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

enum F = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];

int[string] RMap(string[] xs) {
    int[string] ret;
    foreach (int i, x; xs) ret[x] = i;
    return ret;
}

int next(int n) {
    return (n + 1) % 12;
}
int prev(int n) {
    return (n + 12 - 1) % 12;
}

enum R = RMap(F);

int[] T, S;
void main() {
    int N, M;
    void input() {
        scanf("%d %d\n", &N, &M);
        T = [-1] ~ readln.chomp.split(" ").map!((x) => R[x]).array;
        S = [-1] ~ readln.chomp.split(" ").map!((x) => R[x]).array;
    }
    void solve() {
        //writeln([N, M]);
        bool dfs(int i, int k) {
            if (i == 0) return k == 0;
            if (k <= 0 || k > N) return false;
            if (S[i] == T[k].prev && dfs(i - 1, k + 1)) return true;
            if (S[i] == T[k]      && dfs(i - 1, k - 1)) return true;
            if (S[i] == T[k].next && dfs(i - 1, k - 2)) return true;
            return false;
        }
        writeln(dfs(M, N) || dfs(M, N - 1) ? "Yes" : "No");
    }
    int _T; scanf("%d\n", &_T);
    foreach (t; 0 .. _T) {
        input; solve;
    }
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    multiset<int,greater<int>> s;
    for(int i = 0; i < n; ++i)
    {
        int t;
        cin >> t;
        s.insert(t);
    }

    for(int i = 0; i < m; ++i)
    {
        multiset<int>::iterator t = s.begin();
        int num = *t/2;
        s.erase(t);
        s.insert(num);
    }

    long long ans = 0;
    for(int cost : s)
    {
        ans += cost;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

void solve(){
    int N;
    cin >> N;
    vec<ll> A(N);
    for(auto& x:A) cin >> x;
    string S;
    cin >> S;
    vec<ll> base;
    for(int i=N-1;i>=0;i--){
        ll a = A[i];
        for(auto& b:base) a = min(a,b^a);
        if(S[i]=='1'){
            if(a){
                cout << 1 << "\n";
                return ;
            }
        }else{
            base.push_back(a);
        }
    }
    cout << 0 << "\n";
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T;
    cin >> T;
    while(T--){
        solve();
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;

struct team{
	long number;
	int time;
};

int main(){
	while(1){
		int n, num;
		cin>>n;
		if(n==0) break;
		
		vector<struct team> a;
		a.resize(n);

		for(int i=0;i<n;i++){
			cin>>a[i].number;
			a[i].time = 0;

			for(int j=0;j<8;j++){
				cin>>num;
				if(j%2 == 0)
					a[i].time += num * 60;
				else
					a[i].time += num;
			}
		}

		int win, pre, boo, los;
		if(a[0].time < a[1].time){
			win = 0;
			pre = 1;
			boo = 0;
			los = 1;
		}else{
			win = 1; 
			pre = 0;
			boo = 1;
			los = 0;
		}
		
		for(int i=2;i<n;i++){
			if(a[i].time < a[win].time){
				pre = win;
				win = i;
			}else if(a[i].time < a[pre].time){
				pre = i;
			}
			

			if(a[i].time > a[los].time){
				boo = los;
				los = i;
			}else if(a[i].time > a[boo].time){
				boo = i;
			}
		}

		cout<<a[win].number<<endl<<a[pre].number<<endl<<a[boo].number<<endl;
	}

	return 0;
}

Measured memory_bytes: 1276
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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 MAX = 1e6 + 10;

bool used[1000000];
int fact[1000020];

void init() {
    rep(i, MAX + 1) fact[i] = i;
    for (int i = 2; i <= MAX; i++) {
        if (fact[i] != i) continue;
        for (int j = i; j <= MAX; j += i) {
            fact[j] = i;
        }
    }
}

int main() {
    init();
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i, n) cin >> a[i];
    bool pairwise = true;
    rep(i, n) {
        int x = a[i];
        vector<int>vec;
        while (x != 1) {
            if (used[fact[x]]) {
                pairwise = false;
                goto bou;
            }
            vec.push_back(fact[x]);
            x /= fact[x];
        }
        rep(i, vec.size()) {
            used[vec[i]] = true;
        }
    }
    bou:;
    if (pairwise) {
        cout << "pairwise coprime" << endl;
        return 0;
    }
    int bout = a[0];
    rep(i, n) {
        if (i == 0) continue;
        bout = gcd(bout, a[i]);
    }
    if (bout == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    return 0;
}


Measured memory_bytes: 11112
import sys
input = sys.stdin.readline
def main():
   K = int(input())
   CNT = 0
   for i in range(1, K+1):
       for j in range(1, K+1):
           A = gcd(i, j)
           for k in range(1, K+1):
               CNT += gcd(A, k)
   print(CNT)

def gcd(p, q):
    if p%q == 0:
        return q
    return gcd(q, p%q)

if __name__ == '__main__':
    main()

Measured memory_bytes: 74964
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int a,b,c;
	std::cin >> a >> b >> c;
	if(a+b+c>=22) print("bust");
	else print("win");

	return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    l = list(map(int, input().split()))
    ans = 0
    m = 10**9 + 7
    
    for i in range(60):
        x = 0
        for j in l:
            x += 1 & j >> i
        
        tmp = x * (N - x) % m
        tmp *= 2 ** i % m
        ans += tmp
        ans %= m

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 51084
#include <bits/stdc++.h>
#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 sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,a,b;cin>>n>>a>>b;
    ll buf=b-a;
    if(buf%2==0){
        cout<<buf/2<<endl;
        return 0;
    }
    ll buf1=(b-a)/2+a,buf2=(b-a)/2+n-b+1;
    ll res=min(buf1,buf2);
    cout<<res<<endl;
}

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

int main()
{
    int N, S;
    cin>>N>>S;
    vector<int> A(N);
    for (int &a: A)
        cin>>a;

    long long M = 998244353;
    vector<long long> T(S+1);
    T[0] = 1;
    for (int &a: A)
    {
        for (int s=S; s>=0; s--)
        {
            if (s+a<=S)
                T[s+a] = (T[s+a]+T[s])%M;
            T[s] = T[s]*2%M;
        }
    }
    cout<<T[S]<<endl;
}


Measured memory_bytes: 3216
#include<iostream>
#include<string>

using namespace std;

int N, K, Q;
int A[100000 + 10];
int score[100000 + 10];

int main() {
	cin >> N >> K >> Q;
	for (int i = 0; i < Q; i++)cin >> A[i], score[A[i] - 1]++;
	for (int i = 0; i < N; i++) {
		if (score[i] + K > Q) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

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

    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2*b) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define TIME 3

int main(void){
int a[3][3],n,b[15];
int ans[3][3]={0,0,0,0,0,0,0,0,0};

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

scanf("%d",&n);

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

for(int i=0;i<TIME;i++){
    for(int j=0;j<TIME;j++){
       for(int k=0;k<n;k++){
           if(b[k]==a[i][j]){ans[i][j]=1;}
       }
    }
}
//YOKO
if(ans[0][0]==ans[0][1]&&ans[0][1]==ans[0][2]&&ans[0][0]==1){printf("Yes\n"); return 0;}
else if(ans[1][0]==ans[1][1]&&ans[1][1]==ans[1][2]&&ans[1][0]==1){printf("Yes\n");return 0;}
else if(ans[2][0]==ans[2][1]&&ans[2][1]==ans[2][2]&&ans[2][0]==1){printf("Yes\n");return 0;}

//tate
if(ans[0][0]==ans[1][0]&&ans[1][0]==ans[2][0]&&ans[0][0]==1){printf("Yes\n"); return 0;}
else if(ans[0][1]==ans[1][1]&&ans[1][1]==ans[2][1]&&ans[0][1]==1){printf("Yes\n");return 0;}
else if(ans[0][2]==ans[1][2]&&ans[1][2]==ans[2][2]&&ans[2][2]==1){printf("Yes\n");return 0;}

//naname
if(ans[0][0]==ans[1][1]&&ans[1][1]==ans[2][2]&&ans[0][0]==1){printf("Yes\n"); return 0;}
else if(ans[0][2]==ans[1][1]&&ans[1][1]==ans[2][0]&&ans[0][2]==1){printf("Yes\n");return 0;}

printf("No");

}

Measured memory_bytes: 128
#include <stdio.h>

int main() {
  int a, b, c, min=30000;
  scanf("%d %d %d", &a, &b, &c);

  if (a+b<=min) min=a+b;
  if (a+c<=min) min=a+c;
  if (b+c<=min) min=b+c;

  printf("%d\n", min);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main(){
  int k;
  cin>>k;
  string s;
  cin>>s;
  if(k >= s.size()) cout<<s<<endl;
  else {
    string s1;
    s1.assign(s,0,k);
    cout<<s1<<"..."<<endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

#define INF (1 << 30)
#define NMAX 500000

int merge(int A[], int left, int mid, int right) {
    int L[NMAX], R[NMAX], i, j, k, cnt;
    for (i = 0; i < mid - left; i++) {
        L[i] = A[left + i];
    }
    L[i] = INF;
    for (i = 0; i < right - mid; i++) {
        R[i] = A[mid + i];
    }
    R[i] = INF;
    i = 0, j = 0, cnt = 0;
    for (k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
            //cnt += mid - left - i; 
        }
        cnt++;
    }
    return cnt;
}

int mergeSort(int A[], int left, int right) {
    if (right - left <= 1) {
        return 0;
    }
    int mid = (left + right) / 2, cnt = 0;
    cnt += mergeSort(A, left, mid);
    cnt += mergeSort(A, mid, right);
    cnt += merge(A, left, mid, right);
    return cnt;
}

int main() {
    int A[NMAX], N = 50000;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    int cnt = mergeSort(A, 0, N);
    for (int i = 0; i < N; i++) {
        printf("%d", A[i]);
        if (i == N-1) {
            printf("\n");
        } else {
            printf(" ");
        }
    }
    printf("%d\n", cnt);
    return 0;
}



Measured memory_bytes: 6532
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main() {
    
    ll a, b, c;
    cin >> a >> b >> c;
    if (a == b && a != c) {
        cout << "Yes";
        return 0;
    }
    if (a == c && a != b) {
        cout << "Yes";
        return 0;
    }
    if (b == c && a != c) {
        cout << "Yes";
        return 0;
    }
    cout << "No";

}


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


int main() {
    int N;
    cin >> N;
    vector<int> A;
    rep(i, N) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    int evencnt = 0;
    vector<int> evenVec;
    rep(i, N) {
        if(A[i]%2==0) {
            ++evencnt;
            evenVec.push_back(A[i]);
        }
    }
    int cnt = 0;

    for(auto e: evenVec) {
        if(e%3==0 || e%5==0) ++cnt;
    }

    if(cnt==evenVec.size()) {
        cout << "APPROVED" << endl;
    }
    else {
        cout << "DENIED" << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
string ans="";
string abcd;
void dfs(int pos,int sum,string s){
    if(pos==4){
        if(sum==7){
            ans=s;
            ans+="=7";
        }
        return;
    }
    dfs(pos+1,sum+(abcd[pos]-'0'),s+"+"+abcd[pos]);
    dfs(pos+1,sum-(abcd[pos]-'0'),s+"-"+abcd[pos]);
}
int main(void){
    cin>>abcd;
    string s="";
    dfs(1,abcd[0]-'0',abcd[0]+s);
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a * b % 2 == 1) {
    cout << "Odd" << endl;
  }
  if (a * b % 2 != 1) {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
const ll MAXN=1e5+51;
ll cnt,x,res;
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
int main()
{
	cnt=read();
	for(register int i=0;i<cnt;i++)
	{
		x=read();
		if(x%2==0)
		{
			if((x%3)&&(x%5))
			{
				res=1;
				break;
			}
		}
	}
	puts(res?"DENIED":"APPROVED");
}

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

int main() {
	int i, j, l;
	int x, y;
	int a[100][100];
	int b[100];
	cin >> y; cin >> x;
	for (i = 0; i < y; i++) {
		for (j = 0; j < x; j++) {
			cin >> a[i][j];
		}
	}
	for (i = 0; i < x; i++) {
		cin >> b[i];
	}

	for (i = 0; i < y; i++) {
		for (j = 0; j < x; j++) {
			a[i][j] = a[i][j] * b[j];
		}
	}

	for (i = 0; i < y; i++) {
		for (j = 0; j < x-1; j++) {
			a[i][0] = a[i][j + 1] + a[i][0];
		}
		cout << a[i][0]<<"\n";
	}

}


Measured memory_bytes: 3128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

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

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

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

#define PUTS(x) cout << (x) << endl;

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

    string s,t;
    cin>>s>>t;
    PUTS(s == t.substr(0,s.size()) ? "Yes" : "No");
}

Measured memory_bytes: 3656
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int a, c = 0;
		while(true) {
			a = sc.nextInt();
			if(a == 0) break;
			System.out.println("Case " + (++c) + ": " + a);
		}
	}
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






long long int gcd(long long int a,long long int b)
{
 
  long long int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int n,ans=0,count=0,c[5];
  cin>>n;
  rep(i,5) c[i]=0;
  rep(i,n){
    string s;
    cin>>s;
    if(s[0]=='M'){
      c[0]++;
    }else if(s[0]=='A'){
      c[1]++;
    }else if(s[0]=='R'){
      c[2]++;
    }else if(s[0]=='C'){
      c[3]++;
    }else if(s[0]=='H'){
      c[4]++;
    }
  }
  
  for(int p=0;p<3;p++){
    for(int q=p+1;q<4;q++){
      for(int r=q+1;r<5;r++){
        ans+=c[p]*c[q]*c[r];
      }
    }
  }
  cout<<ans<<endl;
}
///////////////////////////



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define db "ONEPIECE"
#define fi first
#define se second
#define endl '\n'
#define int long long
const int INF = 1e15 + 1;
const int mod = 1e9 + 7;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<PII, int> PII2;
typedef pair<int, PII> PII3;

void docfile()
{
    if (ifstream("FORM.inp"))
    {
        freopen("FORM.inp", "r", stdin);
        freopen("FORM.out", "w", stdout);
    }
    else if (ifstream(db".inp"))
    {
        freopen(db".inp", "r", stdin);
        freopen(db".out", "w", stdout);
    }
}

//---------------------------------------------------------------------------
const int N = 2e5 + 2;
int n, m, k;
PII safe[3010];

int f[3010], fac[N], ifac[N];
int sumA[3010], sumB[3010];

int nhan(int a, int b)
{
    return a * b % mod;
}

int power(int a, int b)
{
    if(b == 1) return a;
    int t = power(a, b / 2);
    t = (t * t) % mod;
    if(b % 2) t = (t * a) % mod;
    return t;
}

int binomial(int n, int k)
{
    return nhan(nhan(fac[n], ifac[k]), ifac[n-k]);
}

void sub2()
{
    sort(safe+1, safe+k+1);
    k++;
    safe[k] = {n, m};

    for(int i = 1; i <= k; i++)
    {
        sumA[i] = binomial(safe[i].fi + safe[i].se - 2, safe[i].fi - 1);
        //cout << i << " " << sumA[i] << endl << endl;
        for(int j = 1; j < i; j++)
        {
            if(safe[j].fi <= safe[i].fi && safe[j].se <= safe[i].se)
            {
                int x = safe[i].fi - safe[j].fi + 1;
                int y = safe[i].se - safe[j].se + 1;
                int z = binomial(x + y - 2, x-1);
                (sumB[i] += nhan(z, f[j])) %= mod;
                //cout << x << " " << y << " " << z << " ";
                //cout << f[j] << " " << sumB[i] << endl << endl;
            }
        }
        f[i] = (sumA[i] - sumB[i] + mod) % mod;
    }
    cout << f[k];
}

void solve()
{
    fac[0] = ifac[0] = 1;
    for(int i = 1; i <= n + m; i++)
    {
        fac[i] = nhan(fac[i-1], i);
        ifac[i] = power(fac[i], mod-2);
    }
    sub2();

}

void input()
{
    cin >> n >> m >> k;
    for(int i = 1; i <= k; i++)
    {
        cin >> safe[i].fi >> safe[i].se;
    }
    solve();
}

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

    int test = 1;
    //cin >> test;
    while(test--)
    input();
}



Measured memory_bytes: 3456
/*input
aaaccacabaababc
*/
#include <bits/stdc++.h> 

using namespace std; 

int main() {
    ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	string s;
	cin >> s;

	int c = 0;

	for(int i = 0; i < s.length()-1; i++) {
		if(s[i] == s[i+1]) {
			c++;
			i+= 2;
		}
	}


	cout << s.length() - c;

	return 0; 
} 


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll n;cin>>n;
    ll ans=0;
    rrep(i,n){
        if(i%3==0||i%5==0) continue;
        ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n + 1), b(n + 1), c(n + 1);
	a[0] = 0;
	b[0] = 0;
	c[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	vector<vector<int>> dp(n + 1, vector<int>(3));
	for (int i = 1; i <= n; i++) {
		dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
		dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
		dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
	}

	int ans = max(dp[n][0], max(dp[n][1], dp[n][2]));
	cout << ans << endl;
}

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

int main(){
    int n;
    long long zmi=2e9,zma=-2e9,wmi=2e9,wma=-2e9;
    cin>>n;
    while(n--){
	    long long x,y;
	    cin>>x>>y;
	    zmi=min(zmi,x+y);
	    zma=max(zma,x+y);
	    wmi=min(wmi,x-y);
	    wma=max(wma,x-y);
    }
    cout<<max(zma-zmi,wma-wmi)<<"\n";
}




Measured memory_bytes: 3588
#include <cstdio>
typedef long long ll;

inline bool Query(ll x)
{
    printf("? %lld\n",x),fflush(stdout);
    char s[10];
    return scanf("%s",s),*s=='Y';
}

int main()
{
    ll X=1000000000;
    while(!Query(X))X/=10;
    if(X==1000000000)for(X=1;!Query(X+1);X*=10);
    else
    {
        int l=X,r=X*10-1;
        while(l<=r)
        {
            int Mid=(l+r)>>1;
            if(Query(Mid*10ll))X=Mid,r=Mid-1;
            else l=Mid+1;
        }
    }
    return printf("! %lld\n",X),fflush(stdout),0;
}


Measured memory_bytes: 504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.function.BiConsumer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int a = in.nextInt();
			int b = in.nextInt();
			out.println(lcm(a, b));
		}
	}

	static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	static long gcd(long m, long n) {
		if (m < n)
			return gcd(n, m);
		if (n == 0)
			return m;
		return gcd(n, m % n);
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


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

string S;

int main() {
    cin >> S;

    if (S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;

    

    return 0;
}


Measured memory_bytes: 256
// " --- IN THE NAME OF ALLAH --- " // ;)
// ------------sphr_agz------------ // ;)
 
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <math.h>
#include <cmath>
#include <list>
#include <stack>
#include <bitset>
#include <ctime>
using namespace std;
 
typedef long double ld;
typedef long long int lli;
#define pb(x) push_back(x)
#define fr first
#define sc second
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define stp(x) cout << setprecision(x) << fixed
#define mk make_pair
const lli N = 1e6, N2 = 5e3, delta = 46639, mod = 1e9 + 7, oo = 1e16;
const ld PI = 3.141592653589793;

lli a[N];

int main(){
	lli n, ans = 0;
	string s;
	cin >> n >> s;
	for (lli i = 1; i < n; i++) {
		if (s[i] != s[i - 1])
			ans++;
	}
	cout << ++ans;
}


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

int main(){
  int N;cin>>N;
  int H[N+10];
  for(int i=0;i<N;i++)cin>>H[i];
  int ans=0;
  int tmp=0;
  int tt=H[0];
  for(int i=1;i<N;i++){
    if(tt>=H[i])tmp++;
    else tmp=0;
    ans=max(ans,tmp);
    tt=H[i];
  }
  
  cout<<ans<<endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<vector<int>> map(2,vector<int>(n));
  
  for(int i=0; i<2;i++){
    for(int j=0; j<n; j++){
      cin >> map[i][j];
    }
  }
  
  int max=0;
  int tmp=0;
  
  for(int i=0; i<n; i++){
    tmp=0;
    for(int j=0; j<=i; j++){
      tmp += map[0][j];
    }
    for(int j=i; j<n; j++){
      tmp += map[1][j];
    }
    if(max < tmp) max=tmp;
  }
  
  cout << max << endl;
}

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

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = s[0];
            int r = s[1];

            if (n >= 10)
            {
                //内部レート等しい
                WriteLine(r);
            }
            else//そうでないとき
            {
                WriteLine(r + (100 * (10 - n)));
            }
        }
    }
}

Measured memory_bytes: 13268
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

ll a, b, c, d;

map<ll, ll> m;
ll dist(ll k) {
	if (m.find(k) != m.end()) {
		return m[k];
	}

	if (k == 0) {
		m[0] = 0;
		return 0;
	}
	if (k == 1) {
		m[1] = d;
		return d;
	}

	ll r = d * k;
	if (INF / d < k) {
		r = INF;
	}

	for (int i = -1; i <= 1; ++i) {
		ll num = k + i;

		if (num >= 0 && num % 2 == 0) {
			r = min(r, dist(num / 2) + a + d * abs(i));
		}
	}

	for (int i = -2; i <= 2; ++i) {
		ll num = k + i;
		if (num >= 0 && num % 3 == 0) {
			r = min(r, dist(num / 3) + b + d * abs(i));
		}
	}
	for (int i = -4; i <= 4; ++i) {
		ll num = k + i;
		if (num >= 0 && num % 5 == 0) {
			r = min(r, dist(num / 5) + c + d * abs(i));
		}
	}
	m[k] = r;

	return m[k];
}




int main() {
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		ll n;
		cin >> n;

		cin >> a >> b >> c >> d;
		m.clear();
		cout << dist(n) << endl;
	}


}

Measured memory_bytes: 4240
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <set>
#include <map>
#include <bitset>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1;
		cin >> n;
		if (n < 0) return 0;
		LL ans = 0;
		vector<int> f(n + 1, 0);
		for (LL i = 1; i <= n; ++i) {
			for (LL j = i; j <= n; j += i) {
				f[j] += 1;
			}
			ans += i * f[i];
		}
		cout << ans << endl;
	}
	return 0;
}


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

const int  mod = 1000000007;
struct mint{
    ll x;
    mint (ll x=0) : x((x%mod+mod)%mod){}//カッコの中で初期化している
    mint& operator+=(const mint a){//operatorは構造体同士の比較に用いられる
        if((x +=a.x)>=mod) x-=mod;
        return *this;//thisとは現在のオブジェクトのこと
    }
    mint& operator-=(const mint a){
        if((x +=mod-a.x)>=mod) x-=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x*=a.x)%=mod;
        return *this;
    }
    mint operator+(const mint a){
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a){
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a){
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const{
        if(!t) return 1;
        mint a=pow(t>>1);
        a*=a;
        if(t&1) a*=*this;
        return a;
    }
    mint inv() const{
        return pow(mod-2);//逆元
    }
    mint&operator/=(const mint a) {
        return (*this)*=a.inv();
    }
    mint&operator/(const mint a) const{
    mint res(*this);
    return res/=a;
    }
};
 
int main(void){
    int n;
    cin>>n;
    mint ans = 1;
    rep(i, n) ans *=(i+1);
    cout<<ans.x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    ll n, m; cin >> n >> m;
    ll N = min(n, m);
    ll M = max(n, m);

    if(N == 1) cout << abs(M-2) << endl;
    else if(N == 2) cout << 0 << endl;
    else cout << (N-2)*(M-2) << endl;

    return 0;
}

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

int main(void) {
  long long A, B;
  cin >> A >> B;
  unordered_map<long long, long long> umA;
  unordered_map<long long, long long> umB;
  for (long long i = 2, end = A; i * i <= end; i++) {
    while (A % i == 0) {
      umA[i]++;
      A /= i;
    }
  }
  if (A != 1) umA[A]++;
  for (long long i = 2, end = B; i * i <= end; i++) {
    while (B % i == 0) {
      umB[i]++;
      B /= i;
    }
  }
  if (B != 1) umB[B]++;

  long long ans = 0;
  for (auto m : umA) {
    if (umB.find(m.first) != umB.end()) {
      ans++;
    }
  }

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

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

class DisjointSet {
    public:
    vector<int> rank, p, s;

    DisjointSet(int size) {
        rank.resize(size);
        p.resize(size);
        s.resize(size);
        for(size_t i = 0; i < size; i++)
        {
            makeSet(i);
        }
    }
    void makeSet(int x) {
        p[x] = x;
        rank[x] = 0;
        s[x] = 1;
    }
    bool same(int x, int y) {
        return findSet(x) == findSet(y);
    }
    void unite(int x, int y) {
        link(findSet(x), findSet(y));
    }
    void link(int x, int y) {
        if (x == y) return;
        if (rank[x] > rank[y]) {
            p[y] = x;
            s[x] += s[y];
        }
        else{
            p[x] = y;
            s[y] += s[x];
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }
    int size(int x){
        return s[findSet(x)];
    }
    int findSet(int x){
        if (x != p[x]){
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M+1), B(M+1);
    for(size_t i = 1; i <= M; i++)
    {
        cin >> A[i] >> B[i];
    }
    DisjointSet set(N+1);
    typedef long long ll;
    vector<ll> score(M+1);
    score[M] = ll(N) * ll(N-1) / ll(2);
    for(int i = M-1; i >= 1; --i){
        score[i] = score[i+1];
        if(!set.same(A[i+1], B[i+1])){
            score[i] -= ll(set.size(A[i+1])) * ll(set.size(B[i+1]));
            set.unite(A[i+1], B[i+1]);
        }
    }
    for(size_t i = 1; i <= M; i++)
    {
        cout << score[i] << endl;
    }    
    return 0;
}

Measured memory_bytes: 4096
n = gets.to_i()
i = 0
while i < n do
	a,b,c = gets.split(' ').map(&:to_i)
	if (a**2+b**2==c**2 || b**2+c**2==a**2 || a**2+c**2==b**2) then
		print ("YES\n")
	else
		print ("NO\n")
	end
	i += 1
end


Measured memory_bytes: 6840
import java.util.Scanner;

public class Main{
	public Main(){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String str[] = (sc.nextLine()).split(" ");
			if(str[0].equals("0")){
				break;
			}
			int n = str.length;
			int s = 0;
			int a = 0;
			for(int i = 0; i < n; i++){
				int v = Integer.parseInt(str[i]);
				if(v > 10){
					s += 10;
				} else if(v == 1){
					s += 11;
					a++;
				} else {
					s += v;
				}
				
				while(21 < s && a > 0){
					a--;
					s -= 10;
				}
			}
			if(s > 21){
				s = 0;
			}
			System.out.println(Integer.toString(s));
		}
	}
	
	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 12000
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int a,b;cin>>a>>b;
    cout<<a*b<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000
vector<long long> A;
long long check(vector<vector<int>> &E,int now,int parent){
	if(E[now].size()==1&&parent!=-1){
		return A[now];
	}
	vector<long long> V;
	for(int i=0;i<E[now].size();i++){
		int to = E[now][i];
		if(to==parent)continue;
		V.push_back(check(E,to,now));
	}
	long long sum = 0;
	long long maxi = 0;
	for(int i=0;i<V.size();i++){
		if(V[i]==-1)return -1;
		sum += V[i];
		maxi = max(maxi,V[i]);
	}
	
	long long K = sum-A[now];
	if(K<0)return -1;
	if(min(sum/2,sum-maxi)<K){
		return -1;
	}
	
	return A[now] - K;
	
}

int main(){
	long long N;
	cin>>N;
	for(int i=0;i<N;i++){
		long long a;cin>>a;
		A.push_back(a);
	}
	vector<vector<int>> E(N,vector<int>(0));
	vector<int> ji(N,0);
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
		ji[a]++;ji[b]++;
	}
	int f;
	for(int i=0;i<N;i++){
		if(ji[i]==1){
			f = i;
			break;
		}
	}
	
	int k = check(E,f,-1);
	//cout<<k<<endl;
	if(k!=A[f]){
		cout<<"NO"<<endl;
	}
	else{
		cout<<"YES"<<endl;
	}
	
	
	
	
	return 0;
}


Measured memory_bytes: 17780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  cout << 800 * n - n / 15 * 200 << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# E

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n, m = map(int, input().split())
a = []
b = []
c = []

for i in range(m):
    a_, b_ = map(int, input().split())
    c_ = list(map(int, input().split()))
    a.append(a_)
    b.append(b_)
    val = 0
    for _c_ in c_:
        val += 2 ** (_c_ -1)
    c.append(val)

max_m = 2**n

dp = [[float('inf')] * max_m for _ in range(m+1)]
dp[0][0]=0

# print(c)

for i in range(1, m+1):
    for combi in range(max_m):
        # print(c[i-1])
        combi_diff = 0
        combi_diff = combi & ~c[i-1]
        dp[i][combi] = min(dp[i-1][combi], dp[i-1][combi_diff] + a[i-1])

if dp[-1][-1] == float('inf'):
    print(-1)
else:
    print(dp[-1][-1])



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


int main(){
    long long N,i=1,j=0,ans=0;
    cin>>N;
    long long M=N;
    while(i<=N){
        i*=10;
        j++;
    }
    while(M>=1){
        ans+=(M%10);
        M/=10;
    }
    i/=10;
    if(ans<(N/i-1+(j-1)*9)){
        ans=(N/i-1+(j-1)*9);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>


int comp(const void *a, const void *b)
{
	return *(int *)b - *(int *)a;
}

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

	qsort(set, 10, sizeof(int), comp);

	for(i=0; i<3; i++){ printf("%d\n", set[i]); }

    return 0;
}

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

using namespace std;
const int Max_N(1000050);
const int MOD(1000000000 + 7);

constexpr int Mult(int a, int b)
{
	return a * 1LL * b % MOD;
}

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

void exgcd(int a, int b, int &x, int &y)
{
	if (b == 0)
		x = 1, y = 0;
	else
		exgcd(b, a % b, y, x), y -= x * (a / b);
}

inline int inverse(int a)
{
	int invx, invy;
	exgcd(a, MOD, invx, invy);
	return (invx % MOD + MOD) % MOD;
}

int N, Fac[Max_N], Inv[Max_N];

int main()
{
	scanf("%d", &N);
	Fac[0] = 1;
	for (int i = 1;i <= max(N, 3);++i)
		Fac[i] = Mult(Fac[i - 1], i);
	Inv[max(N, 3)] = inverse(Fac[max(N, 3)]);
	for (int i = max(N, 3) - 1;i >= 0;--i)
		Inv[i] = Mult(Inv[i + 1], i + 1);
	for (int i = 1;i <= max(N, 3);++i)
		Inv[i] = Mult(Inv[i], Fac[i - 1]);
	int Ans = 0, Com = Inv[N];
	for (int i = 0;i <= N - 1;++i)
		Com = Mult(Com, Inv[3]), Ans = Add(Ans, Mult(Com, Inv[N - i]));
	printf("%d", Ans);
	return 0;
}

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

const int maxn=3e5+10;

int n,m,Ans[maxn],vis[maxn];
long long O;

int main()
{
#ifdef h10
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int i,j,l,r,x;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
	{
		scanf("%d%d",&l,&r);
		if (!l) {Ans[1]++; continue;}
		int lu=m+1;
		for (x=1;x*x<=m;x++)
		{
			int u=(l+x-1)/x,v=r/x;
			if (u<=v)
			{
				if (v<lu) Ans[u]++,Ans[v+1]--;
				else Ans[u]++,Ans[lu]--;
				lu=u;
				for (j=u;j<=v&&j*j<=m;j++)
				{
					O++;
					if (vis[j]!=i) vis[j]=i;
					else break;
				}
			}
		}
		for (x=1;x*x<=m;x++)
		{
			int u=(l+x-1)/x,v=r/x;
			if (u<=v&&vis[x]!=i)
				vis[x]=i,Ans[x]++,Ans[x+1]--;
		}
	}
	for (i=1;i<=m;i++)
		Ans[i]+=Ans[i-1],printf("%d\n",Ans[i]);
}


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

unsigned long long max(unsigned long long current, unsigned long long k, unsigned long long a, unsigned long long b, bool doConvert){
  if(!doConvert)
    return current+k;
  if(k==0)
    return current;
  if(k==1)
    return current+1;
  
  while(true){
    //cout << current << ", " << k << endl;
    if(!k)
      return current;
    else if(current<a){
      if(k>=(a-current)){
        k -= (a-current);
        current = a; 
      }else{
        current += k;
        k=0;
      }
    }else{
      if(k>1){
        current += b-a;
        k -= 2;
      }else{
        current++;
        k--;
      }
    }
  }
}

int main(){
  unsigned long long current = 1;
  unsigned long long k,a,b;
  bool doConvert = true;
  cin >> k >> a >> b;
  if(b<=a)
    doConvert = false;
  else if(b-a<3)
    doConvert = false;
  
  unsigned long long res = max(current, k,a,b, doConvert);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stdio.h>
using namespace std;

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

typedef long long ll;

const int INF=1e9+7;
ll v[55];
ll s[55];
ll C[55][55];
int main(){
	rep(i,55){C[0][i]=0;C[i][0]=1;}
	rep(i,55)rep(j,55)C[i+1][j+1]=C[i][j]+C[i][j+1];
	int n,a,b;
	cin>>n>>a>>b;
	rep(i,n)cin>>v[i];
	sort(v,v+n);
	reverse(v,v+n);
	s[0]=v[0];
	rep(i,n)s[i+1]=s[i]+v[i+1];
	double ma=(double)s[a-1]/(double)(a);
	ll tmp=v[a-1];
	int t=0;
	rep(i,n)if(tmp==v[i])t++;
	ll ans=0;
	if(tmp==v[0])for(int i=a-1;v[i]==tmp&&i<b;i++)ans+=C[t][i+1];
	else {
		int cnt=0;
		rep(i,a)if(v[i]==tmp)cnt++;
		ans=C[t][cnt];
	}
	printf("%.6f\n%lld\n",ma,ans);
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int day=sc.nextInt(),n=sc.nextInt();//入力
		int[] high=new int[day];
		for(int i=0;i<day;i++){
			high[i]=sc.nextInt();
		}
		int[] ht=new int[n];
		int[] lt=new int[n];
		int[] loud=new int[n];
		for(int i=0;i<n;i++){
			lt[i]=sc.nextInt();ht[i]=sc.nextInt();loud[i]=sc.nextInt();
		}//入力
		
		int[][] dp=new int[day][n];
		for(int i=0;i<day;i++){//派手さの絶対値の初期値を入力
			for(int j=0;j<n;j++){
				dp[i][j] = 0;
			}
		}
		int ans=0;
		for(int i=1;i<day;i++){//日数-1分ループ
			for(int j=0;j<n;j++){//i日目に適した服の数実行
				if(lt[j]<=high[i]&&high[i]<=ht[j]);//適温の判定
				else continue;
				for(int k=0;k<n;k++){//i-1日目に適した服の数実行
					if(lt[k]<=high[i-1]&&high[i-1]<=ht[k]);//適温の判定
					else continue;
					dp[i][j]=Math.max(dp[i][j],Math.abs(loud[j]-loud[k])+dp[i-1][k]);//
					ans=Math.max(ans,dp[i][j]);
				}
			}	
		}	
		System.out.println(ans);
	}
}

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

int N; vector<vector<int>> to; vector<int> c;
vector<int> visited; int itr = 0;

void dfs(int v){
  for(int p = 0; p < (int)to[v].size(); p++){
    int q = to[v][p]; 
    if( visited[q] != -1){ continue;}
    visited[q] = c[itr]; itr++; dfs(q);  }
  return ;
}
  
   
int main(){
  cin >> N; to.resize(N); visited = vector<int> (N,-1);
  for(int i = 0; i < N-1; i++){ 
    int a,b; cin >> a >> b; a--; b--;
    to[a].push_back(b); to[b].push_back(a);}
   c.resize(N); long long m = 0;
  for(int i = 0; i < N; i++){ cin >> c[i]; m += c[i];}
  sort(c.rbegin(),c.rend()); m -= c[0];
  
  dfs(0);
  
  cout << m << endl;
  for(int i = 0; i < N; i++){ cout << visited[i] << endl; } return 0;}
  
  
  

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define all(v)    ((v.begin()),(v.end()))
#define sz(v)     ((int)(v.size()))
#define forv(i, v) for(int i = 0; i < sz(v); ++i)
#define forn(i,n)   for(int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef vector<int>     vi;
typedef vector<double>  vd;
typedef vector< vi >    vii;
typedef vector< vd >    vdd;
typedef vector<string>  vs;


int main()
{
	fast;
	ll n, x, y;
	cin >> n >> x >> y;
	int ans[n + 3] = {0};
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			int dist;
			dist = min((abs(i - x) + 1 + abs(y - j)), (abs(y - i) + 1 + abs(x - j)));
			dist = min(abs(i - j), dist);
			ans[dist]++;
		}
	}
	for (int i = 1; i < n; i++) {
		cout << ans[i] / 2 << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    vl v(3,0);
    string s; cin >> s;
    rep(i,3) v[s[i]-'a']++;
    if(v[0]==1 && v[1]==1 && v[2]==1) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
N, K = map(int, input().split())
li = [0]*(K+1)

out = 0
mod = 10**9+7

for i in range(K, 0, -1):
  li[i] = pow(K//i, N, mod) 
  for j in range(i*2, K+1, i):
    li[i] -= li[j]
print(sum([i * li[i] for i in range(K+1)])%mod)

Measured memory_bytes: 15452