akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;

#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
const int maxn = 1e6 + 20;
int dp[maxn];
void work() {
    int n, t;
    scanf("%d%d", &n, &t);
    if (n == 1) while(1);
    int mi = (1LL << 31) - 1;
    int mx = -((1LL << 31) - 1);
    for (int i = 1; i <= n; ++i) {
        int x;
        scanf("%d", &x);
        dp[i] = max(0, x - mi);
        mi = min(mi, x);
        mx = max(mx, dp[i]);
    }
    int tim = 0;
    for (int i = 1; i <= n; ++i) {
        tim += dp[i] == mx;
    }
    int ans = tim;
    cout << ans << endl;
}

int main() {
#ifdef local
    freopen("data.txt","r",stdin);
#endif
    work();
    return 0;
}


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

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

int rank[9];

int main(void) {
    int N;
    std::cin >> N;

    for (int i = 0; i < N; i++) {
        int a;
        std::cin >> a;
        if (a < 3200) {
            rank[a / 400]++;
        } else {
            rank[8]++;
        }
    }

    int acc = 0;
    for (int i = 0; i < 8; i++) {
        if (rank[i] > 0) {
            acc++;
        }
    }

    int minimum = (acc == 0 && rank[8] > 0) ? 1 : acc;
    int maximum = acc + rank[8];

    std::cout << minimum << " " << maximum << std::endl;

    return 0;
}


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

bool solve(string s,int j)
{
  int i=0;
  while(j<s.size())
  {
    if(s[i]!=s[j]) return false;
    i++; j++;
  }
  return true;
}

int main()
{
  int n; cin>>n;
  string s; cin>>s;
  if(n%2 !=0) cout<<"No";
  else
  {
    if(solve(s,n/2)) cout<<"Yes";
    else cout<<"No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int k, n;
 
int main () {
	cin>>k>>n;
	int a[n], d[n], maxd=0, total=0;
	for (int i=0; i<n; i++) {
    	cin>>a[i];
   	}
  	for (int i=0; i<n; i++) {
    	if (i!=n-1) d[i]=a[i+1]-a[i];
    	else d[i]=k-a[i]+a[0];
	    if (d[i]>maxd) maxd=d[i];
    	total+=d[i];
  	}
  	cout<<total-maxd<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  string S1, S2, S3;
  cin >> S1 >> S2 >> S3;
  string ans = "ABC";
  ans[1] = S2[0];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	var c [3][3]int
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			c[i][j] = getInt()
		}
	}

	var a [3]int
	var b [3]int
	for a[0] = 0; a[0] <= 100; a[0]++ {
		b[0] = c[0][0] - a[0]
		b[1] = c[0][1] - a[0]
		b[2] = c[0][2] - a[0]
		for a[1] = 0; a[1] <= 100; a[1]++ {
			for a[2] = 0; a[2] <= 100; a[2]++ {
				ans := true
			L0:
				for i := 0; i < 3; i++ {
					for j := 0; j < 3; j++ {
						if c[i][j] != a[i]+b[j] {
							ans = false
							break L0
						}
					}
				}
				if ans == true {
					out("Yes")
					return
				}
			}
		}
	}
	out("No")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2<<11;
int dp[15][MAXN];
int ha[15][15];
int a[15];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int t;
        scanf("%d",&t);
        while(t--){
            int x;  scanf("%d",&x);
            ha[i][x]=1;
        }
    }
    for(int i=1;i<=m;i++)   scanf("%d",&a[i]);
    for(int i=0;i<=(1<<10)-1;i++)   dp[0][i]=1;
    for(int i=1;i<=m;i++){
        for(int j=0;j<=(1<<n)-1;j++){
            int cnt=1,ans=0,k=j;
            while(k){
                if(k&1){
                    if(ha[i][cnt])  ans++;  ///若第cnt开关打开时，并且能够控制第i盏灯，则ans++
                }
                k>>=1;   cnt++;
            }
            if(ans%2 == a[i] && dp[i-1][j])   dp[i][j]=1;///当前开关数量与灯亮的条件一致时，并且上一盏灯能够亮时
        }
    }
    int sum=0;
    for(int i=0;i<=(1<<10)-1;i++)
        if(dp[m][i])    sum++;  ///统计当所有灯亮起来时，开关的组合情况。
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 384
####
n = int(input())
memo = [-1]*(n+10)
def fib(i):
    if i==0 or i == 1:
        return 1
    if memo[i] != -1:
        return memo[i]
    memo[i] = fib(i-1) + fib(i-2)
    return memo[i]
