akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

@SuppressWarnings("unchecked")
class MaxFlow{
    // Dinic O(V^2*E)
    class Edge{
        int to,cap,rev;
        Edge(int to,int cap,int rev){this.to=to;this.cap=cap;this.rev=rev;}
    }
    List<Edge> edges[];
    void add_edge(int from,int to,int cap){
        edges[from].add(new Edge(to,cap,edges[to].size()));
        edges[to].add(new Edge(from,0,edges[from].size()-1));
    }
    int[] itr;
    int[] rank;

    MaxFlow(int V){
        edges = new ArrayList[V];
        for(int i=0;i<V;++i)edges[i]=new ArrayList<>();
        itr = new int[V];
        rank = new int[V];
    }

    private void bfs(int s){
        Arrays.fill(rank,-1);
        rank[s]=0;
        Queue<Integer> que = new ArrayDeque<>();
        que.add(s);
        while(!que.isEmpty()){
            int v = que.poll();
            for(Edge e : edges[v])if(rank[e.to]<0 && e.cap>0){
                rank[e.to]=rank[v]+1;
                que.add(e.to);
            }
        }
    }
    private int dfs(int s,int t,int f){
        if(s==t)return f;
        while(itr[s]<edges[s].size()){
            Edge e = edges[s].get(itr[s]);
            if(rank[e.to]>rank[s] && e.cap>0){
                int res = dfs(e.to,t,Math.min(f, e.cap));
                if(res>0){
                    e.cap-=res;
                    edges[e.to].get(e.rev).cap+=res;
                    return res;
                }
            }
            itr[s]++;
        }
        return 0;
    }

    int get(int s,int t){
        int res = 0;
        boolean update=true;
        while(update){
            update=false;
            Arrays.fill(itr,0);
            bfs(s);
            while(true){
                int f = dfs(s,t,Integer.MAX_VALUE);
                if(f>0){
                    res+=f;
                    update=true;
                }else break;
            }
        }
        return res;
    }

    // AOJ Network Flow
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int V = scan.nextInt();
        int E = scan.nextInt();
        MaxFlow mf = new MaxFlow(V);
        while(E-->0){
            int u = scan.nextInt();
            int v = scan.nextInt();
            int c = scan.nextInt();
            mf.add_edge(u, v, c);
        }
        System.out.println(mf.get(0,V-1));
    }
}

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int V = scan.nextInt();
        int E = scan.nextInt();
        MaxFlow mf = new MaxFlow(V);
        while(E-->0){
            int u = scan.nextInt();
            int v = scan.nextInt();
            int c = scan.nextInt();
            mf.add_edge(u, v, c);
        }
        System.out.println(mf.get(0,V-1));
    }
}


Measured memory_bytes: 33976
def resolve():
  N, M = map(int, input().split(" "))
  H = [int(x) for x in input().split(" ")]

  AB = []
  for i in range(M):
    AB.append([int(x)-1 for x in input().split(" ")])

  result = [True] * N
  for ab in AB:
    if H[ab[0]] > H[ab[1]]:
      result[ab[1]] = False
      continue
    if H[ab[1]] > H[ab[0]]:
      result[ab[0]] = False
      continue
    if H[ab[1]] == H[ab[0]]:
      result[ab[0]] = False
      result[ab[1]] = False
      continue

  print(result.count(True))

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 93360
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define PTT(x) cout << (#x) << " is " << (x) << endl
#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
const int N = 2e6 + 10;
const int IM = 1e15 + 37;
const double PI = 3.1415926535897932384;
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}
void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].fe << " " << v[i].se << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << ' ' ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
inline void PP(int n) { cout << n << " ";}
inline void PP(int n, int m) { cout << n << " " << m << endl;}
inline void PP(int n, int m, int q) {  cout << n << " " << m << " " << q << endl;}
inline void PP(int n, int m, int q, int u) {  cout << n << " " << m << " " << q << " " << u << endl;}
inline void op() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
// <=================================================================================================================================
// <=================================================================================================================================


signed  main() {
    //op();
    lets_go
    int i, j, x, y, u, l;
    // int tt; cin >> tt; while (tt--)
    {
        i = j = x = y = u = l = 0;

        int n;
        cin >> n;
        n = (n % 1000);
        if (n)
            n = 1000 - n;
        PT(n);



        /* */
    }
    return 0;

}


Measured memory_bytes: 3616
#include <stdio.h>
 
