akhauriyash/Code-Regression huggingface dataset:
n, m = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
diff = x.sort.each_cons(2).map { |a, b|
  b - a
}.sort.reverse
ans = diff[(n-1)..-1]
if ans && ans.count > 0
  puts ans.inject(&:+)
else
  puts 0
end

Measured memory_bytes: 14144
#include <bits/stdc++.h>
#define rep(i,n) for (int i=1; i<= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(void){
    ll N,M;
    cin >> N >> M;
    
    ll H[N+1],A,B,C[N+1],D[N+1],sum=0;
    H[0]=C[0]=0;

    for(ll i=1;i<=N;i++){
      cin>> H[i];
      C[i]=0;  
      D[i]=0;
    }
    for(ll i=0;i<M;i++){
      cin >> A >> B;
      D[A]++;
      D[B]++;
      if(H[A]>H[B]){
          C[A]+=2;
    //      C[B]+=2;
      }else if(H[A]<H[B]){
      //    C[A]+=2;
          C[B]+=2;
      }
    }
    
    for(ll i=1;i<=N;i++){
        if(D[i]*2==C[i]){
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 5956
#include<bits/stdc++.h>
#include<assert.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl;
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

//---------------------
#define MAXN 2005
#define MOD 1000000007
//---------------------

ll n,m,s[MAXN],t[MAXN],sum[MAXN][MAXN],dp[MAXN][MAXN];

inline ll modadd(ll a,ll b){return ((a%MOD)+(b%MOD)) % MOD;}
inline ll modsub(ll a, ll b) {return (((a%MOD+MOD)%MOD-(b%MOD+MOD)%MOD)+MOD)%MOD;}

ll getsum(ll i,ll j){
	return sum[i][j]%MOD;
}

ll putsum(ll i,ll j, ll v){
	sum[i][j]=modsub(modadd(modadd(v,getsum(i-1,j)),getsum(i,j-1)),getsum(i-1,j-1));
}

int main(){
	cin>>n>>m;
	REP1(i,n) cin>>s[i];
	REP1(i,m) cin>>t[i];
	ZERO(dp);
	MINUS(sum);
	REP(i,MAXN) sum[i][0] = dp[i][0] = 0;
	REP(j,MAXN) sum[0][j] = dp[0][j] = 0;
	REP1(i,n) REP1(j,m) {if(s[i]==t[j]) {dp[i][j]=(getsum(i-1,j-1)%MOD+1)%MOD;}putsum(i,j,dp[i][j]);}
	cout<<getsum(n,m)+1<<endl;
	return 0;
}

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

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

  map<string,int> mp;
  for(int i=0;i<n;i++){
    string s1;
    cin >> s1;
    sort(s1.begin(),s1.end());
    mp[s1]++;
  }

  long long ans=0;
  for(auto ss:mp){
    long long tmp = ss.second;
    if(tmp >= 2){
      ans+=tmp*(tmp-1)/2;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 11136
#include <cstdio>

int N, C;
int D[35][35];
int c[510][510];
int chg[3][35];
int res;

void solve()
{
	int i, j, k[3], l;
	for(l=0; l<C; l++){
		for(i=0; i<N; i++){
			for(j=0; j<N; j++){
				if(c[i][j] != l)
					chg[(i+j)%3][l] += D[c[i][j]][l]; 
			}
		}
	}
	res = 1000000000;
	for(k[0]=0; k[0]<C; k[0]++){
		for(k[1]=0; k[1]<C; k[1]++){
			if(k[0]==k[1])
				continue;
			for(k[2]=0; k[2]<C; k[2]++){
				if(k[0]==k[2] || k[1]==k[2])
					continue;
				int tmp=0;
				for(i=0; i<3; i++){
					tmp += chg[i][k[i]];
				}
				if(tmp < res)
					res = tmp;
			}
		}
	}
	printf("%d\n", res);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i, j;
	scanf("%d%d", &N, &C);
	for(i=0; i<C; i++){
		for(j=0; j<C; j++)
			scanf("%d", &D[i][j]);
	}
	for(i=0; i<N; i++){
		for(j=0; j<N; j++){
			scanf("%d", &c[i][j]);
			c[i][j] --;
		}
	}
	solve();
	return 0;
}

Measured memory_bytes: 1152
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let css = Array.init 10 @@ fun _ -> Array.init 10 @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let a_ss = Array.init h @@ fun _ -> Array.init w @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let dp = Array.make_matrix 10 10 0
let ms = Array.make 10 0
let ans = ref 0
let _ =
  for i = 0 to 9 do dp.(i).(1) <- css.(i).(1) done;
  for i = 2 to 9 do
    for j = 0 to 9 do
      let m = ref max_int in
      for k = 0 to 9 do if j <> k then m := min !m @@ css.(j).(k) + dp.(k).(i - 1) done;
      dp.(j).(i) <- !m done done;
  for i = 0 to 9 do
    if i <> 1 then
      let m = ref max_int in
      for j = 1 to 9 do m := min !m @@ dp.(i).(j) done;
      ms.(i) <- !m done;
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      if a_ss.(i).(j) <> -1 then ans := !ans + ms.(a_ss.(i).(j)) done done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 4864
import std.stdio;
import std.array;
import std.algorithm;
import std.conv;
import std.string;
import std.numeric;

void main() {
    int n; readf("%d\n", &n);
    int[] x = readln.chomp.split(" ").map!(to!int).array;
    int g = x.reduce!gcd;
    for (int i = 1; i <= g; i++) {
        if (g % i == 0) i.writeln;
    }
}

Measured memory_bytes: 1100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  if(A <= 5){
  	cout << 0 << endl;
  }else if(A <= 12 && A >= 6){
  	cout << B/2 << endl;
  }else{
  	cout << B << endl;
  }
  
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace _0218
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }
                string[] p = new string[n];
                for (int i = 0; i < n; i++)
                {
                    int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    if (x[0] == 100 || x[1] == 100 || x[2] == 100)
                    {
                        p[i] = "A";
                    }
                    else if ((x[0] + x[1]) >= 180)
                    {
                        p[i] = "A";
                    }
                    else if (x[0] + x[1] + x[2] >= 240)
                    {
                        p[i] = "A";
                    }
                    else if (x[0] + x[1] + x[2] >= 210)
                    {
                        p[i] = "B";
                    }
                    else if (x[0] + x[1] + x[2] >= 150)
                    {
                        if (x[0] >= 80 || x[1] >= 80)
                        {
                            p[i] = "B";
                        }
                        else
                        {
                            p[i] = "C";
                        }
                    }
                    else
                    {
                        p[i] = "C";
                    }
                }
                for (int i = 0; i < n; i++)
                {
                    Console.WriteLine(p[i]);
                }
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9252
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    n = get_int()
    D = get_li()
    D.sort()
    a, b = D[len(D) // 2 - 1], D[len(D) // 2]
    print(b - a)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()


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

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long double db;

#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 ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

template<typename T> void print(const T& a, ostream& out){	
	for(auto i: a) out << i << ' ';
	out << endl;
}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n; cin >> n;
	vector<int> a(n);
	FOR(i, 0, n) cin >> a[i];
	LL ans = 0;
	int mx = 0;
	FOR(i, 0, n){
		setmax(mx, a[i]);
		ans += mx - a[i];
	}

	cout << ans << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}


Measured memory_bytes: 4024
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;

int main(){
  int n, prime_num;
  cin>>n;
  prime_num = 0;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    int max = (int)sqrt(x);
    if (x==2 || x==3){
      prime_num += 1;
      continue;
    }
    for(int j=2;j<=max;j++){
      if (x % j == 0) break;
      if (j==max){
	prime_num += 1;
      }
    }
  }
  cout<<prime_num<<endl;
  return 0;
}



Measured memory_bytes: 3076
# -*- coding: utf-8 -*-

N = int(input())
M = [input().split() for i in range(N)]
X = input()

def solver(M,X):
    result = 0
    flag = 0
    for m in M:
        if flag == 1:
            result += int(m[1])
        if m[0]==X:
            flag = 1
    return result

print(solver(M,X))

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> h(n + 10);
  vector<bool> good(n + 10, true);
  rep(i, n) cin >> h[i + 1];

  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    if (h[a] < h[b])
      good[a] = false;
    else if (h[a] == h[b])
      good[a] = false, good[b] = false;
    else
      good[b] = false;
  }
	int ans=0;
	rep(i,n){
		if(good[i+1])ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3976
import java.net.SecureCacheResponse;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();

        int[][] matrix = new int[n][2];


        for (int i = 0; i < n; i++) {
            matrix[i][0] = sc.nextInt();// cost
            matrix[i][1] = sc.nextInt();// time
        }

        int minCost = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            if (matrix[i][1] <= t) {// 時間内
                minCost = Math.min(minCost, matrix[i][0]);
            }
        }

        System.out.println(minCost == Integer.MAX_VALUE ? "TLE" : minCost);
    }
}


