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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  string s;cin>>s;
  int n=s.size();
  vector<int> num(n);
  int i;
  rep(i,n)num[i]=s[i]-'0';
  vector<int> us(n+1,0);
  vector<int> count(2019,0);
  int ans=0;
  count[0]=1;
  int ks=1;
  for(i=n-1;i>=0;i--)
  {
    us[i]=(us[i+1]+num[i]*ks)%2019;
    ans+=count[us[i]];
    count[us[i]]++;
    ks=(ks*10)%2019;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 5156
import scala.io.StdIn._
object Main extends App {
  val Array(n, ww) = readLine.split(" ").map(_.toInt)
  val w = new Array[Int](n)
  val v = new Array[Int](n)
  (0 until n).foreach { i =>
    readLine.split(" ").map(_.toInt) match {
      case Array(a, b) => {
        w(i) = a
        v(i) = b
      }
    }
  }

  val dp = Array.fill(n + 1, ww + 1)(0L)
  for {
    i <- 0 until n
    j <- 0 to ww
  } {
    dp(i + 1)(j) = if (j >= w(i)) {
      math.max(dp(i)(j - w(i)) + v(i), dp(i)(j))
    } else {
      dp(i)(j)
    }
  }

  println(dp(n)(ww))

}


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

int main() {
  long long int L, R;
  cin >> L >> R;
  R = min(R, L + 4038);
  int ans = 2018;
  
  for (long long int i = L; i <= R; i++){
    for (long long int j = i + 1; j <= R; j++){
      int x = i * j % 2019;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt(), flag = -1;
        for (int i = 1; i < 10; i++) {
            if (N % i == 0 && N / i < 10) flag = 1;
        }
        System.out.println(flag == 1 ? "Yes" : "No");
        in.close();
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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 FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void){
  string s; cin >> s;
  string news;
  vector<string> candidates;

  FOR(i,0,1){
    FOR(j,0,1){
      FOR(k,0,1){
        FOR(l,0,1){
          string trys;
          if(i==1) trys += "A";
          trys += "KIH";
          if(j==1) trys += "A";
          trys += "B";
          if(k==1) trys += "A";
          trys += "R";
          if(l==1) trys += "A";

          candidates.PB(trys);
        }
      }
    }
  }
  

  for(auto x: candidates){
    if(s==x){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    else:
        block_W = ["#" for i in range(W)]
        print("".join(block_W))
        for i in range(H - 2):
            block_W_middle = ["." for i in range(W - 2)]
            block_W_middle.insert(0, "#")
            block_W_middle.append("#")
            print("".join(block_W_middle))
        print("".join(block_W))
        print("\n", end = "")


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

int main(){
	int n;
	cin >> n;
	int odds=0;
	float probability=0.0;

	for (int i = 1; i <= n; i++)
	{
		if(i%2 ==1)
		{
			odds++;
		}
	}
	probability=(float)odds/(float)n;
	cout << probability;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;

namespace AtCoder
{
    class AtCoderrrrrr
    {
        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            string s = ReadLine();
            int Rcnt = 0;
            int Bcnt = 0;
            for (int i = 0; i < N; i++)
            {
                if (s[i] == 'R')
                {
                    Rcnt++;
                }
                else
                {
                    Bcnt++;
                }
            }
            if (Rcnt>Bcnt)
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define ALLG(v) v.begin(), v.end() ,greater<int>()
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }
ll GetDigit(ll num) {
	ll digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

using namespace std;
int main() {
	ll n, b, r;
	cin >> n >> b >> r;

	ll ans = 0;
	ll br = b + r;

	ll re = n % br;
	ll count = n / br;
	ans += count * b;
	
	ans += min(b,re);
	


	

	cout <<  ans << endl;
}

Measured memory_bytes: 256
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		
		char S1[] = s1.toCharArray();
		char S2[] = s2.toCharArray();
	
		int count = 0;
		for(int i=0;i<S1.length;i++) {
			if(S1[i] == S2[i]) {
				count ++;
			}
		}
		if(count == S1.length) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

int main()
{
	char S[10001];
	int N, dem;
	scanf("%d%s", &N, &S);
	dem = strlen(S);
	for(int i = 0; i < dem; i++)
	{
		if((int)S[i] + N > 90) printf("%c", S[i] + N - 26);
		else printf("%c", S[i] + N);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; i++)
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
};
class dijkstra {
  private:
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<>> que;

  public:
    dijkstra(int v, int s, vector<edge> G[]) {
        V = v;
        update(s, G);
    }

    void update(int s, vector<edge> G[]) {
        fill(d, d + V + 1, 100000000000ll);
        d[s] = 0;
        que.push(make_pair(0, s));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (d[v] < p.first)
                continue;
            rep(i, G[v].size()) {
                edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(make_pair(d[e.to], e.to));
                }
            }
        }
    }

	int find(int e) {
		return d[e];
	}
};

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

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

bool prime(int a) {
	if (a == 1)
		return false;
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0)
			return false;
	}
	return true;
}

class Union_Find {
  private:
	vector<int> t, s;

  public:
	Union_Find(int max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(int x, int y) {
		if (same(x, y))
			return;
		int tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}

	int Find(int n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(int x, int y) {
		return Find(x) == Find(y);
	}

	int get_Size(int a) {
		return s[a];
	}
};

vector<int> primeFactorization(int n) {
	vector<int> re;
	int cnt = 2;
	while (n != 1) {
		if (n % cnt != 0) {
			cnt++;
			continue;
		}
		n /= cnt;
		re.push_back(cnt);
	}
	return re;
}

signed main(){
    int n,l;
    cin>>n>>l;
    int ans=0;
    ans=l*n;
    ans+=n*(n-1)/2;
    if(l>0)ans-=l;
    else if(l+n-1<0)ans-=(l+n-1);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a, b) = readIntegerList()
    var ans = ""
    if (a < b) {
        repeat(b) { ans += a }
    } else {
        repeat(a) { ans += b }
    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


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

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

   cout << r * r << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int num[2];
  cin >> num[0];
  cin >> num[1];
  int k = num[0]%num[1];
  if(k==0){
  	cout << num[0]/num[1];
  }else{
  	cout << (num[0]-k)/num[1]+1;
  }
}

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

int main(){
  int N,M;
  cin >> N >> M;
  
  double border = 1.0/(4*M);
  
  vector<double> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  
  int flag = 0;
  double sum = accumulate(A.begin(), A.end(), 0.0);
  
  for(int i=0; i<N; i++){
    if(border <= A.at(i)/sum){
      flag += 1;
    }
  }
 
  if(flag >= M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <type_traits>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using SS = stringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define NUMBERED( name, number ) NUMBERED2( name, number )
#define NUMBERED2( name, number ) name ## _ ## number
#define REP1( n ) REP2( NUMBERED( REP_COUNTER, __LINE__ ), n )
#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2, REP1 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a ) ( std::remove_all_extents< decltype( a ) >::type * )a, ( std::remove_all_extents< decltype( a ) >::type * )a + sizeof( a ) / sizeof( std::remove_all_extents< decltype( a ) >::type )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + ( p ), ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

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

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );
	cout << setprecision( 12 ) << fixed;

	int N, M;
	scanf( "%d%d", &N, &M );

	VI A( M );
	for_each( ALL( A ), []( int &a ){ scanf( "%d", &a ); } );
	reverse( ALL( A ) );
	A.resize( M + N );
	iota( begin( A ) + M, end( A ), 1 );

	VI done( N + 1 );
	FOR( a, A )
	{
		if ( !done[a] )
		{
			done[a] = printf( "%d\n", a );
		}
	}
	fflush( stdout );

	return 0;
}

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

int main(){
    string s1,s2,s3,mas;
    bool judge;
    while(1){
        cin >> s1;
        if(s1 == "0") break;
        cin >> s2 >> s3;
        mas = s1 + s2 + s3;
        judge = false;
        for(int i=0;i<9;i+=3){
            if(mas.substr(i,3) == "bbb"){
                cout << "b" << endl;
                judge = true;
                break;
            }
            if(mas.substr(i,3) == "www"){
                cout << "w" << endl;
                judge = true;
                break;
            }
        }
        for(int i=0;i<3;i++){
            if(mas[i] == mas[i+3] && mas[i+3] == mas[i+6] && !judge && mas[i] != '+'){
                cout << mas[i] << endl;
                judge = true;
                break;
            }
        }
        if(mas[0] == mas[4] && mas[4] == mas[8] && !judge && mas[0] != '+') {
            cout << mas[0] << endl;
            judge = true;
        }
        else if(mas[2] == mas[4] && mas[4] == mas[6] && !judge && mas[2] != '+'){
            cout << mas[2] << endl;
            judge = true;
        }
        else if(!judge) cout << "NA" << endl;
    }
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, P;
    cin >> A >> P;
    cout << (A * 3 + P) / 2 << endl;
}


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

int main() {
    string w;
    cin >> w;
    map<int, int>mp;
    rep(i,w.size()){
        mp[w[i]-'a']++;
    }
    rep(i,26){
        if(mp[i]%2==1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <cassert>
using namespace std;

#define sz(a) int((a).size())
#define rep(i, s, n)  for(int i = s; i <= (n); ++i)
#define rev(i, n, s)  for(int i = (n); i >= s; --i)
#define fore(x, a) for(auto &&x : a)
typedef long long ll;
const int mod = 1000000007;
const int N = 100005;

ll a[N];
int main() {
#ifdef loc
  if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
    assert(0);
  }
  freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
#endif
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  ll l, t;
  cin >> n >> l >> t;
  ll start = 0;
  rep(i, 0, n - 1) {
    ll x, w;
    cin >> x >> w;
    a[i] = x;
    if(w == 1) {
      a[i] += t;
    } else {
      a[i] -= t;
    }
    a[i] %= l;
    if(a[i] < 0) {
      a[i] += l;
    }
    if(w == 1) {
      start += (t / l);
      if(l - x <= (t % l)) {
        start++;
      }
    } else {
      start -= (t / l);
      if(x < (t % l)) {
        start--;
      }
    }
    start %= n;
    if(start < 0) {
      start += n;
    }
  }
  sort(a, a + n);
  rep(i, start, n - 1) {
    cout << a[i] << '\n';
  }
  rep(i, 0, start - 1) {
    cout << a[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 2048
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

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

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

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

const unsigned long long INF = 1LL << 60;

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

int main() {
    int N, K;
    cin >> N >> K;

    int ans = K;
    for (int i = 0; i < N - 1; ++i) {
        ans *= K - 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  private static int N;
  private static long K;
  private static int[] A;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    K = sc.nextLong();
    A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(A);
    
    long ok = -1_000_000_000_000_000_005L;
    long ng = 1_000_000_000_000_000_005L;
    while (ok+1 < ng) {
      long m = (ok+ng)/2;
      if (isOk(m)) {
        ok = m;
      } else {
        ng = m;
      }
    }
    System.out.println(ok);
  }
  private static boolean isOk(long x) {
    long count = 0;
    for (int i = 0; i < N; i++) {
      count += calcCount(i, x);
    }
    return count/2 < K;
  }
  private static int calcCount(int idx, long x) {
    int ok;
    int ng;
    if (A[idx] >= 0) {
      long max = (long)A[idx]*A[N-1];
      long min = (long)A[idx]*A[0];
      if (max < x) {
        return N-1;
      }
      if (x <= min) {
        return 0;
      }
      ok = 0;
      ng = N-1;
    } else {
      long max = (long)A[idx]*A[0];
      long min = (long)A[idx]*A[N-1];
      if (max < x) {
        return N-1;
      }
      if (x <= min) {
        return 0;
      }
      ok = N-1;
      ng = 0;
    }
    while ((A[idx] >= 0 && ok+1 < ng)
          || (A[idx] < 0 && ng+1 < ok)) {
      int m = (ok+ng)/2;
      if ((long)A[idx]*A[m] < x) {
        ok = m;
      } else {
        ng = m;
      }
    }
    if (A[idx] >= 0) {
      return idx <= ok ? ok : ok+1;
    } else {
      return idx >= ok ? N-ok-1 : N-ok;
    }
  }
}

Measured memory_bytes: 50488
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int a = in.nextInt();
    int b = in.nextInt();
    int c = in.nextInt();
    int d;
    if (c < a) {
      d = a;
      a = c;
      c = d;
    }
    if (c < b) b = c;
    d = a * b / 2;
    System.out.println(d);
  }
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll x[60];
ll p[60];
ll c{0};

ll f(ll N, ll X)
{

	if (X == 1) {return N == 0;}
	else if (1 < X && X <= x[N-1] + 1) return f(N-1, X-1);
	else if (X == x[N-1] + 2) return p[N-1] + 1;
	else if (x[N-1] + 2 < X && X <= 2*x[N-1] + 2) return p[N-1] + f(N-1, X-x[N-1]-2) + 1;
	else if (X == 2*x[N-1]+3)return 2*p[N-1] + 1;
}

int main(int argc, char **argv)
{
	ll N, X; cin >> N >> X;
	x[0] = p[0] = 1;
	REP(i, 50)
	{
		x[i+1] = 2*x[i] + 3;
		p[i+1] = 2*p[i] + 1;
	}

	std::cout << f(N, X) << std::endl;
}


Measured memory_bytes: 256
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <numeric>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

#define bs(n) (1ull<<(ull)(n))
#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)
#define rrep(i, n) for(ll (i) = 1;(i) <= (n);(i)++)

int main() {

    ll n;
    string s;
    cin >> n >> s;
    for (auto &e:s) {
        switch (e) {
            case 'R':
                e = 0;
                break;
            case 'G':
                e = 1;
                break;
            case 'B':
                e = 2;
                break;
        }
    }
    ll r = 0, cnt[5000][3] = {0};
    rep(i, n) {
        rep(j, 3)cnt[i + 1][j] = cnt[i][j];
        cnt[i + 1][s[i]]++;
    }
    for (int j = 0; j < n; j++) {
        for (int k = j + 1; k < n; k++) {
            if (s[j] == s[k])continue;
            int f[3] = {0};
            f[s[j]]++;
            f[s[k]]++;
            char nl = -1;
            rep(t, 3)if (f[t] == 0)nl = t;
            r += cnt[j][nl];
            if (j - (k - j) >= 0 && s[j - (k - j)] == nl) r--;
        }
    }
    cout << r << endl;
}


Measured memory_bytes: 3748
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll H, W; cin >> H >> W;
	char c[100][100];
	rep(i, 0, H) {
		rep(j, 0, W) {
			cin >> c[i][j];
		}
	}
	rep(i, 0, H) {
		rep(j, 0, W) {
			cout << c[i][j];
		}
		cout << endl;
		rep(j, 0, W) {
			cout << c[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t n, m;
    cin >> n >> m;

    string s;
    cin >> s;

    vector<bool> gameover(n + 1);
    int64_t len = 0;
    for (auto c : s | indexed(0)) {
        gameover[c.index()] = (c.value() == '1');
        if (gameover[c.index()]) {
            ++len;

            if (len >= m) {
                cout << -1 << endl;
                return 0;
            }
        } else {
            len = 0;
        }
    }

    vector<int64_t> path;
    path.push_back(n);
    while (path.back() > 0) {
        auto cur = path.back();
        if (cur - m <= 0) {
            path.push_back(0);
            break;
        }

        for (auto cur2 : irange(cur - m, cur)) {
            if (gameover[cur2]) {
                continue;
            }

            path.push_back(cur2);
            break;
        }
    }

    const auto* delim = "";
    for (uint64_t i = 0; i < path.size() - 1; ++i) {
        cout << delim << path[path.size() - 2 - i] - path[path.size() - 1 - i];
        delim = " ";
    }
    cout << endl;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s=="SSS") cout<<0<<endl;
  if(s=="RSS") cout<<1<<endl;
  if(s=="SRS") cout<<1<<endl;
  if(s=="SSR") cout<<1<<endl;
  if(s=="RRS") cout<<2<<endl;
  if(s=="RSR") cout<<1<<endl;
  if(s=="SRR") cout<<2<<endl;
  if(s=="RRR") cout<<3<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;


int main(){
	int k[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin>>n;
	cout<<k[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<utility>
#include<string>
#include<cmath>
using namespace std;

int main(){
    int n;cin >> n;
    int a[n+1];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    a[n] =(int)2*1e9;
    int ans = 0;
    int tmp = 0;
    for(int i=0;i<n;i++){
        //cout << a[i] << endl;
        if(a[i+1] <= a[i] ){
            tmp ++;
        }
        else{
            if(ans < tmp){
                ans = tmp;
            }
            tmp = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    auto s = sread();
    long result = long.max;
    foreach (i; 0 .. s.length - 2)
    {
        long n = s[i .. i + 3].to!long();
        // writeln("    ", n);
        result.minAssign(abs(n - 753));
    }
    writeln(result);
}


Measured memory_bytes: 256
N = int(input())
strings = sorted([sorted(input()) for _ in range(N)])
ans = 0
temp = 1
for s1, s2 in zip(strings, strings[1:]):
    if s1 == s2: temp += 1
    else:
        ans += temp * (temp - 1) // 2
        temp = 1
ans += temp * (temp - 1) // 2
print(ans)

Measured memory_bytes: 25420
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, m = ns()
    d = []
    for _ in range(m):
        ai, bi = ns()
        ci = na()
        d.append([ai, bi, ci])

    # bit DP
    # dp[i] = iの各bitが1である番目の宝箱を開けられる状態となれる最小コスト
    dp = [INF for _ in range(2 ** n)]
    dp[0] = 0

    for ai, bi, ci in d:
        getkey = 0
        for cii in ci:
            cii -= 1
            getkey += 1 << cii

        for i in range(2 ** n):
            dp[i | getkey] = min(dp[i | getkey], dp[i] + ai)

    tmp = dp[2 ** n - 1]
    print(tmp if tmp != INF else -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11304
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define lun(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<60);
const int inf=(1<<30);
const int nmax=1e5+50;
const ll mod=1e9+7;
using namespace std;
int i,j,t,n;
map<int,int>mp;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	for(i=1;i<=100;i++)for(j=1;j<=100;j++)for(t=1;t<=100;t++)mp[i*i+j*j+t*t+i*j+t*j+i*t]++;
	cin>>n;
	for(i=1;i<=n;i++)cout<<mp[i]<<'\n';
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<tuple<string, int, int>> g(N);
  string s;
  int p;
  rep(i, N) {
    cin >> s >> p;
    g[i]=make_tuple(s,-p,i);
  }
  sort(g.begin(), g.end());
  int n;
  rep(i, N) {
    // cout << get<2>(g[i]) << endl;
    tie(s,p,n) = g[i];
    cout << n+1 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,d;
char s[200005];
inline void failed(){
    puts("No");
    exit(0);
}
inline void success(){
    puts("Yes");
    exit(0);
}
inline void subtask1(){
    bool flag=false;
    for(int i=b+1;i<=d;i++)
      if(s[i]=='#' && s[i-1]=='#') failed();
    for(int i=b+1;i<=d+1;i++)
      if(i>=a+2 && i<=c && s[i]=='.' && s[i-1]=='.' && s[i-2]=='.') flag=true;
    if(!flag) failed();
    for(int i=a+1;i<=c;i++)
      if(s[i]=='#' && s[i-1]=='#') failed();
    success();
}
inline void subtask2(){
    for(int i=b+1;i<=d;i++)
      if(s[i]=='#' && s[i-1]=='#') failed();
    for(int i=a+1;i<=c;i++)
      if(s[i]=='#' && s[i-1]=='#') failed();
    success();
}
int main(){
    cin>>n>>a>>b>>c>>d;
    scanf("%s",s+1);
    if(d<=c) subtask1();
    else subtask2();
    return 0;
}

Measured memory_bytes: 384
m, d = map(int, input().split())
count = 0
for i in range(d + 1):
    if i > 9:
        if i // 10 >= 2:
            if i % 10 >= 2:
                if (i // 10) * (i % 10) in [x for x in range(m+1)]:
                    count += 1
print(count)


Measured memory_bytes: 2940
from collections import defaultdict

def dijkstra(G, s):
  heap = Heap()
  heap.push((s, 0))
  fixed = set()
  d = defaultdict(lambda: 999999999999999999999)
  d[s] = 0
  while len(heap.data) > 0:
    v = heap.pop()
    if v in fixed:
      continue
    for u in G[v]:
      if u in fixed:
        continue
      c = G[v][u]
      if d[v] + c < d[u]:
        d[u] = d[v] + c
        heap.push((u, d[u]))
    fixed.add(v)
  return d


class Heap:
  def __init__(self):
    self.data = []

  def push(self,x):
    self.data.append(x)
    i = len(self.data)-1
    while self._p(i) >= 0:
      if self.data[i][1] < self.data[self._p(i)][1]:
        tmp = self.data[i]
        self.data[i] = self.data[self._p(i)]
        self.data[self._p(i)] = tmp
        i = self._p(i)
      else:
        break

  def pop(self):
    ret = self.top()
    n = self.data.pop()
    if len(self.data) > 0:
      self.data[0] = n
      i = 0
      while True:
        if self._l(i) < len(self.data):
          l = self.data[self._l(i)]
        else:
          l = (-1, 999999999999999999999)
        if self._r(i) < len(self.data):
          r = self.data[self._r(i)]
        else:
          r = (-1, 999999999999999999999)
        if l[1] > r[1]:
          if r[1] < self.data[i][1]:
            tmp = self.data[i]
            self.data[i] = self.data[self._r(i)]
            self.data[self._r(i)] = tmp
            i = self._r(i)
          else:
            break
        else:
          if l[1] < self.data[i][1]:
            tmp = self.data[i]
            self.data[i] = self.data[self._l(i)]
            self.data[self._l(i)] = tmp
            i = self._l(i)
          else:
            break
    return ret[0]

  def top(self):
    return self.data[0]

  def _p(self, i):
    i = i+1
    return i//2-1

  def _l(self, i):
    i = i+1
    return i*2-1

  def _r(self, i):
    i = i+1
    return i*2


G = {}

n = int(input())
for _ in range(n):
  entry = [int(v) for v in input().strip().split(' ')]
  u = entry[0]
  k = entry[1]
  G[u] = {}
  for i in range(k):
    v = entry[2+i*2]
    c = entry[3+i*2]
    G[u][v] = c

d = dijkstra(G, 0)

for i in range(n):
  print(i, d[i])

Measured memory_bytes: 8416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define rep(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define prl(x) cout << (x) << endl

int main(void){
    ll n;cin>>n;vl x(n),y(n),p(n),ans(n+1,1LL<<60);vector<vl>xs(n),ys(n);
    rep(i,n)cin>>x[i]>>y[i]>>p[i];
    rep(i,n){
        xs[i]=vl(1<<n,abs(x[i])),ys[i]=vl(1<<n,abs(y[i]));
        rep(b,1<<n)rep(j,n)if(b&1<<j)
            xs[i][b]=min(xs[i][b],abs(x[i]-x[j])),ys[i][b]=min(ys[i][b],abs(y[i]-y[j]));
    }
    
    rep(b,1<<n){
        ll s=b;
        do{
            ll k=__builtin_popcountl(b),v=0,bx=s,by=b&~s;
      	    rep(i,n)v+=p[i]*min(xs[i][bx],ys[i][by]);
            ans[k]=min(ans[k],v);
            s=(s-1)&b;
        }while (s!=b);
    }
    rep(i,n+1)prl(ans[i]);
    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    long long r[100];
    memset(r, 0, sizeof(r));
    r[0] = 2;
    r[1] = 1;
    for (int i = 2; i < 100; ++i) {
        r[i] = r[i - 1] + r[i - 2];
    }
    cout << r[n] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define SZ(vvv) ((int)vvv.size())
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 1000 + 5, M = 5e4 + 9, INF = 1e9, MOD = 998244353;

vector<int> vec[3];

void runtestcase() {
	int n;
	string str;
	cin >> n >> str;
	for (int i = 0; i < n; ++i) {
		if(str[i] == 'R')
			vec[0].push_back(i);
		else if(str[i] == 'G')
			vec[1].push_back(i);
		else
			vec[2].push_back(i);
	}
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			if(str[i] == str[j]) continue;
			int k = j + 1, noCount = (j - i) + j;
			int num = 0;
			if(str[i] != 'B' && str[j] != 'B') num = 2;
			else if(str[i] != 'G' && str[j] != 'G') num = 1;
			int cnt = SZ(vec[num]) - (lower_bound(vec[num].begin(), vec[num].end(), k) - vec[num].begin());
			if(binary_search(vec[num].begin(), vec[num].end(), noCount))
				--cnt;
			if(cnt)
				ans += cnt;
		}
	}
	cout << ans;
}


int main() {
    fastIO;
#ifdef LOCAL
    freopen("input.in", "rt", stdin);
//    freopen("cache.out", "wt", stdout);
#endif
  int t = 1, tt = 1;
//	cin >> t;
  while(t) {
//		cout << "Case #" << tt << ':' << ' ';
    runtestcase();
		cout << '\n';
    --t, ++tt;
  }
}


Measured memory_bytes: 3632
def gcd(a, b)
  return a if b == 0
  gcd(b, a % b)
end

k = gets.to_i
result = 0
1.upto(k) do |i|
  1.upto(k) do |j|
    m = gcd(i, j)
    1.upto(k) do |l|
      result += gcd(m, l)
    end
  end
end
puts result

Measured memory_bytes: 14324
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Aoj.ALDS.Chapter10B
{
    class Program
    {
        /// <summary>
        /// ????????±?????¨??????(LongestCommonSubsequence)????§£??????
        /// </summary>
        public static int SolveLCS(string str1, string str2)
        {
            int m = str1.Length;
            int n = str2.Length;

            // dp????????????????????????
            int[][] c = new int[m + 1][];
            for (int i = 0; i <= m; i++)
            {
                c[i] = new int[n + 1];
            }

            // str1, str2 ???????????????0?????´??????????????????????????????
            for (int i = 0; i <= m; i++)
            {
                c[i][0] = 0;
            }
            for (int i = 0; i <= n; i++)
            {
                c[0][i] = 0;
            }

            // ?????????????????£????§£??????
            for (int i = 1; i <= m; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    if (str1[i - 1] == str2[j - 1])
                    {
                        c[i][j] = c[i - 1][j - 1] + 1;
                    }
                    else
                    {
                        c[i][j] = Math.Max(c[i - 1][j], c[i][j - 1]);
                    }
                }
            }

            return c[m][n];
        }

        public static void Solve()
        {
            int n = int.Parse(Console.ReadLine()) * 2;

            for (int i = 0; i < n; i += 2)
            {
                string str1 = Console.ReadLine();
                string str2 = Console.ReadLine();

                int lcs = SolveLCS(str1, str2);

                Console.WriteLine(lcs);
            }
        }


        public static void Main()
        {
            // Console.SetIn(new System.IO.StreamReader("Aoj/AlgorithmsAndDataStructures/Input/10_DP_B_01.txt"));
            // var sw = new Stopwatch();
            // sw.Start();

            Solve();

            // Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
        }
    }
}

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

using namespace std;

long long dp[105][10], cnt[105];

int main() {
	int k;
	scanf("%d", &k);
	
	if (k <= 9) return 0 * printf("%d\n", k);
	
	for (int i = 0; i <= 9; i++) dp[1][i] = 1LL;
	cnt[1] = 9;
	
	int len = -1;
	
	for (int i = 2; i <= 100; i++) {
		for (int j = 0; j <= 9; j++) {
			if (j - 1 >= 0) dp[i][j] += dp[i - 1][j - 1];
			dp[i][j] += dp[i - 1][j];
			if (j + 1 <= 9) dp[i][j] += dp[i - 1][j + 1];
		}
		
		cnt[i] = cnt[i - 1];
		for (int j = 1; j <= 9; j++) cnt[i] += dp[i][j];
		
		if (cnt[i] >= k) {
			len = i;
			break;
		}
	}
	
	long long cur = cnt[len - 1];
	int curDigit = -1;
	for (int i = 1; i <= 9; i++) {
		if (cur + dp[len][i] >= k) {
			curDigit = i;
			k -= cur;
			break;
		}
		cur += dp[len][i];
	}
	
	printf("%d", curDigit);
	
	for (int i = len - 1; i >= 1; i--) {
		long long sum = 0;
		for (int j = max(0, curDigit - 1); j <= min(9, curDigit + 1); j++) {
			if (sum + dp[i][j] >= k) {
				k -= sum;
				printf("%d", j);
				curDigit = j;
				break;
			}
			sum += dp[i][j];
		}
	}
	printf("\n");
}


Measured memory_bytes: 3832
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<fstream>
#include<map>
#include<bitset>
#include<unordered_map>
#include<cstring>
#include<cctype>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define mod 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll fix_mod(ll x, ll y)
{
	return (y + x % y) % y;
}
void fast() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
}
vector<vector<int>>edg;
int mem[(int)1e5 + 10];
int solve(int u)
{
	int& ret = mem[u];
	if (~ret)return ret;
	ret = 0;
	for (auto v : edg[u])
	{
		ret = max(ret,solve(v)+1);
	}
	return ret;
}
int main()
{
	Mohammed_Atef_Hassan
		clr(mem, -1);
		int n, m;
	cin >> n >> m;
	edg = vector<vector<int>>(n + 1);
	while (m--)
	{
		int x, y;
		cin >> x >> y;
		edg[x].push_back(y);
	}
	int mx = 0;
	for (int i = 1; i <= n; i++)
	{
		mx = max(mx, solve(i));
	}
	ex(mx);
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9+7;
typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<bool> vb;
long long int max(long long int a,long long int b){
  if(a>b)
    return a;
  else
    return b;
}
long long int min(long long int a,long long int b){
  if(a<b)
    return a;
  else
    return b;
}
long long int binpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
    }
  return res;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}

lli mul(lli a,lli b){
  return (a%mod * b%mod)%mod;
}

lli add(lli a,lli b){
  return (a%mod + b%mod)%mod;
}

lli sub(lli a,lli b){
  return (a%mod-b%mod+mod)%mod;
}
 
//############################ENDOFTEMPLATE############################



void solve(){
  int n;
  cin>>n;
  vector<vector<pii>> test(n);

  for(int i = 0;i<n;i++){
    int a;
    cin>>a;
    for(int j = 0;j<a;j++){
      int x,y;
      cin>>x>>y;
      test[i].push_back({x,y});

    }
  }

  int max_mask = 1<<n;

  int ans = 0;
  for(int mask = 0;mask<max_mask;mask++){
    bool flag = true;
    for(int i = 0;i<n;i++){
      //cout<<(mask&(1<<i));
      if((mask & (1<<i))==0) continue;

      for(auto c:test[i]){
        int x = c.first; int y = c.second;
        x--;
        if((y==0 &&(mask&(1<<x))!=0) || (y==1 && (mask&(1<<x))==0))
          flag = false;
      }
    }
    //cout<<" ";

    //cout<<mask<<" "<<flag<<endl;

    if(flag){
      ans = max(ans,__builtin_popcount(mask));
    }
  }

  cout<<ans;
}

 
 
 
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  int t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 3612
import sys
from math import factorial
sys.setrecursionlimit(100000)

input = sys.stdin.readline

X, Y = list(map(int,input().split()))

mod = 10**9 + 7

def mm(a, b):
    return ((a % mod) * (b % mod)) % mod

def pp(x, y):
    if   y == 0     :
    	return 1
    elif y == 1     : 
    	return x % mod
    elif y % 2 == 0 : 
    	return (pp(x, y/2)**2) % mod
    else            : 
    	return (pp(x, y//2)**2 * x) % mod

def dd(a, b):
    return mm(a, pp(b, mod-2))

def xgcd(a, b):
	x0, y0, x1, y1 = 1, 0, 0, 1
	while b != 0:
	    q, a, b = a // b, b, a % b
	    x0, x1 = x1, x0 - q * x1
	    y0, y1 = y1, y0 - q * y1
	return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

if (X+Y)%3!=0:
	ans = 0
else:
	nmsum = (X+Y)//3
	nmdif = Y-X
	if (nmsum+nmdif)%2!=0:
		ans = 0
	else:
		n = (nmsum+nmdif)//2
		m = (nmsum-nmdif)//2
		if n<0 or m<0:
			ans = 0
		elif n==0 or m==0:
			ans = 1
		else:
			t = 1
			for i in range(1,n+m+1):
				t = (t*i)%mod
				if i==n: bb = t
				if i==m: cc = t
				if i==n+m: aa = t
			# aa = factorial(n+m)%mod
			# bb = factorial(n)%mod
			# cc = factorial(m)%mod
			ans = aa * modinv(bb,mod) %mod
			ans = ans * modinv(cc,mod) %mod

print(ans)

Measured memory_bytes: 39792
import bisect
N=int(input())
A=sorted(map(int,input().split()))
B=sorted(map(int,input().split()))
C=sorted(map(int,input().split()))

ans=0
for i in range(N):
  ans+=bisect.bisect_left(A,B[i])*(N-bisect.bisect_right(C,B[i]))
  
print(ans)

Measured memory_bytes: 23360
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main() {
	int n,k;
	cin>>n>>k;
	vector<long long>dp(n,1145141919),num(n);
	for(int i=0;i<n;i++){
		cin>>num[i];
	}
	dp[0]=0;
	for(int i=0;i<n;i++){	
		for(int j=1;j<=k;j++){
			if(i+j<n)dp[i+j]=min(dp[i+j],dp[i]+abs(num[i]-num[i+j]));
		}	 
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define MAX_V 10000
#define MAX_E 100000

using namespace std;

typedef long long ll;

vector<int> G[MAX_V];
vector<int> ans;
bool done[MAX_V];

void dfs(int i) {
    if (done[i])
        return;
        
    for (int j = 0; j < G[i].size(); ++j) {
        dfs(G[i][j]);
    }
    ans.push_back(i);
    done[i] = true;
}

int main() {
    int V, E;
    cin >> V >> E;
    for (int i = 0; i < E; ++i) {
        int s, t;
        cin >> s >> t;
        G[t].push_back(s);  // 逆向きの辺
    }
    
    for (int i = 0; i < V; ++i) {
        if (done[i])
            continue;
        dfs(i);
    }
    
    for (int i = 0; i < V; ++i) {
        cout << ans[i] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3908
using static System.Console;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var abcd = ReadLine().Split();
            var a = int.Parse(abcd[0]);
            var b = int.Parse(abcd[1]);
            var c = int.Parse(abcd[2]);
            var d = int.Parse(abcd[3]);
            
            int takahashi = c/b;
            int aoki = a/d;

            if(c % b != 0)
            {
                takahashi++;
            }
            if (a % d != 0) 
            {
                aoki++;
            }

            if(takahashi <= aoki)
            {
                Write("Yes");
            }
            else
            {
                Write("No");
            }
        }
    }
}


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


int main() { 
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 2; i <= n; i++) {
        if (i % 2 == 0) ans += n - i + 1;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3584
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int N;
  cin >> N;

  int n = 0;
  for(int i = 11; n < N && i <= 55555; i++) {
    bool sosu = true;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        sosu = false;
        break;
      }
    }
    if (sosu && i % 5 == 1) {
      cout << i << endl;
      n++;
    }
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n); rep(i,n) cin >> a[i];
    //sort(all(a));
    int res=0;
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            for(int k=j+1; k<n; k++){
                if(a[i]==a[j]||a[j]==a[k]||a[k]==a[i]) continue;
                if(abs(a[i]-a[j])<a[k] && a[k]<(a[j]+a[i])) res++;
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3660