akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
#define P pair<int,double>
bool cmp(P a, P b){
	return a.second < b.second;
}

int main() {
	P Group[3][8];
	for(int i=0;i<3;i++) for(int j=0;j<8;j++){
		int tmp; double TMP; cin >> tmp >> TMP;
		Group[i][j]= P (tmp,TMP);
	}
	for(int i=0;i<3;i++) sort(Group[i],Group[i]+8,cmp);
	P ans[8];
	for(int j=0;j<3;j++) for(int i=0;i<2;i++) ans[2*j+i]=Group[j][i];
	P GroupNew[24];
	for(int i=0;i<3;i++) for(int j=2;j<8;j++){
		GroupNew[6*i+(j-2)]=Group[i][j];
	}
	sort(GroupNew,GroupNew+18,cmp);
	for(int j=0;j<2;j++) ans[6+j]=GroupNew[j];
	cout << fixed << setprecision(2);
	for(int i=0;i<8;i++) cout << ans[i].first << ' ' << ans[i].second << '\n' ;
}

Measured memory_bytes: 1300
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  string s; cin >> s;
  int ans = 0, x = 0;
  for (char c : s) {
    if (c == 'I') ++x;
    else --x;
    ans = max(ans, x);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, c;
    cin >> n >> c;
    vector<vector<int>> imos(c, vector<int>(101010, 0));
    for(int i = 0; i < n; i++) {
        int s, t, cc;
        cin >> s >> t >> cc;
        cc--;
        imos[cc][s]++;
        imos[cc][t + 1]--;
    }
    for(int i = 0; i < c; i++) {
        for(int j = 1; j < 101010; j++) {
            imos[i][j] += imos[i][j - 1];
        }
    }
    for(int i = 0; i < c; i++) {
        for(int j = 0; j < 101010; j++) {
            if(imos[i][j] >= 1) {
                imos[i][j] = 1;
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < 101010; i++) {
        int cnt = 0;
        for(int j = 0; j < c; j++) {
            cnt += imos[j][i];
        }
        chmax(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12544
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	string S;
	cin >> S;

	int odd = 0, even = 0;

	FOR(i, 0, S.length()) {
		if (i % 2 == 0) {
			if (S[i] == '0') even++;
			else odd++;
		}
		else {
			if (S[i] == '1') even++;
			else odd++;
		}
	}

	cout << (even > odd ? odd : even);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  bool OK=true;
  vector<string> str(N);
  for(int i=0;i<N;i++){
    cin>>str[i];
  }
  for(int i=0;i<N-1;i++){
    if(str[i].back()!=str[i+1].front()){
      OK=false;
    }
  }
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(str[i]==str[j]){
        OK=false;
      }
    }
  }
  if(OK){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include "stdio.h"

int main()
{
	int N = 0;
	int A[21];
	int B[21];
	int C[21];
	int cnt;
	int sum = 0;


	//printf("料理数\n");
	scanf("%d", &N);
	
	//printf("料理品目\n");
	for (cnt = 0; cnt < N; cnt++) {
		scanf("%d", &A[cnt]);

	}
	//printf("満足度\n");
	
	for (cnt = 0; cnt < N; cnt++) {
		scanf("%d", &B[cnt]);
	}
	//printf("追加満足度\n");
	for (cnt = 0; cnt < N - 1; cnt++) {
		scanf("%d", &C[cnt]);
	}



	for (cnt = 1; cnt <= N; cnt++) {
		sum = sum + B[A[cnt - 1] - 1];
		if (cnt - 1 >= 1) {
			if (A[cnt - 2] == A[cnt - 1] - 1) {
				sum = sum + C[A[cnt - 1] - 2];
			}

		}
		
	}
	printf("%d", sum);
	return 0;

}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#define Z 1001
 
void Def(char *a,char *b){
  int i,j;
int numm,numn;

  int arrayc[Z][Z];

  numn = strlen(a);

  numm = strlen(b);

  for(i = 1;i <= numn;i++) 
    arrayc[i][0] = 0;

  for(j = 0;j <= numm;j++)
    arrayc[0][j] = 0;
   
  for(i = 1;i <= numn;i++){
    for(j = 1;j <= numm;j++){
      if(a[i - 1] == b[j - 1]) 
	arrayc[i][j] = arrayc[i - 1][j - 1] + 1;
      else  if(arrayc[i - 1][j] >= arrayc[i][j - 1]) 
	arrayc[i][j] = arrayc[i - 1][j];
      else arrayc[i][j] = arrayc[i][j - 1];
    }

  }

  printf("%d\n",arrayc[numn][numm]);

}
 
 
 
int main(){
  int num,i;

  char arrayx[Z],arrayy[Z];

  scanf("%d",&num);

  for(i = 1;i <= num;i++){
    scanf("%s",arrayx);

    scanf("%s",arrayy);

    Def(arrayx,arrayy);
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  int maxA = 0;
  for (int i = 0; i < N; i++) maxA = max(A[i], maxA);
  int ans;
  for (ans = 1; ans < maxA; ans++) {
    int work = 0;
    for (int i = 0; i < N; i++) {
      work += A[i];
      work -= ans;

      if (work < 0) {
        ans--;
        break;
      }
    }

    if (work < 0) break;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3120
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
int main()
{
	int n,sum=0,maxs=0,t;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>t;
		sum+=t;
		maxs=max(maxs,t);
	}
	cout<<sum-maxs/2<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
	int N, i, j, k, ans = 0, f;
	scanf("%d", &N);
	char **S = (char **)malloc(sizeof(char *) * N);
	char **T = (char **)malloc(sizeof(char *) * N);
	for(i = 0; i < N; i++){
		S[i] = (char *)malloc(sizeof(char) * (N + 1));
		scanf("%s", S[i]);
		T[i] = (char *)malloc(sizeof(char) * N);
	}
	for(k = 0; k < N; k++){
		for(i = 0; i < N; i++){
			for(j = 0; j < N; j++){
				T[(i + k) % N][j] = S[i][j];
			}
		}
		f = 1;
		for(i = 0; i < N && f == 1; i++){
			for(j = 0; j < N && f == 1; j++){
				if(T[i][j] != T[j][i]){
					f = 0;
				}
			}
		}
		ans += f * N;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
  lint N;
  cin >> N;

  // 点の個数
  lint ans = 0;
  for(lint i=1; i<=N; i++) {
    ans += i*(i+1)/2;
  }

  // 辺の個数
  for(lint i=0; i<N-1; i++) {
    lint u, v;
    cin >> u >> v;
    if(u > v) swap(u, v);
    ans -= u * (N-v+1);
  }
  cout << ans << endl;
}

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

int main() {
  int N, n = 0, count = 0, index = 0;
  cin >> N;
  vector<int> light(N), record(100000);

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    light.at(i) = a - 1;
  }

  while (true) {
    record.at(n) = 1;
    n = light.at(n);
    count++;
    if (n == 1) break;
    if (record[n] == 1) {
      count = -1;
      break;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <unistd.h>

int	main(void)
{
  int	i = 0;
  int	j;
  char	str[27] = {0};
  
  read(0, str, 26);
  while (str[i])
  {
    j = i + 1;
    while (str[j])
    {
      if (str[i] == str[j])
      {
        printf("no");
        return (0);
      }
      j++;
    }
    i++;
  }
  printf("yes");
  return (0);
}


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

using namespace std;

const int mod = 998244353;
const int INF = 1e6;

long long add(long long a, long long b) {
    long long res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

long long sub(long long a, long long b) {
    long long res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

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

long long potolok(long long a, long long b){   // округление вверх для целых
    return (a + b - 1) / b;
}


long long gcd(long long x, long long y){
    if(y == 0){
        return x;
    }
    if(x > y){
         return gcd(y, x % y);
    }
    else{
         return gcd(x, y % x);
    }
}

bool cmpr(int x, int y){            // сортировка по абсолютной величине
    if(abs(x) < abs(y)) return true;
    else{
        return false;
    }
}

bool comp(pair<int, int> x, pair<int, int> y){  // сортировка по первой компоненте
    if(x.first < y.first)return true;
    else if(x.first == y.first){
        if(x.second < y.second)return true;
        else return false;
    }
    else{
        return false;
    }
}

int cnt(string &s, string &p, int m, int n){
    if((m == 0 && n == 0) || n == 0){
        return 1;
    }
    if(m == 0){
        return 0;
    }
    if(s[m - 1] == p[n - 1]){
        return cnt(s, p, m - 1, n - 1) + cnt(s, p, m - 1, n);
    }
    else{
        return cnt(s, p, m - 1, n);
    }
}

int div(int n){
    int ans = 0;
    vector<int> used(n + 1, 0);
    for(int i = 1;i <= sqrt(n);i++){
        if(n % i == 0 && (!used[i] && !used[n / i])){
            if(i * i == n){
                ans++;
            }
            else{
                ans += 2;
            }
        }
    }
    return ans;
}

void solve(){
    long long n;
    cin >> n;
    vector<long long> primes = {2, 3, 5, 7, 11, 13};
    for (int i = 17; i <= n - 1; i += 2) {
    bool is_prime = true;
    for (int j = 0; primes[j] * primes[j] <= i; ++j) {
      if (i % primes[j] == 0) {
        is_prime = false;
        break;
      }
    }
    if (is_prime)
      primes.emplace_back(i);
    }
    long long ans = 0;
    for(long long i = 1;i < n;i++){
        long long k = i;
        long long fac = 1;
        for(long long j = 0;primes[j] * primes[j] <= k;j++){
            if(j >= primes.size()){
                cout << " SYKA " << endl;
            }
            if(k % primes[j] == 0){
                long long cnt = 0;
                while(k % primes[j] == 0){
                    cnt++;
                    k /= primes[j];
                }
                fac *= (cnt + 1);
            }
        }
        if(k != 1){
            fac *= 2;
        }
        ans += fac;
    }
    cout << ans << endl;
}

int main(){
    int t = 1;
    while(t--){
        solve();
    }
 }


Measured memory_bytes: 4292
import scala.io.Source

object Main extends App {
  for (line <- Source.stdin.getLines if line != "0 0") {
    val Array(h, w) = line.split(" ").map(_.toInt)
    for (i <- 1 to h) {
      for (j <- 1 to w) {
        print{ if (i == 1 || i == h || j == 1 || j == w) "#"
                 else "." }
      }
      println()
    }
    println()
  }
}

Measured memory_bytes: 53980
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int main()
{
    string str;
    int k;

    cin >> str >> k;

    set<string> s;
    rep(i, str.size()) {
        rep(j, 5) {
            if ( i + j > str.size() ) break;

            s.insert(str.substr(i, j+1));
            if ( s.size() > k ) s.erase(*s.rbegin());
        }
    }

    auto itr = s.begin();
    rep(i, k-1) ++itr;

    cout << *itr << endl;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  string S,T;
  cin >> S >> T;
  int l = S.size();
  bool ok = true;
  map<char,char> sm,tm;
  rep(i,l){
    char s = S.at(i), t = T.at(i);
    if(sm.count(s))if(sm[s]!=t)ok = false;
    if(tm.count(t))if(tm[t]!=s)ok = false;
    sm[s] = t;
    tm[t] = s;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

int main() {

    int n;
    cin >> n;

    int counter = 0;
    string s;

    cin >> s;

    int first_put_counter = 0;

    for(int i=0; i<n; i++){
        if(s[i] == '('){
            counter++;
        }
        else if(s[i] == ')'){
            counter--;
            if(counter<0){
                counter++;
                first_put_counter++;
            }
        }
    }

    while(first_put_counter--){
        cout << '(';
    }

    cout << s;

    while(counter--){
        cout << ')';
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 1123456789012345
using namespace std;
 
void end(ll n){
	cout << n << endl;
	exit(0);
}
 
int main(){
	ll n, a, b; cin >> n >> a >> b;
	if (a == b || n==2) end(1);
	if (n < 2 || a>b) end(0);
	ll ans = (n - 2)*(b - a) + 1;
	end(ans);
	return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var h, w, n int
  fmt.Scanf("%d", &n)
  fmt.Scanf("%d", &h)
  fmt.Scanf("%d", &w)
  
  ans := (n-w+1)*(n-h+1)
  fmt.Printf("%d\n", ans)
}

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

using namespace std;

int main()
{
  int K, S;
  cin >> K >> S;
  int ret = 0;
  for(int x = 0; x <= K; x++) {
    for(int y = 0; y <= K; y++) {
      int z = S - x - y;
      ret += 0 <= z && z <= K;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
	return a*a + b*b;
}
int main() {
	cin>>n;
	for (int i = 0; i < n; i++) {
		cin>>x[i]>>y[i];
		X += x[i]; Y += y[i];
	}
	X /= n; Y /= n;
	double P = 0.1;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X)*P;
		Y += (y[f] - Y)*P;
		P *= 0.999;
	}
	cout<<sqrt(d)<<endl;
}




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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
// clang-format on

using LL = long long;
using VLL = vector<LL>;
using VVLL = vector<VLL>;

int main()
{
  IOS;

  int N;
  cin >> N;
  VLL A(N);
  forn(i, 0, N) cin >> A[i];

  VLL csum(N + 1);
  for (int i = 1; i <= N; i++)
    csum[i] = csum[i - 1] + A[i - 1];

  VVLL dp(N, VLL(N));
  for (int i = N - 1; i >= 0; i--)
  {
    for (int j = i + 1; j < N; j++)
    {
      LL sum = csum[j + 1] - csum[i];
      LL p = LONG_MAX;
      for (int k = i; k < j; k++)
        p = min(p, dp[i][k] + dp[k + 1][j]);
      dp[i][j] = sum + p;
    }
  }
  cout << dp[0][N - 1] << endl;

  return 0;
}


Measured memory_bytes: 4524
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
ll mod = 1e9 + 7;
int main(){
	ll n, k; cin >> n >> k;
	ll ans = 0;
	for (ll i = k; i <= n + 1; i++) (ans += (i * (n - i + 1) + 1)) %= mod;
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

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

const ll MOD = 1000*1000*1000LL + 7;
const int N = 2005;

ll d[10*N] , fact[N*10] , pfact[N*10];
vector <pii> ar[2];

ll pw(ll a , ll b){
	
	if(b == 0)
	   return 1;
	
	ll k = pw(a , b/2);
	k = (k*k)%MOD;
	
	if(b%2)
	   k*= a;

	return (k % MOD);

}

int main(){

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

	ll ans = 0 , n , x , y , pt1 = 0 , pt2 = 0;
	cin >> n;

	fact[0] = 1;

	for(ll i = 1 ; i < N*5 + 100 ; i++){
	   fact[i] = (fact[i-1]*i) % MOD;
	   pfact[i] = pw(fact[i] , MOD-2);
	}

	for(int i = 0 ; i < n ; i++){
	   
	   cin >> x >> y;
	   ar[0].pb({N-x , N-y});
	   ar[1].pb({N+x , N+y});
   
	   ans -= (fact[2*x+2*y]*pfact[2*x] % MOD) * pfact[2*y] % MOD;
	   ans = (ans+MOD) % MOD;
	}	
	
	for(int i = 0 ; i < 2 ; i++)
		sort(ar[i].begin() , ar[i].end());

	for(int i = 0 ; i < 2*N+10 ; i++){
		for(int j = 1 ; j < 2*N+10 ; j++){		   

			d[j] += d[j-1];
			
			while(pt1 < n && ar[0][pt1] == mp(i , j))
			   d[j]++ , pt1++;
			
			d[j] %= MOD;
			
			while(pt2 < n && ar[1][pt2] == mp(i , j))
				ans = (ans + d[j]) % MOD , pt2++;
		}
	}
	
	cout << (ans*pfact[2])%MOD << endl;

	return 0;
}

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

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();
		int[] a  = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int max = a[a.length - 1] + 2;
		int[] t = new int[max];
		for (int i = 0; i < n; i++) {
			t[a[i] + 1] = 1;
		}
		t[0] = -1;
		for (int i = 1; i < max; i++) {
			if (t[i] == 1) {
				t[i] = i - 1;
			} else {
				t[i] = t[i - 1];
			}
		}

//		System.out.println("query start");
		for (int i = 0; i < q; i++) {
			int p = sc.nextInt();
//			System.out.println(p);
			int opt = 0;
			int idx = t[max - 1];
			while (0 <= idx) {
				int mod = idx % p;
				opt = Math.max(opt, mod);
				idx -= mod;
				idx = t[idx];
			}
			System.out.println(opt);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 145988
from itertools import chain, product
H,W = map(int,input().split())
grid = list(chain(
    ([None,]*(W+2),),
    (list(chain(
      (None,),
      map(lambda x: x=='#', input()),
      (None,),
      )) for _ in range(H)),
    ([None,]*(W+2),),
    ))

neighbors = ((1,0),(0,1),(-1,0),(0,-1))

res = 0

stack = []

for y,x in product(range(1,H+1),range(1,W+1)):
  if grid[y][x] is None:
    continue
  stack.append((y,x))
  black,white = 0,0

  while stack:
    y,x = stack.pop()
    v = grid[y][x]
    if v is None:
      continue
    grid[y][x] = None

    if v:
      black += 1
    else:
      white += 1
    v = not v

    for dy,dx in neighbors:
      w = grid[y+dy][x+dx]
      if w == v:
        stack.append((y+dy,x+dx))

  res += black*white

print(res)




Measured memory_bytes: 19548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N;
    cin >> N;
    vector<bool> sunuke(N);
    int K;
    cin >> K;
    REP(i,K){
        int d;
        cin >> d;
        REP(l,d){
            int a;
            cin >> a;
            a--;
            sunuke[a] = 1;
        }
    }
    int sum = 0;
    REP(i,N){
        if(sunuke[i] == 0)sum++;
    }
    cout << sum << "\n";
}

Measured memory_bytes: 3616
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
// const int MOD = 1e9 + 7;
const int MOD = 10007;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int a, b, c;

int main() {
    cin >> a >> b >> c;
    if (a < b) std::swap(a, b);
    if (a < c) std::swap(a, c);
    printf("%d", a * 10 + b + c);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}




int main(){

    ll x;
    cin >> x;
    if(x>=30){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }

}




Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define ll long long
#define ljc 998244353
using namespace std;
/*
转切比雪夫距离就可以做了。 
直接构造。

左上角R,左下角Y,右上角G,右下角B。 
填充即可。 
*/
#ifdef Fading
#define gc getchar
#endif
#ifndef Fading
inline char gc(){
    static char now[1<<16],*S,*T;
    if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
    return *S++;
}
#endif
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
int n,m;
const int mx=1100;
char S[4]={'R','Y','G','B'};
signed main(){
    n=read(),m=read();
    int D=read();
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
        	int tm1=(((i-j+m)/D)%2+2)%2;
        	int tm2=(((i+j+m)/D)%2+2)%2;
            printf("%c",S[2*tm1+tm2]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <typeinfo>
#include <numeric>
#include "math.h"
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <numeric>
using namespace std;

//　Floor Function

int main() {
	long long int a, b, n,hoge=0,mae,usiro;
	cin >> a >> b >> n;
	/*for (long long int i = 1; i<= b && i <= n; i++) {
		mae = ((a * i) / b);
		usiro = (a * (i / b));
		if (hoge <(mae-usiro) ) {
			hoge = (mae - usiro);
		}
	} */
	if (b > n) {
		mae = ((a * n) / b);
		usiro = (a * (n / b));
		hoge = (mae - usiro);
	}
	else{
		mae = ((a * (b-1)) / b);
		usiro = (a * ((b-1) / b));
		hoge = (mae - usiro);
	}
	cout << hoge << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

bitset<2000*2000> B;

int n;

int main()
{
	n=read();
	B[0]=1;
	int alb=0;
	for ( int i=1;i<=n;i++ )
	{
		int x=read();
		alb+=x;
		B|=B<<x;
	}
	for ( int i=(alb+1)/2;i<=alb;i++ ) 
		if(B[i]) 
			return printf("%d\n",i),0;
	return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    System.out.println(N * (N - 1) / 2 + M * (M - 1) / 2);
  }
}


Measured memory_bytes: 35688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
 cin >> N;
 int c;
 c=1;
 vector<string> gacha(N);
  for (int i = 0; i < N; i++) {
    cin >> gacha.at(i);
  }
  sort(gacha.begin(), gacha.end());
  for (int i = 1; i < N; i++) {
  if(gacha.at(i-1)!=gacha.at(i)){c=c+1;}
  }
  cout<<c<<endl;
}

Measured memory_bytes: 9508
#include<cstdio>
#include<algorithm>

using namespace std;

int n;
int Time[] = {0,0,0,0,0,0,0,0,0,0};
int f[100][10];
int p[100][11];
int MAX = -1000000001;
// int gain[10]


void maximum(int m, int flag, int Time[10]){
    int Time_new[10];
    for(int i = 0; i < 10; i++){
        Time_new[i] = Time[i];
    }
    Time_new[m] = flag;

    if (m < 9){
        maximum(m+1, 0, Time_new);
        maximum(m+1, 1, Time_new);
    }
    bool zero = true;
    for(int i = 0; i < 10; i++){
        if (Time_new[i] == 1) zero = false;
    }
    if (zero) return;
    
    if (m == 9) {

        // for(int i = 0; i < 10; i++){
        //     printf("%d ", Time_new[i]);
        // }
        // puts("");
        int dup_num[n]; // かぶっている日数
        fill(dup_num, dup_num + n, 0);
        int gain = 0;
        for(int i = 0; i < 10; i++){
            if (Time_new[i] == 1){
                for(int j = 0; j < n; j++){
                    // printf("%d ", f[j][i]);
                    if (f[j][i] == 1) {
                        dup_num[j] += 1;
                        // printf("%d\n", dup_num[j]);
                    }
                }
                // puts("");
            }
        }
        for(int i = 0; i < n; i++){
            gain += p[i][dup_num[i]];
            // printf("gain = %d\n", gain);
        }
        

        if (MAX < gain) {
            MAX = gain;
        }
    }

}

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            scanf("%d", &f[i][j]);
        }
    }




    for(int i = 0; i < n; i++){
        for(int j = 0; j < 11; j++){
            scanf("%d", &p[i][j]);
        }
    }

    maximum(0, 0, Time);
    maximum(0, 1, Time);
    printf("%d\n", MAX);
}


Measured memory_bytes: 888
import math
from itertools import permutations


def length(p, q):
    return math.sqrt((p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2)


n = int(input())
l = [list(map(int, input().split(" "))) for i in range(n)]
orders = list(permutations([i for i in range(n)]))

allL = 0

for i in range(len(orders)):
    order = orders[i]
    d = [length(l[order[j]], l[order[j + 1]]) for j in range(n - 1)]
    allL += sum(d)

print(allL / len(orders))


Measured memory_bytes: 8052
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	io := NewIo()
	defer io.Flush()
	s := io.Next()
	max := 0
	count := 0
	for _,c := range s {
		if fmt.Sprintf("%c",c) == "A" || fmt.Sprintf("%c",c) == "C" || fmt.Sprintf("%c",c) == "G" || fmt.Sprintf("%c",c) == "T" {
			count += 1
		} else {
			if count > max {
				max = count
			}
			count = 0
		}
	}
	if count > max {
		max = count
	}
	io.PrintLn(max)
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;
#define ll long long

int main(){
	ios_base::sync_with_stdio(0);
	int a,b,n,W,T,cas=0;
	cin>>n>>W;
	vector<ll> dp(W+1);
	for(int i=0;i<n;++i) {
		int weight, val;
		cin>>weight>>val;
		for(int weight_already=W-weight;weight_already>=0;--weight_already) {
			dp[weight_already+weight] = max(dp[weight_already+weight], dp[weight_already]+val);
		}
	}
	cout<<dp[W]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll N; cin>>N;
    map<string, ll> m;
    REP(i, N) {
        string s; 
        cin>>s;
        sort(ALL(s));
        m[s]++;
    }
    ll res = 0;
    for(auto &x: m){
        if(x.second>1) res += x.second*(x.second-1) / 2;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11136
N = int(input())

nn = N + 10
P = 998244353

fa = [1] * (nn+1)
fainv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P
C = lambda a, b: fa[a] * fainv[b] % P * fainv[a-b] % P if 0 <= b <= a else 0

ans = pow(3, N, P)
for i in range(N//2 + 1, N + 1):
    ans = (ans - 2 * C(N, i) * pow(2, N - i, P)) % P

print(ans)

Measured memory_bytes: 192136
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int k=in(),t=in(),m=0;
    vec a(t);
    rep(i,t)m=max(m,in());
    cout<<max(0,2*m-k-1)<<endl;
}

Measured memory_bytes: 256
main()
{
    int a[5]={0},b[5]={0}, i, j=0, max=0, ans=0;
    for(i=0;i<5;i++)
    {
        int d = 0;
        scanf("%d", &a[i]);d=a[i]%10;
        b[i] = d==0?0:10-d;
        if(max < b[i])
        {
            max=b[i];
            j=i;
        }
    }
    
    for(i=0;i<5;i++)
    {
        ans+=(a[i]+(i==j?0:b[i]));
    }
    
    printf("%d", ans);
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
   static Scanner sc = new Scanner(System.in);

   public static void main(String[] args) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int[] array = {a,b,c};
      Arrays.sort(array);
      System.out.println(array[2] * 10 + array[1] + array[0]);
   }
}

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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
	cout << a << "\n";
}



int main(int argc, const char * argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> a;
  inputVector(a,n);
  vector<ll> num(n,0);
  
  for(auto _a : a){
    ++num[_a-1];
  }
  ll sum=0;
  for ( auto n : num){
    sum+= n*(n-1)/2;
  }

  for(auto _a: a){ // if _a is removed
    ll n = num[_a-1];
    ll diff = n*(n-1)/2 - (n-1)*(n-2)/2;
    cout << sum - diff << endl;
  }
    
  
  return 0;
}


Measured memory_bytes: 5872
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0

for i, a in enumerate(A):
  ans += B[a - 1]
  if i > 0 and (A[i] - A[i - 1]) == 1:
    ans += C[A[i - 1] - 1]
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++) //単純なループの簡略化
typedef struct{int *A,size,maxsize;}vector; //疑似的な可変長配列

vector edge[100050]; //辺の情報を保持
int color[100050]; //頂点の色の情報を保持
int reached[100050]; //最大残り距離いくつでその頂点に到達したことがあるかを保持、ただし-1の時未到達を意味する

void push_back(int v,int push){ //vectorのpush_back機能
    if(edge[v].size==0){
        edge[v].size++;
        edge[v].maxsize++;
        edge[v].A=(int*)malloc(sizeof(int));
        edge[v].A[0]=push;
    }
    else{
        edge[v].size++;
        if(edge[v].size>edge[v].maxsize){ //可変長配列の長さが足りなくなった場合、元の2倍の大きさの領域を再確保
            edge[v].maxsize*=2;
            edge[v].A=(int*)realloc(edge[v].A,sizeof(int)*edge[v].maxsize);
        }
        edge[v].A[edge[v].size-1]=push;
    }
}

void DFS(int V,int dis,int paint){ //入力されたグラフ上での枝狩り深さ優先探索
    if(reached[V]>=dis) return; //到達時の残り距離が以前到達したときより短いなら打ち切る
    reached[V]=dis; //到達時の残り距離を更新
    if(color[V]==0) color[V]=paint; //まだ塗られていない場合、色を塗る
    rep(i,edge[V].size) DFS(edge[V].A[i],dis-1,paint); //隣接している全ての頂点へ移動する
}

int main(void){
    int N,M;
    scanf("%d",&N); //頂点数の入力
    scanf("%d",&M); //辺の数の入力
    rep(i,N) reached[i]=-1; //全ての頂点を未到達を意味する-1で初期化
    rep(i,M){ //辺の情報の入力
        int a,b;
        scanf("%d%d",&a,&b);
        a--,b--; // 0-indexedに直す
        push_back(a,b); //双方向に辺を張る
        push_back(b,a);
    }
    int Q;
    scanf("%d",&Q); //操作の回数の入力
    if(Q<1 || Q>100000) error();
    int V[Q],D[Q],C[Q];
    rep(i,Q){ //操作の入力
        scanf("%d%d%d",&V[i],&D[i],&C[i]);
        V[i]--; // 0-indexedに直す
    }
    for(int i=Q-1;i>=0;i--) DFS(V[i],D[i],C[i]); //枝狩り深さ優先探索を入力の逆順に実行
    rep(i,N) printf("%d\n",color[i]); //結果の出力
    return 0;
}

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

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

    int a[N];
    for (int i = 0; i < N; i++){
        a[i] = K - Q;
    }

    for (int j = 0; j < Q; j++){
        int A;
        cin >> A;
        a[A-1] += 1;
    }

    for (int i = 0; i < N; i++){
        if(a[i] > 0){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i = 0; i < N; i++) cin >> S[i];
    map<string, int> Sm;
    for(string s : S) Sm[s]++;
    int max_n = 0;
    for(auto p : Sm) max_n = max(max_n, p.se);
    vector<string> ans;
    for(auto p : Sm) if(p.se == max_n) ans.push_back(p.fi);
    sort(all(ans));
    for(string s : ans) cout << s << endl;
}


Measured memory_bytes: 33544
#include<cstdio>
#include <algorithm>
#include<queue>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
typedef pair<int,int> mp;
typedef long long int lli;
#define fir first
#define sec second

mp dat[300005];
int n;
int main(void){
	scanf("%d",&n);
	rep(i,0,n){
		int a,b;
		scanf("%d%d",&a,&b);
		dat[i]=mp(-b,a);
	}
	sort(dat,dat+n);
	
	int nb=0;
	lli nf=0;
	priority_queue<int> qi;
	priority_queue<int,vector<int>,greater<int> >qo;
	int ans=0;
	rep(i,0,n){
		ans=max(ans,(int)(qi.size()));
		nb=-dat[i].fir;
		nf+=dat[i].sec;
		qi.push(dat[i].sec);
		while((!qi.empty()) && qi.size()*nb<nf){
			nf-=qi.top();
			qo.push(qi.top());
			qi.pop();
		}
		while((!qo.empty()) && (qi.size()+1)*nb>=nf+qo.top()){
			nf+=qo.top();
			qi.push(qo.top());
			qo.pop();
		}
		ans=max(ans,(int)(qi.size()));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7404
import numpy as np

def longest_common_subsequence(S, T):
    """compute table dp satisfying: 
    dp[i,j] = LCS(S[:i], T[:j])"""
    LS, LT = len(S), len(T)
    dp = np.zeros((LS + 1, LT + 1), np.int32)
    for n in range(1, LS + 1):
        dp[n, 1:] = dp[n - 1, :-1] + (S[n - 1] == T)  # 左上から
        np.maximum(dp[n], dp[n - 1], out=dp[n])  # 上から
        np.maximum.accumulate(dp[n], out=dp[n])  # 左から
    return dp

def reconstruct_LCS(S, T, dp):
    tmp = []
    i, j = len(S), len(T)
    while i and j:
        if S[i - 1] == T[j - 1]:
            i, j = i - 1, j - 1
            tmp.append(S[i])
        elif dp[i, j] == dp[i - 1, j]:
            i -= 1
        else:
            j -= 1
    return ''.join(reversed(tmp))

s, t = np.array(list(input())), np.array(list(input()))

print(reconstruct_LCS(s, t, longest_common_subsequence(s, t)))



Measured memory_bytes: 62236
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;

int main(){
    int inf = 1e9;
    string S,T;
    cin >> S >> T;
    int N = S.size(),M = T.size();
    vector<vector<int>> neS(N+2,vector<int>(2,N+1)),neT(M+2,vector<int>(2,M+1));
    for(int i=0;i<N;i++){
        for(int j=i+1;j<=N;j++){
            if(S[j-1]=='0'){
                neS[i][0] = j;
                break;
            }
        }
        for(int j=i+1;j<=N;j++){
            if(S[j-1]=='1'){
                neS[i][1] = j;
                break;
            }
        }
    }
    for(int i=0;i<M;i++){
        for(int j=i+1;j<=M;j++){
            if(T[j-1]=='0'){
                neT[i][0] = j;
                break;
            }
        }
        for(int j=i+1;j<=M;j++){
            if(T[j-1]=='1'){
                neT[i][1] = j;
                break;
            }
        }
    }
    vector<vector<int>> dp(N+2,vector<int>(M+2,inf));
    vector<vector<P>> pre(N+2,vector<P>(M+2));
    dp[0][0] = 0;
    queue<P> Q;
    Q.push({0,0});
    while(!Q.empty()){
        P p = Q.front();
        Q.pop();
        int x = p.first,y = p.second;
        for(int k=0;k<2;k++){
            int nx = neS[x][k],ny = neT[y][k];
            if(dp[nx][ny]==inf){
                dp[nx][ny] = dp[x][y]+1;
                Q.push({nx,ny});
                pre[nx][ny] = {x,y};
            }
        }
    }
    int nowx = N+1,nowy = M+1;
    vector<char> ans(dp[N+1][M+1]);
    int id = dp[N+1][M+1]-1;
    while(nowx!=0 || nowy!=0){
        P p = pre[nowx][nowy];
        int x = p.first,y = p.second;
        if(neS[x][0]==nowx && neT[y][0]==nowy){
            ans[id] = '0';
        }else{
            ans[id] = '1';
        }
        id--;
        nowx = x,nowy = y;
    }
    for(auto x:ans) cout << x;
    cout << endl;
}


Measured memory_bytes: 191452
#include<bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std;
 
typedef pair<long long int,long long int>pa;
#define resize(A) A.resize(unique(A.begin(), A.end()) - A.begin())
#define pb push_back
 
# define  MAX 200005
long long int MOD=998244353;
long long int INF=1e18;
 
int main()
{
    
       ios_base::sync_with_stdio(false); 
       cin.tie(NULL);
     cout.tie(NULL);
      long long int i,j,k=0,l=0,r=0,m=0,n,p=0,cnt=0,cnt1=0,x,y,z=0,a,b,low,mid,high,ans=0,maxi=0,mini=INF,t;
cin>>n;
long long int A[n];
long long int B[n];
for(i=0;i<n;i++)
{
    cin>>A[i];
    B[i]=A[i];
}
sort(B,B+n);
for(i=0;i<n;i++)
{
    if(A[i]!=B[i])
      cnt++;
}
if(cnt==0||cnt==2)
cout<<"YES\n";
else
cout<<"NO\n";

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int D,T,S;
	scanf("%d%d%d",&D,&T,&S);
	if((S*T)>=D)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
n=int(input())
if n<3:
  print(0)
else:
  cnt=0
  l_list=list(map(int,input().split()))
  sl_list=sorted(l_list)
  for i in range(n):
    for j in range(i+1,n):
      for g in range(j+1,n):
        m=sl_list[i]
        f=sl_list[j]
        d=sl_list[g]
        if m!=f and f!=d and d!=m:
          if d<m+f:
            cnt+=1
  print(cnt)

Measured memory_bytes: 9196
n,k=map(int,input().split())
mod=10**9+7
fra=[1]*(n+2)
inv=[1]*(n+2)
t1=1
t2=1
for i in range(1,n+2):
    t1*=i
    t1%=mod
    t2*=pow(i,mod-2,mod)
    t2%=mod
    fra[i]=t1
    inv[i]=t2
def comb(n,r):
    return fra[n]*inv[n-r]*inv[r]%mod
for i in range(1,k+1):
    if n-k+1<i:
        print(0)
        continue
    print(comb(n-k+1,i)*comb(k-1,i-1)%mod)

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

long long INF = 1e18;

int main(){
    long long n;
    cin>>n;
    set<int> a;
    long long imp;
    for (int i = 0; i < n;i++){
        cin>>imp;
        a.insert(imp);
    }
    if(a.size() == n){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

        return 0;
}

Measured memory_bytes: 9600
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean[] a = new boolean[N+1];
		long odd = 0;
		long even = 0;
		long max = Long.MIN_VALUE;
		int mp = -1;
		for(int i=1;i<=N;++i){
			long temp = sc.nextLong();
			if(temp>max){
				max = temp;
				mp = i;
			}
			if(temp>0){
				a[i] = true;
				if(i%2==1) odd += temp;
				else even += temp;
			}
		}
		
		if(odd==0 && even==0){
			System.out.println(max);
			System.out.println(N-1);
			for(int i=N;i>mp;--i){
				System.out.println(i);
			}
			for(int i=1;i<mp;++i){
				System.out.println(1);
			}
			return;
		}
		
		System.out.println(Math.max(odd, even));
		int offset = odd>even ? 1 : 0;
		int p = N;		
		ArrayList<Integer> al = new ArrayList<Integer>();
		
		while(!a[p]||(p+offset)%2!=0){
			al.add(p);
			p--;
		}
		
		int left = 0;
		while(!a[left]||(left+offset)%2!=0) left++;
		for(int i=p-2;i>=left;i-=2){
			if(a[i]) al.add(i+1);
			else al.add(i);
		}
		
		for(int i=1;i<left;++i) al.add(1);
		
		System.out.println(al.size());
		for(int i=0;i<al.size();i++){
			System.out.println(al.get(i));
		}
		return;
	}
}

Measured memory_bytes: 28008