int main() {
	int n;
	scanf("%d", &n);
	int a[2][100];
	for(int j=0;j<2;j++)
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[j][i]);
	}
	int max = 0;
	for (int i = 0; i < n; i++) {
		int tmp = 0;
		for (int j = 0; j <= i; j++) {
			tmp += a[0][j];
		}
		for (int j = i; j < n; j++) {
			tmp += a[1][j];
		}
		if (max < tmp) max = tmp;
	}
	printf("%d\n", max);
}

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

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


int main() {
	int n;
	string s;
	cin >> n;
	rep(i, n) {
		cin >> s;
		string ans;
		//cout << s.size() << endl;
		if (s.size() % 2 == 1||s.size()==4) {
			ans = "NA";
		}
		else if (s[0] == '>'&&s[s.size() - 1] == '~') {
			if (s[1] == '\'') {
				ans = "A";
				for (int i = 2; i < s.size() - 1; i++) {
					if (i == s.size() / 2) {
						if (s[i] != '#') {
							ans = "NA";
							break;
						}
					}
					else {
						if (s[i] != '=') {
							ans = "NA";
							break;
						}
					}
				}
			}
			else if (s[1] == '^'&&s[s.size()-2]=='~') {
				ans = "B";
				for (int i = 2; i < s.size() - 2; i += 2) {
					if (s[i] != 'Q' || s[i + 1] != '=') {
						ans = "NA";
						break;
					}
				}
			}
			else ans = "NA";
		}
		else {
			ans = "NA";
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1204
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b;
	cin>>a>>b;
	if(b>=a){
		cout<<"unsafe";
	}else cout<<"safe"; 
	RE 0;
}




Measured memory_bytes: 3648
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String[] nyu=sc.nextLine().split(" ");
   //  String nyu=sc.nextLine();


int num=Integer.parseInt(nyu[0]);
int numnext=Integer.parseInt(nyu[1]);

int[] data=new int[3];
data[0]=num+numnext;
data[1]=num * numnext;
data[2]=num - numnext;
Arrays.sort(data);
//int num2=Integer.parseInt(sn[1]);

int count=0;





System.out.println(data[2]);

//System.out.println(a/b);


	}
}

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

