akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

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


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

//define ll long long;
//define ar array;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int minimum_total = 10000000;
    int n, m, k;
    cin >> n >> m >> k;
    int books[n][m+1];

    for (int i = 0; i < n; i++){
        for (int j=0; j<m+1; j++){
            cin >> books[i][j];
        }
    }

    int x = 0b1;
    while (x < pow(2, n)){
        int temp = x;
        int pos = n-1;
        int cur_total = 0;
        int skill_level[13] = {0};
        while (temp > 0){
            int val = temp%2;
            if (val == 1){
                cur_total += books[pos][0];
                for (int i = 1; i< m+1; i++){
                    skill_level[i-1] += books[pos][i]; 
                }
            }
            temp /= 2;
            pos-=1;
        }
        int achieved = 1;
        for(int i = 0; i < m; i++){
            if (skill_level[i] < k) achieved = 0;
        }
        if (achieved){
            minimum_total = min(minimum_total, cur_total);
        }

        x += 1;
    }
    if (minimum_total < 10000000) {
        cout << minimum_total;
    }
    else {
        cout << -1;
    }
    return 0;
}



Measured memory_bytes: 4116
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define rep(i,a,b) for(register int i(a);i <= b;i++)
#define ll long long
using namespace std;
int main()
{
	//freopen("robot.in","r",stdin);
	//freopen("robot.out","w",stdout);
	int n,x,k(0);ll ans(1);
	cin>>n;
	rep(i,1,n)
	{
		scanf("%d",&x);
		++k;
		if(x < (k << 1) - 1) ans *= k,ans %= 1000000007,--k;
	}
	while(k != 1) ans *= k,ans %= 1000000007,--k;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
from typing import Dict, List, Optional, Tuple, Union  # noqa: F401


def main(X: int, N: int, p: List[int]):
    ans = 0

    if not p:
        ans = X
    else:
        p.sort()
        candidates: List[int] = [x for x in range(min(p) - 1, max(p) + 2) if x not in p]

        diff = 10**9
        for i in candidates:
            if abs(i - X) < diff:
                ans = i
                diff = abs(i - X)
    print(ans)



if __name__ == "__main__":
    X, N = map(int, input().split())
    p = list(map(int, input().split()))
    main(X, N, p)


Measured memory_bytes: 10272
N, M = map(int, input().split())
H = list(map(int, input().split()))
loser = set()
for _ in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        loser.add(B)
    elif H[A-1] < H[B-1]:
        loser.add(A)
    else:
        loser.add(A)
        loser.add(B)
print(N - len(loser))

Measured memory_bytes: 85128
# #! /bin/python

# a = int(input())
# b,c = map(int,input().split())
# s = input()

# print('{} {}'.format(a+b+c,s))

# 11 22 といった形で標準入力を数値で受け取る。
a,b = map(int,input().split())
# if (not (1 <= a <= 10000)) or (not (1 <= b <= 10000)):
#     print('over flow argument!')
#     exit()


def checkEvenOdd(a,b):
    mult = a * b

    if mult % 2:
        print('Odd')
    else:
        print('Even')

checkEvenOdd(a,b)

Measured memory_bytes: 2940
import numpy as np
N, M = map(int,input().split())
P_Y_list = np.array([input().split() for _ in range(0, M)], dtype='int')
counts = (np.zeros(N+1)).astype(int)
id_list = []

sort_ind = np.argsort(P_Y_list[:,1])
sorted_P_Y = P_Y_list[sort_ind]

for p, y in sorted_P_Y:
    counts[p] += 1
    id_list.append(str(p).zfill(6) + str(counts[p]).zfill(6))
id_list = np.array(id_list)
id_list = id_list[np.argsort(sort_ind)]
for id in id_list:
    print(id)

Measured memory_bytes: 50556
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(int i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int r = 0, b = 0;
	REP(i, s.size()) {
		if(s[i] == '0') r++;
		else b++;
	}
	cout << min(r, b) * 2 << endl;
	return 0;
}
/* --------------------------------------- */


Measured memory_bytes: 512
a,b=map(int,input().split())
cc=[input() for i in range(a)]
c=[[""for i in range(b)]for j in range(a)]
for i in range(a):
  for j in range(b):
    c[i][j]=cc[i][j]
d=[]
e=0
for i in range(a):
  e=0
  for j in range(b):
    if c[i][j]=="#":
      e=1
  if e==0:
    d.append(i)
for i in d:
  c.pop(i)
  for j in range(len(d)):
    d[j]=d[j]-1
d=[]
for i in range(b):
  e=0
  for j in range(len(c)):
    if c[j][i]=="#":
      e=1
  if e==0:
    d.append(i)
for i in d:
  for j in range(len(c)):
    c[j].pop(i)
  for j in range(len(d)):
    d[j]=d[j]-1

for i in range(len(c)):
  g=""
  for j in range(len(c[i])):
    g+=c[i][j]
  print(g)

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>

using namespace std;
int main(){
	int N,A,B;
	int ok = 0;
	int out = 0;
	string S;
	cin >> N >> A >> B >> S;

	for (int i = 0; i < (int)S.size(); i++){
		if (S[i] == 'c'){
			cout << "No" << endl;
			continue;
		}
		if (S[i] == 'b') out++;
		if (ok < A + B){
			if (S[i] == 'a'){
				ok++;
				cout << "Yes" << endl;
			}
			else if (S[i]=='b' && out <= B){
				ok++;
				cout << "Yes" << endl;
			}
			else{
				cout << "No" << endl;
			}
		}
		else{
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 896
#include<stdio.h>
int main(){
  int x[3000],y[3000],i,z;
  for(i=0;i<=3000;i++){
    scanf("%d%d",&x[i],&y[i]);
    if(x[i]>0 && y[i]>10000)break;
    if(x[i]==0 && y[i]==0)break;
  }
  for(z=0;z<i;z++){
    if(x[z]<=y[z])printf("%d %d\n",x[z],y[z]);
    if(x[z]>y[z])printf("%d %d\n",y[z],x[z]);
  }
  return 0;
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n = 5;
    vector<ll> a(n, 0), b(n, 0), c(n, 0);
    rep1(i, n){
        cin >> c[i];
        if (c[i]%10==0) a[i] = c[i];
        else a[i] = (c[i]/10+1)*10;
        b[i] = c[i]%10;
    }
    ll ndx = 0, mini = 200;
    rep1(i, n){
        if (b[i]==0) continue;
        if (mini > b[i]){
            ndx = i;
            mini = b[i];
        }
    }
    ll ans = 0;
    rep1(i, n){
        if (i == ndx) continue;
        ans += a[i];
    }
    ans += c[ndx];
    cout << ans << endl;
}

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

count = 0
flg = True

while flg:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = A[i] / 2
        else:
            flg = False
            print(count)
            exit()
    count += 1

Measured memory_bytes: 3060
<?php
fscanf(STDIN, "%d%d", $N, $K);
$dArray = explode(" ", trim(fgets(STDIN)));
for($i = $N; true; $i++){
  $flag = true;
  $I = (string)$i;
  for($j = 0; $j < strlen($I); $j++){
    if(in_array($I[$j], $dArray))$flag = false;
  }
  if($flag){
    echo $i,"\n";exit;
  }
}

Measured memory_bytes: 4732
#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<(int64)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;
 
//ONLINE_JUDGE   LOCAL
 
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 LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}


int main(){
	//in_o();
	int64 a,b;
    cin>>a>>b;
    int64 ans=min(a,b/2);
    b-=ans*2;
    ans+=b/4;
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var inputLine string
	fmt.Scan(&inputLine)
	runeS := []rune(inputLine)
	var nums []int
	for _, c := range runeS {
		n, _ := strconv.Atoi(string(c))
		nums = append(nums, n)
	}

	var temp int
	var s string
	for i := 0; i < (1 << uint(len(nums)-1)); i++ {
		temp = nums[0]
		s = strconv.Itoa(nums[0])
		for j := 0; j < (len(nums) - 1); j++ {
			if (i>>uint(j))&1 == 1 {
				temp += nums[j+1]
				s += "+" + strconv.Itoa(nums[j+1])
			} else {
				temp -= nums[j+1]
				s += "-" + strconv.Itoa(nums[j+1])
			}
		}
		if temp == 7 {
			s += "=7"
			fmt.Println(s)
			break
		}
	}
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int w=sc.nextInt();
        int h=sc.nextInt();
        int x=sc.nextInt();
        int y=sc.nextInt();
        int r=sc.nextInt();
        if(x-r<0||x+r>w||y-r<0||y+r>h){
            System.out.println("No");
        }
        else{
            System.out.println("Yes");
        }
    }
}



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

int main(){
	ll n;
	cin >> n;
	
	ll a[100005][5];
	
	rep(i,n){
		rep(j,3){
			cin >> a[i][j];
		}
	}
	
	ll dp[100005][5];
	
	rep(i,n+1){
		rep(j,3){
			dp[i][j] = 0;
		}
	}
	
	rep(i,n){
		rep(j,3){
			rep(k,3){
				if(j != k){
					dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k]);
				}
			}
		}
	}
	
	ll ans = 0;
	
	rep(i,3){
		ans = max(ans,dp[n][i]);
	}
	
	cout << ans << endl;
	
    return 0;
}

