akhauriyash/Code-Regression huggingface dataset:
url = "https://atcoder.jp//contests/abc127/tasks/abc127_c"

def main():
    n, m = list(map(int, input().split()))
    l, r = 0, 999999
    for i in range(m):
        a,b = list(map(int, input().split()))
        l = a if a > l else l
        r = b if b < r else r
    ans = r - l
    print(ans + 1) if ans >= 0 else print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74500
#include<iostream>
using namespace std;
int L[110],D[110];
int main() {
    int N,X;
    cin >> N >> X;
    for (int i=1; i<=N; i++) cin >> L[i];

    D[1]=0;
    for (int i=2; i<=(N+1); i++) {
        D[i]=D[i-1]+L[i-1];
    }

    int cnt=0;
    for (int i=1; i<=(N+1); i++) {
        if (D[i] <= X) cnt++;
        else break;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;


int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N){
        cin >> a[i];
        a[i]--;
    }

    vector<bool> seen(N, false);
    int now = 0, cnt = 0;
//    seen[0] = false;
    while(true){
        if(seen[now]){
            cout << -1 << endl;
            return 0;
        }else if(now == 1) {
            cout << cnt << endl;
            return 0;
        }else {
            seen[now] = true;
            now = a[now];
            cnt++;
        }
    }

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define vi vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define si set<ll>
#define mp map<ll,ll>
#define mpi map<ii,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#include <unordered_map> 
#define ump unordered_map<ll,ll>
#define F first
#define S second
int calc(int n)
{
	int i,j,k;
	int ans=0;
	for(i=1;i<=sqrt(n);i++)
	{
		for(j=1;j<=sqrt(n);j++)
		{
			ll val1=(i*i + j*j +i*j);
			if(val1 > n)
			{
				break;
			}
			for(k=1;k<=sqrt(n);k++)
			{
				ll val=(i*i + j*j + k*k + i*j + j*k + i*k );
				if(val == n)
				{
					ans++;
				}
				if(val>n)
				{
					break;
				}
			}
		}
	}
	return ans;
}
int main()
{
	fast
	ll n;
	cin>>n;
	ll i;
	for(i=1;i<=n;i++)
	{
		cout<<calc(i)<<endl;
	}

	
}

Measured memory_bytes: 3576
# -*- coding: utf-8 -*-
A,B = [int(i) for i in input().split()]

if A+B >= A-B and A+B >= A*B:
    print(A+B)
elif A-B >= A+B and A-B >= A*B:
    print(A-B)
elif A*B >= A+B and A*B >= A-B:
    print(A*B)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
	int N;
	int M = 1e9+7;
	string S;
	cin >> N >> S;
	map<char,int> ma;
	rep(i,N) ma[S[i]]++;
	long long sum = 1;
	for(auto itr = ma.begin();itr != ma.end();itr++){
		sum *= itr->second + 1;
		sum %= M;
	}
	cout << sum - 1 << endl;
    return 0;
}

Measured memory_bytes: 512
S=input()

if S[1]==S[0]:
    if S[2] == S[3]:
        ans = 1
    else:
        ans = 0

elif S[0] == S[2]:
    if S[1] == S[3]:
        ans = 1
    else:
        ans = 0

elif S[0] == S[3]:
    if S[1] == S[2]:
        ans = 1
    else:
        ans = 0

else:
    ans = 0

if S[0]==S[1] == S[2]:
    ans = 0