int main() 
{
  int n;
  cin >> n;
  int ans = 0;
 
 for (int i = 0; i < n; i++) {
  int l, r;
  cin >> l >> r;

  ans += r -l +1;
  }
cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	aa,bb = inputMap()

	a = str(aa)
	b = str(bb)

	A = ""
	B = ""

	for i in range(bb):
		A += a

	for i in range(aa):
		B += b

	if A < B:
		print(A)
	else:
		print(B)



if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=1e2+5;
int g[MAXN][MAXN];
int n,cnt;
int main(){
	scanf("%d",&n);
	if (n%2==0){
		for (int i=1;i<=n;i++){
			for (int j=1;j<=n;j++){
				if (j==n-i+1) continue;
				g[i][j]=g[j][i]=1;
			}
		}
	}
	else {
		for (int i=1;i<=n;i++){
			for (int j=1;j<=n;j++){
				if (j==n-i) continue;
				g[i][j]=g[j][i]=1;
			}
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=i+1;j<=n;j++){
			if (!g[i][j]) continue;
			cnt++;
		}
	}
	printf("%d\n",cnt);
	for (int i=1;i<=n;i++){
		for (int j=i+1;j<=n;j++){
			if (!g[i][j]) continue;
			printf("%d %d\n",i,j);
		}
	}
	return 0;
}


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

signed main(){
  int N;
  cin>>N;
  int C=N/4,D=N/7;
  string ans="No";
  rep(i,C){
    rep(j,D){
      if((4*i+7*j)==N)ans="Yes";
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3584
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?(テァツクツョテ・ツーツ湘ァツ可?

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    string s; cin >> s;
    int ok = 1;
    if(s.length() < 6) ok = 0;
    
    int a = 0, b = 0, c = 0;
    rep(i,0,s.length()) {
        if('0' <= s[i] && s[i] <= '9') a = 1;
        if('A' <= s[i] && s[i] <= 'Z') b = 1;
        if('a' <= s[i] && s[i] <= 'z') c = 1;
    }
    if(ok + a + b + c == 4) cout << "VALID" << endl;
    else cout << "INVALID" << endl;
    return 0;
}

Measured memory_bytes: 3160
import java.util.*;
public class Main {
  
  private static long X = 1000000007;
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    long[][] memo = new long[N+1][N+1];
    for (int i = 1; i <= K; i++) {
      if (N-K+1 >= i) {
        long count = (comb(N-K+1, i, memo) * comb(K-1, i-1, memo)) % X;
        System.out.println(count);
      } else {
        System.out.println(0);
      }
    }
  }
  
  private static long comb(int n, int r, long[][] memo) {

    if (r == n || r == 0) {
      return 1;
    }

    if (memo[n][r] != 0) {
      return memo[n][r];
    }

    memo[n][r] = (comb(n-1, r-1, memo) + comb(n-1, r, memo)) % X;
    
    return memo[n][r];
  }
}


Measured memory_bytes: 80596
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll len,n=0,e=0,w=0,so=0;
    string s;
    cin>>s;
    len=s.length();
    for(int i=0;i<len;i++)
    {
      if(s[i]=='N')
        n++;
      else if(s[i]=='S')
        so++;
      else if(s[i]=='E')
        e++;
      else if(s[i]=='W')
        w++;
      
    }
    cerr<<n<<" "<<so<<" "<<e<<" "<<w<<endl;
    if((e==0&&w==0)&&(n>=1&&so>=1))
      Yes
    else if((n==0&&so==0)&&(e>=1&&w>=1))
      Yes
    else if(n==so&&so==e&&e==w)
      Yes
    else
    {
      No
    }


}
return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	string s; getline(cin, s);
	for (int i = 0; i < s.length(); i++)
		if (s[i] >= 'A' && s[i] <= 'Z') s[i] += 'a' - 'A';
		else if (s[i] >= 'a' && s[i] <= 'z') s[i] += 'A' - 'a';
	cout << s << endl;
}

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


int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	ll num=c-a-b;
	if(num<=0)cout<<"No";
	else{
		ll x=a*a+b*b+c*c+2*a*b-2*b*c-2*a*c;
		ll y=4*a*b;
		if(y<x)cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>
#include <stack>
#include <math.h>
#include <numeric>
#include <set>

using namespace std;
typedef long long Int;
#define REP(i , x) for(Int i = 0 ; i < x ; ++i)
typedef pair<int, int> P;


int main()
{
	auto f = [](int a,int h)
	{
		return (double)(a*sqrt(4 * h*h + a*a) + a*a);
	};

	int aa, bb;
	while (cin >> aa >> bb, aa&&bb){
		printf("%.6lf\n", f(aa, bb));
	}
	return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<pll, pll> node;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 2e5 + 10;
const int Maxk = 60;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

//ll gr[30];
vector<ll> V;
ll mex(){
	V.pb(-1);
	sort(all(V));
	for(int i = 0; i + 1 < V.size(); i++) if(V[i] + 1 < V[i + 1]) return V[i] + 1;
	return V.back() + 1;
}

ll l[Maxn], r[Maxn], d[Maxn], ls = 0;

int get(int nd, int v){
	if(v == 0){
		if(l[nd] == 0) l[nd] = ++ls;
		d[l[nd]] = d[nd] - 1;
		return l[nd];
	}
	if(r[nd] == 0) r[nd] = ++ls;
	d[r[nd]] = d[nd] - 1;
	return r[nd];
}
ll gr(ll x){
	return (x & (-x));
}
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	ll n, L;
	cin >> n >> L;
	d[0] = L + 1;
	str s;
	ll u = 0;
	for(int i = 1; i <= n; i++){
		cin >> s;
		u = 0;
		for(auto x : s) u = get(u, x - '0');
	}
	ll G = 0;
	for(int i = 0; i <= ls; i++){
		if(r[i] == 0) G ^= gr(d[i] - 1);
		if(l[i] == 0) G ^= gr(d[i] - 1);
		//cerr << G << '\n';
	}
	//cerr << G << '\n';
	cout << (G ? "Alice" : "Bob") << '\n';
	return 0;
}

/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string a[333];
string b[333];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i], b[i] = a[i];
  ll res = 0;
  for (int k = 0; k < n; k++) {
    int flag = 1;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        b[(i + k) % n][j] = a[i][j];

      }
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (i != j && b[i][j] != b[j][i])
          flag = 0;
    if (flag) res += n;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 512
N, K = map(int, input().split())
V = list(map(int, input().split()))
able = min(N, K)
ans = 0
for a in range(able + 1):
	for b in range(able + 1 - a):
		if b == 0:
			have = V[:a]
		else:
			have = V[:a] + V[-b:]
		have.sort()
		for i in range(min(a + b, K - a - b) + 1):
			tmp = sum(have[i:])
			if ans < tmp:
				ans = tmp
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}

