akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
ll mod=1000000007;

ll fun(int n,int k,int *a){
    ll dp[n+1][k+1];
    for(int i=0; i<=k; i++){
        dp[1][i]= i>a[0]?0:1;
    }
    for(int i=2; i<=n; i++){
        for(int j=0; j<=k; j++){
            if(j==0){
                dp[i][j]=dp[i-1][j];
            }
            else{
                dp[i][j]=mod+dp[i-1][j]+dp[i][j-1]-((j-a[i-1]-1) >= 0?dp[i-1][j-a[i-1]-1]:0);
                dp[i][j]%=mod;
            }
        }
    }
    return dp[n][k];
}
void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    cout<<fun(n,k,a);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}


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


class squareroute
{
    static void Main(string[] args)
    {
        while (true)
        {
            int N, M;
            string[] s = Console.ReadLine().Split(' ');
            if (s[0] == "0" & s[1] == "0") break;
            N = int.Parse(s[0]);
            M = int.Parse(s[1]);
            int[] hpos = new int[N + 1];
            int[] wpos = new int[M + 1];
            hpos[0] = 0;
            wpos[0] = 0;
            for (int i = 1; i <= N; i++)
            {
                hpos[i] = int.Parse(Console.ReadLine()) + hpos[i - 1];
            }
            for (int i = 1; i <= M; i++)
            {
                wpos[i] = int.Parse(Console.ReadLine()) + wpos[i - 1];
            }

            List<int> hlength = new List<int>();
            List<int> wlength = new List<int>();
            for (int i = 0; i <= N; i++)
            {
                for (int j = i + 1; j <= N; j++)
                {
                    hlength.Add(hpos[j] - hpos[i]);
                }
            }
            for (int i = 0; i <= M; i++)
            {
                for (int j = i + 1; j <= M; j++)
                {
                    wlength.Add(wpos[j] - wpos[i]);
                }
            }
            Dictionary<int, int> hdic = new Dictionary<int, int>();
            Dictionary<int, int> wdic = new Dictionary<int, int>();
            for (int i = 0; i < hlength.Count; i++)
            {
                if (hdic.ContainsKey(hlength[i]))
                {
                    hdic[hlength[i]]++;

                }
                else
                {
                    hdic[hlength[i]] = 1;
                }
            }
            for (int i = 0; i < wlength.Count; i++)
            {
                if (wdic.ContainsKey(wlength[i]))
                {
                    wdic[wlength[i]]++;
                }
                else
                {
                    wdic[wlength[i]] = 1;
                }
            }

            int sum = 0;
            foreach (var x in hdic)
                if (wdic.ContainsKey(x.Key))
                {
                    sum += x.Value * wdic[x.Key];
                }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 58144
n, m = gets.split.map(&:to_i)
a = 1
ans = 1
while a * a <= m
  flag = true
  if m % a != 0
   flag = false
  end

  if flag == true
    b = m / a
    if a * n <= m
      ans = [a, ans].max
    end
    if b * n <= m
      ans = [b, ans].max
    end
  end
    a += 1
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll N, K;
int A[100005];
int B[100005];
vector<int> v;

void make(int n, ll S){
  if(n==0){
    v.push_back(S);
    return;
  }
  if(((K>>(n-1))&1)==0){
    make(n-1,S);
  }else{
    {//0
      int x = (1<<(n-1)) - 1;
      make(0, S+x);
    }
    {//1
      int x = (1<<(n-1));
      make(n-1,S+x);
    }
  }
}

  
int main(){

  cin >> N >> K;
  rep(i,N){
    cin >> A[i] >> B[i];
  }

  int n = 1;
  while(K>>n) n++;

  make(n, 0);
  /*
  rep(i,v.size()){
    cout << v[i] << "\t";
    for(int j=6; j>=0; j--){
      cout << (((v[i]>>j)&1)?1:0);
    }
    cout << endl;
  }
   */

  ll ret = 0;
  rep(i,v.size()){
    ll S = v[i];
    ll sum = 0;
    rep(j,N){
      if((S|A[j]) == S){
        sum += B[j];
      }
    }
    ret = max(ret, sum);
  }
  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 1024
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
ans = 0
for i in [a, b, c, d, e]:
    for j in [a, b, c, d, e]:
        if i != j and k < j - i:
            ans = 1

if ans == 1:
    print(':(')
else:
    print('Yay!')





Measured memory_bytes: 3060
n = int(input())

arm_list = []
for i in range(n):
    array = list(map(int, input().split()))
    a = array[0] - array[1]
    b = array[0] + array[1] - 1
    arm_list.append([a, b])

arm_list.sort(key=lambda x:x[1])

if n == 1:
    print(1)
    exit()
count = 1
a = arm_list[0][1]
b = arm_list[1][0]
for i in range(1, n-1):
    if a < b:
        count += 1
        a = arm_list[i][1]
        b = arm_list[i+1][0]
    else:
        b = arm_list[i+1][0]

if a < b:
    count += 1



print(count)

Measured memory_bytes: 21800
/*

Auther: Ganesh Bhandarkar
							#   RUN   #
		<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/

#include<bits/stdc++.h>
using namespace std;

/* KEYWORDS */
#define FASTIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define sq(a) (a)*(a)
#define rep(i,a,b) for(int i=a;i<b;++i)

/*DATATYPES */
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef pair<int , int > pi;
typedef pair<int , char > pic;
typedef pair<char , char > pc;
typedef pair<char , int > pci;

/*Constants */
const ll mod = 10000000007;

/* Booleans */
// bool OE(int n)  if(n & 1){ return true; } else false;


int main(){

	
	
	FASTIO

	int a,b;
	cin>>a>>b;
	if(a>b){
		for(int i=0;i<a;i++){
			cout<<b;
		}
	}else if(a==b){
		for(int i=0;i<a;i++){
			cout<<b;
		}
	}else if(a<b){
		for(int i=0;i<b;i++){
			cout<<a;
		}
	}


	return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	multiset<pair<int,int>> r,b;
	int x,y;
	for (int i = 0; i < n; ++i)
	{
		cin>>x>>y;
		r.insert({-y,-x});
	}
	for (int i = 0; i < n; ++i)
	{
		cin>>x>>y;
		b.insert({x,y});
	}
	int ans=0;
	for (auto v:b)
	{
		for (auto i = r.begin(); i != r.end(); ++i)
		{
			auto w=*i;
			if (v.first>-w.second&&v.second>-w.first)
			{
				r.erase(i);
				++ans;
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int score,i,sum = 0,average;
	for(i = 0; i < 5; i ++ ){
		scanf("%d",&score);
		if(score < 40)score = 40;
		sum += score;
	}
	average =sum / 5;
	printf("%d\n",average);
	return 0;
}
	
	
	

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
auto &errStream = cerr;
#ifdef LOCAL
#define cerr (cerr << "-- line " << __LINE__ << " -- ")
#else
class CerrDummy {
} cerrDummy;
template <class T>
CerrDummy &operator<<(CerrDummy &cd, const T &) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy &operator<<(CerrDummy &cd,
                      basic_ostream<charTDummy, traitsDummy> &(
                          basic_ostream<charTDummy, traitsDummy> &)) {
  return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr << "reached" << endl
#define DMP(x) cerr << #x << ":" << x << endl
#define ZERO(x) memset(x, 0, sizeof(x))
#define ONE(x) memset(x, -1, sizeof(x))

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

#define CAPITAL
void Yes(bool ex = true) {
#ifdef CAPITAL
  cout << "YES" << endl;
#else
  cout << "Yes" << endl;
#endif
  if (ex) exit(0);
}
void No(bool ex = true) {
#ifdef CAPITAL
  cout << "NO" << endl;
#else
  cout << "No" << endl;
#endif
  if (ex) exit(0);
}

const ll infLL = LLONG_MAX / 3;

#ifdef int
const int inf = infLL;
#else
const int inf = INT_MAX / 2 - 100;
#endif

signed main() {
  int vi[4] = {0, 0, 0, 0};
  REP(i, 3) {
    vi[read() - 1]++;
    vi[read() - 1]++;
  }
  int one = 0, two = 0, three = 0;
  REP(i, 4) {
    if (vi[i] == 1) one++;
    if (vi[i] == 2) two++;
    if (vi[i] == 3) three++;
  }
  if ((one == 2 && two == 2))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;

void solve() {
    int N;
    cin>>N;
	cout << (N + 1) / 2 << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


# どの都市間も同じ人数ずつ移動するとしてよい

N = int(sys.stdin.buffer.readline())
A = [int(sys.stdin.buffer.readline()) for _ in range(5)]
flow = min(A)
ans = math.ceil(N / flow) + 4
print(ans)


Measured memory_bytes: 17880
#include<stdio.h>
 
int main(){
int N, T;
int i, judge;

  scanf("%d %d", &N,&T);
  
int c[N],t[N];

judge = 1001;
 
  for(i = 0; i < N; i++){
  scanf("%d %d", &c[i], &t[i]);

  if(t[i] <= T){

  if(c[i] < judge)
  judge = c[i];
  }
}
 
  if(judge == 1001)
    printf("TLE\n");
 
  else printf("%d\n",judge);

  return 0;
 
}
 
  
 
  

Measured memory_bytes: 128
n, H = [int(e) for e in input().split(' ')]

a = []
b = []
for _ in range(n):
  a_i, b_i = [int(e) for e in input().split(' ')]
  a.append(a_i)
  b.append(b_i)

a.sort()
b.sort()
b.reverse()

while len(b) > 0 and b[-1] <= a[-1]:
  b.pop()

ans = 0
for e in b:
  ans += 1
  H -= e
  if H <= 0:
    break

if H > 0:
  ans += (H + a[-1] - 1) // a[-1]

print(ans)

Measured memory_bytes: 11336
import java.io.*;
 
public class Main{
    public static void main(String[] arsg) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
        while(true){
        int count = Integer.parseInt(br.readLine());
        if(count == 0) break;
         
        String str[] = new String[count];
        str = br.readLine().split(" ");
        double[] s = new double[count];
        double sum = 0;
        for(int i = 0;i<count;i++){
            s[i] = Double.parseDouble(str[i]);
            sum += s[i];
        }
        double average = (double) sum/count;
        double SUM = 0;
        for(int i = 0;i<count;i++){
            SUM += Math.pow(s[i]-average,2);
        }
        double SUM1 = (double) SUM/count;
        System.out.println(Math.sqrt(SUM1));
        }
    }
}


Measured memory_bytes: 26152
package main

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

func main() {
	scanInit()

	n := nextInt()

	fmt.Println((n - 1) * n / 2)

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, As):
    import math
    As = sorted(As, reverse=True)
    ans = As[0]
    for i in range(2, N):
        ans += As[math.ceil((i + 1) / 2) - 1]
    print(ans)



if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(N, As)


Measured memory_bytes: 31684
import sys
sys.setrecursionlimit(10**7)
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
swi = 0
s = [0, 0]
i = 0
while i < len(a) - 1:
    if a[i] == a[i + 1]:
        s[swi] = a[i]
        i += 1
        swi += 1
        if swi == 2:
            break
    i += 1

print(s[0] * s[1])

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

int main() {

  int N;
  cin >> N;

  int sum = 0;
  int mx = 0;

  for (int i = 0; i < N; i++) {
    int L;
    cin >> L;
    sum += L;
    mx = max(mx, L);
  }

  if (mx < sum - mx) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  string s;
  cin >> s;
  string t1 = "dream";
  string t2 = "dreamer";
  string t3 = "erase";
  string t4 = "eraser";

  reverse(ALL(s));
  reverse(ALL(t1));
  reverse(ALL(t2));
  reverse(ALL(t3));
  reverse(ALL(t4));

  for (int i = 0; i < s.size();) {
    string sub = s.substr(i, 3);
    bool flag = true;
    if (sub == t1.substr(0, 3)) {
      if (s.substr(i, t1.size()) != t1) flag = false;
      i += t1.size();
    } else if (sub == t2.substr(0, 3)) {
      if (s.substr(i, t2.size()) != t2) flag = false;
      i += t2.size();
    } else if (sub == t3.substr(0, 3)) {
      if (s.substr(i, t3.size()) != t3) flag = false;
      i += t3.size();
    } else if (sub == t4.substr(0, 3)) {
      if (s.substr(i, t4.size()) != t4) flag = false;
      i += t4.size();
    } else {
      flag = false;
    }
    if (!flag) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}


Measured memory_bytes: 512
import java.awt.print.Printable;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);


        int n = Integer.parseInt(scan.next());
        int rate = Integer.parseInt(scan.next());
        //int c = Integer.parseInt(scan.next());
        if(n>=10)  {
            out.print(rate);
        } else {
            out.print(rate+(100 * (10 - n)));
        }


        out.flush();
    }
}


Measured memory_bytes: 21716
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
from itertools import accumulate as acc
MOD=10**9+7
#======================================================#
def main():
    n = II()
    aa = MII()
    aa_cum = list(acc(aa))
    ans = 0
    for i in range(n):
        mul = aa_cum[-1] - aa_cum[i]
        ans += (aa[i]*mul)%MOD
    print(ans%MOD)


if __name__ == '__main__':
    main()

Measured memory_bytes: 33180
<?php
  $l = 0;
  $r = 0;
  while(list($a,$b,$c) = fscanf(STDIN,"%d,%d,%d\n")) {
      if($a==$b) $l++;
      else if($a*$a+$b*$b==$c*$c) $r++;
  }
  echo $r."\n".$l."\n";

Measured memory_bytes: 15288
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner scan = new Scanner(System.in);
        double r = scan.nextDouble();
		
		double x = r * r * Math.PI;
		double y = r * 2 * Math.PI;
		
		
		BigDecimal X = new BigDecimal(x);
		BigDecimal z = X.setScale(5, BigDecimal.ROUND_HALF_UP);
		BigDecimal Y = new BigDecimal(y);
		BigDecimal z2 = Y.setScale(5, BigDecimal.ROUND_HALF_UP);
		System.out.printf("%.5f",z);
		System.out.print(" ");
		System.out.printf("%.5f",z2);
	}

}

Measured memory_bytes: 28552
###==================================================
### import
import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

N = iIn()
A = iInLV(N)

lst = [A[0]]
for i in range(1, N):
    idx = bisect.bisect_left(lst, A[i])
    if idx == 0:
        lst.insert(0, A[i])
    else:
        lst[idx-1] = A[i]

print(len(lst))

Measured memory_bytes: 80604
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
static long n = 210000;
static long[] factorials = new long[n+1];//i!(mod p)を先にメモ
static long[] factorialRs = new long[n+1];//i!^-1(mod p), pは素数

	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long h = long.Parse(input[0]);
		long w = long.Parse(input[1]);
    long a = long.Parse(input[2]);
		long b = long.Parse(input[3]);
		long p = 1000000007;
    long answerm = 0;
    long answer = 0;

    factorials[0] = 1;
		factorialRs[n] = DivideModFactorial(n,p);
		for(long i = 1; i <= n; i++)
		{
		factorials[i] = (factorials[i-1]*i)%p;//i!(mod p)
		factorialRs[n-i] = (factorialRs[n+1-i]*(n+1-i))%p;//逆元も先にメモ
		}

    for(int i = 0; i < h-a; i++)//下に行く回数
    {
      answer = factorials[b-1+i];
      answer %= p;
      answer *= factorialRs[b-1];
      answer %= p;
      answer *= factorialRs[i];
      answer %= p;

      answer *= factorials[w-b-1 + h-i-1];
      answer %= p;
      answer *= factorialRs[w-b-1];
      answer %= p;
      answer *= factorialRs[h-i-1];
      answer %= p;

      //Console.WriteLine(answer);
      answerm += answer;
      answerm %= p;
    }

		Console.WriteLine(answerm);
	}

  static long DivideMod(long x, long a, long p)//戻り値はx^a(mod p)
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x%p;
    
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
        answer %= p;
      }
    memo *= memo;
    memo %= p;
    num *= 2;
    }
    return answer;
  }