Measured memory_bytes: 8064
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(s):
        d = collections.defaultdict(int)
        ac = {}
        ca = {}
        for i in range(26):
            t = int(2**i)
            c = chr(ord('a') + i)
            ac[t] = c
            ca[c] = t
        a = [ca[c] for c in s]
        z = ca['z']
        d[0] = 1
        for c in a:
            nd = collections.defaultdict(int)
            c2 = c * 2
            for k,v in d.items():
                if k & c or c == 1:
                    nd[k] += v
                if c != z and k & c2 == 0:
                    nd[k|c2] += v
            d = nd
        r = [sum(d.values())]

        ss = set([''])
        for t in s:
            ns = set()
            t2 = chr(ord(t) + 1)
            for si in ss:
                if t in si or t == 'a':
                    ns.add(si + t)
                if t != 'z' and t2 not in si:
                    ns.add(si + t2)
            ss = set(sorted(ns)[:5])
        rs = ss

        ss = set([''])
        for t in s:
            ns = set()
            t2 = chr(ord(t) + 1)
            for si in ss:
                if t in si or t == 'a':
                    ns.add(si + t)
                if t != 'z' and t2 not in si:
                    ns.add(si + t2)
            ss = set(sorted(ns, reverse=True)[:5])
        rs |= ss
        r.extend(sorted(rs))

        return r

    while True:
        s = S()
        if s == '#':
            break
        rr.extend(f(s))

    return '\n'.join(map(str, rr))



