akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    private static char[] N;
    private static int K;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.next().toCharArray();
        K = sc.nextInt();
        int[][][] dp = new int[N.length+1][K+1][2];
        dp[0][0][1] = 1;
        for (int i = 0; i < N.length; i++) {
            for (int j = 0; j <= K; j++) {
                for (int s = 0; s < 2; s++) {
                    if (dp[i][j][s] == 0)  continue;
                    if (s == 0) {
                        dp[i+1][j][0] += dp[i][j][0];
                        if (j+1 <= K) {
                            dp[i+1][j+1][0] += 9*dp[i][j][0];
                        }
                    } else {
                        int a = N[i]-'0';
                        if (a == 0) {
                            dp[i+1][j][1] += dp[i][j][1];
                        } else {
                            dp[i+1][j][0] += dp[i][j][1];
                            if (j+1 <= K) {
                                dp[i+1][j+1][0] += (a-1)*dp[i][j][1];
                                dp[i+1][j+1][1] += dp[i][j][1];
                            }
                        }
                    }
                }
            }
        }
        System.out.println(dp[N.length][K][0]+dp[N.length][K][1]);
    }
}



Measured memory_bytes: 23764
n=int(input())
A=tuple(map(int,input().split()))
B=[0]*n
for i in reversed(range(n)):
    k=i+1
    l=n//k
    tmp=0
    for j in range(2,l+1):
        idx=k*j-1
        tmp^=B[idx]
    B[i]=tmp^A[i]
Ans=[]
for i,b in enumerate(B):
    if b:
        Ans.append(i+1)
print(len(Ans))
print(*Ans)

Measured memory_bytes: 72540
#include<stdio.h>
#include<string>
using namespace std;
int week(int x){
	x++;
	if(x==8)return 1;
	else return x;}
int main(){
	int d[13][32];
	int i,j,k=4;
	for(i=1;i<13;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			for(j=1;j<32;j++){
				d[i][j]=k;
				k=week(k);}}
		if(i==2){
			for(j=1;j<30;j++){
				d[i][j]=k;
				k=week(k);}}
		if(i==4||i==6||i==9||i==11){
			for(j=1;j<31;j++){
				d[i][j]=k;
				k=week(k);}}}
	string day[8]={" ","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int m,n;
	while(1){
		scanf("%d %d",&m,&n);
		if(m==0&&n==0)break;
		switch(d[m][n]){
			case 1:printf("Monday");break;
			case 2:printf("Tuesday");break;
			case 3:printf("Wednesday");break;
			case 4:printf("Thursday");break;
			case 5:printf("Friday");break;
			case 6:printf("Saturday");break;
			case 7:printf("Sunday");break;}
	printf("\n");}
	return 0;}


Measured memory_bytes: 2816
N,L = map(int, input().split())
ans = 0
if L >= 0:
    for i in range(N-1):
        ans += L + i + 1
elif N + L > 0:
    for i in range(N):
        ans += L + i
else:
    for i in range(N-1):
        ans += L + i
print(ans)


Measured memory_bytes: 2940
#include<stdio.h>
main()
{
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if

        (A==5 && B== 5 && C==7)
        {

        printf("YES");

    }
    else if

      (A==5 && B== 7 && C==5)
      {
      printf("YES");
    }
    else if

     (A==7 && B== 5 && C==5)
     {
     printf("YES");
    }
    else
        printf("NO");
}


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

int main()
{
	string s;
	cin>>s;
	int n=s.size();
	int count  = 0;
	
	for(int i=0;i<n;i++)
	{
		if((((i%2)==0)&&(s[i]=='R' || s[i]=='U' || s[i]=='D')) || (((i%2)!=0)&&(s[i]=='L' || s[i]=='U' || s[i]=='D')))
		{
			count++;
		}
		
	}
	if(count==n)
		cout<<"Yes";
		
		else 
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e5+10;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
int main() 
{
	double r;
	cin>>r;
	
	cout<<setprecision(20)<<2*(M_PI)*r;
	
	
}

Measured memory_bytes: 6156
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int X = Integer.parseInt(st.nextToken());
        int N = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(br.readLine());
        HashSet<Integer> hs = new HashSet<>();
        for (int i=0; i<N; i++)
            hs.add(Integer.parseInt(st.nextToken()));
        int ans=500,a=0;
        for (int i=0; i<200; i++){
            if (hs.contains(i))
                continue;
            if (Math.abs(i-X)<ans){
                ans=Math.abs(i-X);
                a=i;
            }
        }
        System.out.println(a);
    }




}



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

