akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,c,k; cin >> n >> c >> k;
    vector<ll> t(n);
    rep(i,n) cin >> t[i];
    sort(all(t));
    ll min_ = 0;
    ll cnt = 0;
    ll ans = 0;
    rep(i,n){
        if(t[min_]+k < t[i]){
            min_ = i;
            cnt = 1;
            ans++;
            continue;
        }
        cnt++;
        if(cnt == c){
            min_ = i+1;
            cnt = 0;
            ans++;
        }
    }
    if(0 < cnt)++ans;
    cout << ans << endl;
}

Measured memory_bytes: 1024
num = gets.to_i

a = Hash.new()
num.times do |i|
    a[gets.chomp] = true
end

["S", "H", "C", "D"].each do |m|
    (1..13).each do |i|
        if !a[m + " " + i.to_s] then
            STDOUT << m << " " << i << "\n"
        end
    end
end



Measured memory_bytes: 8920
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""abc081_b"""

import sys
import pprint
import re

import itertools
pp = pprint.PrettyPrinter(indent=2)

def main():
    """Main function."""
    n = int(input())
    as_ = list(map(int, input().split(' ')))

    count = 0
    while True:
        odds = list(filter(lambda x: x % 2 != 0, as_))
        if odds:
            break
        else:
            count += 1
            as_ = list(map(lambda x: x >> 1, as_))

    print(count)

if __name__ == '__main__':
    sys.exit(main())

Measured memory_bytes: 3700
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        N: i32,
        M: i32,
        A: [i32; M],
    }
    let mut sum = 0;
    for ai in A {
        sum += ai;
    }
    dbg!(sum);
    let ans = if N - sum >= 0 { N - sum } else { -1 };
    println!("{}", ans);
}


Measured memory_bytes: 2220
#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>;

int main() {
  string s;
  cin >> s;
  int ans = 1000;
  rep(i, s.size()-2) {
    int x = 100 * (s[i] - '0') + 10 * (s[i+1] - '0') + s[i+2] - '0';
    ans = min(ans, abs(x - 753));
  }
  cout << ans << endl;
  return 0;
}

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

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

  for (int i = 1; i <= n; i++) {
    int x = (n%2 == 0) ? (n + 1 - i) : n - i;
    for (int j = i+1; j <= n; j++) {
      if (j != x) {
        ans.emplace_back(make_pair(i, j));
      }
    }
  }

  cout << ans.size() << endl;
  for (auto x: ans) {
    cout << x.first << ' ' << x.second << endl;
  }

  return 0;
}

Measured memory_bytes: 384
S = input()
T = input()

Sn = len(S)
Tn = len(T)

ans = 0

for i in range(Sn - Tn + 1):
    L = S[i:i + Tn]
    ans_ = 0
    for j, k in zip(L, T):
        if j == k:
            ans_ += 1
    ans = max(ans, ans_)

print(Tn - ans)


Measured memory_bytes: 9096
void main(){
	real num = readln().chomp().replace(" ","").to!int();
	writeln(num%sqrt(num)==0?"Yes":"No");
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2712
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){

// Seiranchan!
   int A,B;
   cin >> A >>B;

   cout << A+(B/2) << endl;
}

Measured memory_bytes: 256
class SegmentTree(object):
    def __init__(self, a:list, default: int, op):
        from math import ceil, log
        real_size = len(a)
        self.elem_size = elem_size = 1<<ceil(log(real_size, 2))
        self.tree = tree = [default] * (elem_size * 2)
        tree[elem_size:elem_size + real_size] = a
        self.default = default
        self.op = op
        for i in range(elem_size - 1, 0, -1):
            tree[i] = op(tree[i<<1], tree[(i<<1)+1])
    def get_value(self, x:int, y:int):
        l, r = x+self.elem_size, y+self.elem_size
        tree, result, op = self.tree, self.default, self.op
        while l<r:
            if l & 1:
                result = op(tree[l], result)
                l += 1
            if r&1:
                r -= 1
                result = op(tree[r], result)
            l, r = l>>1, r>>1
        return result
    def set_value(self, i:int, value:int):
        k = self.elem_size + i
        self.tree[k] = value
        self.update(k)
    def update(self, i:int):
        op, tree = self.op, self.tree
        while i > 1:
            i >>= 1
            tree[i] = op(tree[i<<1], tree[(i<<1)+1])


N = int(input())
A = list(map(int, input().split()))
Q_ = int(input())
Q = []
for i in range(Q_):
    l, r, d = map(int, input().split())
    Q.append([l, r, d, i])
seg1 = SegmentTree([-1<<30]*N, -1<<30, max)
seg2 = SegmentTree(A, 1<<30, min)
from operator import itemgetter
Q.sort(key=itemgetter(2))
A = sorted(zip(A, range(N)), key=itemgetter(0))

a_idx = 0
Ans = [0] * Q_
for l, r, d, q_idx in Q:
    while a_idx < N:
        a0, a1 = A[a_idx]
        if a0 > d:
            break
        else:
            seg1.set_value(a1, a0)
            seg2.set_value(a1, 1<<30)
            a_idx += 1
    an1 = abs(seg1.get_value(l, r+1) - d)
    an2 = abs(seg2.get_value(l, r+1) - d)
    Ans[q_idx] = min(an1, an2)

print(*Ans, sep="\n")



Measured memory_bytes: 49244
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Control.Applicative
import Data.List
import Data.Array
import Data.Array.IO
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import Text.Printf
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
listToTuple4 [a,b,c,d] = (a,b,c,d)

getWords = getLine >>= return . words

readIntBS = fst . fromJust . BS.readInt

for = flip map

divisor = 10^9+7

main :: IO ()
main = do
  s <- getLine

  let
    cntAl = init $ scanl (+) 0 $ map (\c -> if c=='A' then 1 else 0) s
    cntCr = reverse $ init $ scanl (+) 0 $ map (\c -> if c=='C' then 1 else 0) (reverse s)
    cntQl = init $ scanl (+) 0 $ map (\c -> if c=='?' then 1 else 0) s
    cntQr = reverse $ init $ scanl (+) 0 $ map (\c -> if c=='?' then 1 else 0) (reverse s)
  
  print $ (`mod` divisor) $ sum [
    al*cr*(powerMod 3 (ql+qr) divisor) +
    al*qr*(powerMod 3 (ql+qr-1) divisor) +
    ql*cr*(powerMod 3 (ql+qr-1) divisor) +
    ql*qr*(powerMod 3 (ql+qr-2) divisor)
    | (c,al,cr,ql,qr)<-(zip5 s cntAl cntCr cntQl cntQr), c=='B' || c=='?']
  
{-- n^p mod m --}
powerMod :: Integral a => a -> a -> a -> a
powerMod n 0 m = 1
powerMod n 1 m = n `mod` m
powerMod n p m
  | p < 0 = 0
  | otherwise = (k * k * (if mod p 2 == 0 then 1 else n)) `mod` m
  where
    k = powerMod n (div p 2) m


Measured memory_bytes: 33148
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args) throws Exception{
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int k=sc.nextInt(),n=sc.nextInt();
		int[]in=sc.intArr(n);
		int sum=0;
		int fl=k-(in[n-1]-in[0]);
		int max=fl;
		sum+=fl;
		for(int i=1;i<n;i++) {
			int dif=in[i]-in[i-1];
			max=Math.max(max, dif);
			sum+=dif;
		}
		pw.println(sum-max);
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		static void shuffle(int[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				int tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		static void shuffle(long[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				long tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void addX(int[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
	static void addX(long[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
}

Measured memory_bytes: 47828
s = input()
char_list = ["A","C","G","T"]
temp = 0
now_max = 0

for char in s:
    if char in char_list:
        temp = temp + 1
    else:
        now_max = max(now_max,temp)
        temp = 0

now_max = max(now_max,temp)
print(now_max)


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

using namespace std;

long long res, standard, n, a[100000], sum;
long long ans = 1000000000000000LL;

int get_sign(int x){
	if(0 < x) return 1;
	else if(x < 0) return -1;
	else return 0;
}

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

	res = 0, standard = 1, sum = 0;
	for(int i = 0; i < n; ++i){
		sum += a[i];
		if(standard != get_sign(sum)){
			int add = abs(sum) + 1;
			res += add;
			if(sum > 0) sum -= add;
			else if(sum < 0) sum += add;
			else sum = standard;
		}
		standard *= (-1);
	}
	ans = min(ans, res);

	res = 0, standard = -1, sum = 0;
	for(int i = 0; i < n; ++i){
		sum += a[i];
		if(standard != get_sign(sum)){
			int add = abs(sum) + 1;
			res += add;
			if(sum > 0) sum -= add;
			else if(sum < 0) sum += add;
			else sum = standard;
		}
		standard *= (-1);
	}
	ans = min(ans, res);

	cout << ans << endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

// C++ならpairでsortが便利
int main() {
    int n; cin >> n;
    pair<pair<string, int>, int> p[n];
    rep(i, n){
        string name; cin >> name;
        int point; cin >> point;
        p[i] = make_pair(make_pair(name, -point), i);
    }
    sort(p, p + n);
    rep(i, n) OP(p[i].second + 1);
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

bool isprime (int n){

	if (n == 0 || n == 1){
		return false;
	}else if (n == 2){
		return true;
	}else if (n % 2 == 0){
		return false;
	} // end if
	
	for (int i = 3; i <= sqrt(n); i+= 2){
		if (n % i == 0){
			return false;
		} // end if
	} // end for
		
	return true;
}
int main()
{
//	cut here before submit 
//	freopen ("testcase.twinprime", "r", stdin );
	string str = "";

	while (getline (cin, str ) ){
		int n;
		stringstream ssn(str);
		ssn >> n;
		if (n == 0 ){
			break;
		} // end if
		int i;

		for (i = n; i >= 5; --i){
			if (isprime(i-2) && isprime(i) ){
				cout << (i-2) << ' ' << i << endl;
				break;
			} // end if
		} // end for
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int x[50];
int64_t dp[51][5'001];

int main()
{
    int n, a;
    cin >> n >> a;
    rep(i, n)
    {
        cin >> x[i];
        x[i] -= a;
    }

    irep(i, n)
    {
        for (int j = -2500; j <= 2500; j++) {
            int jidx = (j + 5'000) % 5'000;
            if (i == 0) {
                dp[i][jidx] = j == 0 ? 1 : 0;
            } else {
                dp[i][jidx] = dp[i - 1][jidx];
                if (-2500 <= j - x[i - 1] && j - x[i - 1] <= 2500) {
                    dp[i][jidx] += dp[i - 1][(j - x[i - 1] + 5'000) % 5'000];
                }
            }
        }
    }

    int64_t result = dp[n][0];
    cout << result - 1 << endl;

    return 0;
}

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

using namespace std;

#define pb			push_back
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define hastr(s, c)		((s).find(c) != string::npos)

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

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

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin >> n;
    int x;
    int freq[n+1];
    clr(freq, 0);
    for(int i = 1; i <= n-1; ++i) {
    	cin >> x;
    	freq[x]++;
    }
    for(int i = 1; i <= n; ++i) {
    	cout << freq[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 4436
#include<cstdio>
long long N,A,B,C,D,E;
int main(){
	scanf("%lld%lld%lld%lld%lld",&N,&A,&B,&C,&D); --N;
	A=A+A, B=B+B; D=D+C; C=D-C-C; B-=A; if(B<0) B=-B;
	if(B>(C+D)*N) puts("NO");
	else{
		E=(B-1)/D, ((N^E)&1?++E:0);
		if(E*D-N*C<=B&&B<=E*D+N*C) puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<ll> a(n);
    ll nimber = 0;
    rep(i,n) {
        cin>>a[i];
        nimber ^= a[i];
    }
    if (nimber == 0) {
        cout << 0 << '\n';
        return 0;
    }
    // cout << nimber << '\n';
    ll x = 0;
    for (int i = 2; i < n; ++i) x ^= a[i];
    if (a[0] + a[1] < x) {
        cout << -1 << '\n';
        return 0;
    }
    ll A = a[0]; ll B = a[1];
    ll s = A+B;

    constexpr int N = 50;
    ll dp[N][2][2];
    rep(i,N) rep(j,2) rep(k,2) dp[i][j][k] = -1ll;
    dp[0][0][0] = 0ll;

    ll v = 1ll;
    rep(i,N-1) {
        ll cx = (bool)(x&(1ll<<i));
        ll cs = (bool)(s&(1ll<<i));
        ll ca = (bool)(A&(1ll<<i));

        rep(j,2) rep(k,2) {
            if (dp[i][j][k] == -1ll) continue;
            rep(na,2) rep(nb,2) {
                if ((na^nb) != cx) continue;
                ll ns = na+nb+j;
                if (ns%2 != cs) continue;
                int nj = 0;
                if (ns>=2) nj = 1;
                int nk = k;
                if (na > ca) nk = 1;
                else if (na == ca) nk = k;
                else nk = 0;
                chmax(dp[i+1][nj][nk], dp[i][j][k]|(v*na));
            }
        }
        v *= 2ll;
    }

    if (dp[N-1][0][0] == 0 || dp[N-1][0][0] == -1) cout << -1 << '\n';
    else cout << A-dp[N-1][0][0] << '\n';
    return 0;
}

Measured memory_bytes: 3636
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)
case_out = lambda i, o: out("Case #{}: {}".format(i, o))


def solve(t):
    return t.replace("?", "D")


if __name__ == "__main__":
    out(solve(str_in()))


Measured memory_bytes: 64312
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
int n,i,x,mn,mx,a[5000],j,b[101];
int main() 
{
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n;
    for(i=1;i<=n;i++)cin>>b[i];
    sort(b+1,b+n+1);
    for(i=1;i<=n;i++)
	{
		x=b[i];
		if(!a[x] && x<=3199)
		{
			mn++,mx++;
			if(x<=399)for(j=1;j<=399;j++)a[j]=1;
			else if(x>=400 && x<=799)for(j=400;j<=799;j++)a[j]=1;
			else if(x>=800 && x<=1199)for(j=800;j<=1199;j++)a[j]=1;
			else if(x>=1200 && x<=1599)for(j=1200;j<=1599;j++)a[j]=1;
			else if(x>=1600 && x<=1999)for(j=1600;j<=1999;j++)a[j]=1;
			else if(x>=2000 && x<=2399)for(j=2000;j<=2399;j++)a[j]=1;
			else if(x>=2400 && x<=2799)for(j=2400;j<=2799;j++)a[j]=1;
			else for(j=2800;j<=3199;j++)a[j]=1;
		}
		else if(x>=3200)mx++;
	}
	cout<<max(mn,1)<<" "<<mx<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

MOD = 1000000007  # type: int

def solve(X: int, Y: int):
    def combination(n, r, mod=10**9+7):
        n1, r = n+1, min(r, n-r)
        numer = denom = 1
        for i in range(1, r+1):
            numer = numer * (n1-i) % mod
            denom = denom * i % mod
        return numer * pow(denom, mod-2, mod) % mod

    if (X+Y)%3 != 0 or not (X <= 2*Y and Y <= 2*X):
        print(0)
        exit()

    n = (X+Y)//3
    r = Y-n

    print(combination(n, r))

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


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

// --------------------------------------------------------------------------------
#define fastio	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve_main()
{
    int r;cin>>r;
    double pi = 3.14;
    double ans = 2*pi*r;
    cout<<setprecision(20)<<fixed<<ans;
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("/home/suryakant/input.txt","r",stdin);
 //        freopen("/home/suryakant/output.txt","w",stdout);
 //    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p.at(i);
    }
    int ans = 0;
    int mini = 2000000;
    for (int j : p) {
        if (min(mini, j) == j) {
            mini = j;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4016
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <map>

using namespace std;
int inf = 0x3f3f3f3f;

int maps[50][50];
//int dis[50],vis[50];
void floyd(int k,int n)
{

    for(int t =k; t<=n; t++)
        for(int i = k; i<=n; i++)
            for(int j = k; j<=n; j++)
                if(maps[i][j]>maps[i][t]+maps[t][j])
                    maps[i][j]=maps[i][t]+maps[t][j];
}
int main(void)
{
    int n;
    while(scanf("%d",&n)&&n)
    {
        memset(maps,inf,sizeof(maps));
        //memset(dis,inf,sizeof(dis));
        int ma = 0;
        int k = inf;
        for(int i = 0; i<n; i++)
        {
            int x,y,w;
            scanf("%d%d%d",&x,&y,&w);
            maps[x][y] = maps[y][x] = w;
            maps[i][i] = 0;
            ma = max(ma,x);
            ma = max(ma,y);
            k = min(k,x);
            k = min(k,y);
        }
        floyd(k,ma);
        int mi = inf,b=k;
        for(int i = k;i <=ma; i++)
            {
                int sum = 0;
                for(int j = k; j<=ma; j++)
                {
                    sum += maps[i][j];
                }
                if(sum<mi)   b = i,mi=sum;

            }

        printf("%d %d\n",b,mi);
    }
    return 0;
}

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

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top+1];
}

int main(void) {
	int a,b;
	char s[100];
	
	top = 0;

	while(scanf("%s",s) != EOF) {
		if(s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		} else if(s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		} else if(s[0] == '*') {
			b = pop();
			a = pop();
			push(a * b);
		} else {
			push(atoi(s));
		}
	}
	
	printf("%d\n",pop());
	
	return 0;
}

Measured memory_bytes: 2752
using System;

namespace _0595
{
    class Program
    {
        static void Main(string[] args)
        {
            int day = int.Parse(Console.ReadLine());
            string sekinin = Console.ReadLine();
            int[,] dp = new int[day + 1,8];//J*4+O*2+I
            dp[0,4] = 1;
            for (int i = 1; i <= day; i++)
            {
                for (int j = 0; j < Math.Pow(2,3); j++)
                {
                    bool flag = true;
                    switch (sekinin[i - 1])
                    {
                        case ('J'): { if ((j % 8) / 4 == 0) flag = false; break; }
                        case ('O'): { if ((j % 4) / 2 == 0) flag = false; break; }
                        case ('I'): { if ((j % 2) / 1 == 0) flag = false; break; }
                    }
                    if (flag)
                    {
                        for (int k = 0; k < Math.Pow(2,3); k++)
                        {
                            if ((j & k) != 0) dp[i,j] += dp[i - 1,k];
                        }
                        dp[i,j] %= 10007;
                    }
                }
            }
            int ret = 0;
            for (int i = 0; i < Math.Pow(2,3); i++) ret += dp[day,i];
            Console.WriteLine(ret % 10007);
        }
    }
}


Measured memory_bytes: 9460
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

constexpr int MOD = 1e9 + 7;

struct modint {
	int n;
	modint(int n = 0) : n(n) {}
};

modint operator+(modint a, modint b) { return modint((a.n += b.n) >= MOD ? a.n - MOD : a.n); }
modint operator-(modint a, modint b) { return modint((a.n -= b.n) < 0 ? a.n + MOD : a.n); }
modint operator*(modint a, modint b) { return modint(1LL * a.n * b.n % MOD); }
modint &operator+=(modint &a, modint b) { return a = a + b; }
modint &operator-=(modint &a, modint b) { return a = a - b; }
modint &operator*=(modint &a, modint b) { return a = a * b; }

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

	if (std::abs(n - m) >= 2) {
		std::cout << 0 << std::endl;
	} else if (std::abs(n - m) == 1) {
		modint ans = 1;

		for (int i = 1; i <= n; i++) {
			ans *= i;
		}
		for (int i = 1; i <= m; i++) {
			ans *= i;
		}

		std::cout << ans.n << std::endl;

	} else {
		modint ans = 1;

		for (int i = 1; i <= n; i++) {
			ans *= i;
		}
		for (int i = 1; i <= m; i++) {
			ans *= i;
		}
		ans *= 2;

		std::cout << ans.n << std::endl;

	}
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
//get the biggest element.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  int n, q;
  cin >> n >> q;
  string str;
  cin >> str;

  vector<int> s(n + 1);
  s[0] = s[1] = 0;
  for (int i = 1; i < n; i++) {
    s[i + 1] = s[i];
    if (str[i - 1] == 'A' && str[i] == 'C') ++s[i + 1];
  }

  vector<int> ans;
  rep (i, q) {
    int l, r;
    cin >> l >> r;
    ans.push_back(s[r] - s[l]);
  }

  for (auto v : ans) {
    cout << v << endl;
  }

  return 0;
}


Measured memory_bytes: 4456
#include <iostream>
using namespace std;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

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

const string yes = "YES", no = "NO";
int main() {
  int H, W, N; ins(H, W, N);
  int sr, sc;  ins(sr, sc);
  string S, T; ins(S, T);


  // R方向に動かして落とす
  int pos = sc;
  rep(i, N) {
    if (S[i] == 'R')
      ++pos;
    if (pos > W) {
      cout << no << endl;
      return 0;
    }
    if (T[i] == 'L')
      pos = max(pos-1, 1);
  }

  pos = sc;
  rep(i, N) {
    if (S[i] == 'L')
      --pos;
    if (pos < 1) {
      cout << no << endl;
      return 0;
    }
    if (T[i] == 'R')
      pos = min(pos+1, W);
  }


  pos = sr;
  rep(i, N) {
    if (S[i] == 'D')
      ++pos;
    if (pos > H) {
      cout << no << endl;
      return 0;
    }
    if (T[i] == 'U')
      pos = max(pos-1, 1);
  }

  pos = sr;
  rep(i, N) {
    if (S[i] == 'U')
      --pos;
    if (pos < 1) {
      cout << no << endl;
      return 0;
    }
    if (T[i] == 'D')
      pos = min(pos+1, H);
  }
  cout << yes << endl;
  return 0;

}


Measured memory_bytes: 776
import math
N=int(input())

ans=[0]*(10**4+1)

x,y,z=1,1,1
while True:
  if(x*x+y*y+z*z+x*y+y*z+z*x)<=N:
    ans[x*x+y*y+z*z+x*y+y*z+z*x]+=1
    z+=1
  else:
    z=1
    y+=1
    if not (x*x+y*y+z*z+x*y+y*z+z*x)<=N:
      y=1
      x+=1
      if x==N+1:break
for i in range(1,N+1):
  print(ans[i])

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9;
const LL LINF = INF * INF;

const int mod = 1e9 + 7;
 
inline int add(int x, int y)
{
	if (x + y >= mod)
		return x + y - mod;
	return x + y;
}
 
inline int mult(int x, int y)
{
	return x * (LL) y % mod;
}

inline int power(int x, int y)
{
	int r = 1;
	while(y)
	{
		if (y & 1)
			r = mult(r, x);
		x = mult(x, x);
		y >>= 1;
	}
	
	return r;
}

const int D = 107;
const int N = 10007;

int dp[N][D];

string s;
int d;

int f(int x, int rem)
{
	rem %= d;
	if (x == 0)
		return rem == 0;
	
	if (dp[x][rem] != -1)
		return dp[x][rem];

	if (x == 1)
	{
		dp[x][rem] = 0;
		FOR(i, 0, 10)
			if (i % d == rem)
				++dp[x][rem];
		return dp[x][rem];
	}
	
	int res = 0;
	FOR(i, 0, 10)
	{
		int bude = (((rem - i) % d) + d) % d;
		res = add(res, f(x - 1, bude));
	}
	
	return dp[x][rem] = res;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	FILL(dp, -1);
	cin >> s >> d;
	int n = SZ(s);

	int ans = 0;
	int je = 0;
	FOR(i, 0, n)
	{
		int treba = (d - je) % d;
		FOR(j, 0, s[i] - '0')
		{
			ans = add(ans, f(n - i - 1, treba));
			--treba;
			if (treba < 0)
				treba += d;
		}
		
		je += s[i] - '0';
		je %= d;
	}

	if (je)
		ans = add(ans, mod - 1);
	
	cout << ans << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
void quit(T a)
{
    cout << a << endl;
    exit(0);
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 10010020030040056ll;
const int INF = 1001001001;
const double pi = acos(-1);

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    int tmp = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == 'R')
        {
            tmp += 1;
            ans = max(ans, tmp);
        }
        else
        {
            tmp = 0;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
ll dp[50][5001];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,A;
    cin>>N>>A;
    int x[N];
    rep(i,0,N){
        cin>>x[i];
        x[i]-=A;
    }
    rep(i,0,N){
        if(i==0){
            dp[i][x[0]+2500]++;
            dp[i][2500]++;
        }
        else{
            rep(j,0,5001){
                dp[i][j]=dp[i-1][j]+(0<=j-x[i]&&j-x[i]<=5000?dp[i-1][j-x[i]]:0);
            }
        }
    }
    cout << dp[N-1][2500]-1<<"\n";
}

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

int main(){
	int n;cin>>n;
  	vector<vector<int>> f(n,vector<int>(11));
  	vector<vector<int>> p(n,vector<int>(11));
  	for(int i=0;i<n;i++){
      for(int j=0;j<10;j++){
      	cin>>f[i][j];
      }
    }
  
  	for(int i=0;i<n;i++){
      for(int j=0;j<11;j++){
      	cin>>p[i][j];
      }
    }
  	
  	long long ans=-1e15;
  	for(int mask=1;mask<(1<<10);mask++){
    long long sum=0;
      	for(int i=0;i<n;i++){
        	int cnt=0;
          	for(int j=0;j<10;j++){
            	if(((mask>>j)&1) && f[i][j]) cnt++;
            }
          sum+=p[i][cnt];
        }
    	ans=max(ans,sum);
    }
  cout<<ans<<endl;
}    


Measured memory_bytes: 256
n=gets.to_i
mincnt = {}
('a'..'z').each{|c|
    mincnt[c] = 1000;
}

n.times{
    s=gets.chomp
    cnt = {}
    ('a'..'z').each{|c|
        cnt[c] = 0;
    }
    s.each_char{|c|
        cnt[c] += 1
    }
    ('a'..'z').each{|c|
        mincnt[c] = [mincnt[c], cnt[c]].min
    }
    #puts "cnt=#{cnt}"
    #puts "mincnt=#{mincnt}"
}
result = ""
mincnt.each{|c, num|
    result += c * num;
}
puts result




Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;



int topological_sort(vector<int> &in_degree,vector<vector<int> > &dag, vector<int> &sorted){
    int n = dag.size();
    if(sorted.size() == n) return 0;
    for(int i=0;i<n;i++){
        if(in_degree[i] == 0){
            sorted.push_back(i);
            in_degree[i]--;
            for(auto x: dag[i]) in_degree[x]--;
        }
    }
    return 0;
}
int main(){
    int n,e; cin >> n >> e;
    vector<int> in_degree(n);
    for(int i=0;i<n;i++) in_degree[i] = 0;
    vector<vector<int> > dag(n);
    vector<int> sorted;
    for(int i=0;i<e;i++){
        int f,t; cin >> f >> t;
        dag[f].push_back(t);
        in_degree[t]++;
    }
 
    for(int i=0;i<n;i++) topological_sort(in_degree, dag, sorted);
    for(int i=0;i<n;i++) cout << sorted[i] << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

void solve(int test_case) {
	int x;
	cin>>x;
	if(x==1)cout<<0;
	else cout<<1;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3660
import time
start = time.time()
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]
s = [0 for i in range(n)] #それぞれ何試合目か
ans = 0
need = n*(n-1)//2
while need:
    c = [0 for i in range(n)] #今日試合をするかどうか
    ans += 1
    for first in range(n):
        if c[first] == 0 and s[first] < n-1:
            second = a[first][s[first]]-1 # firstが対戦したい相手
            second_num = s[second] # #secondの対戦番号
            if c[second] == 0 and a[second][second_num]-1 == first:
                c[first] = 1
                c[second] = 1
                s[first] += 1
                s[second] += 1
                need -= 1
    if sum(c) == 0:
        print(-1)
        exit()
    now = time.time()-start
    if now > 1.83:
        print(n*(n-1)//2)
        exit()
print(ans)

Measured memory_bytes: 60504
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int done[300000] = {};
int main() {
	int n, t;
	cin >> n >> t;
	vector<long long> a;
	REP(i, n) {
		long long tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	long long now_min = LONGINF;
	vector<int> pre_min;
	vector<int> ok_min;
	vector<int> maxing;
	long long diff = -1;
	int pre_itr = 0;
	for (int i = 0;i < n;++i) {
		if (now_min == a[i]) {
			pre_min.push_back(i);
		}
		else if (now_min > a[i]) {
			pre_min.erase(pre_min.begin(), pre_min.end());
			pre_itr = 0;
			pre_min.push_back(i);
			now_min = a[i];
		}
		if (a[i] - now_min == diff) {
			maxing.push_back(i);
			for (int q = pre_itr;q < pre_min.size();++q) {
				ok_min.push_back(pre_min[q]);
			}
			pre_itr = pre_min.size();
		}
		else if (a[i] - now_min > diff) {
			diff = a[i] - now_min;
			maxing.erase(maxing.begin(), maxing.end());
			ok_min.erase(ok_min.begin(), ok_min.end());
			for (int q = 0;q < pre_min.size();++q) {
				ok_min.push_back(pre_min[q]);
			}
			pre_itr = pre_min.size();
			maxing.push_back(i);
		}
	}
	cout << min(maxing.size(), ok_min.size()) << endl;
	return 0;
}

Measured memory_bytes: 1780
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include<stack>
#include <unordered_map>

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

using namespace std;

int main() {
	int X, Y;
	cin >> X >> Y;
	if (X % Y == 0) {
		cout << -1;
		return 0;
	}
	int a = gcd(X, Y);
	Y /= a;
	long long ans = X;
	cout << ans * (Y - 1);

	return 0;
}



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

int main()
{
    string s;
    int x, minimum=1000;
    cin >> s;
    for(int i=0; i<s.length()-2; i++){
        x = (s[i] - '0')*100
                + (s[i+1] - '0')*10
                    + (s[i+2] - '0');
        minimum = min(abs(x-753), minimum);
    }
    cout << minimum << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=list(input().strip())
l=[]
for i in s:
    if l!=[]:
        if l[-1]=='(' and i==')':
            l.pop()
        else:
            l.append(i)
    else:
        l.append(i)
cntl=l.count(')')
cntr=l.count('(')
ans='('*cntl+''.join(s)+')'*cntr
print(ans)


Measured memory_bytes: 3060
N, x = map(int, input().split())
a = list(map(int, input().split()))
a = list(sorted(a))

X = x
ans = 0
for i, aa in enumerate(a, 0):
    if X >= aa:
        if i == N - 1:
            if X == aa:
                ans += 1
        else:
            X -= aa
            ans += 1
    else:
        break
print(ans)


Measured memory_bytes: 3060
N,M = map(int,input().split())

lis = [False] * N
num = [1] * N
lis[0] = True

for i in range(M):

    x,y = map(int,input().split())

    x -= 1
    y -= 1

    num[x] -= 1
    num[y] += 1

    if lis[x]:
        lis[y] = True

    if num[x] == 0:
        lis[x] = False

ans = 0

for i in range(N):
    if lis[i]:
        ans += 1

print (ans)


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

using namespace std;
using i64 = long long int;
using ui64 = unsigned long long int;

////////////////////////////////

int main()
{
    int T;
    cin >> T;
    while(T--){
        string s;
        cin >> s;
        vector< deque<int> > d(10000);
        int lv = 0, maxlv = 0, curs = 0, num = 0;
        for(int i=0;i<s.length();i++){
            if(s[i] == '['){
                lv ++;
                maxlv = max(maxlv,lv);
            }
            else if(isdigit(s[i])){
                num *= 10;
                num += s[i] - '0';
            }else{
                curs = maxlv;
                if(num){
                    d[lv].push_back(num);
                    lv--;
                    num = 0;
                }else{
                    lv--;
                    while(curs > lv){
                        // cerr << curs << " " << lv << endl;
                        if(d[curs].size() == 0){
                            --curs;continue;
                        }
                        sort(d[curs].begin(),d[curs].end());
                        int l = 0;
                        if(curs == maxlv){
                            for(auto&& x:d[curs]){
                                d[maxlv-1].push_back(x/2+1);
                            }
                            d[maxlv].clear();
                            --curs;
                        }else{
                            // cerr << d[curs].size() << " " << d[curs].size()/2 + 1 << endl;
                            for(int i=0;i<d[curs].size()/2+1;i++){
                                l += d[curs][i];
                            }
                            d[curs].clear();
                            d[--curs].push_back(l);
                        }
                        // for(int i=0;i<=maxlv;i++){
                        //     cerr << i << " : ";
                        //     for(auto&& x:d[i])cerr << x << " ";
                        //     cerr << endl;
                        // }
                    }
                }
            }
        }
        cout << d[0][0] << endl;
    }
}




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

#define endl '\n'
#define left aba
#define right abc
#define oo if(LOG)
#define pb push_back
#define FIO ios_base::sync_with_stdio(0); cin.tie(0)

#ifdef LOCAL
#define LOG 1
#else
#define LOG 0
#endif

using namespace std;

const int N = 103, MAXST = 100002;

int n, k;

int a[N], dp[MAXST];

int main() {
    FIO;

    cin >> n >> k;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);
    for(int i = 0; i < n; ++i) {
        if(a[i] > k) break;
        dp[a[i]] = 1;
    }
    for(int i = 1; i <= MAXST; ++i) {
        for(int j = 0; j < n; ++j) {
            if(i < a[j]) continue;
            dp[i] = (dp[i - a[j]] == 1 ? dp[i] : 1);
        }
    }
    cout << (dp[k] == 1 ? "First" : "Second") << endl;

    oo cout << "Time: " << (double)clock() / CLOCKS_PER_SEC << "s" << endl;
    return 0;
}


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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
const int maxn = 2*(int)1e5+100;
int n, a[maxn];
unordered_map<int, int, custom_hash> cnt;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> n;
    i64 ans = 0;
    for1(i, n) {
        cin >> a[i];
        //cerr << i << ' ' << i-a[i] << ' ' << a[i]+i << endl;
        ans += cnt[i-a[i]];;
        ++cnt[a[i]+i];
    }
    cout << ans << '\n';


#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 19452
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template <class T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	for (const auto& e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& st) {
	for (const auto& e : st) os << e << " ";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const map<T1, T2>& mp) {
	for (const auto& e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T&& h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head&& h, Tail&&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

Int N;
string S;

vector<vector<Int> > calcNext(const string& S) {
	//int n = (int)S.size();
	vector<vector<Int> > res(N + 1, vector<Int>(10, N));
	for (int i = N - 1; i >= 0; --i) {
		for (int j = 0; j < 10; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - '0'] = i;
	}
	return res;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	cin >> N;
	cin >> S;

	//next[i][c]next[i][c] : = S の i 文字目以降で最初に文字 c が登場する index
	vector<vector<Int>> next = calcNext(S);

	DMP(next);

	Int ans = 0;
	Int temp1,temp2,temp3;
	for (Int i = 0; i < 10; i++) {//暗証番号の先頭数字をiとする
		temp1 = next[0][i];//数字iが最初に現れるindex
		if (temp1==N) {//範囲外ならcontinue	
			continue;
		}
		else {
			for (Int j = 0; j < 10; j++) {//2桁目に考える数字をjとする
				temp2 = next[temp1 + 1][j];
				if (temp2==N) {
					continue;
				}
				else {
					for (Int k = 0; k < 10; k++) {//3桁目に考える数字をkとする
						temp3 = next[temp2 + 1][k];
						if (temp3==N) {
							continue;
						}
						else {
							ans++;
						}
					}
				}

			}
		}
	}

	cout << ans << "\n";
}


Measured memory_bytes: 3840