print(main())



Measured memory_bytes: 11148
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v ) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 2019;

int main()
{
    LL L, R; cin >> L >> R;

    LL ans = LINF;
    if (R-L >= MOD) {
        ans = 0;
    } else {
        for (LL i = L; i < R; ++i) {
            for (LL j = i+1; j <= R; ++j) {
                chmin(ans, (i*j)%MOD);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
  "strings"
)

func main() {
  var n, k int
  var s string
  fmt.Scanf("%d %d", &n, &k)
  fmt.Scanf("%s", &s)
  
  ans := s[:k-1] + strings.ToLower(s[k-1:k]) + s[k:]
  fmt.Printf("%s\n", ans)
}

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

using namespace std;

int n,m;
int dp[1010][1 << 12];
int v[1010];
int val[1010];

int f(int pos, int mask) {
    if(pos == m) {
        if(mask == (1 << n) - 1) return 0;
        return 1e9;
    }
    int &ans = dp[pos][mask];
    if(ans != -1) return ans;
    ans = 1e9;
    ans = min(ans, f(pos + 1, mask | v[pos]) + val[pos]);
    ans = min(ans, f(pos + 1, mask));
    return ans;
}

int main() {
    memset(dp, -1, sizeof dp);
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; ++i) {
        int a,b;
        scanf("%d %d", &a, &b);
        val[i] = a;
        for (int j = 0; j < b; ++j) {
            int x;
            scanf("%d", &x);
            x--;
            v[i] |= (1 << x);
        }
    }
    int ans = f(0,0);
    if(ans == 1e9) puts("-1");
    else printf("%d\n", ans);
    return 0;
}


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

namespace CSTemplete211
{
    using P = System.Drawing.Point;
    class Utls
    {
        public static int[][] int2(int x, int y)
        {

            var ret = new int[x][];
            for (var i = 0; i < x; i++)
            {
                ret[i] = new int[y];
            }
            return ret;
        }
    }


    public class Class1
    {
        public Func<string> ReadLine = Console.ReadLine;
        public struct InputData
        {
            public int N;
            public int[] L;

        }
        public InputData input;
        public int[] hc, wc, hml, wml;
        public int hm, wm;
        public HashSet<P> f;



        static void Main()
        {
            var c = new Class1();
           
            c.Func();

        }
        public int Func()
        {

            this.input = this.Input();

            var l =  input.L.Distinct().ToArray();
            Array.Sort(l);
            Array.Reverse(l);
            var dic = new Dictionary<int, int>();
            var l2 = l.Select((n) =>
           {
               var cnt = input.L.Count((m) =>
               {
                   return n == m;
               });
               dic.Add(n, cnt);
               
               return n;
           }).ToArray();
            

            var ret = 0;
            for (int i = 0; i < l.Length; i++)
            {
                for (int j = i+1; j < l.Length; j++)
                {
                    for (int k  = j+1; k < l.Length; k++)
                    {
                        if (  l[i] <  l[j] + l[k])
                        {
                            ret += dic[l[i]] * dic[l[j]] * dic[l[k]];
                        }
                    }
                }
            }
            Console.WriteLine(ret);
            return ret;
        }

        public dynamic Input()
        {
            var ret = new InputData();

            ret.N = int.Parse(this.ReadLine());

            ret.L = this.ReadLine().Split(' ').Select(int.Parse).ToArray();

            

            return ret;
        }


    }
}


Measured memory_bytes: 35448
n,k = map(int,input().split())
child = [0 for _ in range(n)]
for i in range(1,k+1):
    d = int(input())
    a = [int(i) for i in input().split()]
    for j in a:
        child[j-1] += 1
count = 0
for i in child:
    if i==0:
        count += 1
print(count)

Measured memory_bytes: 67420
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 12/9/2018, 10:40:14 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
const ll infty = 100000000000000;

ll f(ll b, ll n)
{
  if (n < b)
  {
    return n;
  }
  return f(b, n / b) + n % b;
}

ll N, S;

int main()
{
  cin >> N >> S;
  if (N < S)
  {
    cout << -1 << endl;
    return 0;
  }
  if (N == S)
  {
    cout << N + 1 << endl;
    return 0;
  }
  for (ll b = 2; b * b <= N; b++)
  {
    if (f(b, N) == S)
    {
      cout << b << endl;
      return 0;
    }
  }
  ll ans = infty;
  for (ll p = 1; p * p <= N; p++)
  {
    ll q = S - p;
    if ((N - q) % p != 0)
    {
      continue;
    }
    ll b = (N - q) / p;
    if (!(0 <= q && q < b && p < b))
    {
      continue;
    }
    if (f(b, N) == S)
    {
      ans = min(ans, b);
    }
  }
  if (ans < infty)
  {
    cout << ans << endl;
  }
  else
  {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
int a[SIZE],b[SIZE];
int main(void)
{
	int n,k,t,i,j;
	ll res=0,sum;
	scanf("%d%d",&n,&k);
	FOR(i,0,n) scanf("%d%d",&a[i],&b[i]);
	FOR(i,0,n){
		if((k|a[i])==k) res+=b[i];
	}
	FOR(i,0,31){
		if(!(k>>i&1)) continue;
		t=0;
		FOR(j,0,i) t|=(1<<j);
		FOR(j,i+1,31){
			if(k>>j&1) t|=1<<j;
		}
		sum=0;
		FOR(j,0,n){
			if((t|a[j])==t) sum+=b[j];
		}
		res=MAX(res,sum);
	}
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using llGraph = vector<vl>;
using vb = vector<bool>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

template<typename T>
bool CompareBySecond(pair<T, T> a, pair<T, T> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

template<typename T>
T GCD(T a, T b) {
  T c = a % b;
  while (c != 0) { a = b; b = c; c = a % b; }
  return b;
}


/* -------- <templates end> -------- */


void solve() {
  int n; cin >> n;
  vector<string> str(3);
  rep(i,3) cin >> str[i];
  int ans = 0;
  rep(j,n) {
    set<char> s;
    rep(i,3) s.insert(str[i][j]);
    ans += s.size() - 1;
  }
  cout << ans << endl;
}


/* -------- <programs end> -------- */


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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        String[] a =  input.readLine().split(" ");
        for(String jude1 : a ){
            int jude2 = Integer.parseInt(jude1);
            if(jude2 % 2 == 0){
                if(!(jude2 % 5 == 0 || jude2 % 3 == 0)){
                    System.out.println("DENIED");
                    return;
                }
            }
        }
        System.out.println("APPROVED");
    }
}

Measured memory_bytes: 22612
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    vector<int> v(128, 0);
    for(int i=0; i<n; ++i)
        ++ v[s[i]];

    int ans = 0;
    for(int i=0; i<128; ++i){
        while(v[i] > 0){
            int len = 1;
            while(v[i+len] > 0)
                ++ len;

            if(len < 3){
                -- v[i];
                ++ ans;
            }
            else{
                for(int k=0; k<len; ++k)
                    -- v[i+k];
                ans += 3;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1188
def main():
    N = int(input())
    S = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
    judge = ''
    for i in range(N):
        judge = input()
        S[judge] += 1

    print('AC x {}'.format(S['AC']))
    print('WA x {}'.format(S['WA']))
    print('TLE x {}'.format(S['TLE']))
    print('RE x {}'.format(S['RE']))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9184
M = 10**9+7

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def main():
    X, Y = map(int, input().split())
    if (2*X-Y) % 3 != 0 or (2*Y-X) % 3 != 0 or 2*X < Y or 2*Y < X:
        ans = 0
    else:
        a = (2*X-Y)//3
        b = (2*Y-X)//3
        ans = cmb(a+b, a)%M
    print(ans)


if __name__ == '__main__': main()

Measured memory_bytes: 102028
// luogu-judger-enable-o2
    #include<bits/stdc++.h>
    #define int long long
    using namespace std;
    const int inf=1e9,mod=1e9+7;
    typedef long long ll;
    int read() {
    	int x=0,f=1;
    	char c=getchar();
    	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
    	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    	return x*f;
    }
    struct node {
    	int x,y,id;
    } a[1000001];
    multiset<int> red;
    multiset<int> blue;
    bool cmp(const node & a , const node & b ){
    	return a.x<b.x;	
    }
    int calc(){
    	return (*red.rbegin()-*red.begin())*(*blue.rbegin()-*blue.begin());
    }
    main() {
    	int n=read();
    	for(int i=1; i<=n; i++) {
    		a[i].x=read(),a[i].y=read();
    		if(a[i].x>a[i].y) swap(a[i].x,a[i].y);
    		red.insert(a[i].x);
    		blue.insert(a[i].y);
    	}
    	sort(a+1,a+1+n,cmp);
    	int minx=calc();
    	for(int i=1;i<=n;i++){
    		int x=a[i].x,y=a[i].y;
    		red.erase(red.find(a[i].x));
    		blue.erase(blue.find(a[i].y));
    		red.insert(a[i].y),blue.insert(a[i].x);
    		minx=min(minx,calc());
    	}
    	printf("%lld",minx);
    }

Measured memory_bytes: 25088
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
long long mod = 998244353;
int n, s;
vector<int> a;
vector< vector< long long > > dp;
int main(void){
    cin >> n >> s;
    a.assign(n+1, 0);
    for(int i=1;i<=n;i++) cin >> a[i];
    dp.assign(n+1, vector<long long>(s+1, 0));
    dp[0][0] = 1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=s;j++){
            dp[i][j] = dp[i-1][j];
            if(j > a[i]) dp[i][j] += dp[i-1][j-a[i]];
            if(j == a[i]){
                dp[i][j] += i;
            }
            dp[i][j] %= mod;
            // cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    long long ans = 0;
    for(int R=1;R<=n;R++){
        ans += dp[R][s];
        // cout << R << " " << dp[R][s] << endl;
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 70784
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,l,a[110010]={};
	cin>>n>>l;
	REP(i,n)cin>>a[i];
	int f=-1;
	FOR(i,1,n){
		int s=a[i-1]+a[i];
		if(s>=l)f=i;
	}
	if(f==-1)cout<<"Impossible"<<endl;
	else{
		cout<<"Possible"<<endl;
		FOR(i,1,n){
			if(i==f)break;
			cout<<i<<endl;
		}
		FORD(i,n,1){
			if(i==f)break;
			cout<<i<<endl;
		}
		cout<<f<<endl;
	}

    return 0;
}


Measured memory_bytes: 1280
def pad(n):
	n = str(n)
	if len(n) < 6:
		n = "0"*(6-len(n))+n
	return n

N,M = map(int,input().split())
PY = [list(map(int,input().split())) for _ in range(M)]

for i in range(M):
	PY[i].append(i)
PY.sort()

turn = 1
PY[0].append(pad(PY[0][0])+pad(turn))
for i in range(1,M):
	if PY[i][0] != PY[i-1][0]:
		turn = 1
	else:
		turn += 1
	PY[i].append(pad(PY[i][0])+pad(turn))

PY.sort(key = lambda x:x[2])
for i in range(M):
	print(PY[i][3])


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

const int INF = 1001001001;
int dp[1000005][2];

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  s += '0';
  int n = s.size();
  rep(i,n+1)rep(j,2) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i,n)rep(j,2) {
    int x = s[i]-'0';
    x += j;
    rep(a,10) {
      int ni = i+1, nj = 0;
      int b = a-x;
      if (b < 0) {
        nj = 1;
        b += 10;
      }
      dp[ni][nj] = min(dp[ni][nj], dp[i][j]+a+b);
    }
  }
  int ans = dp[n][0];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9220
#include<stdio.h>
#include<string.h>
int main(){
  char s[4];
  scanf("%s",s);
  if(s[0]==s[3] && s[1]==s[2] && s[0]!=s[2]){
    printf("Yes\n");
  }
  else if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]){
    printf("Yes\n");
  }
  else if(s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
///Author : - Code_X

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

ll power(ll x, ll y)
{
    ll res = 1;

    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

int main()
{
    int n,k;
    cin>>n>>k;
    if(k>1)
    cout<<n-k<<'\n';
    else cout<<"0"<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(llong i = 0;i < n;i++)
#define REPR(i, n) for(llong i = n;i >= 1;i--)
#define FOR(i, m, n) for(llong i = m;i < n;i++)
#define FORR(i, m, n) for(llog i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
llong mod = 1000000007;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll n, ll x) {
    ll ret,r;
    if(n-x >= x) {
        ret = n + 2*((n-x)/x)*x;
        r = (n-x)%x;
        if(r) ret += f(x, r) - (x-r) + r;
        else ret -= x;
    }
    else {
        return f(n, n-x);
    }
    return ret;

}
int main() {
    ll n,x;
    cin>>n>>x;
    cout<<f(n, x)<<'\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 10000000000000;

int main() {
	string s;
	cin >> s;
	if (s == "Sunny")cout << "Cloudy" << endl;
	else if (s == "Cloudy")cout << "Rainy" << endl;
	else cout << "Sunny" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;
	public static final long HUGE_NUM = 99999999999999999L;
	public static final double EPS = 0.000000001;

	public static int H,W;

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {

		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(System.in);

		int num_set = scanner.nextInt();

		StringBuilder ans = new StringBuilder();

		for(int loop = 0; loop < num_set; loop++){

			int N = scanner.nextInt();

			int up_max = 0,down_max = 0;

			int pre = scanner.nextInt();
			int tmp;

			for(int i = 1; i < N; i++){

				tmp = scanner.nextInt();
				if(tmp > pre){

					up_max = Math.max(up_max, tmp-pre);

				}else if(tmp < pre){

					down_max = Math.max(down_max, pre-tmp);
				}
				pre = tmp;
			}

			ans.append(Integer.toString(up_max)).append(" ").append(Integer.toString(down_max)).append("\n");
		}
		System.out.print(ans.toString());
	}
}


Measured memory_bytes: 34776
import numpy as np
import sys

_,Q = map(int,input().split())
S = input()

ac_counter = np.zeros(len(S),dtype=np.int)
for i in range(len(S)-1):
    if S[i]=="A" and S[i+1]=="C":
        ac_counter[i+1] = ac_counter[i]+1
    else:
        ac_counter[i+1] = ac_counter[i]


for _ in range(Q):
    l,r = map(int,input().split())
    result = ac_counter[r-1] - ac_counter[l-1]
    print(result)



Measured memory_bytes: 15832
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
string S;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;
 
    int ans = 1010;
    rep(i, 0, 26) {
        char c('a' + i);
 
        vector<int> id;
        rep(j, 0, S.length()) if (S[j] == c) id.push_back(j);
        if (id.size() == 0) continue;
 
        int ma = 0;
        rep(j, 0, id.size() - 1) {
            int a = id[j];
            int b = id[j + 1];
            ma = max(ma, (b - a - 1));
        }
        ma = max(ma, id.front());
        ma = max(ma, (int)S.length() - id.back() - 1);
 
        ans = min(ans, ma);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i > 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  int a, b; cin >> a >> b;

  string c, s = "";
  
  if (a < b) {
    c = to_string(a);
    REP(i, b) {
      s += c;
    }
  } else {
    c = to_string(b);
    REP(i, a) {
      s += c;
    }
  }
  
  cout << s << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <limits.h>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void){
    ll n, a[200020];
    bool picked[200020];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    
    fill(picked, picked + n, true);
    sort(a, a + n);
    
    int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (picked[i]) {
            ll b = 1;
            while (b <= a[i]) b *= 2;
            
            ll low = 0, high = i;
            while (high - low > 1) {
                ll mid = (low + high) / 2;
                if (a[mid] <= b - a[i]) low = mid;
                else high = mid;
            }
            
            while (!picked[low]) {
                low--;
            }
            
            if (low != i && a[low] + a[i] == b) {
                picked[low] = picked[i] = false;
                ans++;
                //cout << low << " " << i << endl;
            }
        }
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <queue>
#include <cassert>
#include <map>
#include <unordered_map>
#include <set>
using namespace std; typedef long long ll; const int MINF=-1e9; typedef pair<int,int> P;

int main() {
  int h,w; cin>>h>>w;
  /*
  string ss[h]; for(int i=0;i<h;i++) cin>>ss[i];
  
  int n=0;
  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      if (ss[i][j] == '#') n++;
    }
  }

  int x[n], y[n];
  set<P> s;
  for(int i=0,k=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      if (ss[i][j] == '#')
        x[k]=i, y[k]=j, s.insert({i,j}), k++;
    }
  }*/
  
  int n; cin>>n;
  int x[n], y[n];
  set<P> s;
  for(int i=0;i<n;i++) {
    cin>>x[i]>>y[i]; x[i]--; y[i]--;
    s.insert({x[i],y[i]});
  }

  int t[w]; for(int i=0;i<w;i++) t[i]=h;
  {
    int i=0,j=0;
    while(i<h && j<w) {
      //cout<<i<<" "<<j<<endl;
      if (s.find({i,j}) != s.end()) j--;
      //cout<<i<<" "<<j<<endl;
      t[j]=min(i,t[j]); i++; j++;
    }
  }
  //for(int i=0;i<w;i++) cout<<t[i]<<" "; cout<<endl;
  int an=h;
  for(int i=0;i<n;i++) {
    if (t[y[i]] < x[i]) an=min(an, x[i]);
  }
  cout<<an<<endl;
}

Measured memory_bytes: 11904
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, x; 
  cin >> N >> x;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  // dp[i][j][k]: i番目まで見た時, j個使って合計がkとなる個数
  vector<vector<vector<int>>> dp(N+1, vector<vector<int>>(100, vector<int>(3000, 0)));
  dp[0][0][0] = 1;
  REP(i, N){
    REP(j, N){
      RREP(k, 3000){
        dp[i+1][j+1][k+A[i]] += dp[i][j][k];
        dp[i+1][j][k] += dp[i][j][k];
      }
    }
  }

  int ans = 0;
  for(int i = 1; i*x < 3000 && i <= N; i++){
    ans += dp[N][i][i*x];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 122368
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int n, a;
  cin >> n >> a;
  if ((n % 500) <= a) Yes;
  else No;
  return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	int ans=0;
	rep(i,0,n){
		int a,b; cin>>a>>b;
		ans+=(b-a)+1;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3552
use proconio::input;

fn main(){
    input!{n:i32};
    let mut ans = vec![0;n as usize];
    for sum in 3..=2020 {
        for i in 1..=sum-2{
            for j in 1..=sum-1-i {
                let k = sum - i - j;
                let tmp = sum*sum - i*j - j*k - i*k;
                if tmp > 0 && tmp <= n {ans[(tmp-1) as usize] += 1;}
            }
        }
    }
    for i in ans.iter() {
        println!("{}",*i);
    }
}

Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, seisu, marume;
  double avg;
  cin >> a;
  cin >> b;
  avg = (a + b)/2.0;
  seisu = (a + b)/2;
  marume = (avg - seisu)*2;
  cout << seisu+marume << endl;
}

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

int main() {
  long long A, B;
	cin >> A >> B;
	for (int i = 0; i < 2000; i++) {
		if (i * 2 / 25 == A && i / 10 == B) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


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

using namespace std ;

int main()
{

    int a,b,c,x ,cnt;
    cin>>a>>b>>c>>x ;

    cnt  = 0 ;
    for(int i=0 ; i<=a; i++)
    {
        for(int j=0 ; j<=b ; j++)
        {
            for(int k= 0 ; k<=c; k++)
            {
                if( i*500+ j*100+ k*50 == x )
                {
                    cnt++ ;
                }
            }
        }
    }

    cout<<cnt <<endl ;
    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void){
  int n; cin >> n;
  map<int, int> mp;
  rep(i, n){
    int a; cin >> a;
    if(a){
      mp[a]++;
      mp[a-1]++;
      mp[a+1]++;
    }
    else {
      mp[a]++;
      mp[a+1]++;
    }
  }
  int ans = 0;
  for(auto x : mp){
    ans = max(ans, x.second);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<pair<ll, pair<int, int>>> E(M);
  int a, b, c;
  for (int i = 0; i < M; ++i) {
    scanf("%d %d %d", &a, &b, &c);
    E[i] = make_pair(c, make_pair(a, b));
  }

  ll ans = -LLINF;
  vector<ll> dist(N + 5, -LLINF);
  dist[1] = 0;
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < N - 1; ++j) {
      for (int k = 0; k < M; ++k) {
        ll d = E[k].first;
        int u = E[k].second.first, v = E[k].second.second;
        if (dist[u] != -LLINF and dist[v] < dist[u] + d) {
          dist[v] = dist[u] + d;
        }
      }
    }
    if (i == 0) { ans = dist[N]; }
    else {
      if (dist[N] > ans) {
        printf("inf\n");
        return 0;
      }
    }
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
arr=[]
3.times{
    
    arr<<gets.split.map(&:to_i)}

a=arr[0][0]
b=arr[0][1]
c=arr[0][2]
d=arr[1][0]
e=arr[1][1]
f=arr[1][2]
g=arr[2][0]
h=arr[2][1]
i=arr[2][2]

if d-a==e-b && e-b==f-c && g-d==h-e && h-e==i-f && b-a==e-d && e-d==h-g && c-b==f-e&& f-e==i-h
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int main(){
  int n;
    cin >> n;
  int a[100000], x;
    for(int i=0; i<n; i++) a[i]=-1;
    for(int i=0; i<n;i++){
      cin >> x;
      a[i] = x-1;
    }
    int cnt=0;
    for(int i=0; i<n;i++){
      if(i==a[a[i]]) cnt += 1;
      //cout << a[a[i]] << i << endl;
    }
    cout << cnt/2 << endl;

}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    char str[5];
    scanf("%s", str);
    int a_cnt = 0;
    int b_cnt = 0;
    int c_cnt = 0;
    
    for(int i = 0; i < 3; i++){
        if(str[i] == 'a')       a_cnt++;
        if(str[i] == 'b')       b_cnt++;
        if(str[i] == 'c')       c_cnt++;
        
        // printf("%c ", str[i]);
    }
    // printf("\n");
    
    if(a_cnt != 1 || b_cnt != 1 || c_cnt != 1){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
}

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

int main(){
	int N;
	cin >> N;
	vector<int> L(N);
	int edge = 0;
	for (int i = 0;i < N;++i) {
		cin >> L[i];
		edge += L[i];
	}
	sort(L.begin(), L.end());
	cout << (edge - L[L.size() - 1] > L[L.size() - 1] ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256