  static long DivideModReverse(long x, long p)//戻り値はx^-1(mod p), pは素数
  {
    long answer = DivideMod(x, p-2, p);
    return answer;
  }

  static long DivideModFactorial(long x, long p)//戻り値はx!^-1(mod p), pは素数
  {
    long answer = 1;
    for(long i = x; i >= 2; i--)
    {
      answer *= DivideModReverse(i, p);
      answer %= p;
    }
    return answer;
  }

  static long Comb(long a, long b, long p)//戻り値は組み合わせC(a,b)のmod p
  {
    long answer = 1;
    answer *= factorials[a];
    answer %= p;
    answer *= factorialRs[a-b];//引数a-bは負にならないようにする
    answer %= p;
    answer *= factorialRs[b];
    answer %= p;
    return answer;
  }

  
}

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

H = A[0]
W = A[1]
K = A[2]



c = [input() for i in range(H)]
result = 0
c_t0 = c
shape_sum = 0

for x in range(H):
    for y in range(W):
        if c[x][y] == '#':
            shape_sum += 1

for xbit in range(2**H):
    for  ybit in range(2**W):

        ban_list = [[0] * W for i in [1] * H]
        tmp = shape_sum
        c = (c_t0)
        Sx = []
        Sy = []
        for i in range(H):
            if (xbit & (1<<i)):
                for iter in range(W) :
                    if c[i][iter] == '#' and ban_list[i][iter] == 0:
                        tmp -= 1
                        # c[i][iter] = '.'
                        ban_list[i][iter] = 1
               
                Sx.append(i) 
        for i in range(W):
            if (ybit & (1<<i)):
                for iter in range(H):
                    if c[iter][i] == '#'  and ban_list[iter][i] == 0:
                        tmp -= 1 
                        ban_list[iter][i] = 1
                        # c[iter][i] = '.'               
                Sy.append(i)        
        
        if tmp == K:
            result += 1

            # print("%d H: {" % xbit, end="")
            # for i in range(len(Sx)):
            #     print(" %d" % Sx[i], end="")
            # print(" }", end="")

            # print("%d W: {" % ybit, end="")
            # for i in range(len(Sy)):
            #     print(" %d" % Sy[i], end="")
            # print(" }")


