akhauriyash/Code-Regression huggingface dataset:
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

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

//get vector of prime numbers which is lower than or equal n
vector<int> get_primes(int n)
{
    vector<bool> is_prime(n + 1, true);
    vector<int> res;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++)
    {
        if (is_prime[i])
        {
            res.push_back(i);
            for (int j = 2 * i; j < is_prime.size(); j = j + i)
            {
                is_prime[j] = false;
            }
        }
    }
    return res;
}

vector<pair<int, int>> factorize(int n)
{
    vector<pair<int, int>> res;
    for (int i = 2; i * i <= n; i++)
    {
        int tmp = 0;
        while (n % i == 0)
        {
            tmp++;
            n /= i;
        }
        res.push_back(make_pair(i, tmp));
    }
    if (n != 1)
    {
        res.push_back(make_pair(n, 1));
    }
    return res;
}

int mpow(int x, int n)
{
    int res = 1;
    while (n != 0)
    {
        if (n & 1)
            res = res * x % INF;
        x = x * x % INF;
        n = n >> 1;
    }
    return res;
}

//mod frac
vector<int> mfrac;
void set_mfrac(int n)
{
    if (mfrac.size() == 0)
    {
        mfrac.push_back(1);
    }
    for (int i = mfrac.size(); i <= n; i++)
    {
        mfrac.push_back((i * mfrac[i - 1]) % INF);
    }
}

//get nCm mod INF
int mcomb(int n, int m)
{
    if (mfrac.size() <= n)
    {
        set_mfrac(n);
    }
    int res = mfrac[n];
    res = res * mpow(mfrac[m], INF - 2) % INF;
    res = res * mpow(mfrac[n - m], INF - 2) % INF;
    return res;
}

signed main()
{
    int N;
    cin >> N;
    vector<pair<int, pair<int, int>>> data;
    for (int i = 0; i < N; i++)
    {
        int x, y, h;
        cin >> x >> y >> h;
        data.push_back(make_pair(h, make_pair(x, y)));
    }

    sort(data.begin(), data.end(), greater<pair<int, pair<int, int>>>());

    int ah;
    for (int ax = 0; ax <= 100; ax++)
    {
        for (int ay = 0; ay <= 100; ay++)
        {
            ah = data[0].first + abs(data[0].second.first - ax) + abs(data[0].second.second - ay);
            bool is_ans = true;
            for (int k = 1; k < data.size(); k++)
            {
                if (max(ah - abs(data[k].second.first - ax) - abs(data[k].second.second - ay), 0) != data[k].first)
                {
                    is_ans = false;
                    break;
                }
            }
            if (is_ans)
            {
                cout << ax << " " << ay << " " << ah << endl;
                return 0;
            }
        }
    }
    cout << "hoge" << endl;
}

Measured memory_bytes: 256
M, D = map(int, input().split())
cnt = 0
for m in range(1, M + 1):
  for d in range(1, D + 1):
    d10 = d // 10
    d1 = d - d10 * 10
    if d10 >= 2 and d1 >= 2:
      if d1 * d10 == m:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
N = int(input())
p = [list(map(int,input().split())) for _ in range(N)]

z = []
w = []

for i in range(N):
  z.append(p[i][0] + p[i][1])
  w.append(p[i][0] - p[i][1])

print(max(max(z)-min(z),max(w)-min(w)))