print(fib(n))


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define OUT(a) cout << (a) << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll n, k;
    ll p[200010] = {0};
    string s;

    cin >> n >> k;
    REP(i, k){
        ll d;
        cin >> d;
        REP(j, d){
            ll x;
            cin >> x;
            p[x-1]++;
        }
    }

    ll ans = 0;
    REP(l, n){
        if(p[l] == 0){
            ans++;
        }
    }

  	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5180
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	//int seed;
	//cin >> seed;
	//srand(time(NULL));
	//while(true)
	//{
	int n = rand() % 100 + 1;
	scanf("%d", &n);
	vector < int > p(n);
	for (int i = 0; i < n; i++)
		scanf("%d", &p[i]);
	//for (int i = 0; i < n; i++)
	//	p[i] = i + 1;	
	//random_shuffle(all(p));
	//~solve
	vector < int > a(n), b(n);
	for (int i = 0; i < n; i++)
		a[i] = i + 1;
	for (int i = 0; i < n; i++)
		b[i] = n - i;
	for (int i = n - 1; i >= 0; i--)
	{	
		p[i]--;
		int pos1 = n, pos2 = -1;
		int mn = a[p[i]] + b[p[i]] - 1;
		for (int j = i + 1; j < n; j++)
		{
			//if (a[p[i]] + b[p[i]] <= a[p[j]] + b[p[j]])
			//{
			mn = min(mn, a[p[j]] + b[p[j]]);
				if (p[i] < p[j])
					pos1 = min(pos1, p[j]);
				else
					pos2 = max(pos2, p[j]);
			//}										
		}
		int val = a[p[i]] + b[p[i]] - mn + 1;
		for (int j = pos1; j < n; j++)
			a[j] += val;
		for (int j = pos2; j >= 0; j--)
			b[j] += val;
	}
	for (int i = 0; i < n - 1; i++)	
	{
		if (a[p[i]] + b[p[i]] >= a[p[i + 1]] + b[p[i + 1]] || a[p[i]] < 0 || b[p[i]] < 0)
		{
			assert(false);
			cout << n << endl;
			for (int i = 0; i < n; i++)
				cout << p[i] << ' ';
	        cout << endl;
			for (int i = 0; i < n; i++)
				cout << a[i] << ' ';
			cerr << endl;
			for (int i = 0; i < n; i++)
				cout << b[i] << ' ';
			cout << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; i++)
		printf("%d ", a[i]);
	printf("\n");
	for (int i = 0; i < n; i++)
		printf("%d ", b[i]);
	//}
	return 0;
}



Measured memory_bytes: 896
#include <iostream>
#include <queue>
#include <utility>

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

using namespace std;

const int INF = 1e9;

int main(){
  int H, W;
  cin >> H >> W;
  
  int D[H][W];
  rep(i,H) fill(D[i], D[i]+W, INF);
  
  queue<pair<int,int> > que;
  rep(i,H){
    rep(j,W){
      char c;
      cin >> c;
      if(c == '#'){
        que.push(make_pair(i,j));
        D[i][j] = 0;
      }
    }
  }
  
  while(!que.empty()){
    pair<int,int> p = que.front();
    que.pop();
    
    int dy[] = {1,-1,0,0};
    int dx[] = {0,0,1,-1};
    
    rep(m,4){
      int y = p.first + dy[m];
      int x = p.second + dx[m];
      if(y < 0 || H <= y || x < 0 || W <= x) continue;
      if(D[y][x] == INF){
        D[y][x] = D[p.first][p.second] + 1;
        que.push(make_pair(y,x));
      }
    }
  }
  
  int ans = 0;
  rep(n,H){
    rep(o,W){
      ans = max(ans,D[n][o]);
    }
  }
  cout << ans << endl;
}
    
  
  

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

int main() {
  int N;
  int ans = 0;
  
  cin >> N;
  
  for(int C = 1; C < N; C++){
    for(int A = 1; A*A <= (N - C); A++){
      if((N - C) == A*A){
        ans = ans + 1;
      } else if((N - C)%A == 0){
        ans = ans + 2;
      }
    }
  }
  
  cout << ans << endl;
}


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

using namespace std;

bool solve(int n, vector<string>& words)
{
    auto c = words[0].back();
    set<string> S;

    S.insert(words[0]);

    for(int i = 1; i < n; i++) {
        if(S.count(words[i]) or words[i].front() != c)
            return false;

        c = words[i].back();
        S.insert(words[i]);
    }

    return true;
}

int main()
{
    ios::sync_with_stdio(false);

    int n;

    cin >> n;

    vector<string> words(n);

    for(int i = 0; i < n; i++)
        cin >> words[i];

    auto ans = solve(n, words);

    cout << (ans ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    
     String s1 = sc.next();
     String s2 = sc.next();
     String s3 = sc.next();

    System.out.println(s1.toUpperCase().charAt(0)+ "" + s2.toUpperCase().charAt(0)+ "" +s3.toUpperCase().charAt(0));




    
    


    
	}
}