if ans == 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include "bits/stdc++.h"

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dy[] = { 0, 1, 0, -1 };
const int dx[] = { 1, 0, -1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

LL solve(LL n,LL a,LL b) {
	if (a > b) {
		return 0;
	} else if (n == 1 && a == b) {
		return 1;
	} else if (n == 1 && a != b){
		return 0;
	}
	return (b - a) * (n - 2) + 1;
}

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

	LL n, a, b;
	cin >> n >> a >> b;

	cout << solve(n, a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int A[5][4][11], n;
    for (int i = 1; i<= 4; i++)
        for (int j = 1; j <= 3; j++)
            for (int k = 1; k <= 10; k++)A[i][j][k] = 0;
    
    cin >> n;
    for (int i = 0; i < n; i++){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        A[b][f][r] += v;
        
    }
    
    for (int f = 1; f<= 4; f++){
        if(f > 1) cout << "####################\n";
        for ( int b = 1; b <= 3; b++){
            for (int r = 1; r <= 10; r ++){
                cout << " " << A[f][b][r];
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define ios ios_base::sync_with_stdio(false);
#pragma GCC optimize("O3")
#define lll __int128_t
time_t start, e_nd;
#define ll long long int
#define FOR(i,a,b) for(ll (i)=(a);i<(ll)(b);i++)
#define FORr(i,a,b) for(ll(i)=(a);i>=(ll)(b);i--)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,n)
#define outi(a) printf("%lld\n",(a))
#define case(i) cout << "Case " << i << ": ";
#define timest auto start = chrono::high_resolution_clock::now();
#define timeend auto end = chrono::high_resolution_clock::now();\
cout<< endl;cout<<"*************************"<<endl;\
double time_taken=chrono::duration_cast<chrono::nanoseconds>(end - start).count();\
time_taken *= 1e-9;\
cout<<"Time Taken "<<setprecision(6)<<fixed<<time_taken<<" sec"<< endl;
#define pb push_back
int dx[] = {-1,0,1,0}; int dy[] = {0,1,0,-1};
#define in(n) ll n = read();
#define show(arr) for(auto a : arr) cout << a << " "; cout << endl;
#define inp(arr, n) ll arr[n] ; rep(i,n) arr[i] = read();
#define mp make_pair
#define f first 
#define s second 
#define mod 1000000007
#define modu(a) if(a>=mod) a-=mod;
#define test int tt = 1; rep(i,tt) solve(i+1);
#define ttest int tt = read(); rep(i,tt) solve(i+1);
using namespace std;
inline ll read()
{
    ll x=0; static ll p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
    return x;
}
//#define debug

void solve(int tt);
int main()
{
	#ifdef debug
	timest
	freopen("input.txt", "r", stdin);
	#endif
	test
	#ifdef debug
	timeend
	#endif
}
void solve(int tt)
{
	vector<int>divs(1000006);
	in(n)
	inp(arr, n)
	rep(i, n)
	{
		divs[arr[i]]++;
	}
	for(int  i = 1; i < 1000006; i++)
	{
		if(divs[i])
		{
			for(int j = i+i; j < 1000006; j+= i)
			{
				if(divs[j])  divs[j]++;
			}
		}
	}
	int ans = 0;
	for(auto a: arr)
	{
		if(divs[a] == 1) ans++;
	}
	cout << ans << endl;
	

}	


Measured memory_bytes: 8676
n = readline.split(' ').map(&:to_i)[0]
p = readline.split(' ').map(&:to_i).join.to_i
q = readline.split(' ').map(&:to_i).join.to_i

a = []
(1..n).each do |i|
  a.push(i)
end
cnt_p = 0
cnt_q = 0
a.permutation.to_a.each do |ap|
  if ap.join.to_i < p
    cnt_p += 1
  end
  
  if ap.join.to_i < q
    cnt_q += 1
  end
end

puts (cnt_p - cnt_q).abs

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

int main(){
    long long a,b,aaa,bbb,tmp,ans;
    cin>>a>>b;
    aaa = a;
    bbb = b;

    tmp = max(aaa,bbb);
    ans = tmp;
    do{
        if (ans%aaa==0 & ans%bbb==0) break;
        ans = tmp +ans;

    }while(true);
    

    cout << ans << endl;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
//using System.Math;

public class Karcal {
  public static void Main(string[] args) {
    string str = Console.ReadLine();
    var h = long.Parse(str);
    var half = h;
    long max = 0;
    //long sum = 0;
    
    
    if (h == 1) {
      Console.WriteLine(1);
      return ;
    }
    
    
    while(true) {
      max++;
      half /= 2;
      if (half == 1) {
        break;
      }
    }
    
    Console.WriteLine(Math.Pow(2, max+1)-1);
  }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

#include<cassert>

typedef string::iterator state;

string lett(state& s){
	int d = 0;
	for(;;){
		if(*s=='+')d++;
		else if(*s=='-')d--;
		else{
			char res = *s;
			d %= 26;
			res = ((res -'A') + d + 26) % 26 + 'A';
			s++;
			char rs[2]={};
			rs[0] = res;
			return string(rs);
		}
		s++;
	}
}

string str(state& s);

string ciph(state& s){
	string rs("");
	for(;;){
		if(*s == '$' || *s==']')return rs;
		rs += str(s);
	}
}

string str(state& s){
	if(*s=='['){
		s++;
		string res = ciph(s);
		reverse(res.begin(),res.end());
		//printf("%c\n",*s);
		assert(*s==']');
		s++;
		return res;
	}
	else return lett(s);
}


vector<string> anss;
char s[85];

void dfs(int p){
	if(s[p]=='\0'){
		string ns(s);
		//printf("%d %s\n",p,s);
		ns += '$';
		state ite = ns.begin();
		anss.push_back(ciph(ite));
	}
	else if(s[p]!='?')dfs(p+1);
	else{
		rep(i,26){
			s[p]='A'+i;
			dfs(p+1);
		}
		s[p]='?';
	}
}

int main(void){
	for(;;){
		scanf("%s",s);
		if(s[0] == '.')break;
		anss.clear();
		dfs(0);
		sort(anss.begin(),anss.end());
		cout << anss[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 5980
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.IOException;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter writer = new PrintWriter(System.out);
        int h = Integer.parseInt(br.readLine());
        writer.println(48-h);
        br.close();
        writer.close();
    }
}

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

int main(){
	int N;
	cin >> N;
	int M = N;
	int sn = 0;
	while ( M != 0){
		sn += M % 10;
		M /= 10;
	}
	if ( N % sn == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int [] valuees = new int[3];
        for (int i = 0; i < 3; i++) {
            valuees[i] = Integer.parseInt(tokenizer.nextToken());
        }
        Arrays.sort(valuees);

        int k = Integer.parseInt(input.readLine());
        for (int i = 0; i < k; i++) {
            valuees[2] *= 2;
        }
        System.out.println(valuees[0] + valuees[1]+ valuees[2]);
    }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define lli long long int
#define d double
using namespace std;
 
int main() {
	FIO;
	int n;
	cin>>n;
	vector<int> vec(n+1);
	for(int i=1;i<=n;i++) cin>>vec[i];
	vector<int> dp(n);
	dp[1]=0;
	dp[2]=abs(vec[2]-vec[1]);
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(vec[i]-vec[i-1]), dp[i-2]+abs(vec[i]-vec[i-2]));
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.lang.StringBuilder

fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val s = (1..n).map { readLine()!! }
    val cnt = mutableMapOf<Char, Int>()
    for(key in ('a'..'z')) {
        val c = s.map { it.count { it == key } }.min()!!
        cnt[key] = c
    }
    val ans = StringBuilder()
    for(key in cnt.keys.sorted()) {
        ans.append("".padStart(cnt[key]!!, key))
    }
    println(ans.toString())
}


Measured memory_bytes: 40604
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

#define MP make_pair
#define MT make_tuple
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	int N;
	cin >> N;

	map<LL, set<LL>> m;
	LL sum = 0;
	REP(i, N){
		LL a;
		cin >> a;
		m[a].insert(i);
		sum += a;
	}

	vector<LL> ret(N, 0LL);
	LL num = 0;
	LL pre = -1, pre_index = 1e9;

	for(auto it = m.rbegin(); it != m.rend(); it++){
		if(pre != -1){
			ret[pre_index] += (pre - it->first) * num;
		}

		pre = it->first;
		pre_index = min(pre_index, *it->second.begin());
		num += it->second.size();
//		cout << pre << " " << num << "  " << pre_index << endl;
	}

	EACH(r, ret) ret[pre_index] -= r;
	ret[pre_index] += sum;
	EACH(r, ret) cout << r << endl;

	return 0;
}


Measured memory_bytes: 15872
import sys
n = int(input())
if n < 357:
  print(0)
  sys.exit()

def dfs(s): 
  if int(s) > n:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0
  for c in '753':
    ret += dfs(s + c)
  return ret

print(dfs('0')) 

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        String s = scan.next();
        boolean out = false;
        if(s.charAt(a) != '-'){
            System.out.println("No");
            System.exit(0);
        }
        for(int i = 0; i <= a + b; i++){
            if(i != a && s.charAt(i) == '-'){
                System.out.println("No");
                System.exit(0);
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 22228
N, A, B = map(int, input().split())
if A == 0:
    print('0')
elif B == 0:
    print(N)
else:
    tmp = N // (A + B)
    result = tmp * A
    N -= tmp * (A + B)
    if N > A:
        result += A
    else:
        result += N
    print(result)

Measured memory_bytes: 3064
#!/usr/bin/env python
# coding: utf-8

# In[6]:


import math


# In[1]:


N,K = map(int, input().split())


# In[10]:


if K%2 == 0:
    ans = (N//K)**3 + (N//(K//2) - N//K)**3
else:
    ans = (N//K)**3
print(ans)


# In[ ]:






Measured memory_bytes: 9088
#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    // ref: https://atcoder.jp/contests/abc091/submissions/2218376
    int n, m;
    std::cin >> n;
    std::vector<std::string> blue, red;
    std::string s;
    for (int i = 0; i < n; i++)
    {
        std::cin >> s;
        blue.push_back(s);
    }
    std::cin >> m;
    for (int i = 0; i < m; i++)
    {
        std::cin >> s;
        red.push_back(s);
    }

    int ans = 0;
    auto compute = [&](std::string s) {
        int buf = 0;
        for (std::string str : blue)
        {
            if (str == s) { buf++; }
        }
        for (std::string str : red)
        {
            if (str == s) { buf--; }
        }
        return buf;
    };

    for (std::string str : blue) { ans = std::max(ans, compute(str)); }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e7;
const int inf=1e9;
int main(){
	double L;cin>>L;
	cout.precision(10);
	cout<<fixed<<L*L*L/27<<endl;
}

Measured memory_bytes: 256
n = int(input())
T = [list(map(int,input().split())) for i in range(n)]

d = [(T[0][0],T[0][1]+T[0][2])]
for i in range(1,n):
    d += [(T[i][0]-T[i-1][0], abs(T[i][1]-T[i-1][1]) + abs(T[i][2]-T[i-1][2]))]

for i in range(n):
    if (d[i][0]+d[i][1])%2 != 0 or d[i][0] < d[i][1]:
        print('No')
        break
else:
    print('Yes')

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

int main() {
  int a, b, x, y;
  cin >> a >> b;
  x = (a + b) / 2;
  y = (a + b) % 2;
  if(y == 0){
    cout << x << endl;
  }
  else{
    cout << x + 1 << endl;
  } 
}

Measured memory_bytes: 256
from itertools import accumulate
n = int(input())
L = list(input())

R = L.count("E")

for i in range(n):
    if L[i] == "W":
        L[i] = 1
    elif L[i] == "E":
        L[i] = 0
liw = list(accumulate(L))

for i in range(n):
    if L[i] == 0:
        L[i] = 1
    elif L[i] == 1:
        L[i] = 0

lie = list(accumulate(L))

for i in range(n):
    lie[i] = R-lie[i]

ans = 10**10
for i in range(n):
    west_num = liw[i]
    east_num = lie[i]
    #print(west_num,east_num,L[i])
    if L[i] == 0:
        west_num =max(west_num -1,0)

    ans = min(ans,west_num+east_num)
print(ans)

Measured memory_bytes: 35392
def main():
    MOD = 10**9 + 7
    n = int(input())
    s = input().rstrip()
    alp = [1]*26
    ans = 0
    for c in s:
        p = ord(c) - ord("a")
        alp[p] += 1
        x = 1
        for i in range(26):
            if i == p:
                continue
            x *= alp[i]
            x %= MOD
        ans += x
        ans %= MOD
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
L = list(map(int, input().split()))
L.sort()
if L[0] == 1 and L[1] == 4 and L[2] == 7 and L[3] == 9 :
  print ("YES")
else :
  print ("NO")

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007



ll n, ans = 1, a[110000], b[110000], now = 1, nx = MINF, nxi = -1;
vector<pair<ll, ll>> p;
int main() {
	cin >> n;
	REP(i, n)cin >> a[i];
	REP(i, n) cin >> b[i];
	sort(a, a + n);
	sort(b, b + n);
	REP(i, n) {
		if (a[i] > b[i])swap(a[i], b[i]);
		p.push_back(make_pair(a[i], b[i]));
	}
	sort(ALL(p));
	REP(i, n) {
		while (nx < p[i].first) {
			now--;
			nxi++;
			nx = p[nxi].second;
		}
		now++;
		ans *= now;
		ans %= MOD;
	}
	cout << ans << endl;
}


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

bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}

int main()
{
    string s;
    cin >> s;
    if (s[0] != 'A')
    {
        cout << "WA" << endl;
        return 0;
    }
    int C_cnt = 0;
    for (size_t i = 1; i < s.length(); i++)
    {
        if (s[i] == 'C' && i != s.length() - 1 && i != 1)
        {
            C_cnt++;
        }
        else if (0 <= s[i] - 'A' && s[i] - 'Z' <= 0)
        {
            cout << "WA" << endl;
            return 0;
        }
        /* code */
    }
    if (C_cnt == 1)
    {
        cout << "AC" << endl;
    }
    else
    {
        cout << "WA" << endl;
    }
    return 0;
}

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

int main() {
    //
    int num;
    int cnt = 0;
    long long kekka = 0;
    cin >> num;

    vector<long long> vec(num);
    for (int i = 0; i < num; i++) {
        long long tmp;
        cin >> tmp;

        if (tmp < 0) cnt++;
        vec.at(i) = tmp;
    }

    sort(vec.begin(), vec.end());
    if (cnt % 2 == 0) {
        for (int i = 0; i < num; i++) {
            kekka += abs(vec.at(i));
        }
    } else {
        for (int i = 0; i < cnt-1; i++) {
            kekka += abs(vec.at(i));
        }

        if(cnt == num){
            kekka += vec.at(num - 1);
        } else {
            if (abs(vec.at(cnt - 1)) > abs(vec.at(cnt))) {
            vec.at(cnt - 1) *= -1;
            vec.at(cnt) *= -1;
        }
        for (int i = cnt - 1; i < num; i++) {
            kekka += vec.at(i);
        }
        }
    }

    cout << kekka << endl;

    //
}


Measured memory_bytes: 4024
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;

int main() {
	int i, j,k;
	string s;
	cin >> s;
	for (i = 0; i < s.size(); i += 2) {
		cout << s[i] ;
	}
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
import heapq as hp


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    q = []
    for i, b in enumerate(B):
        hp.heappush(q, (-b, i))

    c = 0
    while q:
        #print(q)
        _, ind = hp.heappop(q)
        b = B[ind]
        if ind == N-1:
            s = B[ind-1]+B[0]
        else:
            s = B[ind-1]+B[ind+1]
        #print(b, s)
        if (b-A[ind])%s == 0:
            B[ind] = A[ind]
            c += (b-A[ind])//s
        elif b%s <= A[ind] or b < s:
            c = -1
            break
        else:
            c += b//s
            B[ind] = b%s
            hp.heappush(q, (-B[ind], ind))

    print(c)

if __name__ == "__main__":
    main()

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

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

int main() {
  in(int, D);
  vector<int> c(26);
  rep(i, 26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  rep(i, D) rep(j, 26) cin >> s[i][j];

  int sat = 0;
  vector<int> last(26);
  rep(i, D) {
    int d = i + 1;
    int maxi = numeric_limits<int>::min();
    int chosen;
    rep(j, 26) {
      int change = s[i][j];
      rep(k, 26) {
        int last_day = k == j ? d : last[k];
        change -= c[k] * (d - last_day);
      }
      // HACK
      change += (d - last[j]) * 250;
      if (Setmax(maxi, change)) {
        chosen = j;
      }
    }
    last[chosen] = d;
    sat += maxi;
    dbg(sat, maxi, chosen);
#if DEBUG
    rep(i, 26) {
      if (i) cerr << " ";
      cerr << last[i];
    }
    cerr << endl;
#endif
    out(chosen + 1);
  }
  dbg(max(1000000 + sat, 0));
}


Measured memory_bytes: 3676
def calc
  rectangle = 0
  rhombus = 0
  while gets
    x, y, z = $_.split(',').map(&:to_i)
    rhombus += 1 if x == y
    rectangle += 1 if x ** 2 + y ** 2 == z ** 2
  end
  puts rectangle
  puts rhombus
end

calc

Measured memory_bytes: 8540
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    s = int(input())
    a = [int(i) for i in input().split()] 
    
    a.sort()
    print(abs(a[0] - a[len(a)-1]))

Measured memory_bytes: 5144
n,m,q=map(int,input().split())
A=[[0]*(n+1) for i in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  A[a][b]=A[a][b]+1
B=[[0]*(n+1) for i in range(n+1)]
for i in range(1,n+1):
  for j in range(1,n+1):
    B[i][j]=B[i-1][j]+B[i][j-1]-B[i-1][j-1]+A[i][j]
for i in range(q):
  x,y=map(int,input().split())
  print(B[y][y]-B[y][x-1]-B[x-1][y]+B[x-1][x-1])

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll H,W,D;
  cin>>H>>W>>D;
  vector<P> v(H*W+1);

  ll in;
  FOR(i,0,H){
    FOR(j,0,W){
      cin>>in;
      v[in]=P(i,j);
    }
  }

  vector<ll> key(H*W+1,0);
  ll x;
  FOR(i,D,H*W+1){
    key[i]=abs(v[i].first-v[i-D].first)+abs(v[i].second-v[i-D].second);
  }
  FOR(i,0,D){
    x=0;
    while(i+x+D<H*W+1){
      key[i+x+D]+=key[i+x];
      x+=D;
    }
  }

  ll Q;
  cin>>Q;
  //FOR(i,0,H*W+1){
  //  cout<<key[i]<<" ";
  //}
  //cout<<endl;
  vector<ll> av(Q),bv(Q);
  FOR(i,0,Q){
    cin>>av[i]>>bv[i];
  }
  FOR(i,0,Q){
    cout<<key[bv[i]]-key[av[i]]<<endl;
  }
}


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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  std::string S;
  int K;
  std::cin >> K >> S;

  if(S.size() <= K) {
    std::cout << S << '\n';
    return 0;
  } else {
    rep(i, K) {
      std::cout << S[i];
    }
    std::cout << "..." << '\n';
  }
}


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

int compare( const void *, const void * );

int main( void ) {
	int i, j, data[ 10 ], max, tmp;

	for ( i = 10; i--; scanf( "%d", data + i ) ) ;

	qsort( data, 10, sizeof(int), &compare );

	for ( i = 0; i < 3; i++ )
		printf( "%d\n", data[ i ] );

	return 0;
}

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

Measured memory_bytes: 604
import sys
from collections import deque
import heapq
import math
import bisect
from itertools import permutations
from itertools import accumulate
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7

dic={}
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# print(factorization(12))
for i in range(n):
    tmp=factorization(a[i])
    for j in range(len(tmp)):
        if not tmp[j][0] in dic:
            dic[tmp[j][0]]=tmp[j][1]
        else:
            dic[tmp[j][0]]=max(dic[tmp[j][0]],tmp[j][1])
l=1
for i in dic.keys():
    l*=i**dic[i]
    l%=mod
# print(l)
ans=0
for i in range(n):
    ans+=l*pow(a[i],mod-2,mod)
    ans%=mod
print(ans)

Measured memory_bytes: 6656
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun main(args: Array<String>) {
    val n = readInt()
    val s = readString()
    var res = 1
    var lastChar = s[0]
    for (i in 1 until s.count()) {
        if (s[i] != lastChar) {
            res++
            lastChar = s[i]
        }
    }
    println(res)
}



Measured memory_bytes: 32440
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll x;
    cin>>x;
    ll q=(1ll*x)/(1ll*100);
    ll r=x%100;
    if(q*5>=r)
      cout<<1<<endl;
    else
    {
      cout<<0<<endl;
    }
}
return 0;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())

for i in range(K):
    if i % 2 == 0:
        if A % 2 == 1:
            A = A - 1
        A = A // 2
        B = B + A
    else:
        if B % 2 == 1:
            B = B - 1
        B = B // 2
        A = A + B

print(str(A) + " " + str(B))


Measured memory_bytes: 2940
using System;
using System.Linq;

namespace ConsoleApp_ITP1_6_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Int32.Parse(Console.ReadLine());
            int[,,] output = new[,,]
            {
             { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
             { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
             { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
             { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
            };

            for (int i = 1; i <= n; i++)
            {
                int[] input = Console.ReadLine().Split(' ').Select(s=>int.Parse(s)).ToArray();
                var b = input[0];
                var f = input[1];
                var r = input[2];
                var v = input[3];

                output[b-1, f-1, r-1] += v;
            }
        
            for(int z = 0; z < 4; z++)
            {
                for(int y = 0; y < 3; y++)
                {
                    for(int x = 0; x < 10; x++)
                    {
                        Console.Write(" {0}", output[z, y, x]);
                    }
                    Console.WriteLine();
                }
                if(z<=2)
                    Console.WriteLine("####################");
            }
        }
    }
}



Measured memory_bytes: 9672
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int l=s.length();
	int sum=0,ans=0;
	for(int i=0;i<l;i++)
		if(s[i]=='S')
			sum++;
		else if(sum>0)sum--;
			else ans++;
	ans+=sum;
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 640
def main():
    n, d, *x = map(int, open(0).read().split())

    cnt = 0
    for j in range(n):
        for i in range(j):
            y = x[i*d:(i+1)*d]
            z = x[j*d:(j+1)*d]
            dist_double = 0
            for cur_y, cur_z in zip(y, z):
                dist_double += (cur_y - cur_z) ** 2
            dist = int(dist_double ** 0.5 + 0.99)
            if dist ** 2 == dist_double:
                cnt += 1

    ans = cnt
    print(ans)
    return()

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

int main() {
	int ans = 0;
	int A, B, C;

	cin >> A >> B >> C;

	if (A > B)swap(A, B);
	if (A > C)swap(A, C);
	if (B > C)swap(B, C);

	int difA = C - A;
	int difB = C - B;

	if (difA % 2 == 0 && difB % 2 == 0) {
		ans = difA / 2 + difB / 2;
	}
	else if (difA % 2 && difB % 2) {
		ans = difA / 2 + difB / 2 + 1;
	}
	else {
		ans = difA / 2 + difB / 2 + 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;
int main(void){
  int N,k;
  int ans = 0;
  cin >> N >> k;
  int h[N];
  for(int i = 0;i < N;++i)
    cin >> h[i];

  for(int i = 0;i < N;++i){
    if(h[i] >= k)
      ans++;
  }
    
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int v[105],w[105];
long long dp[100005];

int main()
{
	int n,W;
	cin>>n>>W;
//	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++)
		cin>>w[i]>>v[i];
	for(int i=1;i<=n;i++)
		for(int j=W;j>=w[i];j--)
			dp[j]=max(dp[j-w[i]]+v[i],dp[j]);
	cout<<dp[W];
	//long long ans=-1;
//	for(int i=0;i<=W;i++)
//		ans=max(ans,dp[i]);		
//	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

const int max_a = 20005;

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// 2項係数を求める
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

//nが非常に大きく、aが小さい場合
mint choose(int n, int a){
    mint x = 1, y = 1;
    rep(i,a){
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    mint ans = 0;
    mint two_factor = 1;
    rep(i,60){
        mint one_count = 0, zero_count = 0;
        rep(j,N){
            ll bit = 1LL << i;
            if (A[j] & bit) one_count += 1;
            else zero_count += 1;
        }
        ans += one_count * zero_count * two_factor;
        two_factor *= 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 5588
#include <cstdio>
#define ll long long

int main() {
  ll n, a, b, x, px, o = 0;
  scanf("%lld %lld %lld %lld", &n, &a, &b, &px);
  for(int i = 0; i < n - 1; i++) {
      scanf("%lld", &x);
    o += (x - px) * a < b ? (x - px) * a : b;
    px = x;
  }
  printf("%lld\n", o);
}

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

using namespace std;
int digSum(int n){
	int sum = 0;
	string word = to_string(n);
	for(int i = 0; i<word.size(); i++){
		sum += word[i]-'0';
		}
	return sum;
	
	}

int main(){
	int n, a,b;
	cin>>n>>a>>b;
	int sum = 0;
	for(int i = 1; i<n+1 ; i++){
		
		if(a<= digSum(i) and digSum(i)<=b)sum +=i;
		
		}
		
	cout<<sum;
	
	return 0;
	}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

typedef long long ll;
const int MAXN=1e5+5;
int n,x,a[MAXN];

int main(){
    scanf("%d%d",&n,&x);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    ll ans=0,sum,res;
    for(int i=1;i<n;i++){
        sum=a[i]+a[i-1];
        res=max(sum-x,0ll);
        ans+=res;a[i]=max(a[i]-res,0ll);
    }
    printf("%lld\n",ans);
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int w = Integer.parseInt(st.nextToken());
        int h = Integer.parseInt(st.nextToken());
        int n = Integer.parseInt(st.nextToken());
        int xmax = 0;
        int xmin = w;
        int ymax = 0;
        int ymin = h;
        for (int i = 1; i <= n; i++) {
            st = new StringTokenizer(br.readLine());
            int x = Integer.parseInt(st.nextToken());
            int y = Integer.parseInt(st.nextToken());
            int a = Integer.parseInt(st.nextToken());
            if (a == 1) {
                xmax = Math.max(xmax, x);
            }
            if (a == 2) {
                xmin = Math.min(xmin, x);
            }
            if (a == 3) {
                ymax = Math.max(ymax, y);
            }
            if (a == 4) {
                ymin = Math.min(ymin, y);
            }
        }
        if(xmin <= xmax || ymin <= ymax)
            System.out.print("0");
       else  System.out.println((xmin - xmax)*(ymin - ymax));
    }
}


Measured memory_bytes: 8276
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using Graph = vector<vector<int>>;
using ll = long long;


int main() {
    int n,m;
    cin>>n>>m;
    int odd=0;
    int even=0;
    if(n>=2){
        odd=n*(n-1)/2;
    }
    if(m>=2){
        even=m*(m-1)/2;
    }
    cout<<odd+even<<endl;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main(){
int n,i;
scanf("%d",&n);
long lyuca[n+1];

lyuca[0]=2;
lyuca[1]=1;

for(i=2;i<n+1;i++){
lyuca[i]=lyuca[i-1]+lyuca[i-2];
}

printf("%ld\n",lyuca[n]);
return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int H[404];
ll mo=998244353;

ll comb(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
ll p2[2020];

struct res {
	ll V[2][404];
};


res hoge(int L,int R,int B) {
	while(L<R&&H[L]<=B) L++;
	res ret={};
	if(L==R) {
		ret.V[0][0]=ret.V[1][0]=1;
		return ret;
	}
	int i,x;
	int add=0;
	for(i=L;i<R;i++) {
		if(H[i]<=B) {
			res X=hoge(L,i,B);
			res Y=hoge(i+1,R,B);
			int a1,a2;
			int W=R-L-1;
			for(a1=0;a1<=i-L;a1++) for(a2=0;a2<=R-(i+1);a2++) {
				(ret.V[0][a1+a2]+=1LL*X.V[0][a1]*Y.V[0][a2])%=mo;
				(ret.V[1][a1+a2]+=1LL*X.V[1][a1]*Y.V[1][a2])%=mo;
			}
			return ret;
		}
		if(H[i]==B+1) add++;
	}
	res X = hoge(L,R,B+1);
	int a1,a2,u1,u2;
	int W=R-L;
	// no rook
	FOR(u1,W-add+1) ret.V[0][u1+add]=ret.V[1][u1+add]=X.V[0][u1];
	
	FOR(u1,W+1) {
		if(X.V[0][u1]) {
			FOR(x,u1+add+1) (ret.V[0][u1+add-x]+=X.V[0][u1]*comb(u1+add,x)%mo*(p2[W-(u1+add)]-(x==0)))%=mo;
		}
		if(X.V[1][u1]) {
			FOR(x,u1+1) (ret.V[1][u1-x]+=X.V[1][u1]*comb(u1,x)%mo*(p2[W-u1]-(x==0)))%=mo;
		}
	}
		
	return ret;
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	p2[0]=1;
	FOR(i,2010) p2[i+1]=p2[i]*2%mo;
	
	cin>>N;
	FOR(i,N) cin>>H[i];
	
	auto X=hoge(0,N,0);
	cout<<X.V[1][0]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 18816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N;
map<string, ll> mp;

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll ans = 0;
    for (auto &p : mp)
    {
        ll q = p.second;
        ans += q * (q - 1LL) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
#include <iostream>

using namespace std;

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

	int p = 1, q = n;
	if (n % 2 == 1) {
		for (int i = 0; i < m; i++) {
			printf("%d %d\n", p, q);

			p++;
			q--;
		}
	} else {
		if (m % 2 == 0) {
			q -= 1;
			for (int i = 0; i < m / 2; i++) {
				printf("%d %d\n", p, q);

				p++;
				q--;
			}
			p = n / 2 - 1;
			q = n / 2;
			for (int i = m / 2; i < m; i++) {
				printf("%d %d\n", p, q);

				p--;
				q++;
			}
		} else {
			q -= 1;
			for (int i = 0; i < m / 2; i++) {
				printf("%d %d\n", p, q);
				p++;
				q--;
			}
			p = n / 2 - 1;
			q = n / 2;
			for (int i = m / 2; i < m; i++) {
				printf("%d %d\n", p, q);
				p--;
				q++;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n)
    {
        int tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    int m;
    cin >> m;
    rep(i, m)
    {
        int tmp;
        cin >> tmp;
        if (mp[tmp] > 0)
        {
            mp[tmp]--;
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
	string s;

	cin >> s;

	for(int i = 0 ; i < s.size() ; i++){
		if(s[i] == '?'){
			if(i < s.size() - 1){
				if(i > 0 && s[i-1] == 'P'){
					s[i] = 'D';
				}else if(s[i+1] == '?'){
					s[i] = 'P';
					s[i+1] = 'D';
				}else if(s[i+1] == 'D'){
					s[i] = 'P';
				}else{
					s[i] = 'D';
				}
			}else{
				s[i] = 'D';
			}
		}
		cout << s[i];
	}
}


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

int h, n, a, A = 0;

int main(){
  
  cin >> h >> n;
  for (int i = 0; i < n; i++){
    cin >> a;
    A += a;
      if (A >= h){
        cout << "Yes" << endl;
        break;
      }
}

if (A < h) cout << "No" << endl;

  }

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef vector<int> vi;
const int MAX=1e5+5;
const lli INF=1e18;

int main(){
	int N,W;
	cin>>N>>W;
	lli w[101],v[101];
	lli vsum=0;
	rep1(i,N){
		cin>>w[i]>>v[i];
		vsum+=v[i];
	}
	lli dp[102][MAX];
	//dp[i][j]は品物iまでで価値j以上を実現するための最小の重さ
  	dp[0][0]=0;
	rep1(j,vsum)dp[0][j]=INF;
	rep1(i,N)rep(j,vsum+1){
		if(j>=v[i])	dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
		else dp[i][j]=min(w[i],dp[i-1][j]);
	}
	lli ans=0;
	for(lli i=0;i<=vsum;i++){
		if(dp[N][i]<=W)ans=i;
		else break;
	}
	cout<<ans;
}

Measured memory_bytes: 79744
#define X(V,N,z)(0<=V+D[d][N]*z&&V+D[d][N]*z<n)
D[13][3]={{1,0,0},{0,1,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{1,-1,0},{1,0,-1},{0,1,-1},{1,1,1},{-1,1,1},{1,-1,1},{1,1,-1}};
M[7][7][7];main(n,m,p,I,x,y,i,j,k,c,d,z,Z){for(;scanf("%d%d%d",&n,&m,&p),n;){
	for(memset(M,0,sizeof(M)),c=1,I=0;I<p;c*=-1){
		scanf("%d%d",&x,&y),x--,y--,I++;
		for(i=0;;i++)if(!M[x][y][i]){M[x][y][i]=c;break;}
		for(d=0;d<13;d++){
			for(z=0;z<m;z++)if(!X(x,0,z)||!X(y,1,z)||!X(i,2,z)||M[x+D[d][0]*z][y+D[d][1]*z][i+D[d][2]*z]!=c)break;
			for(Z=0;-m<Z;Z--)if(!X(x,0,Z)||!X(y,1,Z)||!X(i,2,Z)||M[x+D[d][0]*Z][y+D[d][1]*Z][i+D[d][2]*Z]!=c)break;
			if(z-Z-1>=m){printf("%s %d\n",c==1?"Black":"White",I);goto next;}
		}
			
	}
	puts("Draw");
next:
	for(;I<p;I++)scanf("%d%d",&x,&y);
}exit(0);}

Measured memory_bytes: 608