vector<ll> vec,clear, is_used(55,0);

bool dfs(vvl &graph, ll pos, ll ed){
    is_used[pos] = 1;
    if(pos == ed){
        vec.emplace_back(pos);
        return true;
    }
    for(auto to : graph[pos]){
        if(is_used[to] == 0){
            if(dfs(graph, to,ed)){
                vec.emplace_back(pos);
                return true;
            }
        }
    }
    return false;
}

int main(){
    ll n; cin >> n;
    vector<vector<ll>> graph(n);
    map<Pll,int> edges;
    rep(i,n-1) {
        ll a,b;cin >> a >> b;
        a--;b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
        edges[Pll(a,b)] = i;
        edges[Pll(b,a)] = i;
    }
    ll m; cin >> m;
    vector<Pll> query(m);
    bitset<55> b[m];
    rep(i,m){
        ll u,v; cin >> u >> v;
        u--;v--;
        query[i] = {u,v};
        vec = clear;
        is_used.assign(55,0);
        dfs(graph, u,v);
        rep(j,vec.size()-1){
            b[i][edges[Pll(vec[j], vec[j+1])]] = 1;
        }
    }
    // dfs(graph, query[0].first, query[0].second);
    // print(vec);
    ll ans = 0;
    rep(i,(1LL<<m)){
        bitset<22> bs(i);
        bitset<55> t(0);
        rep(j,m){
            if(bs[j])t |= b[j];
        }
        if(bs.count() % 2){
            ans -= pow(2,n-1-t.count());
        }
        else{
            ans += pow(2,n-1-t.count());
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string a, b, c;
	
	cin >> a >> b >> c;
	
	vector <char> va, vb, vc;
	
	int as = a.size(), bs = b.size(), cs = c.size();
	
	for(int i = 0; i < as; i ++){
		va.push_back(a[i]);
	}
	for(int i = 0; i < cs; i ++){
		vc.push_back(c[i]);
	}
	for(int i = 0; i < bs; i ++){
		vb.push_back(b[i]);
	}
	
	char t = 'a';
	
	while(true){
		if(t == 'a'){
			if(va.empty()){
				cout << "A";
				return 0;
			}
			
			t = va.front();
			va.erase(va.begin());
			
		}
		else if(t == 'b'){
			if(vb.empty()){
				cout << "B";
				return 0;
			}
			
			t = vb.front();
			vb.erase(vb.begin());
			
		}
		else{
			if(vc.empty()){
				cout << "C";
				return 0;
			}
			
			t = vc.front();
			vc.erase(vc.begin());
			
		}
		
	}
	
	return 0;
}



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

int main() {
  int N, Alice = 0, Bob = 0, flag = 0;
  cin >> N;
  vector<int> cards(N);
  for(int i = 0; i < N; i++) {
    cin >> cards[i];
  }
  sort(cards.begin(), cards.end(), greater<int>());
  for(int i = 0; i < N; i++) {
    if (!flag) {
      Alice += cards[i];
      flag = 1;
    } else {
      Bob += cards[i];
      flag = 0;
    }
  }
  cout << Alice - Bob << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5+10;
const ll mod = 1e9+7;
int c[N],pos[N];
ll dp[N];
int main(void)
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&c[i]);
		if(i==1)
		{
			dp[i]=1;
			pos[c[i]]=i;
			continue;
		}
		if(c[i]==c[i-1])
		{
			dp[i]=dp[i-1];
			continue;
		}
		dp[i]=(dp[i-1]+dp[pos[c[i]]])%mod;
		pos[c[i]]=i;
	}
	printf("%lld\n",dp[n]);
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int k, x;cin >> k >> x;
  if(500*k >= x){
    say("Yes");
  }else{
    say("No");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int INF = 1e9 +7;
signed main(){
    int a,k=0,ans=0;
    for(int i=0;i<5;i++){
        cin>>a;
        k=max(k,((a-1)/10)*10+10-a);
        ans+= ((a-1)/10)*10+10;
    }
    
    cout<<ans-k;
   


    
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

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

int main() {
  int n=0;
  int ans=0;
  int c=0;
  cin>>n;
  vector<int> b(n);
  rep(i,n)cin>>b[i];
  vector<int> bm(n);
  bm=b;
  while(1){
    b[c]=-1;
    c=bm[c]-1;
    ans++;
    if(b[c]==-1){ans=-1;break;}
    if(c==1){break;}
  }
  cout<<ans;
    
}

Measured memory_bytes: 1024
<?php
 
class Answer
{
    public $n;
    public $A = array();
 
    public function __construct()
    {
        $this->n = trim(fgets(STDIN));
        // for ($i = 0; $i < $this->n; ++$i) {
        //     $this->A[] = trim(fgets(STDIN));
        // }
        ini_set('memory_limit', '-1');
        for ($i = 0; $i < $this->n; ++$i) {
            fscanf(STDIN, '%d', $d);
            $this->A[] = $d;
        }
    }
 
    public function showAnswer()
    {
        list($m, $gi, $cnt, $array) = $this->shellSort($this->A, $this->n);
 
        // m (number of Gi)
        echo $m."\n";
        // Gi
        echo join(' ', $gi)."\n";
        // cnt
        echo $cnt."\n";
        // sorted array
        for ($i = 0; $i < count($array); ++$i) {
            echo trim($array[$i])."\n";
        }
    }
 
    public function insertionSort($A, $n, $g, &$cnt)
    {
        for ($i = $g; $i < $n; ++$i) {
            $v = $A[$i];
            $j = $i - $g;
            while ($j >= 0 and $A[$j] > $v) {
                $A[$j + $g] = $A[$j];
                $j = $j - $g;
                ++$cnt;
            }
            $A[$j + $g] = $v;
        }
 
        return $A;
    }
 
    public function shellSort($A, $n)
    {
        $cnt = 0;
        $G = array();
        for ($i = 1; $i <= $n; $i = 3 * $i + 1) {
            $G[] = $i;
        }
        $G = array_reverse($G);
 
        for ($i = 0; $i < count($G); ++$i) {
            $A = $this->insertionSort($A, $n, $G[$i], $cnt);
        }
 
        return array(count($G), $G, $cnt, $A);
    }
}
 
$A = new Answer();
$result = $A->showAnswer();


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

using namespace std;

class Shop{
public:
    long A, B;

    bool operator<(const Shop &s) const{
        if(A < s.A){
            return true;
        }
        return false;
    }
};

vector<Shop> shops;

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

    shops.resize(N);
    for(int i=0; i<N; ++i){
        cin>>shops[i].A>>shops[i].B;
    }

    sort(shops.begin(), shops.end());

    long ans=0;
    long count=0;
    for(int i=0; i<N; ++i){
        if(count + shops[i].B < M){
            count += shops[i].B;
            ans += shops[i].A * shops[i].B;
        }else{
            ans += shops[i].A * (M - count);
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) = yorukatsu20c()

fun yorukatsu20c() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val aList = readLine()!!.split(' ').map { it.toInt() }

    val answer = aList.asSequence()
        .groupBy { it }.map { it.value.size }.sortedDescending().drop(k).sum()

    println(answer)
}


Measured memory_bytes: 93180
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int n,i;cin>>n;
	bool aru[4][14]={0};
	while(n--){
		char c;int a;cin>>c>>a;
		if(c=='S'){aru[0][a]=true;}
		if(c=='H'){aru[1][a]=true;}
		if(c=='C'){aru[2][a]=true;}
		if(c=='D'){aru[3][a]=true;}
	}
	for(i=1;i<=13;i++){if(!aru[0][i]){cout<<"S "<<i<<endl;}}
	for(i=1;i<=13;i++){if(!aru[1][i]){cout<<"H "<<i<<endl;}}
	for(i=1;i<=13;i++){if(!aru[2][i]){cout<<"C "<<i<<endl;}}
	for(i=1;i<=13;i++){if(!aru[3][i]){cout<<"D "<<i<<endl;}}
	RE;
}


Measured memory_bytes: 3088
import math
import itertools
import sys
sys.setrecursionlimit(20000)


def gcd(a, b):
    a, b = abs(a), abs(b)
    a, b = max(a, b), min(a, b)
    while b > 0:
        tmp = b
        b = a % b
        a = tmp
        a, b = max(a, b), min(a, b)
    return a


def dist(p, q):
    return math.sqrt((p[0] - q[0]) ** 2 +
                     (p[1] - q[1]) ** 2)


def is_liner(a, b, c):
    x = (b[0] - a[0], b[1] - a[1])
    y = (c[0] - a[0], c[1] - a[1])
    gcdx = gcd(x[0], x[1])
    x = (x[0] // gcdx, x[1] // gcdx)
    gcdy = gcd(y[0], y[1])
    y = (y[0] // gcdy, y[1] // gcdy)
    return x == y


def angle(a, b, c):
    p = (b[0] - a[0], b[1] - a[1])
    q = (c[0] - a[0], c[1] - a[1])
    ang = abs(math.atan2(p[1], p[0]) - math.atan2(q[1], q[0]))
    return min(ang, math.pi * 2 - ang)


def outer_soul(a, b, c):
    A = angle(a, b, c)
    B = angle(b, c, a)
    C = angle(c, a, b)
    s2A = math.sin(2*A)
    s2B = math.sin(2*B)
    s2C = math.sin(2*C)
    o = [0] * 2
    for i in range(2):
        o[i] = (s2A * a[i] + s2B * b[i] + s2C * c[i]) / (s2A + s2B + s2C)
    return o


def check(o, r, P):
    for p in P:
        if dist(o, p) > r + 1e-6:
            return False
    return True


def main():
    N = int(input())
    P = [None] * N
    for i in range(N):
        x, y = map(int, input().split())
        P[i] = (x, y)
    if N == 2:
        ans = dist(P[0], P[1]) / 2
        print(ans)
        return
    ans = float("inf")
    for a, b, c in itertools.combinations(P, r=3):
        if is_liner(a, b, c):
            continue
        o = outer_soul(a, b, c)
        r = dist(a, o)
        if check(o, r, P):
            ans = min(ans, r)
    for a, b in itertools.combinations(P, r=2):
        o = ((a[0] + b[0]) / 2, (a[1] + b[1]) / 2)
        r = dist(a, b) / 2
        if check(o, r, P):
            ans = min(ans, r)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 97368
memo=[[0]*51 for i in range(5)]
def rec(i,n):
    if memo[i][n]!=0:
        return memo[i][n]
    if i==4:
        return 1 if n==0 else 0
    for m in range(10):
        memo[i][n]+=rec(i+1,n-m)
    return memo[i][n]
    
while True:
    try:
        n=int(input())
        print(rec(0,n))
    except:
        break

Measured memory_bytes: 7568
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);



	int Dijkstra(int[][] cost, int s, int g) {

		int[] tc = new int[cost.length];

		Arrays.fill(tc, Integer.MAX_VALUE);

		tc[s] = 0;

		boolean[] visited = new boolean[cost.length];

		for (;!visited[g];) {

			int min = Integer.MAX_VALUE;

			int v = 0;

			for (int i = 0; i < cost.length; i++) {

				if (visited[i])

					continue;

				if (min > tc[i]) {

					v = i;

					min = tc[i];

				}

			}

//			System.out.println(v+" "+tc[v]);

			visited[v] = true;

			for (int k = 0; k < cost.length; k++) {

				if (cost[v][k] != Integer.MAX_VALUE)

					tc[k] = Math.min(tc[v] + cost[v][k], tc[k]);

//				System.out.println(" "+tc[k]);

			}

		}

		return tc[g];

	}



	void run(){

		int n = sc.nextInt();

		int m = sc.nextInt();

		int cost[][] = new int[n][n];

		for(int i =0 ; i < n;i++){

			Arrays.fill(cost[i],Integer.MAX_VALUE);

		}

		for(int i = 0 ; i < m ; i++){

			String buffer = sc.next();

			Scanner in = new Scanner(buffer.replace(',', ' '));

			int a = in.nextInt()-1;

			int b = in.nextInt()-1;

			int c = in.nextInt();

			int d = in.nextInt();

			cost[a][b] = c;

			cost[b][a] = d;

		}

		String buffer = sc.next();

		Scanner in = new Scanner(buffer.replace(',', ' '));

		int s = in.nextInt()-1;

		int g = in.nextInt()-1;

		int zzz = in.nextInt();

		int zz = in.nextInt();

		int r = zzz - zz;

		System.out.println(r-Dijkstra(cost,s,g)-Dijkstra(cost,g,s));

	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 12000
/**
    @Author:Monk78
    @Topic:
**/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second
#define F first
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end));i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mod 1000000009
#define MAX 100005
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define rf(i,a,b) for(int i=(a);i>=b;i--)
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
#define vpshVar() int main()
vpshVar(){
    ll A,P;
    sl(A);sl(P);
    pl((A*3+P)/2);
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=10000000;

int dp[11][200001];

const int lim=114514;

int main(){
    int D,G;
    cin >> D >> G;
    G/=100;
    int p[D],c[D];
    for(int i=0;i<D;i++){
        cin >> p[i] >> c[i];
        c[i]/=100;
    }
    for(int i=0;i<=D;i++){
        for(int j=0;j<200001;j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    for(int i=0;i<D;i++){
        for(int k=0;k<=lim;k++) dp[i+1][k]=dp[i][k];
        int tp=p[i]-1;
        for(int j=0;tp>0;j++){
            int key=min(tp,1<<j);
            tp-=key;
            for(int k=lim;k>=0;k--){
                if(dp[i+1][k]==INF) continue;
                dp[i+1][k+(i+1)*key]=min(dp[i+1][k+(i+1)*key],dp[i+1][k]+key);
            }
        }
        for(int k=0;k<lim;k++){
            dp[i+1][k+p[i]*(i+1)+c[i]]=min(dp[i+1][k+p[i]*(i+1)+c[i]],dp[i][k]+p[i]);
        }
    }
    int ans=INF;
    for(int k=G;k<lim;k++) ans=min(ans,dp[D][k]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8832
import java.util.*;

 class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        long N = sc.nextLong();
        long[] A = new long[(int)N];
        int k=1;
        int ans=0;
        for(int i=0;i<N;i++) {
        	A[i] = sc.nextLong();
        }

        for(int i=0;i<N;i++) {
        	if(A[i]==k) {
        		k++;
        	}else {
        		ans++;
        	}
        }
        if(ans==N) {
        	ans=-1;
        }
        System.out.println(ans);	
        
        
    }
    

}

Measured memory_bytes: 86288
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
        for(int i=1;;i++){
            int a=sc.nextInt();
            if(a==0){
                break;
            } 
            System.out.println("Case "+i+": "+a);
           
        }
        sc.close();
    }
}


Measured memory_bytes: 42168
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

ll coun[200001];
ll ans1[200001];
ll ans2[200001];
ll sumans;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
		coun[a[i]]++;
	}
	for (int i = 1; i <= n; i++){
		ans1[i] = coun[i]*(coun[i]-1)/2;
		sumans += ans1[i];
		if ((coun[i]-1)*(coun[i]-2)/2 > 0){
			ans2[i] = (coun[i]-1)*(coun[i]-2)/2;
		}else{
			ans2[i] = 0;
		}
	}
	for (int i = 0; i < n; i++){
		cout << sumans-ans1[a[i]]+ans2[a[i]] << endl;
	}
 	return 0;
 }


Measured memory_bytes: 7552
# https://agc023.contest.atcoder.jp/tasks/agc023_a

import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def convert_map(l):
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


N = list(map(int, input()))[0]

li = list(map(int, input().split()))

counter = [0]
for i in li:
    counter.append(counter[-1] + i)

# print(counter)

d = convert_map(counter)

# print(d)

patterns = 0
for key, value in d.items():
    if value >= 2:
        patterns += combinations_count(value, 2)

print(patterns)


Measured memory_bytes: 41472
n=int(input())
from collections import defaultdict
d=defaultdict(int)
def find(n,i):
    if d[n]!=0:
        return i
    d[n]=i
    if n%2==0:
        return find(n//2,i+1)
    else:
        return find(3*n +1 ,i+1)

print(find(n,1))


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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(5e1) + 17;

int n, K;
int x[MAXN];
ll dp[MAXN][MAXN][MAXN * MAXN];

bool read() {
    if (!(cin >> n >> K))
        return false;

    forn (i, n)
        cin >> x[i + 1];

    return true;
}

void solve() {
    dp[0][0][0] = 1;

    for (int i = 0; i < n; ++i)
        for (int s = 0; s < MAXN * MAXN; ++s)
            for (int k = 0; k <= i; ++k) {
                dp[i + 1][k][s] += dp[i][k][s];

                if (s + x[i + 1] < MAXN * MAXN)
                    dp[i + 1][k + 1][s + x[i + 1]] += dp[i][k][s];
            }

    ll ans = 0;

    for (int k = 1; k <= n; ++k)
        ans += dp[n][k][k * K];

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 119040
n,k = [int(x) for x in input().split()]

if k % 2 == 1:
    print((n//k)**3)
else:
    if n % k >= k // 2:
        print((n//k+1)**3 + (n//k)**3)
    else:
        print((n//k)** 3 * 2)

Measured memory_bytes: 3060
x = [int(input()) for i in range(5)]

x_1 = [int(i / 10) for i in x]
x_2 = [(i % 10) for i in x]

ans = sum(x_1)*10 

for i in range(x_2.count(0)):
    x_2.remove(0)

if(x_2 != []):
    ans += min(x_2)
    ans += (len(x_2)-1)*10

print(ans)

Measured memory_bytes: 3064
//

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,l);
    sort(range(l));
    int ans = 0;
    rep(i,0,n-2){
        rep(j,i+1,n-1){
            rep(k,j+1,n){
                if(l[i]+l[j]>l[k]){
                    ans++;
                }else{
                    break;
                }
            }
        }
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = Hash.new{|h,k| h[k] = 0}

1.upto(n) do
  s = gets.chomp
  a[s[0]] += 1
end

march = ["M","A","R","C","H"]

ans = 0

march.combination(3).to_a.each do |x|
  ans += a[x[0]] * a[x[1]] * a[x[2]]
end
puts ans


Measured memory_bytes: 2044
txt = input()
L = len(txt)

def solve():
  for i in range(L-1):
    if txt[i] == txt[i+1]:
      return ' '.join([str(x) for x in [i+1,i+2]])
  for i in range(L-2):
    if txt[i] == txt[i+2]:
      return ' '.join([str(x) for x in [i+1,i+3]])
  return '-1 -1'

ans = solve()
print(ans)


Measured memory_bytes: 3188
n,m = map(int,input().split())

mod = 10**9 + 7
l = 5*10**5 + 3

M = [1]  # i!のmod
mul = 1
for i in range(1, l):
    mul = (mul * i) % mod
    M.append(mul)

def pow(x, y, mod):  # x**y の mod を返す関数
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = (ans * x) % mod
        x = (x**2) % mod
        y //= 2
    return ans

def inv(x, mod):  # x の mod での逆元を返す関数
    return pow(x, mod-2, mod)

# print(inv(8,13))

MI = [0] * (l-1) +[inv(M[l-1], mod)]  # i!の逆元
for i in range(l-2, -1, -1):
    MI[i] = MI[i+1] * (i+1) % mod

def C(x, y):  # コンビネーション
    if y < 0 or y > x:
        return 0
    elif x > l:  # O(min(y, x-y))
        y = min(y, x-y)
        ans = 1
        for i in range(x, x-y, -1):
            ans = (ans * i) % mod
        return (ans * MI[y]) % mod
    else:  # O(1)
        ans = M[x]
        ans = (ans * MI[y]) % mod
        return (ans * MI[x-y]) % mod

def P(x, y):  # パーミュテーション（順列）
    if y < 0 or y > x:
        return 0
    elif x > l:  # O(min(y, x-y))
        y = min(y, x-y)
        ans = 1
        for i in range(x, x-y, -1):
            ans = (ans * i) % mod
        return ans % mod
    else:  # O(1)
        ans = M[x]
        return (ans * MI[x-y]) % mod

ans = (P(m, n) ** 2) % mod
for i in range(1, n+1):
    ans += (C(n, i) * ((-1) ** (i%2)) * P(m, i) * (P(m-i, n-i) ** 2)) % mod
print(ans % mod)

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


void solve(long long X){
  long long last = 1;
  for(long long i = 2; i <= X; i++) {
    long long acc = i;
    while(acc <= X) {
      acc *= i;
      if(acc <= X) last = max(last, acc);
    }
  }

  cout << last << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
  scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  LL a, b, k;
  cin >> a >> b >> k;
  REP(i, 0, k) {
    if (i % 2 == 0) {
      if (a % 2 == 1) --a;
      a/=2;
      b += a;
    } else {
      if (b % 2 == 1) --b;
      b/=2;
      a += b;
    }
    //cerr << a << " " << b << endl;
  }
  cout << a << " " << b << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	vector<int> b(n-1);
	for(int i=0;i<n-1;i++){
		cin >> b[i];
	}
	int ans=0;
	ans+=b[0]+b[n-2];
	for(int i=0;i<n-2;i++){
		ans+=min(b[i],b[i+1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256