akhauriyash/Code-Regression huggingface dataset:
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(String[] args){
 
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        int[] a = new int[n];
 
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
 
        // 通った街を記録する配列
        ArrayList<Integer> list = new ArrayList<Integer>();
        HashSet<Integer> set = new HashSet<Integer>();
        list.add(1);    // 一つ目の町
        set.add(1);
        // ループの先頭の町がリストの何番目にあるかを格納する変数
        int check = -1;
 
        // 転送先を格納する変数。
        int temp = 1;   // 計算のため初期値１
 
        for (long i = 0; i < k; i++) {
            temp = a[temp-1];   //　転送先設定
            // 訪れた町かチェック
            // 訪れていた場合、ループ前のイントロ部分の長さを求める
            if (set.contains(temp)) {
                check = list.indexOf(temp);
            	break;
            }
            list.add(temp);
            set.add(temp);
        }

        if (check == -1) {
            System.out.println(temp);
            return;
        } 
        // 合計移動回数をループ長で割った余りを求める
        int std = (int)((k-check) % (list.size() - check));
 
        System.out.println(list.get(std + check));
    }
}

Measured memory_bytes: 65496
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100100;
int a[maxn];
int main(){
	int n,c,k;
	scanf("%d%d%d",&n,&c,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int lef=0,t=0,ans=0;
	for(int i=1;i<=n;i++){
		if(lef==0||t<a[i]){
			ans++;
			lef=c;
			t=a[i]+k;
		}
		lef--;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 512
antena = 5.times.map{ gets.chomp.to_i }
n = gets.chomp.to_i

flag = true
for i in 0..antena.size-2 do
  for j in 1..antena.size-1 do
    if (antena[i] - antena[j]).abs > n
      flag = false
    end
  end
end

if flag
  puts 'Yay!'
else
  puts ':('
end


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

using namespace std;

int n, a, subs[200010] = {0};

int main()
{
    cin >> n;

    for (int i = 2; i < n+1; i++) {
        cin >> a;
        subs[a]++;
    }

    for (int i = 1; i < n+1; i++) {
        cout << subs[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 4348
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	int sum = 0;
	int mx = 0;
	rep(i, n){
		int x;
		cin >> x;
		sum += x;
		mx = max(mx, x);
	}
	cout << sum - mx / 2 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

#import
#import math
#import numpy as np
#= int(input())
#= input()
N, K = map(int, input().split())
A = list(map(int, input().split()))

dp = [False] * (K + 1)

for i in range(K + 1):
    for a in A:
        if i >= a:
            dp[i] = not dp[i - a] or dp[i]

if dp[K]:
    print("First")
else:
    print("Second")


Measured memory_bytes: 72372
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
const int inf = 1 << 28;

struct unionFind{
    vector<int> par, rank;
    unionFind(size_t n):par(n), rank(n, 0){
        iota(par.begin(), par.end(), 0);
    }
    int findRoot(int x){
        return x == par[x]? x: par[x] = findRoot(par[x]);
    }
    bool unite(int x, int y){
        x = findRoot(x); y = findRoot(y);
        if(x == y)return false;
        if(rank[x] == rank[y])rank[x]++;
        if(rank[x] < rank[y])par[x] = y; else par[y] = x;
        return true;
    }
};

struct edge{int src, dst, wt;};

int n, m;
vector<edge> es;

int solve(){
    sort(all(es), [](const edge &e, const edge &d){return e.wt < d.wt;});
    int res = inf;
    rep(i, m){
        unionFind uf(n);
        int V = 1;
        for(int j=i; j<m; ++j){
            if(res <= es[j].wt - es[i].wt)break;
            if(!uf.unite(es[j].src, es[j].dst))continue;
            if(++V == n)res = min(res, es[j].wt - es[i].wt);
        }
    }
    return res == inf? -1: res;
}

int main(){
    while(cin >> n >> m, n|m){
        es.clear();
        rep(i, m){
            int a, b, w;
            cin >> a >> b >> w;
            es.push_back((edge){a-1, b-1, w});
        }
        cout << solve() << '\n';
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define X first;
#define Y second;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 3e5 + 10;
const int maxK = 1e4+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 998244353;


int a[1010];
int b[1010];

int main()
{
	ll ans = 0;
	int n;
	cin>>n;
	for(int i=1;i<n;i++)
	{
		ans += ((n-1)/i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <stdint.h>
#include <stdio.h>
#include <vector>

unsigned readUnsigned() {
    int c;
    do { c = ::getchar_unlocked(); } while (c < '0');
    unsigned result = c - '0';
    while ((c = ::getchar_unlocked()) >= '0') {
        result *= 10;
        result += c - '0';
    }
    return result;
}

void writeUnsignedLn(unsigned x) {
    static const unsigned MAX_DIGITS = 10;
    static const unsigned BUF_SIZE = MAX_DIGITS + 1;
    static char buffer[BUF_SIZE] = {0};
    buffer[BUF_SIZE - 1] = '\n';
    unsigned i = BUF_SIZE - 1;
    do {
        buffer[--i] = x % 10 + '0';
        x /= 10;
    } while (x);
    ::fwrite_unlocked(buffer + i, 1, BUF_SIZE - i, stdout);
}

uint64_t N, L, T;
std::vector<uint64_t> xs, W;

std::vector<unsigned> solve() {
    std::vector<uint64_t> crossings(N);

    struct xid { uint64_t x, id; };
    std::vector<xid> left, right;
    for (unsigned n = 0; n <= 1; ++n) {
        for (unsigned i = 0; i < N; ++i) {
            if (W[i] == 1) {
                right.push_back({xs[i] + n*L, i});
            }
            else {
                left.push_back({xs[i] + n*L, i});
            }
        }
    }

    uint64_t numleft = left.size() / 2;
    uint64_t numright = right.size() / 2;

    for (unsigned i = 0, min = 0, max = 0; i < N; ++i) {
        if (W[i] != 1) {
            continue;
        }
        crossings[i] = (2 * T) / L * numleft;
        uint64_t lo = xs[i];
        uint64_t hi = xs[i] + 2 * T % L;
        for (; min < left.size() && left[min].x < lo; ++min);
        for (; max < left.size() && left[max].x < hi; ++max);
        crossings[i] += max - min;
    }

    for (unsigned i = 0, min = 0, max = 0; i < N; ++i) {
        if (W[i] != 2) {
            continue;
        }
        crossings[i] = (2 * T) / L * numright;
        uint64_t lo = xs[i] + L - 2 * T % L;
        uint64_t hi = xs[i] + L;
        for (; min < right.size() && right[min].x <= lo; ++min);
        for (; max < right.size() && right[max].x <= hi; ++max);
        crossings[i] += max - min;
    }

    std::vector<unsigned> result(N);
    for (unsigned i = 0; i < N; ++i) {
        if (W[i] == 1) {
            unsigned j = (i + crossings[i]) % N;
            unsigned t = (xs[i] + T) % L;
            result[j] = t;
        }
        else {
            unsigned j = (i - crossings[i] % N + N) % N;
            unsigned t = (xs[i] - T%L + L) % L;
            result[j] = t;
        }
    }
    return result;
}

int main() {
    N = readUnsigned();
    L = readUnsigned() * 2;
    T = readUnsigned() * 2;

    xs.resize(N);
    W.resize(N);
    for (unsigned i = 0; i < N; ++i) {
        xs[i] = readUnsigned() * 2;
        W[i] = readUnsigned();
    }

    std::vector<unsigned> result = solve();
    for (unsigned i = 0; i < N; ++i) {
        writeUnsignedLn(result[i] / 2);
    }
}


Measured memory_bytes: 8048
#include<bits/stdc++.h>
// #include"testlib.h"

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)1e6 + 10;
const int mod = (int)1e9 + 7;


int main(int argc, char* argv[]){

    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);

    int n, m;
    cin >> n >> m;

    vector<int> a(n + 1), b(m + 1);
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    for(int i = 1; i <= m; ++i)
        cin >> b[i];

    dp[0][0] = 1;

    for(int i = 0; i <= m; ++i) dp[0][i] = 1;
    for(int i = 0; i <= n; ++i) dp[i][0] = 1;

    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j){
            if(a[i] == b[j]) dp[i][j] = dp[i - 1][j - 1];
            dp[i][j] += ((dp[i - 1][j] + dp[i][j - 1]) % mod - dp[i - 1][j - 1] + mod) % mod;
            while(dp[i][j] >= mod) dp[i][j] -= mod;
        }
    }

    cout << dp[n][m] << endl;

    return 0;
}

Measured memory_bytes: 16000
#include<iostream>
#include<cstdlib>
#include<cstdio>

using namespace std;

struct node {
	int key;
	node *next, *prev;
};

class list {
	int length;
public:
	node *head, *tail;
	list(): length(0) {
		head=new node;  //????????§??????????¢???????????????¨??????????????????????????¨??????????????????????????§????????¢???????¢?????????????????????????
		tail=new node;
		head->next=tail;
		head->prev=NULL;
		tail->next=NULL;
		tail->prev=head;
	} 

	int len(){  return length;  }

	void insert(int);
	void del(int);
	void dell();
	void delf();

	
};

void list::insert(int x)
{
	node* nx=new node;

	if( !nx ){
		cout<<"MEMORY ALLOCATION ERROR!"<<endl;
		exit(1);
	}

	length++;


	nx->next=head->next;
	nx->prev=head;
	head->next->prev=nx; 
	head->next=nx;
	nx->key=x;

	
}	

void list::del(int x)   //???????????????????????????????????????!!
{
	node *t=head;
	while( t->next != tail ) {
		t=t->next;
		if( t->key == x ){
			t->prev->next=t->prev->next->next;
			t->next->prev=t->next->prev->prev;

			delete t;


			



			length--;

			return;
		}
	}
}

void list::dell()
{
	if( head->next==tail )
		return;
	node *d=tail->prev;

	tail->prev->prev->next=tail;
	tail->prev=tail->prev->prev;


	delete d;

	length--;
}

void list::delf()
{
	if( head->next==tail )
		return;
	node *d=head->next;

	head->next->next->prev=head;
	head->next=head->next->next;

	delete d;
	length--;
}

void show(list l) 
{
	for( node *t=l.head->next; t !=l.tail; t=t->next ){
		if( t->next != l.tail )
			cout<<t->key<<' '<<flush;
		else
			cout<<t->key<<endl;
	}
}
int main() 
{

	long n;cin>>n;
	char com[20];
	int x;
	list dll;

	for( long i=0; i<n; i++ ) {
		scanf("%s",com);
		
		if( com[0]=='i' ){
			scanf("%d",&x);
			dll.insert(x);
		}else if( com[0]=='d' && com[6]=='F' )
			dll.delf();
		else if( com[0]=='d' && com[6]=='L' )
			dll.dell();
		else{
			scanf("%d",&x);
			dll.del(x);
		}
	}

	show(dll);
}

Measured memory_bytes: 32420
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  string s;
  cin >> s;

  string t(s.size(), 'x');
  cout << t << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using  ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

//string ans = "Yes";

int SetAns() {
	int N, K;
	cin >> N >> K;
	vector<int> p(N, 0);

	rep(i, N) {
		cin >> p[i];
	}

	sort(p.begin(), p.end());
	int nowAns = 0;
	rep(i, K) nowAns += p[i];
	return nowAns;
}

int main() {
	cout << SetAns() << endl;
	return 0;
}


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

public class Program{
    public static void Main(){
        int n=int.Parse(Console.ReadLine());
        List<int> p=Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList();
        int ans=0;
        for(int i=0;i<n-2;i++){
            List<int> q=p.Skip(i).Take(3).ToList();
            if(q[1]!=q.Max() && q[1]!=q.Min()){
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13396
import sys
import math
import bisect

def solve(a, b, k):
    A = []
    for i in range(1, min(a, b) + 1):
        if a % i == 0 and b % i == 0:
            A.append(i)
    A.sort(reverse=True)
    return A[k-1]

def main():
    a, b, k = map(int, input().split())
    print(solve(a, b, k))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import defaultdict

N = int(readline())
C = (0,) + tuple(map(int, readline().split()))
m = map(int, read().split())
AB = zip(m, m)

graph = [[] for _ in range(N + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)


root = 1
parent = [0] * (N + 1)
depth = [0] * (N + 1)  # 根を深さ 1 として
order = []
stack = [root]
depth[root] = 1
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)
        depth[y] = depth[x] + 1


def merge(v, p):
    A = dp[v]
    B = dp[p]
    size_A = size[v]
    size_B = size[p]
    c = C[p]
    if len(A) < len(B):
        A, B = B, A
        size_A, size_B = size_B, size_A
    answer[c] += (size_A - A[c]) * (size_B - B[c])
    # B を A にマージ
    for key, cnt in B.items():
        answer[key] -= cnt * A[key]
        A[key] += cnt
    size[p] = size_A + size_B
    dp[p] = A


answer = [0] * (N + 1)
dp = [defaultdict(int) for _ in range(N + 1)]
size = [0] * (N + 1)

for v in order[::-1]:
    c = C[v]
    n = size[v] + 1 - dp[v][c]
    answer[c] -= size[v] * n
    size[v] += 1
    dp[v][c] = size[v]
    if v == root:
        break
    p = parent[v]
    merge(v, p)

A = dp[root]
c = size[root]
for v in range(1, N + 1):
    print(c * A[v] + answer[v])


Measured memory_bytes: 162800
// ABC 155-C
// 2020.2.16 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0; int c;
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int ins(char *s) { // 文字列の入力　スペース以下の文字で入力終了
	char *p = s--;
	do *++s = gc();
	while (*s > ' ');
	*s = 0;
	return s - p;
}

// 文字列のハッシュ関数
#define HASHSIZ 2000081
typedef struct { char *s; int id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash + HASHSIZ;

int insert(char *s, int id) {
	unsigned long long i;
	int j;
	char *p;
	HASH *tp;

	i = 0, p = s;
	for (j = 0; *p && j < 10; j++) i = (i << 5) + (*p++ +1-'a');
	tp = hash + (int)(i % HASHSIZ);
	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return tp->id;
		if (++tp == hashend) tp = hash;
	}
	tp->s = s, tp->id = id;
	return -1;
}

#define MAX 200005
typedef struct { char *p; int n; } T;
T tbl[MAX];
char S[MAX][12];
int K;

int cmp(const void *u, const void *v) {
	int r;
	if (r = ((T *)v)->n - ((T *)u)->n) return r;
	return strcmp(((T *)u)->p, ((T *)v)->p);
}

int main()
{
	int i, N;

	N = in();
	while (N--) {
		ins(tbl[K].p = S[K]);
		if ((i = insert(S[K], K)) < 0) tbl[K++].n = 1;
		else tbl[i].n++;
	}
	qsort(tbl, K, sizeof(T), cmp);
	puts(tbl[0].p);
	for (i = 1; i < K; ++i) {
		if (tbl[i].n != tbl[i-1].n) break;
		puts(tbl[i].p);
	}
	return 0;
}


Measured memory_bytes: 40060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 200000
#define INF 2140000000
#define MOD 1000000007

int col[MAX] = {0};

void visit(vector<vector<pair<int, int> > > &adj, int u, int flag[]) {
	flag[u] = 1;
	
	for (int i = 0; i < (int) adj[u].size(); ++i) {
		if(!flag[adj[u][i].first]) {
			if (adj[u][i].second % 2) {
				col[adj[u][i].first] = !col[u];
			}
			else {
				col[adj[u][i].first] = col[u];	
			}
			visit(adj, adj[u][i].first, flag);
		}
	}
	
	return;
}

void dfs(vector<vector<pair<int, int> > > &adj) {
	int flag[(int) adj.size()] = {0};

	for (int i = 0; i < (int) adj.size(); ++i) {
		if(!flag[i]) {
			col[i] = 0;
			visit(adj, i, flag);
		}
	}

	return;
}

int main() {
	int ver, edge, u, v, l;
	cin >> ver;

	vector<vector<pair<int, int> > > adj(ver);

	for (int i = 0; i < ver - 1; ++i) {
		cin >> u >> v >> l;
		adj[u - 1].push_back(make_pair(v - 1, l));
		adj[v - 1].push_back(make_pair(u - 1, l));
	}

	dfs(adj);

	for (int i = 0; i < ver; ++i) {
		cout << col[i] << endl;
	}

	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  int i, j;
  vector<int> a(n);
  int nmin = 101;
  int nmax = -101;
  for(i = 0; i < n; i++)
  {
    cin >> a.at(i);
    if(a.at(i) > nmax) nmax = a.at(i);
    if(a.at(i) < nmin) nmin = a.at(i);
  }
  int cmin = 10000000;
  int cost;
  for(i = nmin; i <= nmax; i++)
  {
    cost = 0;
    for(j = 0; j < n; j++)
    {
      cost += (a.at(j)-i)*(a.at(j)-i);
    }
    if(cost<cmin)cmin = cost;
  }
  cout << cmin << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}
 


 
int main(){
	//in_o();
	string s[3];
	cin>>s[0]>>s[1]>>s[2];
	int top=0,next,ans;
	while(1){
		if(s[top].empty()){
			ans=top;
			break;
		}
		if(s[top][0]=='a') next=0;
		else if(s[top][0]=='b') next=1;
		else next=2;
		s[top]=s[top].substr(1);
		top=next;
	}	
	if(ans==0) cout<<"A"<<endl;
	else if(ans==1) cout<<"B"<<endl;
	else cout<<"C"<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
*a, = map(int, input().split())

*b, = filter(lambda x: x%4 != 0, a)
mul_4 = n-len(b)

*c, = filter(lambda x: x%2 != 0, b)
mul_2 = (len(b)-len(c))

k = n-(mul_4+mul_2)

if mul_2 == 0 and k <= mul_4+1:
    print("Yes")
elif k <= mul_4:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
const ll INF = 1LL << 60;
using Graph = vector<vector<ll>>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);

// 2*nに耐えるように
ll used_red[210];

int main(){
    ll n, x, y, ans = 0;
    cin >> n;
    vector<pair<ll, ll>> red(n), blue(n);
    rep(i, n){
        cin >> x >> y;
        red[i] = make_pair(x, y);
    }
    // x座標昇順
    sort(all(red));
    rep(i, n){
        cin >> x >> y;
        blue[i] = make_pair(x, y);
    }
    // x座標昇順
    sort(all(blue));

    for(auto pb: blue){
        ll ind_x, max_y = -1;
        for(auto pa: red){
            // redのx座標がblueのx座標以上になったらやめる
            if(pa.first >= pb.first) break;
            // ペア候補
            if(!used_red[pa.first] && pa.second < pb.second){
                // y座標の最大で貪欲
                if(chmax(max_y, pa.second)) ind_x = pa.first;
            }
        }
        // ペア候補が一つでも見つかっていたら
        if(max_y != -1){
            ans++;
            used_red[ind_x] = 1;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3600
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int MAX = 100000+24;
    private static int[][] knift=new int[MAX][2];
    private static int[] temp=new int[MAX*2];
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        while(in.hasNext()) {
            int n=in.nextInt(),h=in.nextInt(),idx=0,Size=0;
            for(int i=0;i<n;i++){
                knift[i][0]=in.nextInt();
                knift[i][1]=in.nextInt();
                if((knift[i][0]>knift[idx][0])||(knift[i][0]==knift[idx][0] && knift[i][1]<knift[idx][1])){
                    idx=i;
                }
            }
            for(int i=0;i<n;i++){
                if(idx==i){
                    continue;
                }
                temp[Size++]=Math.max(knift[i][0],knift[i][1]);
            }
            Arrays.sort(temp,0,Size);
            int answer=0;
            for(int i=Size-1;i>=0&&h>0;i--){
                if(temp[i]<=knift[idx][0]){
                    break;
                }
                h-=temp[i];
                answer++;
            }
            if(knift[idx][1]>knift[idx][0]&&h>0){
                answer++;
                h-=knift[idx][1];
            }
            if(h>0){
                answer+=(int)Math.ceil(((double)h)/knift[idx][0]);
            }
            out.println(answer);
            out.flush();
        }
        in.close();
        out.close();
    }

}


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

using namespace std;

int main(){
    int n,s,sum_l = 0,sum_r = 0;
    int ans = 10000;
    cin >> n;
    int w[n];
    for (int i = 0; i < n; i++)
    {
        cin >> s; 
        w[i] = s;
        sum_l += s;
    }
    for (int i = 0; i < n; i++)
    {
        sum_r += w[i];
        sum_l -= w[i];
        ans = min(abs(sum_r - sum_l),ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// D - Lucky PIN
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define all(x) (x).begin(),(x).end()
#define ubound(x,c) upper_bound(all(x),(c))-(x).begin()

int main(){
	int N; char S[30001]; scanf("%d%s",&N,S);
	vector<int> ix[10];
	rp(i, 0, N) ix[S[i]-'0'].push_back(i);
	int ans = 0;
	rp(a, 0, 10){
		int p = ubound(ix[a], -1); if(p >= ix[a].size()) continue;
		p = ix[a][p];
		rp(b, 0, 10){
			int q = ubound(ix[b], p); if(q >= ix[b].size()) continue;
			q = ix[b][q];
			rp(c, 0, 10) if(ubound(ix[c], q) < ix[c].size()) ans++;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 512
YYMM = input()
YY = int(YYMM[:2])
MM = int(YYMM[2:])

if 0<YY and YY<13:
    if 0<MM and MM<13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0<MM and MM<13:
        print("YYMM")
    else:
        print("NA")

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

int main() {
    int n;
    cin >> n;
    vector< pair<int, int> > a(n);

    for(int i=0; i<n; i++){
        int aa = 0;
        cin >> aa;
        a[i].first = aa;
        a[i].second = i;
    }

    sort(a.begin(), a.end());
    for(int i=0; i<n; i++){
        cout << a[i].second + 1 << ' ';
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
struct Integer{
public:
    Integer(ll n){
    }

    ll gcd(ll a,ll b){return b ? gcd(b, a % b) : a;} //最大公約数

    ll lcm(ll a,ll b){return a / gcd(a, b) * b;} //最小公倍数

    bool isPrime(ll x){
        if(x < 2) return false;
        if(x == 2) return true;
        if(x % 2 == 0) return false;
        for(ll i = 3;i <= sqrt(x) + 1;i += 2) if(x % i == 0) return false;
        return true;
    }

    vector<ll> divisor(ll M){ //約数の全列挙
        vector<ll> dd;
        for(ll i = 1; i * i <= M; i++){
            if(M % i == 0){
                dd.push_back(i);
                if(i * i != M){
                    dd.push_back(M / i);
                }
            }
        }
        sort(dd.begin(), dd.end());
        return dd;
    }

    vector<ll> factor(ll M){ //素因数分解
        vector<ll> dd;
        if(M == 1){
            dd.push_back(1);
            return dd;
        }
        for(ll i = 2; i*i <= M; i++){
            while(M % i == 0){
                dd.push_back(i);
                M /= i;
            }
        }
        if(M != 1) dd.push_back(M);
        sort(dd.begin(), dd.end());
        return dd;
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[200010];
    Integer it(0);
    rep(i,0,N) cin >> A[i];
    ll ans[200010] = {};
    ll cnt[200010] = {};
    rrep(i,N-1,0){
        vector<ll> dd = it.divisor(i+1);
        if(A[i] == 0){
            if(cnt[i+1] % 2 == 0){
            }else{
                ans[i]++;
                rep(j,0,dd.size()){
                    cnt[dd[j]]++;
                }
            }
        }else{
            if(cnt[i+1] % 2 == 0){
                ans[i]++;
                rep(j,0,dd.size()){
                    cnt[dd[j]]++;
                }
            }else{
            }

        }

    }
    vector<ll> v;
    rep(i,0,N){
        if(ans[i] != 0) v.push_back(i+1);
    }
    ll M = v.size();
    print(M);
    rep(i,0,M){
        cout << v[i] << " \n"[i == M-1];
    }




    
}

Measured memory_bytes: 6772
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	n := func() int { stdin.Scan(); i, _ := strconv.Atoi(stdin.Text()); return i }()
	m := map[string]int{}
	for i := 0; i < n; i++ {
		stdin.Scan()
		t := strings.Split(stdin.Text(), "")
		sort.Strings(t)
		m[strings.Join(t, "")]++
	}
	count := 0
	for _, i := range m {
		if i == 1 {
			continue
		}
		n := combination(i, 2)
		count += n
	}
	fmt.Println(count)
}

func permutation(n int, k int) int {
	v := 1
	if 0 < k && k <= n {
		for i := 0; i < k; i++ {
			v *= (n - i)
		}
	} else if k > n {
		v = 0
	}
	return v
}
func factorial(n int) int {
	return permutation(n, n-1)
}
func combination(n int, k int) int {
	return permutation(n, k) / factorial(k)
}

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

long long mod=998244353,ara[200044];

long long bigmod(long long n,long long p)
{
     if(p==0)return 1;
     if(p%2==0)
     {
         long long ret=bigmod(n,p/2);
         return ((ret%mod)*(ret%mod))%mod;
     }
     else
        return ((n%mod)*(bigmod(n,p-1)%mod))%mod;
}


int main()
{

    long long n,m,k,a,b,d,e,f,g,h,fr,sc,c=1,i,j,ans=0;   ara[0]=1;

    scanf("%lld %lld %lld",&n,&m,&k);

    for(i=1;i<=n+4;i++)
    {
        c=(c*i)%mod;  ara[i]=c;
    }

    b=n-1-k;

    for(i=b;i<=n-1;i++)
    {
        d=ara[n-1];   e=(ara[i]*ara[n-1-i])%mod;
        f=bigmod(e,mod-2);  g=(d*f)%mod;

        h=(g*m)%mod;  fr=bigmod(m-1,i);   sc=(h*fr)%mod;

        ans=(ans+sc)%mod;

    }

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


    return 0;
}


Measured memory_bytes: 5308
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>





using namespace std;
int main() {
	
	int p[6] = {};
	for (int i = 0; i < 6; i++)cin >> p[i];

	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
//			cout << p[i] - p[i - 1] << endl;
			if (abs(p[i] - p[j]) > p[5]) {
				cout << ":(" << endl;

				return 0;
			}
		}
	}

	cout << "Yay!" << endl;

	return 0;
}

Measured memory_bytes: 256
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
N,K = map(int,input().split())
A = list(map(int,input().split()))
a = A[0]
for i in range(1,N):
    a = gcd(a,A[i])
flag = 0
for i in range(N):
    if A[i]>=K:
        b = A[i]-K
        if b%a==0:
            flag = 1
            break
if flag==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 85380
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#ifndef LOCAL
struct ostdmy{template<class T>ostdmy&operator<<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
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(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n,h,w;
    cin>>n>>h>>w;
    int ans=0;
    REP(i,n){
        int a,b;
        cin>>a>>b;
        if(a>=h && b>=w)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int MAX_N = 105000+1;

bool prime[MAX_N];
vector<int> p;

void make_prime (void )
{
	fill (prime, prime+MAX_N, true );
	prime[0] = false;
	prime[1] = false;
	for (int i = 2; i*i < MAX_N; i++ ){
		if (prime[i] ){
			for (int j = 2*i; j < MAX_N; j += i ){
				prime[j] = false;
			} // end for
		} // end if
	} // end for
	
	p.clear();
	rep (i, MAX_N ){
		if (prime[i] ) p.push_back (i );
	} // end rep

//	cerr << p.size() << ": " << p[p.size()-1] << endl;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.SPN", "r", stdin );
	make_prime ();
	int n;
	while (scanf ("%d", &n ), n ){
		int sum = 0;
		rep (i, n ) sum += p[i];
		printf ("%d\n", sum );
	} // end while

	return 0;
}

Measured memory_bytes: 1412
#include <iostream>
#include <stack>
using namespace std;
static const int N=100;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

//??¶????????°
int n;
//?????\??????
int M[N][N];
//??°?????¶???????¢????
int color[N];
//??\??¶????????°??¶???
int d[N];
//??\??¶???????????¶???
int f[N];
//??¶???
int tt;

int nt[N];

//????????????????????????u?????????v
int next(int u){
    for(int v=0;v<n;v++){
        nt[u]=v+1;
        if(M[u][v]&&color[v]==WHITE)
            return v;
    }
    return -1;
}

//??¨????????°?????±?????????????´¢
void dfs_visit(int r){
    for(int i=0;i<n;i++)
        nt[i]=0;

    stack<int> S;
    S.push(r);
    color[r]=GRAY;
    //?????°??¶???
    d[r]=++tt;

    while(!S.empty()){
        int u=S.top();
        int v=next(u);
        if(v!=-1&&color[v]==WHITE){
            color[v]=GRAY;
            d[v]=++tt;
            S.push(v);
        }
        else{
            //????????????
            S.pop();
            color[u]=BLACK;
            f[u]=++tt;
        }
    }
}

void dfs(){
    //????§????
    for(int i=0;i<n;i++)
        color[i]=WHITE;
    tt=0;

    //??\????????????u?????????????????±?????????????´¢
    for(int u=0;u<n;u++)
        if(color[u]==WHITE)
            dfs_visit(u);

    for(int i=0;i<n;i++)
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
}

int main(){
    int u,k,v;

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

    for(int i=0;i<n;i++){
        cin>>u>>k;u--;
        for(int j=0;j<k;j++){
            cin>>v;v--;
            M[u][v]=1;
        }
    }

    dfs();
}

Measured memory_bytes: 3084
#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LLINF = 4e18;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

// LIS　最長増加部分列(非減少)
int LIS(const vector<int> &A) {
    vector<int> lis(A.size(), INF);
    for (int i = 0; i < A.size(); i++)
    {
        lis[upper_bound(ALL(lis), A[i]) - lis.begin()] = A[i];
    }
    return lower_bound(ALL(lis), INF) - lis.begin();
}

int main() {
    int n; input(n);
    vector<int> a(n),b(n); input(a);
    int k = a[0];
    int cnt = 0;
    REP(i, n) {
        if (k == a[i]) cnt++;
        b[n - 1 - i] = a[i];
    }
    if (cnt == n) {
        cout << cnt << endl;
    }
    else {
        cout << LIS(b) << endl;
    }
    getchar(); getchar();
}

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

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

	int a[n];
	long long sum=0;

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

	int mm = 0;

	for(int i=1; i<n; ++i)
	{
		if(mm < a[i] - a[i-1])
			mm = a[i]-a[i-1];
	}

	if(mm < k - ( a[n-1] - a[0]) )
		mm = k - ( a[n-1] - a[0] );

	cout<<k - mm;
return 0;
}

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

const int mod = 1000000007;

int dp[334334];

signed main() {
	int n;
	cin >> n;
	vector<int> v;
	rep(i, n) {
		int c;
		cin >> c;
		v.push_back(c - 1);
	}
	v.erase(unique(v.begin(), v.end()), v.end());
	rep(i, 334334) {
		dp[i] = 0;
	}
	int now = 1;
	rep(i, v.size()) {
		int c = v[i];
		int nex = (now + dp[c]) % mod;
		dp[c] = (dp[c] + now) % mod;
		now = nex;
	}
	cout << now << endl;
}

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

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

    if(s[0] == s[1] && s[1] == s[2] 
        || s[1] == s[2] && s[2] == s[3]) {
        cout << "Yes" << endl; 
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxt(),a=nxt();
    vector <ll> v(n);
    generate(all(v),nxt);
    vector <vector < vector <ll> > > dp;
    vector <ll> row;
    row.resize(2501,0);
    vector <vector  <ll> > row2;
    row2.resize(n+1,row);
    dp.resize(n,row2);

    dp[0][1][v[0]]=1;
    for(ll i=1;i<n;i++)
    {
        dp[i]=dp[i-1];
        dp[i][1][v[i]]+=1;
        for(ll len=1;len<=i;len++)
        {
            for(ll val=1;val<=2500;val++)
                if(dp[i-1][len][val]>0)
                    dp[i][len+1][val+v[i]]+=dp[i-1][len][val];
        }
    }

    ll test=0;
    for(int len=1;len<=n;len++)
        test+=dp[n-1][len][len*a];
    cout<<test<<endl;


    

    
    return 0;   
}


 
 


Measured memory_bytes: 51200
#include <cmath>
#include <string.h>
#include <iostream>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

#define rep(i, j, n) for (int i = j; i < n; i++)
#define rep_nested(i, s, n) for (ull i = s; i <= n; i++)
#define ll long long
#define ull unsigned long long

const int N = 500;
const ll INF = 1e9 + 7;

using namespace std;

template <class T>
T limit(T n, T k) {
	return (n > k) ? k : n;
}

template <class T>
T has_order(T a, T b, T c) {
	return (b > a && b < c) || (b < a && b > c);
}

template <class T>
float points_distance(T a) {
	return sqrt(a);
}

template <class T>
T is_integer(T a) {
	return floor(a) == a;
}

int main() {
	int n, k, count = 0;
	multiset<int> ms;
	multiset<int>::iterator it;
	vector<int> v;
	
	cin >> n;
	
	rep(i, 0, n) {
		cin >> k;
		v.push_back(k);
		ms.insert(k);
	}
	
	int i = 0;
	
	for(it = ms.begin(); it != ms.end(); it++) {
		count += (*it - v[i++] != 0);
	}
	
	if (count == 0 || count == 2) cout << "YES" << endl;
	else cout << "NO" << endl;
	
    return 0;
}

Measured memory_bytes: 256
/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

const LL INF = 99999999999999;
int a, b, q;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    scanf("%d%d%d", &a, &b, &q);
    vector<LL> s(a+2);
    vector<LL> t(b+2);
    s[0] = -INF;
    t[0] = -INF;
    s[a+1] = INF;
    t[b+1] = INF;
    for(int i = 1; i <= a; i++) scanf("%lld", &s[i]);
    for(int i = 1; i <= b; i++) scanf("%lld", &t[i]);
    while(q--) {
        LL x;
        scanf("%lld", &x);
        LL id1 = lower_bound(s.begin(), s.end(), x) - s.begin();
        LL id2 = lower_bound(t.begin(), t.end(), x) - t.begin();
        // printf("%lld, %lld, %lld, %lld\n", s[id1 - 1], s[id1], t[id2-1], t[id2]);
        LL s1 = abs(x - s[id1 - 1]);
        LL s2 = abs(x - s[id1]);
        LL t1 = abs(x - t[id2 - 1]);
        LL t2 = abs(x - t[id2]);
        LL ans = INF;
        ans = min(max(s1, t1), ans);
        ans = min(max(s2, t2), ans);
        ans = min(min(t1 * 2 + s2, t1 + s2 * 2), ans);
        ans = min(min(s1 * 2 + t2, s1 + t2 * 2), ans);
        
        printf("%lld\n", ans);
    }

    return 0;
}
/*
    input:
    output:
    modeling:
    methods:
    complexity:
    summary:
*/

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,c,d=0,e;
  cin>>a>>b;
  for(int i=0;i<a;i++){
    cin>>c;
    d+=(min(c,abs(b-c))*2);
  }
  cout<<d<<"\n";
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        Console.ReadLine();
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var q = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < q; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var b = int.Parse(line[0]);
            var e = int.Parse(line[1]);
            var k = int.Parse(line[2]);
            var ret = 0;
            for (int j = b; j < e; j++) if (a[j] == k) ret++;
            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 9380
import java.util.Scanner;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt()*sc.nextInt();
		int m = sc.nextInt()*sc.nextInt();
		System.out.println(n>m?n:m);
	}
}


Measured memory_bytes: 9684
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

ll N, Q;
string s;
vec<char> t, d;

template <typename Comp> bool simulate(ll pos, ll threshold, Comp comp) {
  REP(i, Q) {
    if (s[pos] == t[i]) {
      pos += ((d[i] == 'L') ? -1 : 1);
    }
  }
  return comp(pos, threshold);
}

template <typename Comp> ll search(ll ok, ll ng, ll threshold, Comp comp) {
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    (simulate(mid, threshold, comp) ? ok : ng) = mid;
  }
  return ok;
}

int main() {
  cin >> N >> Q >> s;
  t.resize(Q);
  d.resize(Q);
  REP(i, Q) { cin >> t[i] >> d[i]; }

  const ll l = search(-1, N, 0, less<ll>());
  const ll r = search(N, -1, N - 1, greater<ll>());

  cout << max(0ll, r - l - 1ll) << endl;
  return 0;
}


Measured memory_bytes: 976
n = int(input())
ls = sorted(map(int, input().split()))
MOD = 10**9 + 7
ok = True
if n % 2 == 0:
    for i in range(n // 2):
        i *= 2
        ok = ls[i] == ls[i + 1] == i + 1
        if not ok:
            break
else:
    ok = ls[0] == 0
    for i in range(n // 2):
        i *= 2
        ok = ls[i + 1] == ls[i + 2] == i + 2
        if not ok:
            break
if not ok:
    print(0)
else:
    print(2**(n // 2) % MOD)

Measured memory_bytes: 13880
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define pri 1000000007
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
using namespace std;
void run(){
	ll a,b;cin>>a>>b;
	ll z=max(b,a)+min(a,b);
	if(a==b)cout<<1<<endl;
	else if((z%2)!=0)cout<<"IMPOSSIBLE"<<endl;
	else cout<<(z/2)<<endl;
	
}
int main() {
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)run();
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

LL h[51];
LL patty[51];

LL ans(LL n, LL x){
  if(n==0&&x<=0) return 0;
  else if(n==0&&x>0) return 1;
  else if(x<=h[n-1]+1) return ans(n-1, x-1);
  else return ans(n-1, x-h[n-1]-2) +patty[n-1]+1;
}

int main(){
  int n;
  LL x;
  cin>>n>>x;

  h[0]=1;
  patty[0]=1;
  REP(i, 50){
    h[i+1]=3+2*h[i];
    patty[i+1]=1+2*patty[i];
    //cout<<i<<" "<<h[i]<<" "<<patty[i]<<endl;
  }
  cout<<ans(n, x)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int d;
  while (scanf("%d", &d) != EOF) {
    int i;
    int sum = 0;
    for (i = 1; i < 600 / d; i++) {
      sum += d * ((i * d) * (i * d));
    }
    printf("%d\n", sum);
  }
  return 0;
}

Measured memory_bytes: 596