print(result)


Measured memory_bytes: 9248
use std::io;
use std::str::FromStr;

fn main(){
    let stdin = io::stdin();

    loop {
        let mut buf = String::new();
        let _ = stdin.read_line(&mut buf);
        let vec : Vec<&str> = buf.split_whitespace().collect();

        let (a, op, b) = (i64::from_str(vec[0]).unwrap(), vec[1], i64::from_str(vec[2]).unwrap());
        if op == "?" {
            break
        }

        println!("{}", if op!="+" { if op!="-" { if op!="*" { a/b } else { a*b } } else { a-b } } else { a+b });
    }
}



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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

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

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}


int main(){

    ll a, b, c; cin >> a >> b >> c;

    cout << ((c-a-b>0 && 4*a*b<(c-a-b)*(c-a-b))?"Yes":"No") << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cnta[60],cntb[60];
int main(){
  ll a,b;
  cin>>a>>b;
  if(!a)a=1;
  ll ans=0;
  for(ll i=0;i<60;i++){
    cnta[i]=(a-1)/(1ll<<(i+1))*(1ll<<i);
    ll na=(a-1)%(1ll<<(i+1))+1;
    cnta[i]+=max(0ll,na-(1ll<<i));
    cntb[i]=b/(1ll<<(i+1))*(1ll<<i);
    ll nb=b%(1ll<<(i+1))+1;
    cntb[i]+=max(0ll,nb-(1ll<<i));
    if(abs(cnta[i]-cntb[i])%2)ans+=(1ll<<i);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
    int S[6];
    for (int &s: S)
        cin>>s;
    cout<<accumulate(S,S+6,0)-*min_element(S,S+4)-*min_element(S+4,S+6)<<endl;
}

Measured memory_bytes: 3056
#include<bits/stdc++.h>  
#define mod 1000000007
#define mp make_pair
#define pb push_back
 
using namespace std;
typedef long long ll;
 
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	ll n,d;
	cin >> n;
    
    cout << 3*n*n << endl;
}

Measured memory_bytes: 256
enum class State {
    None, Vacant, Male, Female
}

fun main(args: Array<String>) {
    fun query(pos: Int): State {
        println(pos)
        return State.valueOf(readLine()!!)
    }

    val n = readLine()!!.toInt()
    val seats = Array(n) { State.None }

    seats[0] = query(0)
    if (seats[0] == State.Vacant) return

    var l = 0
    var r = n - 1
    while (true) {
        val m = l + (r - l) / 2
        seats[m] = query(m)
        if (seats[m] == State.Vacant) return
        if (m % 2 == 0) {
            if (seats[m] == seats[0]) {
                l = m + 1
            } else {
                r = m
            }
        } else {
            if (seats[m] == seats[0]) {
                r = m
            } else {
                l = m + 1
            }
        }
    }
}


Measured memory_bytes: 34168
#include<cstdio>
#include<iostream>
#include<cctype>
#include<algorithm>
using namespace std;
int main(){
  string str;
  getline(cin , str);
  for(int i=0;i<str.size();i++){
    if(str[i] != ' ' && str[i] != '.' )str[i] -= 0x20;
  }
  cout << str << endl;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
const int M=1e6;
using namespace std;
int f[M];
struct node
{
	int x,y,id;
}a[M];
struct edge
{
	int u,v,wt;
	bool operator < (const edge &e) const
	{
		return wt<e.wt;
	}
}g[M];
bool cmpx(node a,node b)
{
	return a.x<b.x;
}
bool cmpy(node a,node b)
{
	return a.y<b.y;
}
int find(int x)
{
	return x==f[x]?x:f[x]=find(f[x]);
}
int main() {
	int n,m=1;
	long long cst=0;
	cin>>n;
	for(int i=1;i<=n;i++)
    {
    	f[i]=i;
    	cin>>a[i].x>>a[i].y;
    	a[i].id=i;
    }
    sort(a+1,a+n+1,cmpx);
    for(int i=2;i<=n;i++) g[m++]=(edge){a[i-1].id,a[i].id,a[i].x-a[i-1].x};
    sort(a+1,a+n+1,cmpy);
    for(int i=2;i<=n;i++) g[m++]=(edge){a[i-1].id,a[i].id,a[i].y-a[i-1].y};
    sort(g+1,g+m);
    for(int i=1;i<m;i++)
    {
    	if(find(g[i].u)!=find(g[i].v))
    	{
    		cst+=g[i].wt;
    		f[f[g[i].u]]=f[g[i].v];
    	}
    }
    cout<<cst<<endl;
	return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  if(K <= A) cout << K << endl;
  else if(K <= A+B) cout << A << endl;
  else {
    ll tmp = K - (A+B);
    cout << A - tmp << endl;
  }
}


Measured memory_bytes: 3644
#include<stdio.h>

int main(){
    long long int N;
    long long int A[5];
    long long int ans;
    long long int min = 2000000000000000;

    scanf("%ld", &N);

    for(int i=0; i<5; i++){
        scanf("%ld", &A[i]);
        if(A[i]<min){
            min = A[i];
        }
    }

    ans = N/min +5;
    if(N%min == 0){
        ans = ans -1;
    }

    printf("%ld", ans);

    return 0;
}

Measured memory_bytes: 128
"use strict"
let input=require('fs').readFileSync('/dev/stdin','utf8');
let arr=input.split(' ');
let a=parseInt(arr[0]);
let b=parseInt(arr[1]);
let d=a/b;
let m=a%b;
console.log(Math.floor(d)+' '+m+' '+d.toFixed(8));



Measured memory_bytes: 15388
import java.math.BigInteger;
import java.util.Scanner;

public class Main{

	//????????????X?????????????????°??????????????????
	static String assignX(String str, int attempt){
		char[] chars = new char[str.length()];

        //????????????ASC?????§????????????X?????????????????°???????????´??????
		for(int iChar = 0; iChar < chars.length; iChar++){
			if(str.charAt(iChar) >= '0' && str.charAt(iChar) <= '9'){
				chars[iChar] = str.charAt(iChar);

			} else {
				chars[iChar] = (char)('0' + attempt);
			}
		}
		return String.valueOf(chars);
	}

	public int searchRightX(String str){

		//???????????????????????????
		String s1 = str.substring(0, str.indexOf('+'));
		String s2 = str.substring(str.indexOf('+') + 1, str.indexOf('='));
		String s3 = str.substring(str.indexOf('=') + 1);

		//0???9?????¨??¶?????????????????????????????????????????°???????????????
		for(int iTry = 0; iTry < 10; iTry++){

			//iTry??§X?????£??\??????
			String a1 = assignX(s1,iTry);
			String a2 = assignX(s2,iTry);
			String a3 = assignX(s3,iTry);

			//?????¶????????????????????¶????????????????????????
			if(a1.length() != 1 && a1.charAt(0) == '0'){
				continue;
			}
			if(a2.length() != 1 && a2.charAt(0) == '0'){
				continue;
			}
			if(a3.length() != 1 && a3.charAt(0) == '0'){
				continue;
				}

			//?????£?????????????????????????????§???????????????????????????
			//???????????´?????????????????????X????????´??????
			//???????????´??????????????????-1????????´??????
			BigInteger a = new BigInteger(a1);
			BigInteger b = new BigInteger(a2);
			BigInteger c = new BigInteger(a3);
			if(a.add(b).equals(c)){
				return iTry;
			}
		}
		return -1;
	}

	public static void main(String[] args) {

		Main alphametic = new Main();

		Scanner input = new Scanner(System.in);
		while(input.hasNext()){
			String str = input.next();

			//X????????????????????????
			int answerX = alphametic.searchRightX(str);

			//X????????¨????????°????????????????????§??????????????°NA?????????
			if(answerX == -1){
				System.out.println("NA");
			} else {
				System.out.println(answerX);
			}
		}
		input.close();
	}
}

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

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String ans = "APPROVED";

    int n = sc.nextInt();
    int a;
    for(int i=0; i<n; ++i) {
      a = sc.nextInt();
      if( a % 2 == 0 && a % 3 != 0 && a%5 != 0 ) {
        ans = "DENIED";
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

public class Main {

	public static void main(String args[]) {
		FastScanner cin = new FastScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(FastScanner cin, PrintWriter cout) {
		String s = cin.next();
		Set<Integer> set = s.chars().boxed().collect(Collectors.toSet());
		if (set.size() == s.length())
			cout.println("yes");
		else
			cout.println("no");
	}

	/**
	 * How to read input in Java — tutorial <br />
	 * By Flatfoot<br />
	 * http://codeforces.com/blog/entry/7018
	 */
	static class FastScanner {
		private BufferedReader br;
		private StringTokenizer st;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new IllegalStateException(e);
				}
			return st.nextToken();
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				throw new IllegalStateException(e);
			}
			return str;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 26708
#include<bits/stdc++.h>
using namespace std;
#define MAX 100
struct state{  int r,c,s,sum;};

vector<int> R,C,S;
int N,M;
string t[MAX];
int u[MAX],rc[MAX],cc[MAX],sc[MAX];

void init(){
  for(int i=0;i<MAX;i++){
    u[i]=0;
    rc[i]=0;
    cc[i]=0;
    sc[i]=0;
  }
}

vector<int> change(vector<int> vec){
  vector<int> res;
  sort(vec.begin(),vec.end());
  for(int i=0;i<(int)vec.size();i++){
    if(i&&vec[i]==vec[i-1])continue;
    res.push_back(vec[i]);
  }
  return res;
}

bool check(int x,int y,int z){
  for(int i=0;i+1<N;i++)
    if(x*rc[i]+y*cc[i]+z*sc[i]!=(u[i+1]-u[i]))return false;
  return true;
}

void solve(){
  R.clear();
  C.clear();
  S.clear();
  for(int i=1;i<=20;i++){
    for(int j=1;j<=20;j++){
      for(int k=1;k<=20;k++){
	if(check(i,j,k)){
	  R.push_back(i);
	  C.push_back(j);
	  S.push_back(k);
	}
      }
    }
  }
}

int calc(int x,int y,int z){
  //cout<<endl;
  set<int> T;
  int res;
  for(int i=0;i<(int)R.size();i++){
    res=R[i]*x+C[i]*y+S[i]*z;
    //cout<<x<<' '<<y<<' '<<z<<' '<<res<<endl;
    //cout<<R[i]<<' '<<C[i]<<' '<<S[i]<<' '<<res<<endl;
    T.insert(R[i]*x+C[i]*y+S[i]*z);
  }
  if(T.size()!=1)return -1;
  return res;  
}

int main(){
  while(1){
    cin>>N>>M;
    if(N==0&&M==0)break;
    init();
    for(int i=0;i<N;i++){      
      cin>>t[i];
      bool flg=true;
      for(int j=0;j<(int)t[i].size();j++){
	if(t[i][j]!='.')flg=false;
	if(flg)u[i]++;
	if(t[i][j]=='(')rc[i]++;
	if(t[i][j]==')')rc[i]--;
	if(t[i][j]=='[')cc[i]++;
	if(t[i][j]==']')cc[i]--;
	if(t[i][j]=='{')sc[i]++;
	if(t[i][j]=='}')sc[i]--;
      }
     
    }

    solve();
    
    string str;
    int x=0,y=0,z=0;
    cout<<"0";
    for(int i=0;i+1<M;i++){
      cin>>str;
      for(int j=0;j<(int)str.size();j++){
	if(str[j]=='(')x++;
	if(str[j]==')')x--;
	if(str[j]=='[')y++;
	if(str[j]==']')y--;
	if(str[j]=='{')z++;
	if(str[j]=='}')z--;
      }
      cout<<" "<<calc(x,y,z);
    }
    cout<<endl;
    cin>>str;
  }
  return 0;
}

Measured memory_bytes: 1364
#include <iostream>
using namespace std;
                      
int main(){           
  int a[3];           
  int ans = 0;        
  for(int i = 0; i < 3; i++) cin >> a[i];
  for(int i = 0; i < 3; i++) ans += a[i];
  int max = 0;        
  for(int i = 0; i < 3; i++) if(max < a[i]) max = a[i];
  cout << ans - max << endl;                                                    
  return 0;           
}         

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

int main(){
    int a, b;
    
    while(true){
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        for ( int i = 0; i < a; i++ ){
            for ( int j = 0; j < b; j++ ){
                cout << "#";
            }
        cout << endl;
        }
    cout << endl;
    }
    
}


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

typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18


int main() {
    int N,K; cin >> N >> K;
    if(N%K==0) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3596
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/4;
    public static final int inf = Integer.MAX_VALUE/4;

    static void solve(InputReader in, PrintWriter out){
        char[] s = in.ns().toCharArray();
        long[][] dp = new long[s.length+1][13];
        dp[0][0] = 1;
        for (int i = 0; i < s.length; i++) {
            if(s[i]=='?'){
                for (int j = 0; j < 13; j++) {
                    for (int k = 0; k <= 9; k++) {
                        dp[i+1][(10*j+k)%13] += dp[i][j];
                        dp[i+1][(10*j+k)%13] %= mod;
                    }
                }
            }else{
                for (int j = 0; j < 13; j++) {
                    dp[i+1][(j*10+(s[i]-'0'))%13] += dp[i][j];
                    dp[i+1][(j*10+(s[i]-'0'))%13] %= mod;
                }
            }
        }
        out.println(dp[s.length][5]);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 37460
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;cin>>N>>M;
  vector<vector<pair<int,int>>>pref(N);
  for(int i=0;i<M;i++){
    int p,y;cin>>p>>y;
    pref[p-1].push_back(pair<int,int>(y,i));
  }
  for(int i=0;i<N;i++)sort(pref[i].begin(),pref[i].end());
  vector<string>ids(M);
  string zeros="000000";
  for(int i=0;i<N;i++){
    for(int p=0;p<pref[i].size();p++){
      string a=to_string(i+1),b=to_string(p+1);
      ids[pref[i][p].second]=zeros.substr(0,6-a.length())+a+
        zeros.substr(0,6-b.length())+b;
    }
  }
  for(int i=0;i<M;i++)cout<<ids[i]<<endl;
}



Measured memory_bytes: 12416
//A-Together
/***************************
基本思路
1、因为数据范围有限，故可以用数组来标记得到X的整数个数 
2、避免下溢出，把变化改为不变、减一、加一。 
***************************/ 
#include <bits/stdc++.h>
using namespace std; 
const int N = 1e5 + 5;

int main()
{
	int n,a[N];
	int c[N] = {0}; //对于每个X，求可以得到X的整数个数 
	cin >> n;
	//输入数据，并求出a[i]可以变化到的数据范围 
	for(int i = 0;i < n;i++){ 
		cin >> a[i]; 
		c[a[i]]++;		//减1操作，避免负数溢出 
		c[a[i] + 1]++; 	//nothing
		c[a[i] + 2]++;	//加1操作 
	} 
	//求c数组的最大值
	int ans = 0;
	for(int i = 0;i < N;i++)
		ans = max(ans,c[i]);
	cout << ans << endl;	 
	return 0;	
} 

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int l, r;
  cin >> l >> r;

  int ans = 2020;  
  for ( int i = l; i <= min(l+2020, r); i++) {
    for ( int j = i+1; j <= min(l+2020, r); j++ ) {
      ans = min(ans, i*j%2019);
    }
  }

  cout << ans << endl;
  
  return 0;
}


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

int main() {
  int N,A;
  cin >> N;
  int mind = 50;
  for (int i = 0; i < N; i++) {
    cin >> A;
    int d = 0;
    while(A % 2 == 0){
      A /= 2;
      d += 1;
    }
    mind = min(mind,d);
  }
  cout << mind;
}


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

long long dp[1001][1001];
int main(void) {
  int N, M;
  cin >> N >> M;
  vector<string> a(N);

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

  dp[0][0] = 1;
  long long MOD = 1000000007;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (i < N - 1 && a[i + 1][j] == '.') dp[i + 1][j] += dp[i][j];
      if (j < M - 1 && a[i][j + 1] == '.') dp[i][j + 1] += dp[i][j];

      dp[i + 1][j] %= MOD;
      dp[i][j + 1] %= MOD;
    }
  }
  cout << dp[N - 1][M - 1] << endl;

  return 0;
}

Measured memory_bytes: 9600
# coding: utf-8
H, W = map(int, input().split())
S = []
dx = [1, 0, -1, 0, 1, -1, -1, 1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]
for i in range(H):
    S.append(list(input()))
for i in range(H):
    for j in range(W):
        cnt = 0
        if S[i][j] == "#":
            continue
        
        for k in range(len(dx)):
            if i+dx[k] < 0 or i+dx[k] >= H:
                continue
            if j+dy[k] < 0 or j+dy[k] >= W:
                continue
            if S[i+dx[k]][j+dy[k]] == "#":
                cnt += 1
        S[i][j] = str(cnt)
for i in range(H):
    print("".join(S[i]))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll X, N;
        cin >> X >> N;

        vll p(N);
        rep(i, 0, N) cin >> p[i];

        ll mn = inf;
        rep(i, -1000, 1001) {
                if (isin(i, p)) continue;
                chmin(mn, abs(i - X));
        }

        rep(i, -1000, 1001) {
                if (isin(i, p)) continue;
                if (abs(i - X) == mn) {
                        cout << i << endl;
                        return 0;
                }
        }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define long long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar
using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }
const int N= (int)1e5+10;
int x,y,z;
long res= 0;
struct point
{
	int a,b,c;
}p[N];
long fx[N],fy[N];
multiset<int> s;
void input()
{
	cin>>x>>y>>z;
	up(i,1,x+y+z) cin>>p[i].a>>p[i].b>>p[i].c;
}
bool byba(point x,point y)
{
	return x.b- x.a< y.b- y.a;
}
void solve()
{
	sort(p+1,p+1+x+y+z,byba);
    up(i,1,x+y+z)
    {
    	res+= p[i].c;
		p[i].a-= p[i].c; p[i].b-= p[i].c; p[i].c-= p[i].c;
    };


    s.clear();
    up(i,1,x+y+z)
    {
    	fx[i]= fx[i-1];
        if (s.size()< x)
		{
			s.insert(p[i].a); fx[i]+= p[i].a;
		}
		else
		{
            if (p[i].a> *s.begin())
			{
				fx[i]+= p[i].a- *s.begin();
				s.erase(s.begin()); s.insert(p[i].a);
			};
		}
    }
    s.clear();
    down(i,x+y+z,1)
    {
    	fy[i]= fy[i+1];
    	if (s.size()< y)
		{
			s.insert(p[i].b); fy[i]+= p[i].b;
		}
		else
		{
			if (p[i].b> *s.begin())
			{
				fy[i]+= p[i].b- *s.begin();
				s.erase(s.begin()); s.insert(p[i].b);
			}
		}
    }

    long mx= -1e18;
    up(id,x,x+z) mx= max(mx, fx[id]+ fy[id+1]);
    cout<<res+ mx;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// don't use when interactive

    #ifdef I_Love_Pork
    #define TASK "tmp"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
	#endif

    input();
    solve();

    return 0;
}


Measured memory_bytes: 7424