akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long int;

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(T);
    int result = 1001;
    REP(i, N){
        scanInt(ci);
        scanInt(ti);
        if (ti <= T){
            result = min(result, ci);
        }
    }
    if (result != 1001){
        cout << result << endl;
    }else{
        cout << "TLE" << endl;
    }
}

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

int main() {
    vector<int> a(5);
    int minv = 1e9;
    int p = 0;
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
        if (a[i] % 10 != 0 && a[i] % 10 < minv) {
            minv = min(minv, a[i] % 10);
            p = i;
        }
    }
    int sum = 0;
    for (int i = 0; i < 5; i++) {
        if (i == p) {
            sum += a[i];
        } else {
            if (a[i] % 10 != 0) {
                sum += a[i] / 10 * 10 + 10;
            } else {
                sum += a[i];
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

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

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

type Card struct {
	b, c int
}

type ByC []Card

func (a ByC) Len() int           { return len(a) }
func (a ByC) Less(i, j int) bool { return a[i].c < a[j].c }
func (a ByC) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, M := sc.nextInt(), sc.nextInt()
	A := sc.nextIntSlice(N)
	C := make([]Card, M)
	for i := 0; i < M; i++ {
		C[i] = Card{sc.nextInt(), sc.nextInt()}
	}
	sort.Ints(A)
	sort.Sort(ByC(C))
	ans := []int{}
	countA := N - 1
	countC := M - 1
	for i := 0; i < N; i++ {
		a := A[countA]
		if countC < 0 {
			ans = append(ans, a)
			countA--
			continue
		}
		c := C[countC]
		if a < c.c {
			ans = append(ans, c.c)
			C[countC].b -= 1
			if C[countC].b == 0 {
				countC--
			}
		} else {
			ans = append(ans, a)
			countA--
		}
	}

	//fmt.Fprintln(wtr, ans)
	sum := 0
	for i := 0; i < N; i++ {
		sum += ans[i]
	}
	fmt.Fprintln(wtr, sum)
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////
map<ll,ll> mp;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    ll n;
    cin>>n;
    ll a[n];
    REP(i,n){cin>>a[i];mp[a[i]]++;}
    ll l=0,b=0;
    sort(a,a+n,greater<int>());
    REP(i,n)
    {
        if(l && b)break;
        if(mp[a[i]] >= 2)
        {
            if(l)b=a[i];
            else l=a[i];
            mp[a[i]]-=2;
        }
    }
    cout<<l*b*1LL;
  }  
  return 0;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

Measured memory_bytes: 10584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long a = sc.NextLong();
        long b = sc.NextLong();
        long[] pp = sc.LongArray();

        long count1 = 0;
        long count2 = 0;
        long count3 = 0;

        for (int i = 0; i < n; i++)
        {
            if (pp[i] <= a)
            {
                count1++;
            }
            else if (pp[i] > b)
            {
                count3++;
            }
            else
            {
                count2++;
            }
        }

        long answer = Math.Min(count1, Math.Min(count2, count3));

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28252
//
//  main.c
//  Changing a Character
//
//  Created by yuta on 2019/05/19.
//  Copyright © 2019 501Software. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {

	int inp_length, inp_k;
	char string[256];
	
	scanf("%d %d", &inp_length, &inp_k);
	scanf("%s",    string);

	
	string[inp_k-1] = string[inp_k-1] + 32;

	
	printf("%s \n", string);
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
const ll INF=1e18+5;
int arr[1000006];

int main() {
    IO;
    int n ;
    cin>>n ;
    int a;
    for(int i = 0 ;i<n ; i++ ){
        cin>>a;
        arr[a]++;
    }
    int ans=0;
    for(int i =1 ; i < 1000005; i++){
        if(arr[i]==0)continue;
        if(arr[i]==1)ans++;
        for(int j = i ; j < 1000005 ; j+=i)arr[j]=0;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7560
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

string s,t;
int dp[3001][3001];

int dfs(int k){
  if(k == s.length()){
    int m = 0;
    int a = 0;
    for(int i = 0; i <= t.length(); i++){
      if(a < dp[k][i]){
        a = dp[k][i];
        m = i;
      }
    }
    return m;
  }
  for(int i = 0; i < t.length(); i++){
    if(s[k] == t[i]){
        if(dp[k+1][i+1] <= dp[k][i]) dp[k+1][i+1] = dp[k][i] + 1;
    }
    if(dp[k+1][i+1] <  dp[k][i+1]) dp[k+1][i+1] = dp[k][i+1];
    if(dp[k+1][i+1] < dp[k+1][i]) dp[k+1][i+1] = dp[k+1][i];
  }
  return dfs(k+1);
}

string restore(int k){
  string ans = "";
  for(int i = s.length(); i > 0; i--){
    for(int j = k ; j > 0; j--){
      if(dp[i][j] == dp[i-1][j]){
        break;
      }
      else if(dp[i][j] == dp[i][j-1]){
        continue;
      }
      else if(dp[i][j] > dp[i][j-1]){
        ans = t[j-1] + ans;
        k = j-1;
        break;
      }
    }
  }
  return ans;
}

int main(){
  cin >> s >> t;
  for(int i = 0; i < 3001; i++){
    for(int j = 0; j < 3001 ; j++){
      dp[i][j] = 0;
    }
  }
  string ans = restore( dfs(0) );
  cout << ans << endl;
}


Measured memory_bytes: 35456
#include<iostream>
#include<set>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  set<int> hs,ws;
  bool same;
  char ch;
  char grid[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> grid[i][j];
    }
  }
  for(int i=0;i<h;i++){
    ch = '.';
    same=true;
    for(int j=0;j<w;j++){
      if(grid[i][j]!=ch){
        same=false;
        break;
      }
    }
    if(same){
      hs.insert(i);
    }
  }
  for(int i=0;i<w;i++){
    ch = '.';
    same=true;
    for(int j=0;j<h;j++){
      if(grid[j][i]!=ch){
        same=false;
        break;
      }
    }
    if(same){
      ws.insert(i);
    }
  }
  bool print;
  for(int i=0;i<h;i++){
    print=false;
    if(hs.find(i)==hs.end()){
      for(int j=0;j<w;j++){
        if(ws.find(j)==ws.end()){
          print=true;
          cout <<grid[i][j];
        }
      }
      if(print){
        cout << endl;
      }
    }
  }
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> point(N, K);
	rep(i, Q) {
		int A;
		cin >> A;
		point.at(A - 1)++;
	}
	rep(i, N) {
		point.at(i) -= Q;
		if (point.at(i) <= 0) {
			puts("No");
		}
		else {
			puts("Yes");
		}
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#define n 1000
using namespace std;
int main(){
	string s;
	int a1[n],b1[n],a2[n],b2[n];
	int c1 = 0;
	int c2 = 0;
	while(1){
		getline(cin,s);
		if(s.size()==0) break;
		istringstream is(s);
		char d;
		is >> a1[c1] >> d >> b1[c1];
		c1++;
	}
	while(getline(cin,s)){
		istringstream is(s);
		char d;
		is >> a2[c2] >> d >> b2[c2];
		c2++;
	}
	bool e[c2];
	int a3[c2],b3[c2];
	int c3 = 0;
	for(int i=0;i<c2;i++) e[i] = false;
	for(int i=0;i<c2;i++){
		if(e[i]) continue;
		int s = 1;
		bool ex = false;
		for(int j=0;j<c1;j++){
			if(a2[i]!=a1[j]) continue;
			ex = true;
			s++;
		}
		if(not ex) continue;
		for(int j=i+1;j<c2;j++){
			if(a2[j]!=a2[i]) continue;
			e[j] = true;
			s++;
		}
		a3[c3] = a2[i];
		b3[c3] = s;
		c3++;
	}
	while(1){
		bool out = true;
		for(int i=0;i<c3-1;i++){
			if(a3[i]>a3[i+1]){
				out = false;
				int t = a3[i];
				a3[i] = a3[i+1];
				a3[i+1] = t;
				t = b3[i];
				b3[i] = b3[i+1];
				b3[i+1] = t;
			}
		}
		if(out) break;
	}
	for(int i=0;i<c3;i++) cout << a3[i] << " " << b3[i] << endl;
}

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

#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define FORD(i,a,b) for(int i=a ; i>=b ; i--)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )
#define all(x) x.begin(),x.end()
#define flog2(n) 64 - __builtin_clzll(n) - 1
#define popcnt(n) __builtin_popcountll(n)

using namespace std;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;


const ll K = 1e9 + 7;

struct Matrix {
	ll coef[51][51];

	Matrix() {
		FOR (i, 0, 50) {
			FOR (j, 0, 50) coef[i][j] = 0;
		}
	}

	Matrix operator * (const Matrix &a) {
		Matrix res;
		FOR (i, 1, 50) {
			FOR (j, 1, 50) {
				FOR (k, 1, 50) {
					res.coef[i][j] += coef[i][k] * a.coef[k][j] % K;
					res.coef[i][j] %= K;
				}
			}
		}
		return res;
	}

};

Matrix A;

Matrix mu(Matrix &A, ll n) {
	if (n == 1) {
		return A;
	}

	Matrix Q = mu(A, n / 2);

	if (n % 2 == 0) {
		return Q * Q;
	}
	return Q * Q * A;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    int n;
    ll k;

    cin >> n >> k;
    FOR (i, 1, n) {
    	FOR (j, 1, n) {
    		cin >> A.coef[i][j];
    	}
    }

    A = mu(A, k);
   	//A = A * A;

    ll res = 0;

    FOR (i, 1, n) {
    	FOR (j, 1, n) {
    		res = (res + A.coef[i][j]) % K;
    		//cout << A.coef[i][j] << " ";
    	}
    	//cout << endl;
    }	

	cout << res << endl;
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    int n,m;
    cin >> n >> m;
    if(n>=m) {cout << "0" << endl; return 0;}
    vector<int> x(m);
    for(int i=0;i<m;i++){
        cin >> x[i];
    }
    sort(x.begin(),x.end());
    vector<int> d(m-1);
    for(int i=0;i<m-1;i++){
        d[i] = x[i+1] - x[i];
    }
    sort(d.begin(),d.end(),greater<int>());
    int ans = x.back() - x[0];
    for(int i=0;i<n-1;i++){
        ans -= d[i];
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

signed main()
{
  ll K, N;
  vector< ll > v;
  priority_queue< ll, vector< ll >, less< ll > > q;

  cin >> K >> N;

  ll a = 0;
  while (cin >> a)
  {
    v.push_back(a);
  }
  for (ll i = 0; i < v.size() - 1; i++)
  {
    q.push(v[i + 1] - v[i]);
  }
  q.push(v[0] + K - v[v.size() - 1]);

  ll ans = 0;
  q.pop();
  while (!q.empty())
  {
    ans += q.top();
    q.pop();
  }

  cout << ans << endl;
}


Measured memory_bytes: 4848
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
vector<pair<int,int> >B[510][510];
int dx[]={1,1,1,0,0,0,-1,-1,-1};
int dy[]={1,0,-1,1,0,-1,1,0,-1};
int ax[110000];
int ay[110000];
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c),a+b){
		for(int i=0;i<510;i++)
			for(int j=0;j<510;j++){
				B[i][j].clear();
			}
		for(int i=0;i<a;i++){
			int x,y;scanf("%d%d",&x,&y);
			ax[i]=x;ay[i]=y;
		}
		for(int i=0;i<b;i++){
			int x,y;scanf("%d%d",&x,&y);
			B[x/40][y/40].push_back(make_pair(x,y));
		}
		int ret=0;
		for(int i=0;i<a;i++){
			int x=ax[i]/40;
			int y=ay[i]/40;
			for(int j=0;j<9;j++){
				int nx=x+dx[j];
				int ny=y+dy[j];
				if(nx<0||ny<0||nx>=250||ny>=250)continue;
				for(int k=0;k<B[nx][ny].size();k++){
					if((ax[i]-B[nx][ny][k].first)*(ax[i]-B[nx][ny][k].first)+
					(ay[i]-B[nx][ny][k].second)*(ay[i]-B[nx][ny][k].second)<=c*c*16)ret++;
				}
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 10388
import java.util.Scanner;

public class Main {

	private final static long MOD = 998244353;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] D = new int[N];
		int[] cnt = new int[N];
		for(int i = 0;i < N;i++) {
			D[i] = sc.nextInt();
			cnt[D[i]]++;
		}
		sc.close();
		long ans = 1;
		if(D[0] != 0 || cnt[0] != 1) {
			System.out.println(0);
			return;
		}else{
			for(int i = 1;i < N;i++) {
				for(int j = 0;j < cnt[i];j++) {
					ans *= cnt[i-1];
					ans %= MOD;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 59216
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define MOD 1000000007


//RMQ セグメント木
struct SegmentTree{
private:
	int N;
	vector<long long> node;
	const long long DEFAULT = 0;
public:
	void init(int n){ //初期化する O(N)
		node.clear();
		N = 1;
		while(N < n) N *= 2;
		for(int i=0; i<2*N-1; i++) node.push_back(DEFAULT);
	}
	void update(int i, long long x){ //値を変更する O(log N)
		i += N - 1;
		node[i] = x;
		while(i > 0){
			i = (i-1)/2; //親の取得は(i-1)/2
			node[i] = max(node[i*2+1], node[i*2+2]); //子の取得はi*2+1,i*2+2
		}
	}
	long long maximum(int a, int b, int k=0, int l=0, int r=-1){ //[a,b)の最小値を求める O(log N)
		if(r == -1) r = N;
		if(r <= a || b <= l) return DEFAULT; //交差する場合
		if(a <= l && r <= b) return node[k]; //完全に含む場合
		return max( maximum(a, b, k*2+1, l, (l+r)/2) , maximum(a, b, k*2+2, (l+r)/2, r) );
	}
};

int N,h[200000];
LL a[200000];
SegmentTree st;

int main(){
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> h[i];
		h[i]--;
	}
	st.init(N);
	for(int i=0; i<N; i++){
		cin >> a[i];
	}

	for(int i=0; i<N; i++){
		LL tmp = st.maximum(0, h[i]) + a[i];
		st.update(h[i], tmp);
	}
	cout << st.maximum(0, N) << endl;

	return 0;
}



Measured memory_bytes: 7152
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll d;
  cin>>d;
  ll c[26];
  for (ll i = 0; i < 26; ++i)
  {
    cin>>c[i];
  }
  vector<vector<ll>> s(d,vector<ll>(26));
  for (ll i = 0; i < d; ++i)
  {
    for (ll j = 0; j < 26; ++j)
    {
      cin>>s[i][j];
    }
  }
  ll t;
  ll ans=0;
  vector<ll> last(26,-1);
  for (ll i = 0; i < d; ++i)
  {
    cin>>t;
    t--;
    ans+=s[i][t];
    last[t]=i;
    for (ll j = 0; j < 26; ++j)
    {
      ans-=c[j]*(i-last[j]);
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3688
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double

#define pll pair<ll,ll>
#define ff first
#define ss second

#define pb push_back
#define all(x) x.begin(),x.end()

#define MOD  1000000007
const int N = 100005; 

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
struct ft 
{
    vector<ll> bit;
    ll n;
    ft(ll n1) 
    {
        n = n1;
        bit.assign(n,0);
    }
    ll sum(ll r) 
    {
        ll ret = 0;
        for(; r >= 0; r = (r&(r+1))-1)
            ret = max(ret,bit[r]);
        return ret;
    }
    void add(ll idx, ll d) 
    {
        for(; idx < n; idx = idx | (idx+1))
            bit[idx] = max(bit[idx],d);
    }
};   
void solve()
{
    ll n;
    cin >> n;
    ll h[n],a[n],b[n];
    for(ll i=0;i<n;i++)   cin >> h[i],b[i] = h[i];
    for(ll i=0;i<n;i++)   cin >> a[i];
    map<ll,ll> val;
    sort(b,b+n);
    for(ll i=0;i<n;i++)      val[b[i]] = i;
    for(ll i=0;i<n;i++)      h[i] = val[h[i]];
    ft ft1(n+2);
    for(int i=0;i<n;i++)
    {
        ll maxi = ft1.sum(h[i]);
        maxi += a[i];
        ft1.add(h[i],maxi);
    }
    ll ans = ft1.sum(n-1);
    cout<<ans;
}

int main()
{
    FAST;
    int t = 1;
 // cin >> t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
}

 /// 6 8 14 18 

Measured memory_bytes: 21944
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
ll n;
const ll mod=998244353;
vector<pair<int,int>> vt;  //存输入 
stack<pair<int,int>> stk;   //将不覆盖的点入栈 ，用栈优化（对于正在检测的点，如果栈顶不满足，则栈里面的都不满足） 
//存点的坐标（identifier）和扫描到这个点时，它满足的集合数量 
int t1,t2;
int main()
{
	//freopen("input.txt","r",stdin);
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>t1>>t2;
		t2+=t1;
		vt.emplace_back(t1,t2);
	}
	sort(vt.rbegin(),vt.rend());  //这种题目几乎都要sort 此处逆序遍历 
	for(int i=0;i<n;i++)
	{
		ll t=1;
		//cout<<stk.empty()<<endl;
		while(!stk.empty() && vt[i].second>stk.top().first)		//遍历栈 注意开区间 
		{
			t=(t*stk.top().second)%mod;
			stk.pop();
			
		}
		//cout<<t<<endl;
		stk.push(make_pair(vt[i].first,t+1));   //!!!!! 一定要加1，因为枚举集合数的时候，对于每个点分两种情况（激活和不激活） 
	} 
	ll ans=1;
	while(!stk.empty())
	{
		ans=(ans*stk.top().second)%mod;
		stk.pop();
		//cout<<ans<<endl;
	}
	cout<<ans%mod<<endl;
	return 0;
} 

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

main()
{
  int n;
  int data[105];
  int a;
  int ans=0;
  
  cin >> n;
  for(int i=0;i<=100;i++)
    data[i]=0;
  for(int i=0;i<n;i++){
    cin >> a;
    data[a]=1;
  }

  for(int i=0;i<=100;i++){
    if(data[i])
      ans++;
  }

  cout << ans << endl;
  

  return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    ll half = min(2 * q, h);
    ll one = min(2 * half, s);
    ll two = min(2 * one, d);
    cout << two * (n / 2) + one * (n % 2) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    set<int> ans;
    int a,b,k;
    cin >> a >> b >> k;
    rep(i,0,k){
        ans.insert(a + i);
        ans.insert(b - i);
    }
    for(auto &e: ans){
        if(e >= a && e <= b){
            cout << e << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[102];
long long dp[102][5][2];
int main(){
    int n, k;
    scanf("%s%d", s+1, &k);
    n = strlen(s+1);
    int cur = 0;
    for(int i=1;i<=n;i++){
        if(i == 1){
            for(int j=1;j<s[i]-'0';j++) dp[i][1][0]++;
            dp[i][0][0]++;
            dp[i][1][1]++;
        }
        else{
            for(int j=1;j<s[i]-'0';j++){
                for(int k=0;k<=3;k++){
                    dp[i][k+1][0] += dp[i-1][k][1];
                }
            }
            if(cur <= k){
                if(s[i] == '0'){
                    dp[i][cur][1] += dp[i-1][cur][1];
                }
                else{
                    dp[i][cur][0] += dp[i-1][cur][1];
                    dp[i][cur+1][1] += dp[i-1][cur][1];
                }
            }

            for(int j=1;j<=9;j++){
                for(int k=0;k<=3;k++){
                    dp[i][k+1][0] += dp[i-1][k][0];
                }
            }
            for(int k=0;k<=3;k++){
                dp[i][k][0] += dp[i-1][k][0];
            }
        }
        if(s[i] != '0') cur++;
    }
    printf("%lld\n", dp[n][k][0] + dp[n][k][1]);
}

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

int main(){
  long long int x,k,d;
  cin >> x >> k >> d;
  long long int y,z;
  if(x<0){
    x=-x;
  }
  y=x%d;
  z=abs(x%d-d);
  if(y<z){
    if((x-y)/d<=k&&(k-(x-y)/d)%2==0){
      cout << y << endl;
    }else if((x-y)/d<=k&&(k-(x-y)/d)%2!=0){
      cout << abs(y-d) << endl;
    }else{
      cout << x-k*d << endl;
    }
  }else if((x+z)/d<=k&&(k-(x+z)/d)%2==0){
    cout << z << endl;
  }else if((x+z)/d<=k&&(k-(x+z)/d)%2!=0){
    cout << abs(z-d) << endl;
  }else{
    cout << x-k*d << endl;
  }
}

Measured memory_bytes: 3568
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set('display_errors', 'Off');

// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d", $N);
$tt = explode(" ", trim(fgets(STDIN)));
$vv = explode(" ", trim(fgets(STDIN)));

$cur_t = 0;
$cur_v = 0;
$ans = 0;

$t[0] = $cur_t;
$cur_speed = 0;
$speed = array(0 => 0);

foreach ($tt as $key => $dummy) {
    $cur_t += $tt[$key] * 2;
    $cur_v = $vv[$key];
    $t[] = $cur_t;
    $v[] = $cur_v;
}
$v[] = 0;

foreach ($t as $key => $val) {
    if (DEBUG) echo "key:{$key} t:{$t[$key]} v:{$v[$key]}\n";
}

$seigen = array_pad(array(), $cur_t + 1, PHP_INT_MAX);
// var_dump($seigen);
// exit;

for ($i = 1; $i < count($t); $i++) {
    if (DEBUG) echo "**** {$i} {$t[$i]}\n";
    for ($j = 0; $j <= $t[$i]; $j++) {
        $seigen[$j] = min($seigen[$j], ($t[$i] - $j) * .5 + $v[$i]);
        if (DEBUG) echo "!!! j:{$j} base:{$v[$j]} seigen:{$seigen[$j]}\n";
    }
}
// var_dump($seigen);

for ($i = 0; $i < count($t); $i++) {
    for ($j = $t[$i]; $j <= $t[$i+1]; $j++) {
        $seigen[$j] = min($seigen[$j], $v[$i]);
    }
}
if (DEBUG) var_dump($seigen);

for ($i = 1; $i <= $cur_t; $i++) {
    $cur_speed += .5;
    $cur_speed = min($cur_speed, $seigen[$i]);
    $speed[$i] = $cur_speed;
    if (DEBUG) echo "t:{$i} speed:{$cur_speed}\n";
    $ans += ($speed[$i-1] + $speed[$i]) * .5 / 2;
}
echo $ans . PHP_EOL;


Measured memory_bytes: 8696
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	string s,r;
	int count1=0,count2=0,y=0;
	bool flag[100000];
	bool x=false;

	cin>>s;
	r=s;

	for(int i=0;i<100000;i++)
		flag[i]=false;
	if(s[0]=='1')
		flag[0]=true;
	//一個めが固定の場合;
	for(int i=1;i<s.length();i++){
		if(s[i]=='1')flag[i]=true;
		if(flag[i-1]==flag[i]){
			if(flag[i-1])flag[i]=false;
			else flag[i]=true;
			count1++;
		}
	}
	//二個めが固定の場合;
	for(int i=0;i<100000;i++)flag[i]=false;
	for(int i=1;i<s.length();i++){	
		x=false;
		if(s[i-1]==s[i]){
			x=true;
			break;
		}
		y=i;
	}
	if(!x){
		cout<<"0"<<endl;
		return 0;
	}


	if(r[y]=='1')r[y]=true;
	for(int i=y;i<s.length();i++){
		if(flag[i]=='1')flag[i]=true;
		if(flag[i-1]==flag[i]){
			if(flag[i])flag[i-1]=false;
			else flag[i-1]=true;
			count2++;
		}
	}

	count1=min(count1,count2);
	cout<<count1<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD=998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=200005;

int dp[N][3];
void solve()
{
int n;
cin>>n;
int a[n+1][3];
for(int i=1;i<=n;i++)
cin>>a[i][0]>>a[i][1]>>a[i][2];
for(int i=1;i<=n;i++)
{
    for(int j=0;j<3;j++)
    {
        for(int k=0;k<3;k++)
        {
            if(k!=j)
            dp[i][j]=max(dp[i][j],a[i][j]+dp[i-1][k]);
        }
    }
}
cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;



}




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

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    long double xs,ys,xt,yt;
    int N;
    cin >> xs >> ys >> xt >> yt >> N;
    vector<long double> x(N),y(N),r(N);
    rep(i,0,N) cin >> x[i] >> y[i] >> r[i];

    vector<vector<long double>> dist(N+2,vector<long double>(N+2));
    rep(i,0,N) rep(j,i+1,N) dist[i][j]=dist[j][i]=max((long double)0,sqrtl((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]);
    rep(i,0,N) dist[N][i]=dist[i][N]=max((long double)0,sqrtl((x[i]-xs)*(x[i]-xs)+(y[i]-ys)*(y[i]-ys))-r[i]);
    rep(i,0,N) dist[N+1][i]=dist[i][N+1]=max((long double)0,sqrtl((x[i]-xt)*(x[i]-xt)+(y[i]-yt)*(y[i]-yt))-r[i]);
    dist[N][N+1]=dist[N+1][N]=sqrtl((xs-xt)*(xs-xt)+(ys-yt)*(ys-yt));

    vector<long double> f(N+2,inf64);
    vector<bool> done(N+2);
    f[N]=0;
    for(;;){
        int u=-1;
        rep(i,0,N+2) if(!done[i] and (u==-1 or f[i]<f[u])) u=i;
        if(u==-1) break;
        done[u]=true;
        rep(i,0,N+2) if(f[u]+dist[u][i]<f[i]) f[i]=f[u]+dist[u][i];
    }
    cout << f[N+1] << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 16128
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = int.Parse(Console.ReadLine());
            Console.WriteLine(3 * r * r);
        }
    }
}

Measured memory_bytes: 13140
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll gcd(ll a, ll b){//計算量はO(log(max(a,b))
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};



int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll E = C / gcd(C, D) * D;
  ll b = B - (B / C + B / D - B / E);
  A--;
  ll a = A - (A / C + A / D - A / E);
  cout << b-a << endl;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			//long n = long.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int n = vs[0];
			int m = vs[1];
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			long sum = 0;
			Dictionary<long, int> count = new Dictionary<long, int>();
			count.Add(0, 1);
			for (int i = 0; i < n; i++) {
				sum += a[i];
				long key = sum % m;
				if (!count.ContainsKey(key)) {
					count.Add(key, 0);
				}
				count[key]++;
			}
			//foreach (var item in count.OrderBy(p => p.Key)) {
			//	System.Diagnostics.Debug.WriteLine(item);
			//}
			long ans = 0;
			foreach (var c in count.Values) {
				ans += (long)c * (c - 1) / 2;
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


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

int main(){
  int N;
  cin >> N;
  int sum = 0;
  int w = N;
  while(w){
    sum += w % 10;
    w /= 10;
  }
  string result;
  if(N % sum == 0){
    result = "Yes";
  }else{
    result = "No";
  }
  cout << result << endl;
}


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

int main() {
  int n,a,b;
  cin>>n>>a>>b;
  if((b-a)%2==0) cout<<"Alice"<<endl;
  else cout<<"Borys"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i=0;i<n;i++){
			a[i]=scanner.nextInt();
			b[i]=a[i];
		}
		Arrays.sort(a);
		int cnt=0;
		for(int i=0;i<n;i++){
			if(a[i]!=b[i]){
				cnt++;
			}
			if(cnt==3){
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 24532
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

    int res = 1001;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;

        if (b <= t) res = min(res, a);
    }
    if (res == 1001) cout << "TLE" << endl;
    else cout << res << endl;
}


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

using namespace std;
int main (void) {
	string s;
	cin >> s;

	if (s.size() == 2) {
		cout << s << endl;
		return 0;
	}else {
		cout << s[2] << s[1] << s[0];
		return 0;
	}

}


Measured memory_bytes: 256
import sys

class A:

    def solve(self):
        s1 = input()
        s2 = input()
        print("Yes" if s1 == s2[:-1] else "No")

class B:

    def solve(self):
        A, B, C, K = tuple(map(int, input().split(" ")))
        sum = min(A, K)
        K -= A
        K -= B
        sum -= max(min(K, C), 0)
        print(sum)

class C:

    def solve(self):
        n, m, t = tuple(map(int, input().split(" ")))
        costs = []
        matrix = [[0 for x in range(m)] for y in range(n)]

        for i in range(n):
            line = [int(x) for x in input().split(" ")]
            costs.append(line[0])
            for j in range(len(line[1:])):
                matrix[i][j] = line[j+1]

        end = 2**n
        min_cost = sys.maxsize
        for i in range(end):
            binary = [int(x) for x in ("{:032b}".format(i))[-n:]]
            skills = list(map(lambda x: x[1], filter(lambda x: x[0] == 1, zip(binary, matrix))))
            acc = [0 for x in range(m)]

            for x in skills:
                acc = [x + y for x,y in zip(acc, x)]

            if all(map(lambda x: x >= t, acc)):
                ccost = sum(map(lambda x: x[1], filter(lambda x: x[0] == 1, zip(binary, costs))))
                if min_cost > ccost:
                    min_cost = ccost

        print(min_cost if min_cost != sys.maxsize else -1)

C().solve()


Measured memory_bytes: 9328
n = int(input())
a = list(map(int, input().split()))

multi = 1
if min(a) == 0:
    print(0)
else:
    for i in range(n):
        multi = multi * a[i]
        if multi > 1000000000000000000:
            print(-1)
            break
    if multi <= 1000000000000000000:
        print(multi)

Measured memory_bytes: 21576
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for(int i=0; i<N; i++){
            A[i]=sc.nextInt();
        }
        int res=0;
        Arrays.sort(A);
        for(int i=0; i<K; i++){
            res += A[i];
        }
        System.out.println(res);
        }
    }

Measured memory_bytes: 38672
#include<iostream>
#include<vector>
#include<set>
#include<numeric>

int main(){
    int inf = 1e9;
    int n;
    std::cin >> n ;
    std::vector<int> A(n);
    for(int i = 0 ; i < n ; i++){
        std::cin >> A[i];
    }
    int ans = inf;
    for(int i = 0 ; i < n ; i++){
        int cnt = 0;
        while(A[i]%2 == 0){
            A[i] /= 2;
            cnt++;
        }
        ans = std::min(ans, cnt);
    }
    std::cout << ans << std::endl;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int a, b;
	string s;
	cin >>a >>b;
	int ans = max({a+b,a-b, a*b});
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256