Measured memory_bytes: 23120
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
int counter(int x) {
	if (x == 0) return 0;
	return (x & 1) + counter(x >> 1);
}

void solve() {
	int n; cin >> n;
	vector<int> a(n + 1);
	vector<vector<int>> x(n + 1, vector<int>(n + 1));
	vector<vector<int>> y(n + 1, vector<int>(n + 1));
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		for (int j = 1; j <= a[i]; ++j) {
			cin >> x[i][j] >> y[i][j];
		}
	}
	int ans = 0;
	for (int bits = 1; bits < (1 << n); ++bits) {
		bool ok = true;
		for (int i = 1; i <= n; ++i) {
			if (!(bits & (1 << (i - 1)))) continue;
			for (int j = 1; j <= a[i]; ++j) {
				if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) ok = false;
			}
		}
		if (ok) ans = max(ans, counter(bits));
	}
	cout << ans << endl;
	return;
}

int main() {
	solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;
int s(int x) {
  int sum = 0;
  while(x) {
    sum += x%10;
    x = x/10;
  }
  return sum;
}
int main() {
  int x;
  cin >> x;
  if(x%s(x) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> hoge(n);
    for (int i = 0; i < n; i++) cin >> hoge[i];
    sort(hoge.begin(), hoge.end(),greater<>());
    int ans=0,alice = 0, bob = 0;
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
        {
            alice += hoge[i];
        }
        else
        {
            bob += hoge[i];
        }
    }
    ans = alice-bob;
    cout << ans;
}

Measured memory_bytes: 256
import static java.util.Comparator.comparing;

import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==========================================================
    List<PPL> list = new ArrayList<>();
	Queue<PPL> que = new ArrayDeque<>();
    public void solve() {
    	int N = ni();
    	long D = nl();
    	long A = nl();
    	long x, h;
    	for (int i = 0; i < N; i++) {
			x = nl();
			h = nl();
			list.add(new PPL(x,h));
		}
    	list.sort(comparing(PPL::getKey));
    	long wk, cnt, total = 0, ans = 0;
    	PPL bb;
    	for (PPL pp : list) {
    		wk = pp.val;
    		while(!que.isEmpty() && que.peek().key < pp.key) {
   				bb = que.poll();
   				total -= bb.val;
    		}
    		wk -= total;
    		if(wk > 0) {
   				cnt = (wk + A - 1) / A;
   				ans += cnt;
   				total += A * cnt;
   				que.add(new PPL(pp.key + 2 * D, A * cnt));
    		}
		}
    	out.println(ans);
    }
    class PPL {
    	public long key, val;
    	public PPL(long key, long val) {
    		this.key = key;
    		this.val = val;
    	}
		public long getKey() {
			return key;
		}
		public void setKey(long key) {
			this.key = key;
		}
		public long getVal() {
			return val;
		}
		public void setVal(long val) {
			this.val = val;
		}
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 160604
import itertools
 
N = int(input())
keep = []
P = tuple((map(int, input().split())))
Q = tuple((map(int, input().split())))
for i in range(1, N + 1):
    keep.append(i)
all = list(itertools.permutations(keep))

for j in range(len(all)):
    if all[j] == P:
        ans1 = j
    if all[j] == Q:
        ans2 = j
print(abs(ans1 - ans2))


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

int main () {
  int H , W ;
  cin >> H >> W ;
  
  int dx[4] = {-1,1,0,0} ;
  int dy[4] = {0,0,-1,1} ;
  
  char board[H][W] ;
  
  for(int i = 0 ; i < H ; i++ ) {
    for(int j = 0 ; j < W ; j++ ) {
      cin >> board[i][j] ;
    }
  }
  
  bool ans = true ;
  
  for(int i = 0 ; i < H ; i++ ) {
    for(int j = 0 ; j < W ; j++ ) {
      if(board[i][j] == '#') {
        
        bool can2 = false ;
        
        for(int k = 0 ; k < 4 ; k++ ){
          
          
          int nx = i + dx[k] ;
          int ny = j + dy[k] ;
          
          if( nx < 0 || nx >= H ) continue ;
          if( ny < 0 || ny >= W ) continue ;
          
          if(board[nx][ny] == '#' ) can2 = true ;
          
        }
        if(!can2) ans = false ;
      }
    }
  }
  if(ans) cout << "Yes" << endl ;
  else cout << "No" << endl ;
}

Measured memory_bytes: 256
def B():
    n, k = list(map(int, input().split()))
    a = []
    for i in range(2*k):
        ipt = input()
        if i%2==1:
            a += list(map(int, ipt.split()))
    a = set(a)
    res = set(range(1, n+1)) - a 
    print(len(res))
B()

Measured memory_bytes: 9196
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author KY2001
 */


#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}

class CMarch {
public:
  int solve(std::istream &cin, std::ostream &cout) {
    int N;
    cin >> N;
    vector<int> MARCH(5, 0);
    string march = "MARCH";
    rep(i, N) {
      string temp;
      cin >> temp;
      rep(j, 5) {
        if (temp[0] == march[j])
          MARCH[j] += 1;
      }
    }
    int ans = MARCH[0] * (MARCH[1] * (MARCH[2] + MARCH[3] + MARCH[4]) + MARCH[2] * (MARCH[3] + MARCH[4]) + MARCH[3] * MARCH[4]) + MARCH[1] * (MARCH[2] * (MARCH[3] + MARCH[4]) + MARCH[3] * MARCH[4]) + MARCH[2] * MARCH[3] * MARCH[4];
    cout << ans << endl;
  }
};


signed main() {
	CMarch solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	return (a+b)%m;}
int sub(int a,int b,int m=mod){	return (a-b+m)%m;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}



void solve()
{
	int n;
	cin>>n;
	int a[n],i,ans=0;
	map<int,int> mp;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		ans+=mp[i-a[i]];
		mp[i+a[i]]++;
	}
	cout<<ans<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	while(t--)	solve();
	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vull vector<ull>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int tt; cin >> tt; for(int cs = 1; cs <= tt; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define reset(x,y) memset(x,y,sizeof x);
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

ll pref[4005][105];
ll suf[10005][105];
map<char,string> tmp;
int main() {
	IOS
	tmp['R']="GB";
	tmp['G']="RB";
	tmp['B']="RG";
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i = 1; i<=n;i++) {
		for(auto x : tmp) {
			pref[i][x.fi]=pref[i-1][x.fi]+(s[i-1]==x.fi);
//			debug(pref[i][x.fi])
//			debug(x.fi)
		}
	}
//	testing
	for(int i = n; i>=1;i--) {
		for(auto x : tmp) {
			suf[i][x.fi]=suf[i+1][x.fi]+(s[i-1]==x.fi);
//			debug(suf[i][x.fi])
		}
	}
	ll res=0;
	for(int i = 2; i <= n; i++) {
		for(int j = 1; j < i; j++) {
			char a=tmp[s[i-1]][0];
			char b=tmp[s[i-1]][1];
			ll haduh=(s[i-j-1]==a)*(suf[i+1][b]-suf[i+j][b]+suf[i+j+1][b]);
//			debug(haduh)
			ll haduh2=(s[i-j-1]==b)*(suf[i+1][a]-suf[i+j][a]+suf[i+j+1][a]);
//			debug(haduh2)
			res+=haduh;
			res+=haduh2;
//			testing
		}
	}
	cout<<res<<endl;
}


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

int main(){
    int w, h, n;
    cin >> w >> h >> n;
    int xmin = 0, xmax = w, ymin = 0, ymax = h;
    for(int i = 0; i < n; i++){
        int x, y, a;
        cin >> x >> y >> a;
        if(a == 1) if(xmin < x) xmin = x;
        if(a == 2) if(xmax > x) xmax = x;
        if(a == 3) if(ymin < y) ymin = y;
        if(a == 4) if(ymax > y) ymax = y;
    }
    if(xmax - xmin > 0 && ymax - ymin > 0){
        cout << (xmax - xmin) * (ymax - ymin) << endl;
    }
    else cout << 0 << endl;
}

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

int main() {
  int N;
  cin >> N;
  int M; 
  M = N % 10;
  
  if(M == 3){
    cout << "bon" << endl;
  }
  else if(M == 1 || M == 6 || M == 8 || M == 0){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}


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

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    auto pi = acos(-1);

    h = h + (m / 60);

    auto x1 = a * cos((h / 6) * pi);
    auto y1 = a * sin((h / 6) * pi);

    auto x2 = b * cos((m / 30) * pi);
    auto y2 = b * sin((m / 30) * pi);

    auto dx = x1 - x2;
    auto dy = y1 - y2;

    cout << std::setprecision(15) << sqrt(dx * dx + dy * dy);
    return 0;
}


Measured memory_bytes: 4108
#nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

a = int(input())

while(True):
    if is_prime(a):
        print(a)
        break
    a += 1

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void fast()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
}
int gcd(int a,int b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int main()
{
    fast();
    int a,b;cin>>a>>b;
    cout<<(ll)a*b/gcd(a,b);
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x=0,max_x=0;
  cin>>n;
  char s[n+1];
  cin>>s;
  for(int i=0;i<n;++i){
    if(s[i]=='I')
      x++;
    if(s[i]=='D')
      x--;
    if(x>max_x)
      max_x=x;
  }
  cout<<max_x<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int nsum(int n) {
	return (n<10)?n:n%10+nsum(n/10);
}

int isHarshad(int n) {
	return (n%nsum(n))?0:1;
}

int main() {
	int h,n;
	scanf("%d",&n);
	if(isHarshad(n)) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
using namespace std;
//
const int inf=1e9+7;//0x3f
//
int N,M;
string S;
vector<int> V[200001];
bool used[200001];
int A[200001],B[200001];
int main(){
	cin>>N>>M>>S;
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		V[a].push_back(b);
		V[b].push_back(a);
		if(S[a]=='A'){
			A[b]++;
		}else{
			B[b]++;
		}
		if(S[b]=='A'){
			A[a]++;
		}else{
			B[a]++;
		}
	}
	queue<int> que;
	for(int i=0;i<N;i++){
		if(A[i]==0||B[i]==0){
			que.push(i);
			used[i]=true;
		}
	}
	int ans=0;
	while(!que.empty()){
		int v=que.front();
		que.pop();
		ans++;
		for(int i=0;i<V[v].size();i++){
			int t=V[v][i];
			if(!used[t]){
				if(S[v]=='A'){
					A[t]--;
				}else{
					B[t]--;
				}
				if(A[t]==0||B[t]==0){
					used[t]=true;
					que.push(t);
				}
			}
		}
	}
	if(ans<N){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 12548
def break_number(N: int)->int:
    if N == 1:
        return 1

    freq = [0] * (N+1)
    d = 2
    while d <= N:
        i = d
        while i <= N:
            freq[i] += 1
            i += d
        d <<= 1

    return freq.index(max(freq))


if __name__ == "__main__":
    N = int(input())
    ans = break_number(N)
    print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
inline int read(){
	int s=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) s=s*10+ch-'0',ch=getchar();
	return s;
}
typedef pair<int,int> pii;
#define fi first
#define se second
int n;
set<int> s[N];
map<pii,int> mp; 
queue<pii> q;
int fa[N];
inline int findf(int x){
	return x==fa[x]?x:fa[x]=findf(fa[x]);
}
int main(){
	n=read();
	for(int i=1;i<=2*(n-1);i++){
		int x=read(),y=read();
		if(x>y) swap(x,y);
		s[x].insert(y),s[y].insert(x);
		pii p=make_pair(x,y);
		mp[p]++;
		if(mp[p]==2) q.push(p);
	}
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<n;i++){
		if(q.empty()) {
			puts("NO");
			return 0;
		}
		int x=0,y=0;
		while(!q.empty()&&x==y) x=findf(q.front().fi),y=findf(q.front().se),q.pop();
		if(s[x].size()>s[y].size()) swap(x,y);
		fa[x]=y;
		for(set<int>::iterator it=s[x].begin();it!=s[x].end();++it){
			int z=*it;
			s[z].erase(x);
			if(z==y) continue;
			s[z].insert(y);s[y].insert(z);
			pii p;
			if(z<y) p=make_pair(z,y);
			else p=make_pair(y,z);
			mp[p]++;
			if(mp[p]==2) q.push(p);
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 48128
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> x(26, 0);
  for (int i = 0; i < s.length(); i++) {
    x[s[i] - 'a']++;
  }
  long long ans = 1;
  for (int i = 0; i < 26; i++) {
    ans *= (x[i] + 1);
    ans %= 1000000007;
  }
  
  cout << ans - 1;
  return 0;
}

Measured memory_bytes: 512
n = gets.to_i
doublet_cnt = 0
n.times do |i|
  next if doublet_cnt >= 3
  d1, d2 = gets.split.map(&:to_i)
  if d1 == d2
    doublet_cnt += 1 
  else
    doublet_cnt = 0
  end
end
if doublet_cnt >= 3
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14412
#!/usr/bin/ruby
class UnionFind < Hash
	def root(a)
		self[a]=a if !has_key?(a)
		return self[a]==a ? a : (self[a]=root(self[a]))
	end
	def unite(a,b)
		x=root(a)
		y=root(b)
		self[x]=y
	end
end
uf=UnionFind.new
n,m=gets.split.map &:to_i
q=gets.split.map &:to_i
m.times{
	x,y=gets.split.map &:to_i
	uf.unite(x,y)
}
h=Hash.new{|h,k|h[k]=[]}
g=Hash.new{|g,k|g[k]=[]}
(1..n).each{|i|
	h[uf.root(i)]<<q[i-1]
	g[uf.root(i)]<<i
}
r=0
h.each_key{|k|r+=(h[k]&g[k]).size}
p r


Measured memory_bytes: 40052
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m,i,cnt=0;
  double sum=0.0;
  cin >> n >> m;
  vector<int>a(n);
  for(i=0; i<n; i++){
    cin >> a.at(i);
    sum+=a.at(i);
  }
  for(i=0; i<n; i++){
    if(a.at(i)<sum/(4*m)){
      cnt++;
    }
  }
  if(n-cnt>=m){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	ll k; cin >> k;
	ll a, b; cin >> a >> b;

	for (ll i = a; i <= b; ++i)
		if (i % k == 0)
		{
			std::cout << "OK"<< std::endl;
			return 0;
		}
	std::cout << "NG"<< std::endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

typedef pair<int , int> ii;
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int N;
string S;
ll fac[maxn];

int main(){
  cin >> N;
  cin >> S;
  fac[0] = 1;
  for(int i = 1; i < maxn; ++i)fac[i] = fac[i - 1] * i % mod;
  ll ret = 1;
  ll cnt = 0;
  for(int i = 0; i < 2 * N; ++i){
    char cc;
    if(cnt & 1){
      if(S[i] == 'W'){
        cc = 'L';
      }
      else{
        cc = 'R';
      }
    }
    else{
      if(S[i] == 'W'){
        cc = 'R';
      }
      else{
        cc = 'L';
      }
    }
    if(cc == 'R'){
      ret = (ret * cnt) % mod;
      --cnt;
    }
    else ++cnt;
    if(cnt < 0){
      cout << 0 << endl;
      return 0;
    }
  }
  if(cnt)cout << 0 << endl;
  else cout << (ret * fac[N] % mod + mod) % mod << endl;
  return 0;
}


Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
        out << '(' << p.first << ',' << p.second << ')';
            return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
        in >> p.first >> p.second;
            return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
        for (T &x : v)
                    in >> x;
            return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
        for (const vector<T> &x : v)
                    out << x << '\n';
            return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
        for (const T &x : v)
                    out << x << ' ';
            return out;
}

template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
        for (const T &x : s)
                out << x << ' ';
            return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

ll sum(vi &count,ll i,ll j)
{
    if(i<=j)
    {
        ll ans=count[j];
        if(i)
            ans-=count[i];
        return ans;
    }
    return 0;
}

int main()
{
    fast();
    ll n;
    cin>>n;
    string c;
    cin>>c;
    vi count(n,0);
    for(ll i=0;i<n;i++)
    {
        if(c[i]=='R')
            count[i]=1;
        if(i)
            count[i]+=count[i-1];
    }
    ll ans=inf;
    for(ll r=0;r<=n;r++)
    {
        ll ind=r-1;
        //0...ind
        //ind+1,...n-1
        
        ll curr1=sum(count,0,ind);
        ll curr2=sum(count,ind+1,n-1);
        
        ll w1=r-curr1;
        ll r2=curr2;
        ll swa=min(w1,r2);
        
        w1-=swa;
        r2-=swa;

        ans=min(ans,swa+w1+r2);
    }
    cout<<ans<<nl;
}


Measured memory_bytes: 5192
import java.util.Scanner;

class Main {

public static void main(String[] args){
     

      Scanner sc = new Scanner(System.in);

      int Smax = sc.nextInt();



System.out.println((Smax / 3600) + ":" + ((Smax/60)%60) + ":" + (Smax % 60));

}
}



Measured memory_bytes: 26256
// #include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
#define pi 3.14159
int32_t main()
{
    IOS
  
	
	int n,k;
	cin>>n;
	int x[n+1];
	memset(x,0,sizeof(x));
	for(int i=1;i<=n-1;i++)
	{
		int p;
		cin>>p;
		x[p]++;
	}
	for(int i=1;i<=n;i++)
		cout<<x[i]<<endl;
}       

Measured memory_bytes: 5180
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    d = int(ipt())
    c = [int(i) for i in ipt().split()]
    s = [[int(i) for i in ipt().split()] for _ in range(d)]
    ld = [-1]*26
    edval = [0]*26

    for i in range(d):
        edval = s[i]*1
        for j in range(26):
            dl = i-ld[j]
            edval[j] += c[j]*dl*(dl+1)/15
        v = edval.index(max(edval))
        ld[v] = i
        print(v+1)

    return

if __name__ == '__main__':
    main()


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

#define SE second
#define FI first
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int) (x).size())

#define _ << " " <<
#define TR(x) cout << #x _ x << endl

using namespace std;
const int INF = (int) 1e9 + 5;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int t = a + b + c - max(a, max(b, c));
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  for (int i = 0; i < n; i++) {
    if (i == k - 1) {
      cout << (char)(s[i] + 32);
    } else {
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = 998244353;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 6000 + 7;

int a, b, c, d;

bool read () {
	if (scanf("%d%d%d%d", &a, &b, &c, &d) != 4)
		return false;
	return true;
}

int fact[N];
int rfact[N];

int add(int a, int b){
	a += b;
	if (a >= MOD)
		a -= MOD;
	if (a < 0)
		a += MOD;
	return a;
}

int mul(int a, int b){
	return a * li(b) % MOD;
}

int dp[N][N][2];

void solve() {	
	memset(dp, 0, sizeof(dp));
	dp[a][b][1] = 1;
	forn(i, c + 1) forn(j, d + 1){
		if (i < c)
			dp[i + 1][j][0] = add(dp[i + 1][j][0], mul(add(dp[i][j][0], dp[i][j][1]), j));
		if (j < d)
			dp[i][j + 1][1] = add(dp[i][j + 1][1], add(dp[i][j][0], mul(dp[i][j][1], i)));
	}
	printf("%d\n", add(dp[c][d][0], dp[c][d][1]));
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if(read()) {
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 285744
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int c=a+b;
	int d=a-b;
	int e=a*b;
	cout<<max(c,max(d,e))<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif
 
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000000
#define ll long long
#define db double
#define str string
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Forrev(i,s,e) for (ll i=(s); i>=(e); i--)
#define all(v) v.begin(),v.end()
 
#define vll vector<ll>
#define vs vector<string>
#define mapll map<ll,ll>
#define pll pair<ll,ll>
#define initialise(a, x) memset(a, x, sizeof(a))
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
 
#define ff first
#define ss second
#define endl "\n"
#define mp make_pair
const ll mod=1e9 + 7;
 
ll takemod(ll a) {
    return ((a%mod)+mod)%mod;
}
 
ll gcd(ll a, ll b) { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);        
}
 
ll fast_exp(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%mod;
        base=(base*base)%mod;
        expo>>=1;}
    return res;
}
 
ll modinv(ll a) {
    return takemod(fast_exp(takemod(a), mod-2));
}
 
void solve () {
	
	int n, k;
	cin >> n >> k;

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

	int dp[k+1];
	memset(dp, 0, sizeof(dp));
	
	for (int i = 1; i <= k; i++) {
		
		int flag = 0;
		for (int j = 0; j < n; j++) {
			
			if(arr[j] <= i and dp[i - arr[j]] == 0)
				flag = 1;
		}

		if (flag == 1)
			dp[i] = 1;
	}

	if (dp[k] == 1)
		cout << "First" << endl;
	else 
		cout << "Second" << endl;
}

 
signed main() 
{
    fast_cin();
    
    
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    
    
    return 0;    
}

Measured memory_bytes: 3996
#include <iostream>

using namespace std;

int main()
{
   int a,x,y=0;
   cin >> a;
   for (int i=1; i<=a; i++)
   {
       cin >> x;
       if (x%2==1&&i%2==1)
       {
           ++y;
       }
   }
   cout << y;
   return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define maxn 4000040
#define r1 rt << 1
#define r2 rt << 1 | 1
#define root 1, n, 1
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
const ll MIN = -2e16;


int main() {
    ll a, b, c, k;
    while(~scanf("%lld%lld%lld%lld", &a, &b, &c, &k)) {
        ll ans = a - b;
        if(k & 1) cout << -ans << endl;
        else cout << ans << endl;
    }
    return 0;
}
/*

2
3
40 30 20
1 2 3
20 20 10
5
25 25 50 60 10
10 50 5 100 30
70 5 30 25 40
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define pi  3.14159265358979323846
 
double abss(double a){
	if(a >= 0) return a;
	else return -a;
}
double minn(double a, double b){
	if(a <= b) return a;
	else return b;
}
void Solve(){
 	double a, b, h, m;
 	cin>>a>>b>>h>>m;
 	if(a > b){
 		double c = a;
 		a = b;
 		b = c;
 	}
 	h += (m / 60);
 	h *= 5;
 	double d = abss(h - m);
 	d = minn(d, 60 - d);
 	//cout<<d<<endl;
 	double res = 0;
 	double degree = d * 6;
 	//cout<<degree<<endl;
 	double x = cos(degree * pi / 180) * a;
 	double y = b - x;
 	double z = sin(degree * pi / 180) * a;
 	res = z * z + y * y;
 	res = sqrt(res);
 	//cout<<x<<" "<<y<<" "<<z<<endl;
 	cout<<fixed<<setprecision(15)<<res<<'\n';
 
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T = 1;
	//cin>>T;
	while(T--){
		Solve();
	}
}

Measured memory_bytes: 4140
def sumitrust2019_d():
    n = int(input())
    s = input()

    ans = 0

    for i in range(1000):
        # 確認するpinの数字の組み合わせと桁の初期化
        # pin = list(str(i).zfill(3))
        current_digit = 0
        pin = f'{i:0>3}'
        search_num = pin[current_digit]

        for num in s:
            # 見つけると桁を右に一つずらす
            # 毎回リストにアクセスするより変数に取り出しておくほうがいいかも。
            # if num == pin[current_digit]:
            if num == search_num:
                current_digit += 1

                # indexが3(桁が3→2→1→0)になったときはそのPINは作れる
                if current_digit == 3:
                    ans += 1
                    break
                # 見つけ終わるまではチェックする数字を置き換え。
                elif current_digit < 3:
                    search_num = pin[current_digit]

    print(ans)

if __name__ == '__main__':
    sumitrust2019_d()

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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n + 1), b(n);
    for(ll i = 0; i < n + 1; i++) cin >> a[i];
    for(ll i = 0; i < n; i++) cin >> b[i];
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        ll ai = a[i], bi = b[i];
        a[i] = max((ll)0, ai - bi);
        b[i] = max(bi - ai, (ll)0);
        ll ai2 = a[i + 1], bi2 = b[i];
        a[i + 1] = max((ll)0, ai2 - bi2);
        b[i] = max(bi2 - ai2, (ll)0);
        ans += bi - b[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
  int a,i,c=0;
  double b=0;
  scanf("%d", &a);
  for(i=1; i<=a; i++){
  if(i%2 !=0){
    c++;
  }
  }
  b=(double)c/a;
  printf("%f",b);
  return 0;
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::{BTreeMap,BTreeSet};
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! tf {
    ($c:expr, $t:expr, $f:expr) => {{
        if $c { $t } else { $f }
    }};
}

fn main() {
    let z = read_i64();
    let digits = {
        let mut res = vec![];
        let mut x = z;
        while x != 0 {
            res.push(x % 3);
            x /= 3;
        }
        res
    };
    let mut total = 0;
    let mut edges = vec![];
    for i in 0..12 {
        edges.push((i, i+1, 0 * 3i64.pow(i as u32)));
        edges.push((i, i+1, 1 * 3i64.pow(i as u32)));
        edges.push((i, i+1, 2 * 3i64.pow(i as u32)));
    }
    for (i, &d) in digits.iter().enumerate() {
        for _ in 0..d {
            edges.push((13, i, total));
            total += 3i64.pow(i as u32);
        }
    }
    println!("{} {}", 14, edges.len());
    for &(s,t,w) in &edges {
        let s = 14 - s;
        let t = 14 - t;
        println!("{} {} {}", min(s, t), max(s, t), w);
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    //ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 4352