Measured memory_bytes: 61276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n);
    vector<int> b(1000001);
    rep(i,n){
        cin >> a[i];
        b[a[i]]++;
    }
    vector<bool> c(n,true);
    rep(i,n){
        if(a[i]==1){
            if(b[1]>2){
                c[i]=false;
            }
            continue;
        }
        if(b[1]){
            c[i]=false;
            continue;
        }
        for(int j=2;j*j<=a[i];j++){
            if(a[i]%j==0){
                if(b[j]){
                    c[i]=false;
                    break;
                }
                if(j*j!=a[i]){
                    if(b[a[i]/j]){
                        c[i]=false;
                        break;
                    }
                }
            }
        }
    }
    int ans=0;
    rep(i,n){
        if(c[i]&&b[a[i]]==1){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7944
//Tag : #
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>

#define Inf                     1001001001
using namespace std;

typedef long long int           ll;
typedef pair<ll, ll>            p_ll;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
typedef unsigned char           uchar;
typedef unsigned int            ui;
typedef unsigned long long int  ull;
/*************************************************/
int N, ans(0);
string X;

void input() {
    cin >> N >> X;
}

void sol() {
    for (int i = 0; i < N - 2; i++)
        if (X[i] == 'A')
            if (X[i + 1] == 'B' && X[i + 2] == 'C')
                ans++;
    cout << ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(); cout.tie();
    input();
    sol();
    return 0;
}


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

long long int x;
long long int ans;

int main(){
	scanf("%lld", &x);
	ans += x / 11 * 2;
	x %= 11;
	if(x >= 7) ans += 2;
	else if(x != 0) ans ++;
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
(defun list-slice (lst x1 x2 y1 y2)
  (mapcar (lambda (k) (subseq k x1 x2)) (subseq lst y1 y2)))
(let* ((n (read))
       (m (read))
       (lst-a (loop :repeat n :collect (concatenate 'list (read-line))))
       (lst-b (loop :repeat m :collect (concatenate 'list (read-line)))))
  (if (loop :for x :from 0 :upto (- n m)
            :always(loop :for y :from 0 :upto (- n m) :never (equal lst-b (list-slice lst-a x (+ x m) y (+ y m)))))
      (format t "No~%")
      (format t "Yes~%")))


Measured memory_bytes: 14688
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n, k = geta(int)
    p = list(geta(int))

    p.sort()

    print(sum(p[:k]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9520
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 11;
int n, m;
int dl[N], dis[N], fr[N];
vector<int> G[N];
int main(){
    cin>>n>>m;
    memset(dis, -1, sizeof dis);
    int u, v;
    for(int i = 1;i <= m; i++){
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int hd = 0, tl = 0;
    dl[++tl] = 1;
    dis[1] = 0;
    while(hd < tl){
        u = dl[++hd];
        for(int v : G[u]){
            if(dis[v] != -1)continue;
            dis[v] = dis[u] + 1;
            fr[v] = u;
            dl[++tl] = v;
        }
    }
    if(hd != n){
        puts("No");
    }
    else{
        puts("Yes");
        for(int i = 2;i <= n; i++){
            printf("%d\n", fr[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 11256
import sys
input=sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))

from functools import reduce
import fractions
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
num=lcm_list(a)
ans=0
for tmp in a:
    ans+=num//tmp
print(ans%(10**9+7))

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

template <int MOD_>
struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");
 
private:
	using ll = long long;
 
	int v;
 
	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}
 
public:
 
	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }
 
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }
 
	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
 
	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}
 
	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}
 
	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<998244353>;

const int MAXN = 2.1e5;
int N;
string X_;
bool X[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> X_;
	for (int i = 0; i < N; i++) {
		X[i] = bool(X_[i] - '0');
	}

	num ans = 0;
	unordered_map<int, num> weights;
	for (int p = 2*N; p >= 1; p--) {
		if ((2*N) % p != 0 || N % p == 0) continue;
		assert(p % 2 == 0);

		num weight = p;
		for (auto it : weights) {
			if (it.first % p == 0) {
				weight -= it.second;
			}
		}
		weights[p] = weight;

		num ways = 0;
		for (int i = 0; i < p/2; i++) {
			ways *= 2;
			ways += int(X[i]);
		}
		bool canEqual = true;
		for (int i = 0; i < N; i++) {
			bool v = X[i % (p/2)] ^ ((i / (p/2) & 1));
			if (v < X[i]) {
				break;
			}
			if (v > X[i]) {
				canEqual = false;
				break;
			}
		}
		ways += int(canEqual);
		ans += ways * weight;
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 788
#include<bits/stdc++.h>
#define N 500005
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,p,q,c[N],x[N],ans;
priority_queue<ll> X;

int main(){
  cin>>n>>p>>q;
  for(int i=0;i<n;i++)cin>>c[i];
  for(int i=0;i<n;i++)
    x[i]=p*q,q++,ans+=x[i];
  for(int i=0;i<n;i++)
    X.push(c[i]-x[i]-2*p*(n-i-1));
  ll cnt=0,sum,maxsum=0;
  while(!X.empty()){
    ll t=X.top(); X.pop();
    sum+=t+cnt*(2*p);
    maxsum=max(maxsum,sum);
    cnt++;
  }
  cout<<ans+maxsum<<endl;
  return 0;
}

Measured memory_bytes: 14876
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int64_t X;
cin >> X;
for (int i = 0;i < INF;i++) {
    int i5 = i*i*i*i*i;
    for (int j = 0;j < i;j++) {
        int j5 = j*j*j*j*j;
        if (i5-j5 == X) {
            cout << i << " " << j << endl;
            return 0;
        } else if (i5+j5 == X) {
            cout << i << " " << -j << endl;
            return 0;
        }
    }
}



return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(void)
{
    int a;
    char blood[3];
    int countA = 0,countB = 0,countAB = 0,countO = 0;
    while(scanf("%d,%s",&a,blood) != EOF){
        if(blood[1] == 'B') countAB++;
        else if(blood[0] == 'B') countB++;
        else if(blood[0] == 'A') countA++;
        else countO++;
    }
    printf("%d\n",countA);
    printf("%d\n",countB);
    printf("%d\n",countAB);
    printf("%d\n",countO);
    return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

class Main
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		if (a < b){
			System.out.println("a < b");}
		else if (a > b){
			System.out.println("a > b");}
		else{
			System.out.println("a == b");}
	}
}


Measured memory_bytes: 26364
# require 'pp'
N = gets.to_i
a = gets.split.map(&:to_i)
org = a.inject(:+)
b = gets.split.map(&:to_i) + [0]
for i in 0..N
    if a[i] <= b[i-1]
        b[i-1] = b[i-1] - a[i]
        a[i] = 0
    else
        a[i] = a[i] - b[i-1]
        b[i-1] = 0
    end
    if a[i] <= b[i]
        b[i] = b[i] - a[i]
        a[i] = 0
    else
        a[i] = a[i] - b[i]
        b[i] = 0
    end
    # puts "i = #{i}"
    # pp a
    # pp b
end
dst = a.inject(:+)
puts org - dst

Measured memory_bytes: 16276
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int n; cin>>n;
    int m=n;
    int a=0;
    while(true){
        a=a+n%10;
        n=n/10;
        if(n/10==0&&n%10==0){
            break;
        }
    }
    if(m%a==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


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

int main()
{
    string S;
    cin >> S;
    vector<int> count(26, 0);
    for (int i = 0; i < S.size(); i++)
    {
        count[S[i] - 'A']++;
    }
    bool ans = true;
    int exist = 0;
    for (auto c : count)
    {
        if (c > 0)
        {
            if (c == 2)
            {
                exist++;
            }
            else
            {
                ans = false;
            }
        }
    }
    if (exist != 2)
    {
        ans = false;
    }
    if (ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

int main(){
  string s;
  cin >> s;
  if(s<="2019/04/30"){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
 
int main(){

	ll n, a[200000], total=0, ans=1e12;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
		total+=a[i];
	}
	if(n==2){
		cout << abs(a[0]-a[1]) << endl;
		return 0;
	}
	ll tmp=0;
	for(int i=0; i<n-1; i++){
		total-=a[i];
		tmp+=a[i];
		ans=min(ans, abs(total-tmp));
	}
	
	cout << ans << endl;

	return 0;
}


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

int main() {
  int n,t;
  cin >> n >> t;
  int ans=t;
  vector<int> v(n,0);
  r(i,n)cin >> v[i];
  r(i,n-1){
    if(v[i+1]-v[i]<t)ans+=v[i+1]-v[i];
    else ans+=t;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
n = int(input())
s = input()

kumikazu = s.count('R')*s.count('B')*s.count('G')

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2*j-i
        if k >= n:
          break
        if (s[i] != s[j]) and (s[i] != s[k]) and (s[j] != s[k]):
                kumikazu -= 1
print(kumikazu)




Measured memory_bytes: 9088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] nums = br.readLine().split(" ");
		int[] numsInt = new int[2];
		numsInt[0] = Integer.parseInt(nums[0]);
		numsInt[1] = Integer.parseInt(nums[1]);
		if(-1000000 > numsInt[1] - numsInt[0]){
			for(int i =-1000000; i<numsInt[1]+numsInt[0]; i++){
				if(i == -1000000){
					System.out.print(i);
				}else{
					System.out.print(" " + i);
				}
			}
		}
		else if(1000000 < numsInt[1] + numsInt[0]){
			for(int i=numsInt[1]-numsInt[0]+1; i<1000001; i++){
				if(i == numsInt[1]-numsInt[0]+1){
					System.out.print(i);
				} else{
					System.out.print(" " + i);
				}
			}
		}
		else{
			for(int i=numsInt[1]-numsInt[0]+1; i<numsInt[1]+numsInt[0];i++){
				if(i == numsInt[1]-numsInt[0]+1){
					System.out.print(i);
				} else{
					System.out.print(" " + i);
				}
			}
		}
	}
}


Measured memory_bytes: 21204
#include <stdio.h>

int main(void) {
  char b;
  scanf("%c", &b);

  if(b == 'A') {
    printf("T\n");
  } else if(b == 'C') {
    printf("G\n");
  } else if(b == 'G') {
    printf("C\n");
  } else if(b == 'T') {
    printf("A\n");
  }
  return 0;
}


Measured memory_bytes: 128
n = int(input())
dp = [{"a":0,"b":0,"c":0} for _ in range(n+1)]

for i in range(n):
    a, b, c = map(int,input().split())
    dp[i+1]["a"] = max(dp[i]["b"],dp[i]["c"]) + a
    dp[i+1]["b"] = max(dp[i]["a"],dp[i]["c"]) + b
    dp[i+1]["c"] = max(dp[i]["a"],dp[i]["b"]) + c
print(max(dp[n].values()))

Measured memory_bytes: 83060
//vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n,m; cin >> n >> m;
  vector<vector<int>> A(n, vector<int>(m));//int型の2次元配列(3×4要素の)の宣言
  rep(i,n){
    int k; cin >> k;
    rep(j,k){
      cin >> A.at(i).at(j);
    }
  }
  
/*  rep(i,n){
    rep(j,m){
      cout << A.at(i).at(j);
      }
    cout << endl;
    }
*/

  vector<int>c(m);
/*  rep(i,m){
      cout << c.at(i);
  }
*/
  
  rep(i,n){
    rep(j,m){
      if(A.at(i).at(j)!=0){
//        int num = A.at(i).at(j);
//        num = num -1;
//        c.at(num) += 1;
        c.at(A.at(i).at(j)-1) += 1 ;
      }
    }
  }
  int count=0;
  rep(i,m){
    if(c.at(i)==n)count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main(){
    ll n; cin >> n;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    cout << (((((modpow(10, n, MOD) + modpow(8, n, MOD)) % MOD) - modpow(9, n, MOD) + MOD) % MOD) - modpow(9, n, MOD) + MOD) % MOD << endl;
}


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

#define rep(i,n) for(int (i)=0;(i)<n;++(i));
#define SORT(s) sort((s).begin(),(s).end());
#define SORTR(s) sort((s).begin(),(s).end(),greater<int>());

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const double PI=acos(-1.0);

int N,K;
int input()
{  
    cin>>N>>K;
}

int solve()
{
    double ans=double(0);
    for(int i=N;i>=1;--i){
        int d=1; int j=i;
        while(j<K){
            d*=2; j*=2;
        }
        ans+=double(1)/double(d)/double(N);
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

int main(){
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

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

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
int main(){
    LL k, n;
    cin >> k >> n;
    VL a(n), b(n);
    REP(i, n){
        cin >> a[i];
    }
    FOR(i, 1, n){
        b[i]=a[i]-a[i-1];
    }
    b[0]=a[0]+(k-a[n-1]);
    sort(b.begin(), b.end());
    LL ans = k-b[n-1];
    cout << ans << endl;

}
    




Measured memory_bytes: 3328
import sys
from collections import deque

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, K = MAP()
A = [MAP() for _ in range(N)]

A.sort()
cur = 0
for a in A:
	cur += a[1]
	if cur >= K:
		print(a[0])
		break

Measured memory_bytes: 21972
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		long a = long.Parse(input[0]);
		long v = long.Parse(input[1]);
		input = Console.ReadLine().Split(' ');
		long b = long.Parse(input[0]);
		long w = long.Parse(input[1]);
		input = Console.ReadLine().Split(' ');
		long t = long.Parse(input[0]);

		bool success = false;
		if(w >= v) success = true;
		else if (Math.Abs(a-b) > (v-w)*t) success = true;

		Console.WriteLine(success ? "NO" : "YES");

	}
}



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

using namespace std;

typedef long long LL;
typedef double db;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;
int main()
{
	int n , m;
	cin >> n >> m;
	if(n + m >= 10)cout << "error" << endl;
	else cout << n + m << endl;
	return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int cnt=0;
    while(A!=B || B!=C){
        //C<B<Aの順にする
        if(A<B) swap(A,B);
        if(B<C) swap(B,C);
        if(A<B) swap(A,B);
        if(A!=B && B!=C){
            int tmp=A-B;
            cnt+=tmp;
            B+=tmp;
            C+=tmp;
        }else if(A==B){
            int tmp=A-C;
            if(tmp%2) ++tmp;
            cnt+=tmp/2;
            C+=tmp;
        }else if(B==C){
            int tmp=A-B;
            cnt+=tmp;
            B+=tmp;
            C+=tmp;
        }
        //cout << A << " " << B <<" " << C << endl;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *x, int *y)
{
    int tmp;
    tmp = *x;
    *x = *y;
    *y = tmp;
}

int main(void)
{
    int i, j, N, tmp;
    int ans=0, alice=0, bob=0;
    scanf("%d", &N);

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

    while(j<N-1)
    {
        for(i=N-1; i>j; i--)
        {
            if(a[i]>a[i-1])
            {
                swap(&a[i], &a[i-1]);
            }
        }
        j++;
    }

    for(i=0; i<N; i++)
    {
        if(i % 2 == 0)
        {
            alice += a[i];
        }
        else
        {
            bob += a[i];
        }
    }

    ans = alice - bob;

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

    return 0;
}


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

using namespace std;
#define sz(a) (int)a.size()
const int MAXN = 2e5 + 228;
template<typename T1, typename T2>
ostream &operator<<(ostream &out, pair<T1, T2> &p) {
     out << "{" << p.first << ", " << p.second << "} ";//optional
     return out;
}

template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
     in >> p.first >> p.second;
     return in;
}

template<typename T>
istream &operator>>(istream &in, vector<T> &arr) {
     for (auto &i : arr)
          in >> i;
     return in;
}

template<typename T>
ostream &operator<<(ostream &out, vector<T> &arr) {
     for (int i = 0; i < (int)arr.size(); ++i) {
          if (i != 0) {
               out << ' ';
          }
          out << arr[i];//optional
     }
     out << endl;
     return out;
}


#define SIZE 200005
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair <int,int> P;

ll inv[SIZE],fac[SIZE],finv[SIZE];
void make()
{
     fac[0]=fac[1]=1;
     finv[0]=finv[1]=1;
     inv[1]=1;
     for(int i=2;i<SIZE;i++)
     {
          inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
          fac[i]=fac[i-1]*(ll) i%MOD;
          finv[i]=finv[i-1]*inv[i]%MOD;
     }
}
ll C(int a,int b)
{
     if(a<b) return 0;
     return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
signed main()
{
     make();
     int W,H,A,B;
     scanf("%d %d %d %d",&H,&W,&A,&B);W--,H--;
     ll ret=C(W+H,W);
     for(int i=0;i<B;i++)
     {
          ll all=C((H-A)+i,i);
          ll all2=C((W-i)+(A-1),A-1);
          ret-=all*all2%MOD;
          if(ret<0) ret+=MOD;
     }
     printf("%lld\n",ret);
     return 0;
}


Measured memory_bytes: 4992
import sys
import numpy as np

x = int(input())

a = np.arange(255)
b = a**5
for i in range(255):
    for j in range(255):
        if b[i] + b[j] == x:
            print(i, -j)
            sys.exit()
        if b[i] - b[j] == x:
            print(i, j)
            sys.exit()

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

int vector_finder(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}


int main(void){
    ll X=0;
    ll N=0;
    cin>>X>>N;
    bool flag=0;
    ll abs1=-1;
    ll abs2=-1;
    
     vector<ll> vec(N);
    for (ll i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    
    sort(vec.begin(), vec.end());
    
    for (ll i = 0; i < 102; i++) {
        if(i>=X){
            if(vector_finder(vec,i)!=1){
            abs1=i-X;
            break;
        }
    }
    }
    
    for (ll i = 0; i < 102; i++) {
        if(100-i<=X){
            if(vector_finder(vec,100-i)!=1){
            abs2=X-(100-i);
            break;
            }
        }
    }
    
    // cout<<abs1<<endl;
    // cout<<abs2<<endl;
    if(abs1<abs2){
        cout<<X+abs1<<endl;
    }
    else{
        cout<<X-abs2<<endl;
    }
    
        
}

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



int main() {
    int n, m;
    cin >> n >> m;
    
    int ans_l = 1, ans_r = n;
    rep(i,m) {
        int l, r;
        cin >> l >> r;
        
        ans_l = max(ans_l, l);
        ans_r = min(ans_r, r);
    }
    
    cout << max(ans_r - ans_l + 1, 0) << endl;
    
    
    return 0;
}


Measured memory_bytes: 3604
/*
ID: skipian1
PROB: 
LANG: C++11
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF = 2000000000
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define X first
#define Y second

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) {
    cout << "Yes" << "\n";
  } else {
    cout << "No" << "\n";
  }
}


Measured memory_bytes: 384
""" AtCoder """

A, B = map(int, input().split())

if A % 2 == 0 and B % 2 == 0:
    if (B - A) % 4 == 0:
        tmp = 0
    else:
        tmp = 1
    print(tmp ^ B)
elif A % 2 != 0 and B % 2 == 0:
    if (B - A - 1) % 4 == 0:
        tmp = 0
    else:
        tmp = 1
    print(A ^ tmp ^ B)
elif A % 2 == 0 and B % 2 != 0:
    if (B - A + 1) % 4 == 0:
        tmp = 0
    else:
        tmp = 1
    print(tmp)
else:
    if (B - A) % 4 == 0:
        tmp = 0
    else:
        tmp = 1
    print(A ^ tmp)


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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(){
  ll N,M,ans=0;
  cin>>N>>M;
  
  ll DP[1<<N];
  REP(i,1<<N) DP[i]=INF;
  DP[0]=0ll;
  
  REP(i,M){
    ll A,B,C=0;
    cin>>A>>B;
    REP(j,B){
      ll c;
      cin>>c;
      C+=1<<(c-1);
    }
    for(ll j=0; j<(1<<N); ++j){
      if((j|C)>j && (j|C)<(1<<N)) chmin(DP[(j|C)],DP[j]+A);
    }
    
  }
  
  if(DP[(1<<N)-1]==INF) co(-1);
  else co(DP[(1<<N)-1]);
  return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>

int main(void)
{
 int a;
 int b;
 

	scanf("%d %d\n", &a,&b);
	
 int c=a*b;
 int d=(a+b)*2;
	
	printf("%d %d\n", c,d);
	

   return 0;
   
}

Measured memory_bytes: 2700
#include <stdio.h>
int f(int , int);
int main()
{
    int n,a;
    scanf("%d %d",&n,&a);
    printf("%d\n",f(n,a));
    return 0;
}
int f(int n, int a)
{
    int x = n*n - a;
    if(x<=0)
    {
        return 0;
    }
    else
    {
        return x;
    }
}

Measured memory_bytes: 128
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007

class UF
{
private:
    int n;
    vector<int> root;
    vector<int> size;

public:
    UF(int k)
    {
        n = k;
        root = vector<int>(n, -1);
        size = vector<int>(n, 1);
    }
    int getRoot(int x)
    {
        if (root[x] == -1)
            return x;
        else
            return root[x] = getRoot(root[x]);
    }
    void connect(int x, int y)
    {
        x = getRoot(x);
        y = getRoot(y);
        if (x == y)
            return;
        if (y < x)
            swap(x, y);
        root[y] = x;
        size[x] += size[y];
    }
    int getSize(int x)
    {
        return size[getRoot(x)];
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    UF uf(n);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.connect(a, b);
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans = max(ans, uf.getSize(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define mk make_pair
#define int long long
using namespace std;
int dx[]={1,-1,0,0,0,0};
int dy[]={0,0,1,-1,0,0};
int dz[]={0,0,0,0,1,-1};
set<pair<pair<int,int>,int> >s;
main(){
  int a,b,c,n,x,y,z,sum;
  cin>>a>>b>>c>>n;
  sum=a*b*2+a*c*2+b*c*2;
  while(n--){
    int r=0;
    cin>>x>>y>>z;
    r(i,6){
      int xx=dx[i]+x,yy=dy[i]+y,zz=dz[i]+z;
      if(xx<0||xx==a||yy<0||yy==b||zz<0||zz==c)r++;
      else if(s.count(mk(mk(xx,yy),zz)))r++;
    }
    s.insert(mk(mk(x,y),z));
    sum+=(3-r)*2;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3156
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define N_MAX 100
#define M_MAX 1000
#define INF 10000000
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;

int d[M_MAX];
int n, m;

int i, j, k;

int e[M_MAX][2];

void deb(){
	return;
}

void solve(){
	return;
}

int main (void) {
	scanf("%d%d%d\n", &i, &j, &k);

	printf("%d\n", (i+j)*k/2);

	solve();
	return 0;
}




Measured memory_bytes: 128
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL - 1

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u) {
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if (T[u].p == NIL) cout << "root, ";
    else if (T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
        if (i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

// 再帰的に深さを求める
void rec(int u, int p) {
    D[u] = p;
    if (T[u].r != NIL) rec(T[u].r, p);  // 右の兄弟に同じ深さを設定
    if (T[u].l != NIL) rec(T[u].l, p + 1);  // 最も左の子に自分の深さ+1を設定
}

int main() {
    int i, j, d, v, c, l, r;
    cin >> n;
    for (i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

    for (i = 0; i < n; i++) {
        cin >> v >> d;
        for (j = 0; j < d; j++) {
            cin >> c;
            if (j == 0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for (i = 0; i < n; i++) {
        if (T[i].p == NIL) r = i;   // rootのidをrに設定しておく
    }

    rec(r, 0);

    for (i = 0; i < n; i++) print(i);

    return 0;
}


Measured memory_bytes: 7724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;

int main() {
  int m, k;
  cin >> m >> k;
  if (m == 1) {
    if (k == 0)
      puts("0 0 1 1");
    else
      puts("-1");
    return 0;
  }
  ll pow2m = pow(2, m);
  if (k >= pow2m) {
    puts("-1");
    return 0;
  }
  for (ll a = 0; a < pow2m; a++) {
    if (a == k) continue;
    cout << a << " ";
  }
  cout << k;
  for (ll a = pow2m - 1; a >= 0; a--) {
    if (a == k) continue;
    cout << " " << a;
  }
  cout << " " << k << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, const char * argv[]) {
    int length, width;
    char input[100];
    fgets(input, sizeof(input), stdin);
    length = atoi(strtok(input, " "));
    width = atoi(strtok(NULL, " "));
    printf("%d %d\n", length * width, length * 2 + width * 2);
    return 0;
}

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

vector<int> si = {-1, 0, 1, 0};
vector<int> sj = {0, -1, 0, 1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  vector<vector<int>> dist(h,vector<int>(w,M));
  queue<pair<int,int>> q;
  q.push(make_pair(0, 0));
  dist[0][0] = 0;
  while(!q.empty()){
    int i = q.front().first;
    int j = q.front().second;
    q.pop();
    rep(x, 4){
      int ni = i + si[x];
      int nj = j + sj[x];
      if (ni < 0 || nj < 0 || ni >= h || nj >= w) continue;
      if (s[ni][nj] == '#') continue;
      if (dist[ni][nj] != M) continue;
      dist[ni][nj] = dist[i][j] + 1;
      q.push(make_pair(ni,nj));
    }
  }

  if (dist[h-1][w-1] == M) {
    cout << -1 << endl;
    return 0;
  }

  int black = 0;
  rep(i,h) rep(j,w) if(s[i][j] == '#') black++;
  cout << h*w - black - dist[h-1][w-1] - 1 << endl;
  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define double long double
#define x first
#define y second
#define long long long
#define int long 



           //       |----|       /\      |    |   -----   |
           //       |   /       /  \     |    |     |     |
           //       |--/       /----\    |----|     |     |
           //       |   \     /      \   |    |     |     |
           //       |    \   /        \  |    |   -----   -------

int n,k;
int arr[101];
int cache[100005];
int dp(int stones)
{
	if(stones<0)
		return 0;
	if(stones==0)
		return 1;
	if(cache[stones]!=-1)
		return cache[stones];
	int bit=0;
	for(int i=0;i<n;i++)
		bit|=dp(stones-arr[i]);
	return cache[stones]=bit^1;
}
int32_t main()
{
    IOS
    cin>>n>>k;
    for(int i=0;i<n;i++)
    	cin>>arr[i];
    memset(cache,-1,sizeof(cache));
    if(dp(k)==1)
    	cout<<"Second";
    else
    	cout<<"First";
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e7) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
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; }

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

  int a[n];
  vector<ll> counts(INF, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    counts[a[i]] += 1;
  }

  ll sum = 0;
  for (int i = 0; i <= n; ++i) {
    if (counts[i] <= 1) continue;
    sum += counts[i] * (counts[i] - 1) / 2;
  }

  for (int i = 0; i < n; ++i) {
    cout << sum - counts[a[i]] + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 81536
import java.io.*;

public class Main{
  public static void main(String[]args){
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    long p = 1000000007;
    int N = 0;
    String[] S = new String[0];
    try{
      N = Integer.parseInt(br.readLine());
      S = br.readLine().split(" ");
    }catch(IOException e){
    }
    int r = 0, g = 0, b = 0;
    long ans = 1;
    for(int i = 0; i < N; i++){
      int M = Integer.parseInt(S[i]);
      int count = 0;
      if(r == M) count++;
      if(g == M) count++;
      if(b == M) count++;
      
      ans *= count;
      ans %= p;
      
      if(r == M){
        r++;
      }else if(g == M){
        g++;
      }else if(b == M){
        b++;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 35412
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int f(int n){
	int sum=0;
	while(n){
		int m;
		m=n%10;
		n=n/10;
		sum+=m;
	}
	return sum;
}
int main(){
	int n,sum=0,l,r;
	cin>>n>>l>>r;
	for(int i=1;i<=n;i++){
			if(f(i)>=l&&f(i)<=r)
			//	printf("%d",f(i));
				sum+=i;
	}
	printf("%d\n",sum);

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
	return b==0?a:(gcd(b,a%b));
}
int main()
{
	int n;
	long long sum=0;
	cin >> n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				sum+=gcd(i,gcd(j,k));
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
     
    #define LENGTH 100
     
    int main(void) {
      int x1 = 1;
      int x2 = 2;
      int x3 = 3;
      int x4 = 4;
      int x5 = 5;
      char input[LENGTH];
      //while (1) {
        fgets(input, LENGTH-1, stdin);
        sscanf(input, "%d %d %d %d %d", &x1, &x2, &x3, &x4, &x5);
        int n = 0;
        if (x1 == 0) n = 1;
        else if (x2 == 0) n = 2;
        else if (x3 == 0) n = 3;
        else if (x4 == 0) n = 4;
        else n = 5;
        printf("%d\n", n);
    //  }
      return 0;
     
    }

Measured memory_bytes: 2120
#include<stdio.h>


int main (void){

  int N;
  int i,j;
  int ans=0;
  int cnt=0;
  
  scanf("%d",&N);
  
  int H[N-1];
  
  for(i=0;i<N;i++){
    scanf("%d",&H[i]);
  }

  for(i=1;i<N;i++){
    cnt=0;
    for(j=0;j<i;j++){

      if(H[j]<=H[i]){cnt++;}
      else{}
    }
    if(cnt==i){ans++;}
    else{}
  }
  
  
  printf("%d\n",ans+1);
  
  return 0;
}



Measured memory_bytes: 128
import java.util.*;
import java.io.*;
 
public class Main{
    public static void main(String[] args){
        Main m = new Main();
        m.input();
    }

    public void input(){
        Scanner sc = new Scanner(System.in);
        String ord ="abcdefghijklmnopqrstuvwxyz";
        String[] ords = ord.split("");
        String s = sc.next();
        String ans = "";
        int ins = -1;
        int ordnum = -1;
        for(int i = 0; i < ords.length; i++){
            if(!s.contains(ords[i])){
                ans = s + ords[i];
                System.out.println(ans);
                return;
            }        
        }
        for(int i = s.length()- 1; i >= 0; i--){
            int c = ord.indexOf(s.charAt(i));
            String sub = s.substring(0, i + 1);
            for(int j = c; j < ords.length; j++){
                if(!sub.contains(ords[j])){
                    ans = s.substring(0, i) + ords[j];
                    System.out.println(ans);
                    return;
                }
            }
        }
        System.out.println("-1");
        sc.close();
    }
}

Measured memory_bytes: 21716
import java.util.Scanner;
import java.util.Arrays;

public class Main{
	static int a,b;
    
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       while(true) {
    	   int n = sc.nextInt();
    	   if(n==0)break;
    	   int[] a = new int[n];
    	   for(int i=0;i<n;i++) {
    		   a[i] = sc.nextInt();
    	   }
    	   int min = 1000001;
    	   for(int i=0;i<n;i++) {
    		   for(int j=0;j<n;j++) {
    			   if(i==j)continue;
    			   int s = Math.abs(a[i]-a[j]);
    			   if(s < min) min = s;
    		   }
    	   }
    	   System.out.println(min);
       }
    }
}


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

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

int main(){
    int h, w; cin >> h >> w;
    char c[h + 1][w + 1];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> c[i][j];
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (c[i][j] == '#') {
                for (int k = 0; k < 4; k++) {
                    int nx = dx[k] + i, ny = dy[k] + j;
                    if (0 <= nx && nx < h && 0 <= ny && ny < w && c[nx][ny] == '#') break;
                    else {
                        if (k == 3) { puts("No"); return 0; } 
                    }
                }
            }
        }
    }
    puts("Yes");
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

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

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x)
{ //bit計算
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
signed main()
{
    int N;
    cin >> N;
    vector<int> A;
    rep(i, N)
    {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());
    int count = 1;
    for (int i = 1; i < N; i++)
    {
        if (A[i - 1] != A[i])
        {
            count++;
        }
    }
    if (count % 2 == 0)
    {
        count--;
    }
    cout << count << endl;
}


Measured memory_bytes: 1400