int main(void){
  int n;
  int cnt;

  while( scanf("%d" ,&n ) != EOF ){

    cnt = 0;

  for( int i = 0 ; i <= 9 ; i++ ){
    for( int j = 0 ; j <= 9 ; j++ ){
      for( int k = 0; k <= 9 ; k++ ){
	for( int l = 0 ; l <= 9 ; l++ ){

	  if( n == i + j + k + l ) cnt++;

	}
      }
    }
  }

  cout << cnt << endl;

  }
  return 0;

}

Measured memory_bytes: 1208
#include<stdio.h>
#include<string.h>


int main(void){
	char str[1010],word[1010][40],*temp,length[40],wd[40];
	int count[1010],i,leng=0,max;
	for(i=0;i<1010;i++)count[i]=0;
	scanf("%[^\n]",str);
	temp=strtok(str," ");
	while(temp!=NULL){
		if(leng<strlen(temp)){
			strcpy(length,temp);
			leng=strlen(temp);
		}
		i=0;
		while(count[i]!=0){
			if(strcmp(word[i],temp)==0){count[i]++;break;}
			i++;
		}
		strcpy(word[i],temp);
		count[i]++;
		temp=strtok(NULL," ");
	}
	i=0;
	max=count[i];
	while(count[i]!=0){
		if(max<count[i]){max=count[i];strcpy(wd,word[i]);}
		i++;
	}

	printf("%s %s\n",wd,length);

	return 0;
}

Measured memory_bytes: 568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
// #define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n;
  cin >> n;
  ll ans = 1;
  vector<ll> a(n);
  REP(i, n) {
    ll t;
    cin >> a.at(i);
  }
  REP(i, n) {
    if (a.at(i) == 0){
      cout << "0\n";
      return 0;
    }
  }
  REP(i, n) { 
    if(a.at(i)>1000000000000000000ll/ans){
      cout << "-1\n";
      return 0;
    }
    ans*=a.at(i);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3996
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX

#include <bits/stdc++.h>

using namespace std;

#define db(x) cout << (x) << '\n';
#define all(x) x.begin(),x.end()
#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define LB(v,x) lower_bound(all(v),x)
#define UB(v,x) upper_bound(all(v),x)
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define PF push_front
#define int long long
#define double long double
#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

int dy[]={0,1,1,1,0,-1,-1,-1};
int dx[]={-1,-1,0,1,1,1,0,-1};
const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1);

void maxself(int &a,int b)
{a=max(a,b);}
void minself(int &a,int b)
{a=min(a,b);}

vector<vi> g(maxn);


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

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);

    int a;
    cin >> a;
    cout << a + a*a + a*a*a;

	return 0;
}



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

int a[100010];
int b[100010];
int c[100010];
int d[100010];