Measured memory_bytes: 39048
/*
Author: Arham_doshi
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
#include <bits/stdc++.h>

#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define isp2(x)     x && (!(x&(x-1)))
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
//#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define _init(b)     memset(b,-1,sizeof(b))
using namespace std;

int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}
int grid[1005][1005];
string arr[1005];


int logb(int base, int x) {
    return (log(x) / log(base));
}
double sushi[301][301][301];
int n;
double dfs(int i,int j,int k){
    
    if(i+j+k==0)return 0;
   
    if(sushi[i][j][k]!=-1){
         //cout<<"arham"<<endl;
        return sushi[i][j][k];
    }
    else{
        //cout<<i<<" "<<j<<" "<<k<<endl;
        sushi[i][j][k]=0;
        double t=i+j+k;
        double ks=(double)n/(i+j+k);
        if(i>=1){
            sushi[i][j][k]+=(dfs(i-1,j,k)+ks)*(i/t);
        }
        if(j>=1){
            sushi[i][j][k]+=(dfs(i+1,j-1,k)+ks)*(j/t);
        }
        if(k>=1){
            sushi[i][j][k]+=(dfs(i,j+1,k-1)+ks)*(k/t);
        }
        return sushi[i][j][k];
    }
}



signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int i,j,k;
    fo(i,0,301){fo(j,0,301){fo(k,0,301){sushi[i][j][k]=-1;}}}
    int  x;
    cin>>n;
    int arr[4]={0};
    fo(i,0,n){
        cin>>x;
        arr[x]++;
    }
    cout<<setprecision(12)<<dfs(arr[1],arr[2],arr[3]);
   
    

    return 0;
}

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve()
{
    ll n;
    cin >> n;
    vector<double> pr(n+1);
    for(ll i=1;i<=n;i++) {
        cin >> pr[i];
    }
    double dp[n+1][n+1];
    dp[0][0] = 1.0;
    for(ll i=0;i<=n;i++) {
        for(ll j=0;j<=n;j++) {
            if(i == 0) {
                if(j!=0)dp[i][j] = 0.0;
            } else {
                dp[i][j] = (1-pr[i])*dp[i-1][j];
                if(j > 0) {
                    dp[i][j] += pr[i]*dp[i-1][j-1];
                }
            }
        }
    }
    double ans = 0;
    for(ll i=n/2+1;i<=n;i++) {
        ans += dp[n][i];
    }
    cout << fixed << setprecision(10) << ans << "\n";
}

int main()
{
    FAST_IO;
    #ifndef ONLINE_JUDGE 
      // OC;
    #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> t(N);
    rep(i,N) cin >> t[i];

    ll ans  = 0;
    rep1(i, N) {
      if(t[i] - t[i-1] >= T){
        ans += T;
      } else {
        ans += (t[i] - t[i-1]);
      }
    }
    ans += T;
    cout << ans << endl;
}

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

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

    string S;
    cin >> S;

    int cnt=1;
    for(int i=0; i<N-1; i++){
        if(S.at(i) != S.at(i+1)){
            cnt++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
	char ch=getchar();
	for (int i=0;i<=2;i++){
		if (ch=='1') ch='9';
		else if (ch=='9') ch='1';
		printf("%c",ch);ch=getchar();
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

 struct UF {
	vector<int>par;//親
	vector<int>Rank;//木の深さ
    vector<int>sz;//要素数

    UF(int n){init(n);}

	//初期化
	void init(int n) {
		par.resize(n); Rank.resize(n);sz.resize(n);
		for (int i = 0; i < n; i++) {
			par[i]= i;
			Rank[i] = 0;
            sz[i]=1;
		}
	}

	//木の根を求める
	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

	//xとyの属する集合を併合
	bool unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return false;//すでに同じ集合に属している

		if (Rank[x] < Rank[y]) {//高さが小さい方を下に
			par[x] = y;
            sz[y]+=sz[x];
		}
		else {
			par[y] = x;
			if (Rank[x] == Rank[y])Rank[x]++;//同じだとrankが変わらないままになるので増やす（それ以外は大きい方のrankが採用される）
            sz[x]+=sz[y];
		}
		return true;
	}

	//xとyが同じ集合に属するかを判定
	bool same(int x, int y) {
		return find(x) == find(y);
	}

    int size(int k){//要素数を求める
        return sz[find(k)];
    }
};


void solve(){
    int n;
    cin>>n;
    UF tree(n);
    vector<pair<ll,int>>a(n),b(n);
    rep(i,n){
        ll x;
        cin>>x;
        a[i]={x,i};
    }
    rep(i,n){
        int x;
        cin>>x;
        b[i]={x,i};
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    rep(i,n){
        if(a[i].first>b[i].first){
            cout<<"No\n";
            return;
        }
    }
    rep(i,n){
        tree.unite(a[i].second,b[i].second);
    }
    if(tree.size(0)!=n){//set使わなくてよい
        cout<<"Yes\n";
        return;
    }
    else {
        rep(i,n-1){
            if(a[i+1].first<=b[i].first){
                cout<<"Yes\n";
                return;
            }
        }
    }
    cout<<"No\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define IO std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
#define FIN freopen("entrada.txt", "r", stdin);
#define FOUT freopen("saida.sol", "w", stdout);

#define ull unsigned long long
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define MAX int(1e9+6)

const int INF = 0x3f3f3f3f;
using namespace std;



int main() {

   IO

   int h1, h2, m1, m2, k;
   cin >> h1 >> m1 >> h2 >> m2 >> k;

   int t1=h1*60+m1;
   int t2=h2*60+m2;

   cout << abs(t1-t2)-k << "\n";

   return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>
#include <bits/stdc++.h>
using namespace std;

int N, M, Q;
vector<long long> a, b, c, d;

long long score(const vector<int> &A) {
    long long res = 0;
    for (int i = 0; i < Q; ++i) if (A[b[i]] - A[a[i]] == c[i]) res += d[i];
    return res;
}

long long dfs(vector<int> &A) {
    if (A.size() == N) {
        return score(A);
    }
    long long res = 0;
    int plast = (A.empty() ? 0 : A.back());
    for (int add = plast; add < M; ++add) {
        A.push_back(add);
        res = max(res, dfs(A));
        A.pop_back();
    }
    return res;
}

int main() {
    cin >> N >> M >> Q;
    a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
    for (int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]-= 1;b[i]-=1;
    }
    vector<int> A;
    cout << dfs(A) << endl;
}

Measured memory_bytes: 3624
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String[] className = new String[9];
		int[] am = new int[9];
		int[] pm = new int[9];
		for(int i = 0; i < 9; i++) {
			className[i] = stdIn.next();
			am[i] = stdIn.nextInt();
			pm[i] = stdIn.nextInt();
		}
		int[] count = new int[9];
		int[] in = new int[9];
		for(int i = 0; i < 9; i++) {
			count[i] = am[i] + pm[i];
			in[i] = am[i] * 200 + pm[i] * 300;
		}
		
		for(int i = 0; i < 9; i++) {
			System.out.println(className[i] + " " + count[i] + " " + in[i]);
		}
	}

}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    map<ll,ll> mp;
    for(i = 1;i <= 100;++i){
        mp[i] = 0;
    }
    for(i = 2;i <= n;++i){
        j = i;
        ll tmp = 2;
        while(tmp <= 10){
            if(j%tmp == 0){
                ++mp[tmp];
                j /= tmp;
            }else{
                ++tmp;
            }
        }
        if(j != 1){
            ++mp[j];
        }
    }
    ll ans = 0;
    vector<ll> a; //75
    vector<ll> b; //25
    vector<ll> c; //15
    vector<ll> d; //5
    vector<ll> e; //3
    for(auto x: mp){
        ll tmp = x.second;
        ll tmp1 = x.first;
        if(tmp >= 74){
            a.push_back(tmp1);
            b.push_back(tmp1);
            c.push_back(tmp1);
            d.push_back(tmp1);
            e.push_back(tmp1);
        }else if(tmp >= 24){
            b.push_back(tmp1);
            c.push_back(tmp1);
            d.push_back(tmp1);
            e.push_back(tmp1);
        }else if(tmp >= 14){
            c.push_back(tmp1);
            d.push_back(tmp1);
            e.push_back(tmp1);
        }else if(tmp >= 4){
            d.push_back(tmp1);
            e.push_back(tmp1);
        }
        else if(tmp >= 2){
            e.push_back(tmp1);
        }
    }
    ans += a.size();
    //3x25
    for(i = 0;i < b.size();++i){
        rep(j, e.size()){
            if(b.at(i) != e.at(j)) ++ ans;
        }
    }
    //5x15
    for(i = 0;i < c.size();++i){
        rep(j, d.size()){
            if(c.at(i) != d.at(j)) ++ ans;
        }
    }
    //3x5x5
    ll k;
    for(i = 0;i < e.size();++i){
        for(j = 0;j < d.size()-1;++j){
            for(k = j+1;k < d.size();++k){
                if(e.at(i) != d.at(j) && e.at(i) != d.at(k)) ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
''' Hey stalker :) '''
INF = 10**10
def main():
    #print = out.append
    ''' Cook your dish here! '''
    n = get_int()
    li = get_list()
    for i in li:
        if i%2==0 and not (i%3==0 or i%5==0):
            print("DENIED")
            return
    print("APPROVED")


''' Pythonista fLite 1.1 '''
import sys
from collections import defaultdict, Counter
#from bisect import bisect_left, bisect_right
#from functools import reduce
#import math
#input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')


Measured memory_bytes: 38384
#include<iostream>
#include<vector>

using namespace std;

int main() {
	
	int n;
	cin >> n;
	int n2;
	cin >> n2;
	
	int choice;
	int temp, temp2;	
	vector<int> vt[n];
	for(int i=0;i<n;i++)
		vt[n].clear();
	
	for(int i=0;i<n2;i++) {
		
		cin >> choice;
		switch(choice) {
			case 0:
				cin >> temp >> temp2;
				vt[temp].push_back(temp2);
				break;
			case 1:
				cin >> temp;
				if(vt[temp].size() == 0)
				cout << "\n";
				
				else {
				for(int i=0;i<vt[temp].size()-1;i++)
					cout << vt[temp][i] << " ";
				cout << vt[temp][vt[temp].size()-1] << "\n";
			}
			
				break;
			case 2:
				cin >> temp;
				vt[temp].clear();
				break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 5820
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
#include <functional>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

const int SIZE = 5;
bool alltrue(bool bb[]) {
	for (int i = 0; i < SIZE; i++) {
		if (bb[i] == false) {
			return false;
		}
		
	}
	return true;
}
int main() {
	int a[SIZE];
	bool chked[SIZE];
	int sum = 0;
	for (int i = 0; i < SIZE; i++) {
		cin >> a[i];
		chked[i] = 0;
	}
	for (int i = 0; i < SIZE; i++) {
		if (a[i] % 10 == 0) {
			sum += a[i];
			chked[i] = true;
		}
	}
	while (!alltrue(chked)) {
		while (!(sum % 10 == 0)) {
			sum++;
		}
		int MaxAmari = 0;
		int MaxPos;
		for (int i = 0; i < SIZE; i++) {
			if (chked[i] == true) { continue; }
			int atmp = a[i] % 10;
			if (atmp == 0) { continue; }
			if (MaxAmari < atmp) {
				MaxAmari = atmp;
				MaxPos = i;
			}
		}
		sum += a[MaxPos];
		chked[MaxPos] = true;
	}
	cout << sum << endl;
	return 0;
}


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

int main(){
    int X, A, B;
    cin >> X >> A >> B;
    int a, b;

    if(X < B){
        b = B - X;
    }
    else if(X > B){
        b = X - B;
    }

    if(X < A){
        a = A - X;
    }
    else if(X > A){
        a = X - A;
    }

    if(a > b){
        cout << 'B' << endl;
    }
    else{
        cout << 'A' << endl;
    }
}

Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
static const int MAX=200000;
int main()
{
    int r[MAX],n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&r[i]);
    int maxv=-2000000000;
    int minv=r[0];
    for(int i=1;i<n;i++){
        maxv=max(maxv,r[i]-minv);
        minv=min(minv,r[i]);
    }
    printf("%d\n",maxv);
    return 0;
}

Measured memory_bytes: 4008
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define inf 0x7f7f7f7f7f7f7f7f 
#define maxn 1000010
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define mod 998244353
#define db(x) cout << x << endl; 
#define eps 0.0001
using namespace std;
string a,b;
char s[maxn];
signed main()
{
	ios::sync_with_stdio(0);
	cin >> a >> b;
	int flag = 0;
	for(int i=0;i<=b.length();i++)
		if(a[i] != b[i])
		{
			flag = i;
			break;
		}
	if(flag == a.length())
		cout <<"Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;
int main()
{
    int H;
    int N;
    int x=0;
    
    cin >> H >> N;
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        x+=tmp;
    }
    
    (x>=H) ? cout << "Yes" : cout << "No";

    return 0;
}

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



namespace Test1 {

    class ClassMain {



           
        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int t = int.Parse(line); if (t == 0) { break; }
                int n = int.Parse(Console.ReadLine());
                
                for (int i = 0; i < n; i++) {
                    string[] strs = Console.ReadLine().Split(' ');
                    int time = int.Parse(strs[1]) - int.Parse(strs[0]);
                    t -= time;
                }

                if (t <= 0) {
                    Console.WriteLine("OK");
                }
                else { Console.WriteLine(t); }



            }
        }

       



    }
}

Measured memory_bytes: 5764
#include<iostream>
#include<stdlib.h>
using namespace std;
int compare(const void *a,const void *b){
	return *(int*)b-*(int*)a;
}

int main(){
	int data[5];
	for(int i=0;i<5;i++)cin>>data[i];
	
	qsort(data,5,sizeof(int),compare);
	
	for(int i=0;i<4;i++)cout<<data[i]<<" ";
	cout<<data[4]<<endl;
}

Measured memory_bytes: 1176
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const ll mod = 1000000007;

ll N;
vl A;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    A = vl(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    solve();
}

// 2 <= N <= 2× 10^5
// 0 <= A_i <= 10^9
// 入力は全て整数

#ifndef TEMPLATE_USED
#include "../template/template.hpp"
#endif

template<int m>
struct MInt{
    //static int m;

    ll x;
    MInt(ll x=0):x((x%m+m)%m){}

    MInt operator-()const{return MInt(-x);}
    MInt operator+(const MInt &p)const{return MInt(*this)+=p;}
    MInt operator-(const MInt &p)const{return MInt(*this)-=p;}
    MInt operator*(const MInt &p)const{return MInt(*this)*=p;}
    MInt operator/(const MInt &p)const{return MInt(*this)/=p;}

    MInt &operator+=(const MInt &p){
        if((x+=p.x)>=m)x-=m;
        return *this;
    }
    MInt &operator-=(const MInt &p){
        if((x+=m-p.x)>=m)x-=m;
        return *this;
    }
    MInt &operator*=(const MInt &p){
        (x*=p.x)%=m;
        return *this;
    }
    MInt &operator/=(const MInt &p){
        return *this*=p.inv();
    }

    MInt pow(ll n)const{
        MInt ret(1),mul(x);
        while(n){
            if(n&1)ret*=mul;
            mul*=mul;
            n>>=1;
        }
        return ret;
    }
    MInt inv()const{
        //return pow(m-2);
        int a=x,b=m,u=1,v=0,t;
        while(b){
            t=a/b;
            swap(a-=t*b,b);
            swap(u-=t*v,v);
        }
        return MInt(u);
    }

    friend ostream& operator<<(ostream& os,const MInt& a) {return os<<a.x;}
};
//int MInt::m=0;
using mint=MInt<mod>;

// ll N, vl A
// \sum_{i=1}^{N-1}\sum_{j=i+1}^{N} A_i A_j を \bmod (10^9+7) で出力せよ。
void solve(){
    mint sum=0;
    rep(i,N)sum+=A[i];
    sum*=sum;
    rep(i,N)sum-=A[i]*A[i];
    sum/=2;
    cout<<sum<<endl;
}


Measured memory_bytes: 4780
import itertools

N = int(input())
*P, = map(int, input().split())
*Q, = map(int, input().split())

P = tuple(P)
Q = tuple(Q)

count = 0
pc = qc = -1
for per in itertools.permutations(range(1,N+1), N):
    if per == P:
        pc = count + 1
    if per == Q:
        qc = count + 1
    if pc != -1 and qc != -1:
        break
    count += 1

print(abs(pc - qc))

Measured memory_bytes: 3064
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors
    
a = int(input())
fac = dict()
for i in range(a + 1):
	for k in prime_factors(i):
		if k not in fac:
			fac[k]  = 1
		else:
			fac[k] += 1

for i in list(fac):
	if fac[i] == 1:
		fac.pop(i)

out = 0
for i in fac:
	if fac[i] >= 74:
		out += 1
		
for i in fac:
	if fac[i] >= 24:
		for j in fac:
			if i != j and fac[j] >= 2:
				out += 1
					
for i in fac:
	if fac[i] >= 14:
		for j in fac:
			if i != j and fac[j] >= 4:
				out += 1
		
used = dict()
for i in fac:
	if fac[i] >= 4:
		for j in fac:
			if i != j and tuple(sorted([i,j])) not in used and fac[j] >= 4:
				used[tuple(sorted([i,j]))] = 1
				for k in fac:
					if k != i and k != j and fac[k] >= 2:
						out += 1

print(out)
	

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

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;
}
struct Unionfind {
    vector<int> par;

    Unionfind(int n) : par(n) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] =ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    int n;
    ll k;
    cin >> n >> k;

    vector<vector<int>> graph(n);
    rep(i, n) {
        int a;
        cin >> a;
        --a;
        graph[i].emplace_back(a);
    }

    const int INF = 1e9;
    vector<int> dist(n, INF);
    queue<int> q;
    dist[0] = 0;
    q.push(0);
    int c_cnt = 0;
    int pre_d = 0;

    bool flag = false;
    while(!q.empty()) {
        int p = q.front();
        q.pop();
        for(int next_p : graph[p]) {
            if(dist[next_p] != INF) {
                c_cnt = (dist[p] + 1) - dist[next_p];
                pre_d = dist[next_p];
                flag = true;
            }
            if(flag) break;
            dist[next_p] = dist[p] + 1;
            q.push(next_p);
        }
        if(flag) break;
    }

    int x = 0;
    if(k < pre_d) {
        for(int i = 0; i < k; ++i) x = graph[x][0];
        cout << x+1 << endl;
        return 0;
    }
    else {
        for(int i = 0; i < pre_d; ++i) x = graph[x][0];
            
        int rem = (k - pre_d) % ll(c_cnt);

        int s = x;
        for(int i = 0; i < rem; ++i) {
            s = graph[s][0];
        }

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


Measured memory_bytes: 15080
N = int(input())
A = list(map(int, input().split()))

c = 1000
s = 0

for i in range(0,N-1):
  if ((A[i]-A[i-1])*(A[i+1]-A[i])>0) and i>0:
    continue
  if A[i]<A[i+1]:
    s = s + c//A[i]
    c = c - c//A[i]*A[i]
  else:
    c = c + s * A[i]
    s = 0

c = c + s * A[i+1]
s = 0

print(c)

Measured memory_bytes: 9204
use v5.18; # strict say state
use warnings;
use List::Util qw(max min sum);

chomp (my ($r1, $g1, $b1, $n) = split / /, <STDIN>);
my $ans = 0;
my $r = max($r1, $g1, $b1);
my $b = min($r1, $g1, $b1);
my $g = sum($r1, $g1, $b1) - $r - $b;
for my $i (0..$n) {
  last if $r * $i > $n;
  for my $j (0..$n) {
    last if $r * $i + $g * $j > $n;
    my $c = $n - $r * $i - $g * $j;
    $ans++ if $c % $b == 0;
  }
}
say $ans;

Measured memory_bytes: 896
S,T=[list(input()) for _ in range(2)]
k = -1
for i in range(len(S)-len(T)+1):
	ok = True
	for j in range(len(T)):
		if S[i+j] != "?" and S[i+j] != T[j]:
			ok = False
			break
	if ok:
		k = i
if k == -1:
	print("UNRESTORABLE")
else:
	for i in range(len(T)):
		S[i+k] = T[i]
	print("".join(S).replace("?", "a"))


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

int a,b,c,x,y;

int main(){
    cin>>a>>b>>c>>x>>y;  
    int ans=min(a+b,2*c)*min(x,y);
    if(x>y)
        ans+=min(a,2*c)*(x-y);
    else
        ans+=min(b,2*c)*(y-x);
    cout << ans << endl;
}

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

int main(){
  int m, f, r;
  while(true){
    cin >> m >> f >> r;
    if(m == -1 && f == -1 && r == -1)break;
    if(m == -1 || f == -1 || m + f < 30){
      cout << "F" << endl ;
      continue;
    }
    if(m + f >= 30 && m + f < 50){
      if(r >= 50)cout << "C";
      else cout << "D";
    }
    if(m + f >= 50 && m + f < 65)cout << "C";
    if(m + f >= 65 && m + f < 80)cout << "B";
    if(m + f >= 80)cout << "A";
    cout << endl;
  }
}


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


int main() {
    string T;
    cin >> T;
    int len_T = T.size();
    int max_len = 0;
    set<char> valid_chars = {'A', 'C', 'G', 'T'};
    for (int start = 0; start < len_T; start++) {
        for (int end = start; end < len_T; end++) {
            bool is_ok = true;
            for (int i = start; i <= end; i++) {
                char c = T.at(i);
                // is an invalid character
                if (valid_chars.find(c) == valid_chars.end()) {
                    is_ok = false;
                    break;
                }
            }
            if (is_ok) {
                max_len = max(max_len, end - start + 1);
            }
        }
    }
    cout << max_len << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 1e5+5;
int n, arr[nax];

int main(){
	IOS
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> arr[i];
	}
	sort(arr+1, arr+n+1);
	if(arr[n/2]==arr[n/2+1]){
		cout << 0 << '\n'; return 0;
	}
	cout << abs(arr[n/2]-arr[n/2+1]) << '\n';
}


Measured memory_bytes: 4028
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>






const int N=60,N2=2510;
ll n,a,x[N],dp[N][N][N2+10],res;





void solve()
{
	cin>>n>>a;
	for(int i=1;i<=n;i++)cin>>x[i];
	for(int j=0;j<=n;j++)
	{
		for(int k=0;k<=N2;k++)
		{
			dp[0][j][k]=0;
		}
	}
	dp[0][0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int k=0;k<=N2;k++)
			{
				dp[i][j][k]=dp[i-1][j][k];
				if(j>0&&k>=x[i])dp[i][j][k]+=dp[i-1][j-1][k-x[i]];
			}
		}
	}
	res=0;
	for(int i=1;i<=n;i++)
	{
		res+=dp[n][i][i*a];
	}
	cout<<res<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 61568
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 100100100100100

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

// 隣接リストで使う辺を表す型
struct Edge {
  int to;
  ll cost;  // 辺の接続先頂点, 辺の重み
  Edge(int to, ll cost) : to(to), cost(cost) {}  // コンストラクタ
};

typedef vector<vector<Edge> > AdjList;  // 隣接リストの型
AdjList graph;  // グラフの辺を格納した構造体
                // graph[v][i]は頂点vから出るi番目の辺Edge


vector<ll> dist; // 最短距離

// 戻り値がtrueなら負の閉路を含む
void bellman_ford(int n, int s) { // nは頂点数、sは開始頂点
  dist = vector<ll>(n, INF);
  dist[s] = 0; // 開始点の距離は0
  bool loop=false;
  for (int i = 0; i < n; i++) {
    for (int v = 0; v < n; v++) {
      for (int k = 0; k < graph[v].size(); k++) {
        Edge e = graph[v][k];
        if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
          dist[e.to] = dist[v] + e.cost;
          if (i == n - 1){
            dist[e.to]=-INF;
            loop=true;
          } // n回目にも更新があるなら負の閉路が存在
        }
      }
    }
  }
  if(loop){
    for (int i = 0; i < n; i++) {
      for (int v = 0; v < n; v++) {
        for (int k = 0; k < graph[v].size(); k++) {
          Edge e = graph[v][k];
          if (dist[v] ==-INF) {
            dist[e.to] = -INF;
          }
        }
      }
    }
  }
}

int main() {
  int n, m;
  cin >> n >> m;

  graph = AdjList(n);

  for (int i = 0; i < m; i++) {
    int from, to;
    ll cost;
    cin >> from >> to >> cost;
    --from; --to;
    cost*=-1;
    graph[from].push_back(Edge(to, cost));
  }
  bellman_ford(n, 0);
  if(dist[n-1]==-INF){
    cout << "inf" << endl;
  } else {
    cout << -dist[n-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int p, q, r;
	int ans;

	scanf("%d%d%d", &p, &q, &r);

	//どのルートが短いか判定
	ans = p + q;//a→b→cルート
	if (p + r < ans) {
		ans = p + r;//c→a→bルート
	}
	if (q + r < ans) {//b→c→aルート
		ans = q + r;
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <stack>
using namespace std;

typedef pair<int,int> pii;
typedef vector<vector<int> > table;

const int INF = (int)1e9;

int V, E, K;
table unit;

inline void update(int &a, int b){
	if( a < b ) a = b;
}

void mul(table &t1, const table &t2){
	table tmp = unit;
	for(int i = 0; i < V; ++i)
	for(int j = 0; j < V; ++j)
	for(int k = 0; k < V; ++k){
		update(tmp[i][k], t1[i][j] + t2[j][k]);
	}
	t1.swap(tmp);
}

pii maxindex(const table &t){
	int mi = 0, mj = 0;
	for(int i = 0; i < V; ++i)
	for(int j = 0; j < V; ++j){
		if( t[i][j] > t[mi][mj] ){
			mi = i;
			mj = j;
		}
	}
	return pii(mi, mj);
}

inline table pow(int k, const vector<table> &tbls){
	table t = unit;
	for(int i = 0; (1 << i) <= k; ++i){
		if( (1 << i) & k )
			mul(t, tbls[i]);
	}
	return t;
}

int main(){
	scanf("%d%d%d", &V, &E, &K);
	
	unit.assign(V, vector<int>(V, -INF) );
	for(int i = 0; i < V; ++i){
		unit[i][i] = 0;
	}
	
	int s, f, c;
	table t0 = unit;
	for(int i = 0; i < E; ++i){
		scanf("%d%d%d", &s, &f, &c);
		update(t0[s][f], c);
	}

	vector<table> tbls;
	tbls.reserve(32);
	
	table t1 = t0;
	for(int i = 0; ; ++i){
		tbls.push_back(t1);
		
		pii p = maxindex(t1);
		if( t1[p.first][p.second] >= K ) break;
		
		if( i >= 30 ){
			puts("-1");
			return 0;
		}
		
		mul(t1, t1);
	}

	int right = 1 << (tbls.size() - 1);
	int left = right / 2;
	while(left < right){
		int mid = (left + right) / 2;
		
		t1 = pow(mid, tbls);
		pii p = maxindex(t1);

		if( t1[p.first][p.second] >= K ){
			right = mid;
		}
		else{
			left = mid + 1;
		}
	}
	
	printf("%d\n", left);
	if( left > 100 ) return 0;

	f = maxindex( pow(left, tbls) ).second;
	vector<vector<int> > from(left, vector<int>(V, -1) );

	vector<int> c1(V, 0), c2(V, -INF);
	for(int i = 0; i < left; ++i){
		for(int j = 0; j < V; ++j)
		for(int k = 0; k < V; ++k){
			if( c2[k] < c1[j] + t0[j][k] ){
				c2[k] = c1[j] + t0[j][k];
				from[i][k] = j;
			}
		}
		
		c1.swap(c2);
		fill(c2.begin(), c2.end(), -INF);
	}

	stack<int> st;
	for(int i = left - 1; i >= 0; --i){
		st.push(f);
		f = from[i][f];
	}

	printf("%d", f);
	while( !st.empty() ){
		printf(" %d", st.top() );
		st.pop();
	}
	puts("");
}

Measured memory_bytes: 4172
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(i=a;i<b;i++)
#define re(i,a,b) for(int i=a;i<=b;i++)
#define fr(i,n) for(int i=0;i<n;i++)
#define ll long long
#define mod 1000000007
#define pb(x) push_back(x)
#define mp map<ll,ll>
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define vi vector<ll>
#define start int t; cin>>t; while(t--)
#define dumb ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
dumb
ll i,j,k,l,n,p,q,c=0,d=0,sum=0,flag=0,min1=999999999999,max1=-999999999999,x,y;
string s;
cin>>k;
for(i=0;i<k;i++)
{
    cout<<"A"<<"C"<<"L";
}


}


Measured memory_bytes: 3604
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        n: usize,
        k: usize,
        r: usize,
        s: usize,
        p: usize,
        t: chars,
    );

    let t :Vec<char> = t;

    let mut ans = Vec::new();
    ans.resize(n, 0);

    let mut sum = 0;

    for i in 0..n {
        let pre = i as i32 - k as i32;
        let c: char = t[i];
        let mut score = match Some(c) {
            Some('r') => p,
            Some('p') => s,
            Some('s') => r,
            _ => 0,
        };

        if pre >= 0 && t[i] == t[pre as usize] && ans[pre as usize] > 0 {
            score = 0;
        }

        sum += score;
        ans[i] = score;
//        print!("{}", score);
    }

    println!("{}", sum);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

Measured memory_bytes: 8572