int main () {

int n;
cin >>n;
for (int i = 0; i < n; i ++) {
	cin >> a[i];
	b[a[i]]++;
	c[a[i]-1]++;
	d[a[i]+1]++;
}
int maxi = 0, br = 0;
for (int i = 0; i < 100001; i ++) {
	if (b[i]+c[i]+d[i]>maxi) {maxi=b[i]+c[i]+d[i]; br=i;}
}
int sol = 0;
for (int i = 0; i < n; i ++) {
	if (a[i]==br) {sol++;}
	if (a[i]+1==br) {sol++;}
	if (a[i]-1==br) {sol++;}
}
cout<<sol;


return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.Arrays;
 
public class Main {
  public static void main(String[] args) {
    Integer[] age753 = {7,5,3};
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if (Arrays.asList(age753).contains(x)) System.out.println("YES");
    else System.out.println("NO");
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<char> ans(N);
  vector<string> S_vec(N);
  for (ll i = 0; i < N; ++i) {
    cin >> S_vec.at(i);
  }
  for (ll i = 0; i < N; ++i) {
    string S = S_vec.at(i);
    if (S == "AC") {
      if (A == 0 && C == 0) {
        cout << "No" << "\n";
        return 0;
      }
      if (A == 1 && C == 1) {
        bool add_a = true;
        for (ll j = i + 1; j < N; ++j) {
          if (S_vec.at(j) == "AC") {
            continue;
          }
          if (S_vec.at(j) == "BC") {
            add_a = false;
            break;
          }
          else {
            break;
          }
        }
        if (!add_a) {
          A -= 1;
          C += 1;
          ans.at(i) = 'C';
        }
        else {
          C -= 1;
          A += 1;
          ans.at(i) = 'A';
        }
      }
      else if (A > C) {
        A -= 1;
        C += 1;
        ans.at(i) = 'C';
      }
      else {
        C -= 1;
        A += 1;
        ans.at(i) = 'A';
      }
    }
    if (S == "AB") {
      if (A == 0 && B == 0) {
        cout << "No" << "\n";
        return 0;
      }

      if (A == 1 && B == 1) {
        bool add_a = true;
        for (ll j = i + 1; j < N; ++j) {
          if (S_vec.at(j) == "AB") {
            continue;
          }
          if (S_vec.at(j) == "BC") {
            add_a = false;
            break;
          }
          else {
            break;
          }
        }
        if (!add_a) {
          A -= 1;
          B += 1;
          ans.at(i) = 'B';
        }
        else {
          B -= 1;
          A += 1;
          ans.at(i) = 'A';
        }
      }
      else if (A > B) {
        A -= 1;
        B += 1;
        ans.at(i) = 'B';

      }
      else {
        B -= 1;
        A += 1;
        ans.at(i) = 'A';
      }
    }
    if (S == "BC") {
      if (B == 0 && C == 0) {
        cout << "No" << "\n";
        return 0;
      }

      if (C == 1 && B == 1) {
        bool add_b = true;
        for (ll j = i + 1; j < N; ++j) {
          if (S_vec.at(j) == "BC") {
            continue;
          }
          if (S_vec.at(j) == "AC") {
            add_b = false;
            break;
          }
          else {
            break;
          }
        }
        if (add_b) {
          C -= 1;
          B += 1;
          ans.at(i) = 'B';
        }
        else {
          B -= 1;
          C += 1;
          ans.at(i) = 'C';
        }
      }
      else if (B > C) {
        B -= 1;
        C += 1;
        ans.at(i) = 'C';
      }
      else {
        C -= 1;
        B += 1;
        ans.at(i) = 'B';
      }
    }
  }
  cout << "Yes" << "\n";
  for (ll i = 0; i < N; ++i) {
    cout << ans.at(i) << "\n";
  }
}


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

using namespace std;

int main()
{
  vector< int > E(12);
  for(int i = 0; i < 12; i++) {
    cin >> E[i];
  }
  sort(E.begin(), E.end());
  if(E[0] == E[3] && E[4] == E[7] && E[8] == E[11]) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }

}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 10;
LL N;
set<int> s;
bool check(LL x)
{
    LL t = N;
    while(t % x == 0)
        t /= x;
    if((t - 1) % x == 0)
        return true;
    else
        return false;
}
int main()
{
    scanf("%lld", &N);
    for(LL i = 1; i * i <= N - 1; i++)
    {
        if((N-1) % i == 0)
        {
            s.insert(i);
            s.insert((N - 1) / i);
        }
    }
    for(LL i = 2; i * i <= N; i++)
    {
        if(N % i == 0)
        {
            if(check(i))
                s.insert(i);
            if(check(N / i))
                s.insert(N / i);
        }
    }
    printf("%d\n", s.size());
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define ls rt<<1
#define rs rt<<1|1
#define pb push_back
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 1e5+5;
const ll MOD = 1e9+7;

ll comb(ll m, ll n){
    if (m < n) return 0;
    if (m == n) return 1;
    if (n > m - n) n = m - n;
    ll up = 1, down = 1;
    rep(i, 0, n-1){
        up *= (m - i);
        down *= (n - i);
    }
    return up / down;
}

int main()
{
    int n, m;
    cin >> n >> m;
    ll ans = comb(n, 2) + comb(m, 2);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

void solution(){
	int n; cin >> n;
	vector<int> A(n); for(int& x : A) cin >> x;
	int g = A[0];
	unordered_map<int,int> c;
	for(int x : A){
		g = __gcd((unsigned)g,(unsigned)x);
		c[x]++;
	}
	if(g > 1){
		cout << "not coprime" << endl;
		return;
	}
	int m = *max_element(all(A));
	for(int i = 2; i <= m; i++){
		int cur = 0;
		for(int j = i; j <= m; j += i){
			cur += c[j];
		}
		if(cur > 1){
			cout << "setwise coprime" << endl;
			return;
		}
	}
	cout << "pairwise coprime" << endl;
	return;
}	


int main(){ 
	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX_V 100000

#define MOD 1000000007L
#define INF 100000000000

map<char, int> count(string s) {
	map<char, int> m = {};
	for (size_t i = 0; i < s.size(); i++) {
		m[s[i]]++;
	}
	return m;
}

void ca(int n, vector<string>& s) {
	map<char, int> m = {};
	for (size_t i = 'a'; i <= 'z'; i++) {
		m[i] = 50;
	}
	for (size_t i = 0; i < n; i++) {
		map<char, int> m2 = count(s[i]);
		for (size_t i = 'a'; i <= 'z'; i++) {
			m[i] = min(m[i], m2[i]);
		}
	}
	for (auto& e: m) {
		// cout << e.first << ": " << e.second << endl;
		for (size_t i = 0; i < e.second; i++) {
			cout << e.first;
		}
	}
	cout << endl;
}

signed main() {
	int n;
	cin >> n;
	vector<string> s;
	for (size_t i = 0; i < n; i++) {
		string t;
		cin >> t;
		s.push_back(t);
	}
	ca(n, s);
}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n), b(n), p(n);
    for (Int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (Int i = 0; i < n; i++) {
        a[i] = 1;
    }
    for (Int i = 0; i < n; i++) {
        b[i] = 1;
    }
    for (Int i = 0; i < n; i++) {
        a[p[i] - 1] += i;
    }
    for (Int i = 0; i < n; i++) {
        b[p[i] - 1] += i;
    }
    for (Int i = 0; i < n - 1; i++) {
        a[i + 1] += a[i];
    }
    for (Int i = n - 1; i > 0; i--) {
        b[i - 1] += b[i];
    }
    print(a);
    print(b);
    return 0;
}


Measured memory_bytes: 3820
#include <stdio.h>

int main(void)
{
	int H, W, i, j;
	while(1)
	{
		scanf("%d %d", &H, &W);
		if(H==0&&W==0)
		{
			break;
		}
		for(i=0; i<H; i++)
		{
			for(j=0; j<W; j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 2596
#include <iostream>
#include <string>
using namespace std;
int main(){
  while(true){
    int n;
    cin>>n;
    if(n==0){
      break;
    }
    int len[40];
    for(int i=0;i<n;i++){
      string w;
      cin>>w;
      len[i]=w.size();
    }
    for(int i=0;i<n;i++){
      bool flg=false;
      int sta=0;
      int sum=0;
      for(int j=i;j<n;j++){
        sum+=len[j];
        if(sum==5||sum==12||sum==17||sum==24||sum==31){
          sta++;
        }
        if(sta==5){
          flg=true;
          break;
        }
        else if(sum>=31){
          break;
        }
      }
      if(flg){
        cout<<i+1<<endl;
        break;
      }
    }
  }
    return 0;
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main(){
  double n, k;
  cin >> n >> k;
  double point;
  double rate_sum = 0;
  for(int i = 1; i <= n; ++i){
    point = i;
    int count = 0;
    while(point >= 1 && point <= k - 1){
      point *= 2;
      count++;
    }
    rate_sum += (1.0 / n) * pow((1.0 / 2.0), count);
  }
  printf("%.12f\n", rate_sum);
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
   int H,W;
   cin >> H >> W;
   while(!(H==0 && W==0)){
      for(int i=1; i<=H; i++){
         for(int j=1; j<=W; j++){
            printf("#");
         }
         printf("\n");
      }
   printf("\n");
   cin >> H >> W;
   }

   return 0;
}



Measured memory_bytes: 3064
d = {}

for i in range(int(input())):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

for i in range(int(input())):
    t = input()
    if t in d:
        d[t] -= 1

print(max(0, max(i for i in d.values())))

Measured memory_bytes: 9116
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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; }
const int INF = 1<<30;
const int mod = 1000000007;

int dp[1010][1010] = {0};

int main(){
	int h, w;
	cin >> h >> w;
	vector<string> board(h);
	rep(i,h) cin >> board[i];
	dp[0][0] = 1;
	rep(i,h)rep(j,w){
		if(i+1 < h && board[i+1][j] == '.') dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod;
		if(j+1 < w && board[i][j+1] == '.') dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % mod;
	}
	cout << dp[h-1][w-1] << endl;
	return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	int n;
	cin>>n;
	int ans=0,max=0;
	rep(i,n){
		int x;
		cin>>x;
		if(max<x)max=x;
		ans+=x;
	}
	cout<<ans-max/2<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300IQ as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         sort(arr);
         long res = arr[N-1];
         int turn = 2;
         for(int i=N-2; i >= 0; i--)
         {
            if(turn == N)
               break;
            res += arr[i];
            turn++;
            if(turn == N)
               break;
            res += arr[i];
            turn++;
            if(turn == N)
               break;
         }
         System.out.println(res);
      }
      public static void sort(int[] arr)
      {
         //stable heap sort
         PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
         for(int a: arr)
            pq.add(a);
         for(int i=0; i < arr.length; i++)
            arr[i] = pq.poll();
      }
   }

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

ll gcd(ll a, ll b) {
	if (a < b) swap(a, b);
	while (ll r = a%b) {
		a = b;
		b = r;
	}

	return b;
}

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

int main() {
	int N;  cin >> N;
	vector<ll> T(N);

	ll ans = 1;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
		ans = lcm(ans, T[i]);
	}
	cout << ans << endl;
}


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

using namespace std;
const int MAX = 1000000 + 10;
typedef long long ll;

int AC[MAX] = {0};
int WA[MAX] = {0};
//A[i] = {a,b}
//iが一回でもACしたらb=1

int main(){
    ll n, m;
    ll ans=0;
    ll wasum=0;
    cin >> n >> m;
    for (ll i = 0; i < m; i++)
    {
        ll pi;
        string si;
        cin >> pi >> si;

        if(AC[pi]==1)
        {
            continue;
        }
        else if(si=="AC")
        {
            AC[pi] = 1;
            ans++;
        }
        else
        {
            WA[pi]++;
        }
    }
    for (int i = 1; i < n+1; i++)
    {
        if(AC[i]==1)
            wasum += WA[i];
    }

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

Measured memory_bytes: 4736
#include <iostream>

using namespace std;

int main(){
	int n,p;
	int i=0;
	int data[50];
	int allp;
	while(cin >> n >> p, n+p){
		for(int j=0; j < n; j++){
			data[j]=0;	
		}
		i = 0;
		allp = p;
		while(1){
			
			if(p > 0){
				p--;
				data[i]++;
			}
			else{
				p = data[i];
				data[i] = 0;
			}
			if(allp == data[i]) break;
			i++;
			if(i == n) i = 0;
		}
		cout << i << endl;
	}	
}

Measured memory_bytes: 3016
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int n, x, d = 0, cnt = 0;
	int l[105];
	cin >> n >> x;
	rep(i, n) cin >> l[i];
	for(int i = 0; i < n; i++){
		d += l[i];
		if(d <= x){
			cnt++;
		}
	}
	cout << cnt+1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define repr(i,n) for(int i=1;i<=n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long 
using namespace std;
const int N=1e5+5;
int f[N]; 
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=100;i++)
	{
		for(int j=1;j<=100;j++)
		{
			for(int k=1;k<=100;k++)
			{
				int t=i*i+j*j+k*k+i*j+j*k+i*k;
				if(t>=1&&t<=10000)
				f[t]++;
			}
		}
	}
	for(int i=1;i<=n;i++)
	cout<<f[i]<<"\n";
	
	return 0;
 } 

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

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

signed main() {
	int n, m;
	string s, t;
	cin >> n >> m >> s >> t;
	bool ok = true;
	long l = lcm(n, m);
	int N = l / n;
	int M = l / m;
	for (int i = 0; i <= n; i++) {
		if ((N * i) % M == 0) {
			if (s[i] != t[(N * i) / M]) {
				ok = false;
			}
		}
	}
	if (ok) cout << l << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;
int a[MAXN];

int main()
{
	int n,m;
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		scanf("%d",&a[i]);
	}
	LL sum = 0;
	for(int i = 0;i < m;i++){
		sum += a[i];
		if(sum >= n){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cassert>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <iterator>
#include <queue>
#include <utility>

using namespace std;

#define MN 200
#define MR 1000
#define INF 0x7F7F7F7F
#define FILL_INF(xs) memset(xs, 0x7F, sizeof(xs))

int N, M, R;
int L[MN][MN];
int S[MN][MN];
int Z[MR];

bool input() {
    cin >> N >> M;
    if (N == 0 && M == 0) return false;
    FILL_INF(L);
    FILL_INF(S);
    for (int i = 0; i < M; i++) {
        int x, y, t; char sl;
        cin >> x >> y >> t >> sl;
        x--; y--;
        if (sl == 'L') L[x][y] = L[y][x] = t;
        else           S[x][y] = S[y][x] = t;
    }
    cin >> R;
    for (int i = 0; i < R; i++) {
        cin >> Z[i];
        Z[i]--;
    }
    return true;
}


void WarshallFloyd(int G[MN][MN]) {
    for (int i = 0; i < N; i++) G[i][i] = 0;
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (G[i][k] == INF || G[k][j] == INF) continue;
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
}

int Cache[MR][MN];
int dfs(int zindex, int ship) {
    if (zindex == R) return 0;
    if (Cache[zindex][ship] >= 0) return Cache[zindex][ship];
    int next = Z[zindex];
    int prev = Z[zindex - 1];
    int Ans = INF;
    if (L[prev][next] != INF)
        Ans = min(Ans, L[prev][next] + dfs(zindex + 1, ship));
    for (int i = 0; i < N; i++) {
        if (L[prev][ship] == INF || S[ship][i] == INF || L[i][next] == INF) continue;
        Ans = min(Ans, L[prev][ship] + S[ship][i] + L[i][next] + dfs(zindex + 1, i));
    }
    return Cache[zindex][ship] = Ans;
}

int main() {
    while (input()) {
        WarshallFloyd(L);
        WarshallFloyd(S);
        memset(Cache, -1, sizeof(Cache));
        cout << dfs(1, Z[0]) << endl;
    }
    return 0;
}

Measured memory_bytes: 2352
# イルカはプログラミングコンテスト好きで、今日はAtCoderのコンテストに参加します。
# 現在時刻は、24時間表記(0:00〜23:59)でA時ちょうどであり、コンテストがちょうどB時間後に始まります。
# コンテストの開始時刻は、24時間表記で何時ちょうどでしょうか?

A,B = map(int,input().split())

if A + B < 24:
    print(A + B)

else:
    print((A + B) - 24)

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            final int times = Integer.parseInt(br.readLine());
            if (times == 0) { break; }
            
            Map<String, Long> data = new LinkedHashMap<>();
            for (int i=1; i <= times; i++) {
                String[] e = br.readLine().split(" ");
                data.merge(e[0], Long.parseLong(e[1]) * Long.parseLong(e[2]), Long::sum);
            }
            
            long count = data.entrySet().stream()
                .filter(e -> e.getValue() >= 1_000_000L)
                .peek(e -> System.out.println(e.getKey()))
                .count();
            if (count == 0L) { System.out.println("NA"); }
        }
    }
}

Measured memory_bytes: 31968
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
 
  int ans = A;
  if (A == B)
    ans = C;
  if (A == C)
    ans = B;
  if (B == C)
    ans = A;
 
  cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn solve(s: &str) -> bool {
    let s = s.chars().collect::<Vec<char>>();
    for i in 1..4 {
        let i = i as usize;
        if s[i - 1] == s[i] {
            return true;
        }
    }

    false
}

fn main() {
    let s = read_line!();
    println!("{}", if solve(&s) { "Bad" } else { "Good" });
}

#[test]
fn solve_test() {
    assert_eq!(solve("3779"), true);
    assert_eq!(solve("8080"), false);
    assert_eq!(solve("1333"), true);
    assert_eq!(solve("0024"), true);
}


Measured memory_bytes: 4352
n = int(input())
lc = input()
lc = lc.lstrip("R").rstrip("W")

ans = 0
lin = 0
rin = len(lc)-1
flg = False
while lin < rin:
    while True:
        if lc[lin] == "W":
            break
        lin += 1
    while True:
        if lc[rin] == "R":
            break
        rin -= 1
    if lin > rin:
        break
    lin += 1
    rin -= 1
    ans += 1

print(ans)


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

void func(int idx, vector<vector<int>> &e, vector<bool> &v, vector<ll> &counter){
    v[idx] = true;
    for(int tgt : e[idx]){
        if(v[tgt]) continue;
        counter[tgt] += counter[idx];
        func(tgt, e, v, counter);
    }
}

int main(void){
    int N, Q;
    cin >> N >> Q;
    vector<ll> counter(N, 0);
    vector<vector<int>> e(N);
    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    for(int i = 0; i < Q; i++){
        int p;
        ll x;
        cin >> p >> x;
        p--;
        counter[p] += x;
    }
    vector<bool> v(N, false);
    func(0, e, v, counter);
    for(int i = 0; i < N; i++) cout << counter[i] << endl;
    return 0;
}


Measured memory_bytes: 30592
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, a, b, c; 
	cin >> N;
	a = N % 10;
	N /= 10;
	b = N % 10;
	N /= 10;
	c = N % 10;
	if(1000 - (100*c+10*b+a) == 1000){
		cout << 0;
	}
	else{
		cout << 1000 - (100*c+10*b+a);
	}
}



Measured memory_bytes: 3632
N = int(input())
for h in range(3501):
    for n in range(3501):
        a = N * h * n
        b = 4 * h * n - N * n - N * h
        if b > 0 and a % b == 0:  # 余りがでない -> 整数
            w = int(a / b)
            print(h, n, w)
            exit()
        else:
            continue


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

int main(){
  int N;
  cin >> N;
  
  //全探索
  bool just = false;
  for(int i=0; 4*i <= N; i++){
    if((N-4*i) % 7 ==0){
      just = true;
    }
  }
  
  string ans = just? "Yes": "No";
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <set>
using namespace std;
int main(){
    int n,a[3];
    set<pair<int,pair<int,int>>>s;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++)scanf("%d",&a[j]);
        sort(a,a+3);
        s.insert({a[0],{a[1],a[2]}});
    }
    printf("%ld\n",n-s.size());
}


Measured memory_bytes: 2904
#include<iostream>
#include<algorithm>
#include<math.h>
#include<map>
#include<set>
#include<vector>
using namespace std;
#define mod 1000000007
#define ll long long 


vector<int> b;

ll solve(ll n) { 

	ll ans = 0;
   	ll count = 0; 
   
    while (!(n % 2)) { 
        n >>= 1; 
        count++; 
    } 

  	if(count != 0) {
  		// cout<<"2's = "<<count<<endl;
	    for(int i = 0; i < 12; i++) {
	    	if(b[i] >= count) {
	    		ans += i;
		    	if(b[i] == count) ans++;
	    		break;
	    	}
	    }
	}
	// cout<<ans<<endl;

    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if(count) {
        	for(int i = 0; i < b.size(); i++) {
		    	if(b[i] >= count) {
		    		ans += i;
		    		if(b[i] == count) ans++;
		    		break;
		    	} 
		    }
        }
    } 
    if (n > 2) 
        ans ++;
    return ans;
} 



int main() {
	
	for(int i = 1; i <= 40; i++) {
		ll num = i*(i + 1);
		num /= 2;
		b.push_back(num);
	}

	ll x;
	cin>>x;
	
	cout<<solve(x)<<endl;

}

Measured memory_bytes: 3692
/*
author: Apoorv Singh
*/

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

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define aint(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX

int modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int arr[5];
    FOR(i,0,5)
        cin >> arr[i];
    int ans = inf;
    do
    {
        int time = 0;
        FOR(i,0,5)
        {
            time += arr[i];
            if (i < 4)
            {
                int x = (int)(ceil(arr[i]/10.0));
                time += (x*10 - arr[i]);
            }
        }
        ans = min(ans, time);

    } while (next_permutation(arr, arr+5));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

ll calc(int x) {
  return max(0LL, 1LL * x * (x - 1) / 2);
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  map<int, int> mp;
  rep(i, n) mp[a[i]]++;
  ll tmp = 0;
  for (auto e : mp) tmp += calc(e.S);
  // cout << tmp << endl;
  rep(i, n) {
    cout << tmp - calc(mp[a[i]]) + calc(mp[a[i]] - 1) << endl;
  }
}


Measured memory_bytes: 8320
from sys import stdin
from collections import deque
input = stdin.readline

nodelist = deque()
N = int(input())
for i in range(N):
    command = input().split()
    if command[0] == 'insert':
        nodelist.appendleft(command[1])
    elif command[0] == 'delete':
        try:
            nodelist.remove(command[1])
        except:
            continue
    elif command[0] == 'deleteFirst':
        nodelist.popleft()
    else:
        nodelist.pop()
print(*nodelist)


Measured memory_bytes: 69736
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
        int nums[] = new int[3];
      	boolean irj = true;
      
      	for(int i = 0;i < 3;i++) nums[i] = sc.nextInt();
        Arrays.sort(nums); 
      
      	if(nums[0] != 5) irj = false;
      	if(nums[1] != 5) irj = false;
      	if(nums[2] != 7) irj = false; 
          
        if(irj) System.out.print("YES");
        else System.out.println("NO");
      
	}
}

Measured memory_bytes: 35776
N = int(input())
A = []
for i in range(N):
    a,b = map(int,input().split())
    A.append((a,b,a+b))
A = sorted(A,key=lambda x:x[2],reverse=True)
a = 0
for i in range(N):
    if i%2==0:
        a += A[i][0]
    else:
        a -= A[i][1]
print(a)

Measured memory_bytes: 22904
#include<bits/stdc++.h>
using namespace std;
typedef long long int ULL;
int main(){
	ULL n;cin>>n;
	ULL arr[n];
	for(ULL i = 0 ; i < n ; i++) cin>>arr[i];
	int poss = 0;
	sort(arr,arr+n);
	for(ULL  i = 0 ; i < n-2 ; i++){
		for(ULL j = i + 1 ; j < n- 1 ; j++){
			for(ULL  k  = j + 1 ; k < n ; k++){
				if((arr[i] + arr[j] > arr[k])&&(arr[k] + arr[j] > arr[i])&&(arr[i] + arr[k] > arr[j])) poss++;
			}
		}
	}
	cout<<poss;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 998244353
#define mad(a,b) a=(a+b)%mod;
#define N 200010
typedef pair<ll,ll> P;
namespace seg{
  ll dat[2*N];
  void init(){
    for(int i=0;i<2*N;i++){
      dat[i]=0;
    }
  }
  void upd(ll p,ll x){
    p+=N;
    dat[p]=x;
    for(;p;p>>=1){
      dat[p/2]=dat[p]+dat[p^1];
    }
  }
  ll qry(ll l,ll r){
    l+=N,r+=N+1;
    ll res=0;
    for(ll a=l,b=r;a<b;a>>=1,b>>=1){
      if(a&1)res+=dat[a++];
      if(b&1)res+=dat[--b];
    }
    return res;
  };
};
ll po(ll x,ll y){
    ll res=1;
    for(;y;y>>=1){
	if(y&1)res=res*x%mod;
	x=x*x%mod;
    }
    return res;
}

ll n,x[N],y[N],xxx[N],yyy[N];
vector<ll> xx,yy;
unordered_map<ll,ll> compx,compy;
ll solve(){
  xx.clear(); yy.clear();
  compx.clear(); compy.clear();
  for(int i=0;i<n;i++){
    xx.push_back(x[i]);
    yy.push_back(y[i]);
  }
  sort(xx.begin(),xx.end());
  for(int i=0;i<xx.size();i++){
    compx[xx[i]]=i;
  }
  sort(yy.begin(),yy.end());
  for(int i=0;i<yy.size();i++){
    compy[yy[i]]=i;
  }
  for(int i=0;i<n;i++){
    xxx[i]=compx[x[i]];
    yyy[i]=compy[y[i]];
  }
  ll ans=0;
  seg::init();
  vector<P> v;
  for(int i=0;i<n;i++){
    v.push_back(make_pair(yyy[i],xxx[i]));
  }
  sort(v.begin(),v.end());
  for(int i=0;i<v.size();i++){
    ll e=seg::qry(0,n-1); mad(ans,(po(2,e)-1));
    ll w=seg::qry(0,v[i].second); mad(ans,(po(2,w)-1)*-1);
    seg::upd(v[i].second,1);
  }
  return ans;
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>x[i]>>y[i];
  ll ans=solve();
  for(int i=0;i<n;i++)x[i]*=-1;
  mad(ans,solve());
  for(int i=0;i<n;i++)y[i]*=-1;
  mad(ans,solve());
  for(int i=0;i<n;i++)x[i]*=-1;
  mad(ans,solve());
  ans*=-1;
  mad(ans,(po(2,n)-1)*n);
  if(ans<0)ans+=mod;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 37172
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int)1e18 + 18;
const int maxn = (int) 1e6 + 6; 
using namespace std;

string s, t;
int ans = 0;

signed main() {
    
   cin >> s >> t;
    for(int i = 0; i < 3; i++){
        if(s[i] == t[i]) ans++;
    }
    
    cout << ans;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys

LIMIT = 1000000
is_prime = [True] * (LIMIT+1)
p = 2
while p**2 <= LIMIT:
    if is_prime[p]:
        for i in range(p*2, LIMIT+1, p):
            is_prime[i] = False
    p += 1

for line in sys.stdin.readlines():
    n = int(line.strip())
    if n <= 1:
        print(0)
        continue
    if n == 2:
        print(1)
        continue
    num_prime = 1
    for i in range(3, n+1):
        if is_prime[i]:
            num_prime += 1
    print(num_prime)

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

int main()
{
	char A[4];

	cin >> A[0] >> A[1] >> A[2] >> A[3];
	int count = 0;

	if (A[0]==A[1] && A[2]==A[3])
	{
		if (A[1]!=A[2])
		{
			count++;
		}
		
	}
	if (A[0] == A[2]&&A[1] == A[3])
	{
		if (A[1] != A[0])
		{
			count++;
		}
		
	}
	if (A[0] == A[3] && A[2] == A[1])
	{
		if (A[0] != A[2])
		{
			count++;
		}
	}
	
	if (count==1)
	{
		cout << "Yes" << endl;

	}
	else
	{
		cout << "No" << endl;
	}


}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

from itertools import permutations,  combinations, accumulate, product, combinations_with_replacement
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop


N, M, Q = map(int, input().split())
abcd_ls = []

for _ in range(Q):
    abcd_ls.append(list(map(int, input().split())))

a_candidate = list(combinations_with_replacement(range(1, M + 1), N))

max_total = 0
for A in a_candidate:
    total = 0
    for abcd in abcd_ls:
        a, b, c, d = abcd
        a -= 1
        b -= 1
        if c == A[b] - A[a]:
            total += d
    max_total = max(total, max_total)

print(max_total)



Measured memory_bytes: 21900
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B >C+D){
  cout<<"Left"<<endl;
  }
  else if(A +B == C+D){
    cout<<"Balanced"<<endl;
  }
  else{
  cout<<"Right"<<endl;
  }
}

Measured memory_bytes: 256
//ABC75 D
#include<queue>
#include <bits/stdc++.h>
#include<cstdio>
#include <stdio.h>
#include <iostream>
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX_N 50
#define MAX_K 50
using namespace std;
using ll = long long;

int n,K,cnt;
struct point {
    ll x, y;
};

int main(){
    cin >> n >> K;
    vector<long long> x(n), y(n);
    vector<point> xy(n);
    rep(i,n){
      cin >> x[i] >> y[i];
      xy[i] = {x[i], y[i]};
    }

    sort(all(x));
    sort(all(y));

    ll ans = (x[n-1]-x[0]) * (y[n-1] - y[0]);
    rep(i,n){
      rep(j,n){
        rep(k,n){
          rep(l,n){
            if (xy[l].x < xy[k].x && xy[j].y < xy[i].y){
              cnt = 0;
              rep(m,n){
                if(xy[l].x <= xy[m].x && xy[m].x <= xy[k].x && xy[j].y <= xy[m].y && xy[m].y <= xy[i].y){
                  cnt++;
                }
              }
              if(cnt >= K){
                ll S = (xy[i].y - xy[j].y)*(xy[k].x - xy[l].x);
                ans = min(ans,S);
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256