akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
	int W,H,N;
	scanf("%d %d %d",&W,&H,&N);
	int high=H,low=0,right=W,left=0;
	int x,y,a,i,S;

	for(i=0;i<N;i++){
		scanf("%d %d %d",&x,&y,&a);
		
		if(a==1){
			if(x>left)	left=x;
		}else if(a==2){
			if(x<right)	right=x;
		}else if(a==3){
			if(y>low)	low=y;
		}else if(a==4){
			if(y<high)	high=y;
		}
	}
	if(right<=left || high<=low){
		S=0;
	}else{
		S=(high-low)*(right-left);
	}
	printf("%d\n",S);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=2005;
const ll INF=1LL<<60;

vector<int> prime;//i番目の素数
bool is_prime[500003+1];

void sieve(int n){
    for(int i=0;i<=n;i++){
        is_prime[i]=true;
    }
    
    is_prime[0]=is_prime[1]=false;
    
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime.push_back(i);
            prime.push_back(i);
            for(int j=2*i;j<=n;j+=i){
                is_prime[j] = false;
            }
        }
    }
}

ll ans[MAX][MAX];

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

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    sieve(500001);
    
    for(int j=0;j<MAX;j+=2){
        ans[0][j]=prime[j];
        //cout<<ans[0][j]<<endl;
    }
    
    for(int j=1;j<MAX-1;j+=2){
        ans[1][j]=ans[0][j-1]*ans[0][j+1];
    }
    
    for(int i=2;i<MAX;i++){
        for(int j=i;j<MAX-i;j+=2){
            ll x=gcd(ans[i-1][j-1],ans[i-2][j]),y=gcd(ans[i-1][j+1],ans[i-2][j]);
            ans[i][j]=(ans[i-1][j-1]/x)*(ans[i-1][j+1]/y);
        }
    }
    
    for(int i=1;i<MAX-1;i++){
        for(int j=i+1;j<MAX-i-1;j+=2){
            ans[i][j]=ans[i][j-1]*ans[i][j+1]+1;
        }
    }
    
    int N;cin>>N;
    
    for(int i=1;i<1+N;i++){
        for(int j=501;j<501+N;j++){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
}



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

inline bool query(const LL& n) {
	printf("? %I64d\n",n);
	fflush(stdout);
	char ch=getchar();
	while (ch==' ' || ch=='\n') ch=getchar();
	return ch=='Y';
}

inline bool query(const char* s) {
	printf("? %s\n",s);
	fflush(stdout);
	char ch=getchar();
	while (ch==' ' || ch=='\n') ch=getchar();
	return ch=='Y';
}

inline int getlen() {
	int l=1,r=10;
	while (l<r) {
		int mid=(l+r+1)/2;
		LL x=1;
		for (int i=1;i<mid;++i) x=x*10;
		bool f=query(x);
		if (!f) r=mid-1;else l=mid;
	}
	return l;
}

inline LL getnum(const int& len) {
	char str[20];
	for (int i=0;i<len+3;++i) str[i]=0;
	for (int i=0;i<len-1;++i) {
		int l=0,r=9;
		while (l<r) {
			int mid=(l+r+1)/2;
			str[i]='0'+mid;
			bool f=query(str);
			if (!f) r=mid-1;else l=mid;
		}
		str[i]='0'+l;
	}
	str[len]='0';
	int l=0,r=9;
	while (l<r){
		int mid=(l+r)/2;
		str[len-1]='0'+mid;
		bool f=query(str);
		if (!f) l=mid+1;else r=mid;
	}
	str[len-1]='0'+l;
	str[len]=0;
	return atoi(str);
}

inline LL prefix_special() {
	const int MaxLen = 10;
	char str[MaxLen+3];
	for (int i=0;i<MaxLen;++i) str[i]='9';
	int l=0,r=10;
	while (l<r) {
		int mid=(l+r+1)/2;
		str[mid]=0;
		bool f=query(str);
		str[mid]='9';
		if (f) r=mid-1;else l=mid;
	}
	LL x=1;
	for (int i=1;i<=l;++i) x*=10;
	return x;
}

int main() {
	LL ans;
	if (query(100000000000LL)) {
		ans=prefix_special();
	} else {
		int len=getlen();
		ans=getnum(len);
	}
	printf("! %I64d\n",ans);
	return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>

using namespace std;

int main() {

	int n, max, min;
	char s[9];
	deque<int> x;

	cin >> n;
	while(1) {
		if(n==0)
			break;

		x.clear();
		max=min=0;
		cin >> s;
		for(int i=0; i<8; i++) {
			x.push_back((s[i]-'0'));
		}

		sort(x.begin(), x.end(), greater<int>());
		for(int i=0; i<8; i++) {
			max+=x[i]*pow(10, (double)(7-i));
		}
		sort(x.begin(), x.end());
		for(int i=0; i<8; i++) {
			min+=x[i]*pow(10, (double)(7-i));
		}

		cout << max-min << endl;
		n--;
	}

	return 0;

}

Measured memory_bytes: 0
# 3
# 9 1
# 5 4
# 0 8
# 3
# 9 1
# 5 4
# 1 0
# 3
# 9 1
# 5 5
# 1 8
# 0

while True:
	n = int(input())
	if n == 0:
		exit(0)
	a, b = 0, 0
	for i in range(n):
		A = list(map(int, input().split()))
		if A[0] > A[1]:
			a = a + A[0] + A[1]
		elif A[0] < A[1]:
			b = b + A[0] + A[1]
		elif A[0] == A[1]:
			a, b = a + A[0], b + A[1]
	print('{0} {1}'.format(a, b))



Measured memory_bytes: 5616
import java.io.*;
import java.util.*;
 
public class Main {

	public static void main(String[] args)throws IOException {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
		int n = in.nextInt();
		int k=in.nextInt();
		int c=in.nextInt();
		String s = in.next();
		int arr[] = new int[n];
		Arrays.fill(arr,0);
		for(int i=0;i<n;i++)
			if(s.charAt(i)=='o')
				arr[i]=1;
		int left[] = new int[k];
		int right[] = new int[k];
		int pos=0;
		for(int i=0;i<n&&pos<k;i++)
		{
			if(pos==0)
			{
				if(arr[i]==1)
				{
					left[pos++]=i;
				}
			continue;
			}
			int gap = i-left[pos-1]-1;
			if(arr[i]==1 && gap>=c)
			{
				left[pos++]=i;
			}
		}
		pos=0;
		for(int i=n-1;i>=0&&pos<k;i--)
		{
			if(pos==0)
			{
				if(arr[i]==1)
				{
					right[pos++]=i;
				}
			continue;
			}
			int gap = right[pos-1]-i-1;
			if(arr[i]==1 && gap>=c)
			{
				right[pos++]=i;
			}
		}	
		for(int i=0;i<k;i++)
		{
			if(left[i]==right[k-i-1])
			{
				out.println(left[i]+1);
			}
		}
        out.close();
	}
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }

}

Measured memory_bytes: 40664
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int m[20][20];

int main(){
    int x,y;
    while(cin >> x >> y, x||y){
        rep(k,20){
            rep(l,20){
                m[k][l] = 0;
            }
        }
        int n;
        cin >> n;
        rep(k,n){
            int a, b;
            cin >> a >> b;
            m[a][b] = 2 << 24;
        }
        m[1][1] = 1;
        int i, j;
        for(i = 1; i <= x; i++){
            for(j = 1; j <= y; j++){
                if(m[i][j] < 2 << 24){
                    m[i + 1][j]+= m[i][j];
                    m[i][j + 1]+= m[i][j];
                }
            }
        }
        cout << m[i-1][j-1] << endl;
    }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
  int n; string s; cin >> n >> s;
  ll ans = 1;
  ll cnt[3];
  cnt[0]=0; cnt[1]=0; cnt[2]=0;
  rep(i,n){
    if(s[i]=='R') cnt[0]++;
    if(s[i]=='G') cnt[1]++;
    if(s[i]=='B') cnt[2]++;
  }
  rep(i,3) ans *= cnt[i];
  rep(j,n) rep(i,j){
    int k = j + (j - i);
    if(k < n){
      if(s[i]==s[j]) continue;
      if(s[i]==s[k]) continue;
      if(s[j]==s[k]) continue;
      ans--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(void){
    int a, b, k, i;
    scanf("%d%d%d", &a, &b, &k);

    for(i=0; i<k; i++){
        if(i%2==0){
            if(a%2==1){
                a--;
            }
            b+=a/2;
            a-=a/2;
        }
        
        if(i%2==1){
            if(b%2==1){
                b--;
            }
            a+=b/2;
            b-=b/2;
        }
    }

    printf("%d %d\n", a, b);

    return 0;
}

Measured memory_bytes: 128
def main():
    N = int(input())
    a = list(map(int, input().split()))    
    even_num = [e for e in a if e % 2 == 0]
    flag = True
    for e in even_num:
        if e % 3 != 0 and e % 5 != 0:
            flag = False
    if flag: print("APPROVED")
    else: print("DENIED")
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
    int a,b;
    int p,q;
    int item = 2000;
    cin >> a >> b;

    for (int i=0;i<a;++i) {
        cin >> p >> q;
        if (p < item && q <= b) {
            item = p;
        }
    }
    if (item == 2000) {
        cout << "TLE";
    } else {
        cout << item;
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

int main(){
	int a[100][100];
	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			a[i][j] = 10000000;
		}
		a[i][i] = 0;
	}

	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		a[i][i] = 0;
		for (int j = 0; j < k; j++) {
			int c, v;
			cin >> v >> c;
			a[u][v] = c;
		}
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i << " " << a[0][i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#カードがなくなったら勝ちじゃない！！！　カードない人のターンが来たら、終わり。

a=list(input())
b=list(input())
c=list(input())
a_num,b_num,c_num=len(a),len(b),len(c)
now="A"
ans="A"
flag=True
def delete(now): #プレイヤーのカードを消す。
    global a_num 
    global b_num 
    global c_num 
    global ans
    global flag
    if now=="A":
        if a_num==0:
            ans="A"
            flag=False
            return
        change(a[0])
        del a[0]
        a_num-=1
    elif now=="B":
        if b_num==0:
            ans="B"
            flag=False
            return
        change(b[0])
        del b[0]
        b_num-=1
    else:
        if c_num==0:
            ans="C"
            flag=False
            return
        change(c[0])
        del c[0]
        c_num-=1
        
def change(card): #出たカードの人がプレイヤーになる。
    global now
    if card=="a":
        now="A"
    elif card=="b":
        now="B"
    else:
        now="C"
        
while flag:
    delete(now)
    #print(a)
    #print(a_num)
print(ans)

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

typedef long long int ll;


int main()
{
	ios::sync_with_stdio(0);
	ll n,k;
	cin >> n >> k;
	ll arr[n],i,j,dp[n];
	if(k>n)
		k=n-1;
	for(i=0;i<n;i++)
		cin >> arr[i];
	for(i=0;i<n;i++)
		dp[i]=-1;
	dp[0]=0;
	for(i=1;i<k;i++)
	{
		ll mi = 1e10;
		for(j=0;j<i;j++)
		{
			mi = min(mi,dp[j]+abs(arr[i]-arr[j]));
		}
		dp[i]=mi;
	}
	for(i=k;i<n;i++)
	{
		ll mi = 1e10;
		for(j=1;j<=k;j++)
		{
			mi = min(mi,dp[i-j]+abs(arr[i-j]-arr[i]));
		}
		dp[i]=mi;
	}
	cout << dp[n-1] << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, k; cin >> n >> k;
    vector<long long> vec(n+1);
    for(long long i = 0; i < n; i ++){
        cin >> vec[i];
    }
    

    for(ll i = 0; i < k; i++){
        vector<ll> imos(n+1);

        for(ll j = 0; j < n; j++){
            imos[max(j - vec[j], (ll)0)]++;
            imos[min(j + vec[j] + 1, n)]--;
        }

        rep(j, n+1){
            if(j > 0){
                imos[j] += imos[j-1];
            }
        }

        

        if(vec == imos){
            break;
        }

        vec = imos;

    }

    
    rep(i, n){
        cout << vec[i] << " ";
    }
    br;
}

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

int main(void) {
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end(), greater<int>());
  long long ans = 1;
  int cnt = 0;
  for (int i = 1; i < N; i++) {
    if (cnt >= 2) break;
    if (A[i] == A[i - 1]) {
      ans *= A[i];
      cnt++;
      i++;
    }
  }

  cout << (cnt != 2 ? 0 : ans) << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <math.h>
#define PI 3.141592653589793
using namespace std;
int main(){
  double a, b, x;
  cin >> a >> b >> x;
  double tan_th, theta;
  if(a*a*b/2 < x){
    x = a*a*b - x;
    tan_th = (2*x)/(a*a*a);
  } else{
    tan_th = (a*b*b)/(2*x);
  }
  theta = atan(tan_th);
  printf("%lf\n", theta * 180.0 / PI);
  return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, class Op = multiplies<T>>
constexpr T power(T a, long long n, Op op = Op(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  static constexpr unsigned mod = M;
  unsigned v;
  modular(long long x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((int)(v += b.v - mod) < 0) v += mod; return *this; }
  m& operator-=(m b) { if ((int)(v -= b.v) < 0) v += mod; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % mod; return *this; }
  m& operator/=(m b) { return *this *= power(b, mod - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
};

using mint = modular<2019>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = size(s);
  vector<mint> a(n + 1);
  for (int i = n; i--; ) {
    a[i] = (s[i] - '0') * power<mint>(10, n - i - 1) + a[i + 1];
  }
  vector<int> c(2020);
  auto res = 0LL;
  for (int i = n; i >= 0; --i) {
    res += c[a[i].v]++;
  }
  cout << res << '\n';
}


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

using namespace std;

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

    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << '\n';
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int a, b;

        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();

        int addition = a + b;
        int subtraction = a - b;
        int multiplication = a * b;

        System.out.println(Math.max(Math.max(addition, subtraction), multiplication));
    }
}


Measured memory_bytes: 21844
a[200],b[200],c[1000],d[1000],n,m,i,j,k,t,w,q;main(){for(;;){scanf("%d",&n);if(n==0)break;for(i=0;i<n;i++){scanf("%d %d",&a[i],&b[i]);}scanf("%d",&m);for(i=0;i<m;i++){scanf("%d %d",&c[i],&d[i]);}for(i=0;i<m;i++){w=c[i]-a[0];q=d[i]-b[0];for(j=1;j<n;j++){for(k=0;k<m;k++){if(a[j]+w==c[k]){if(b[j]+q==d[k]){t++;break;}}}}if(t==n-1){printf("%d %d\n",w,q);t=0;break;}t=0;}}return 0;}

Measured memory_bytes: 608
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
	double a,b,c,C;
	double S,L,h;

	cin>>a>>b>>C;
	
	h = b * sin( C * (M_PI / 180 ) );
	S = a*h/2;
	c =  a*a + b*b - 2*a*b*cos( C * (M_PI / 180 ));
	L = a+b+sqrt(c);

	cout.setf( ios::fixed );
	cout<<S<<endl<<L<<endl<<h<<endl;

	return 0;
}



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

int main() 
{
    int N,K;
    cin >> N >> K;
    vector<int> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
    }
    
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int sum1 = abs(0-X[i]) * 2 + 0;
        int sum2 = abs(K-X[i]) * 2 + 0;
        if (sum1 <= sum2) {
            ans += sum1;
        }else{
            ans += sum2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N, K, X, Y;
    
    N = scan.nextInt();
    K = scan.nextInt();
    X = scan.nextInt();
    Y = scan.nextInt();
  
    int sa = N - K;
    int ans = 0;
    if(sa > 0){
    	ans = K * X + sa * Y;
    }
    else{
    	ans = N * X;
    }
    
    System.out.println(ans);
    
  }

}

Measured memory_bytes: 22484
import math
n = int(input())
a = list(map(int,input().split()))

cnt = 0
while True:
 flg = 0
 for i in range(n):
  if a[i] % 2 == 1:
   flg = 1
   break
  else:
   a[i] = a[i] / 2
 if flg == 1:
  break
 cnt += 1

print(cnt)











Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 200005;
const ll MOD = 1000000007;
const int iNF = 0x3f3f3f3f;

int n, m, ans, seg[MAXN * 4], tag[MAXN * 4];
vector<int> x[MAXN];

void push (int o) {
    if (tag[o]) {
        seg[o] += tag[o];
        tag[o<<1] += tag[o];
        tag[o<<1|1] += tag[o];
        tag[o] = 0;
    }
}

int get (int o) {
    return seg[o] + tag[o];
}

void pull (int o) {
    seg[o] = max(get(o<<1), get(o<<1|1));
}

void build (int o, int l, int r) {
    if (r == l + 1) {
        seg[o] = -(m+1-l);
        tag[o] = 0;
    } else {
        int md = (l + r) >> 1;
        build(o<<1, l, md);
        build(o<<1|1, md, r);
        pull(o);
    }
}

int qry (int qL, int qR, int o=1, int nL=0, int nR=m+2) {
    if (qL >= nR || qR <= nL || qL >= qR) {
        return -iNF;
    } else if (qL <= nL && nR <= qR) {
        return get(o);
    } else {
        push(o);
        int nM = (nL + nR) >> 1;
        return max(qry(qL, qR, o<<1, nL, nM), qry(qL, qR, o<<1|1, nM, nR));
    }
}

void add (int qL, int qR, int o=1, int nL=0, int nR=m+2) {
    if (qL >= nR || qR <= nL || qL >= qR) {
        return;
    } else if (qL <= nL && nR <= qR) {
        tag[o]++;
    } else {
        push(o);
        int nM = (nL + nR) >> 1;
        add(qL, qR, o<<1, nL, nM);
        add(qL, qR, o<<1|1, nM, nR);
        pull(o);
    }
}

/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> m;

    REP (i, n) {
        int l, r;
        cin >> l >> r;
        x[l].emplace_back(r);
    }

    ans = max(0, n-m);

    build(1, 0, m+2);
    REP (i, m+1) {
        for (auto r : x[i]) {
            add(0, r+1);
        }
        ans = max(ans, qry(i+2, m+2) - i);
    }

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


Measured memory_bytes: 14080
#include <iostream>
#include <cstring>
#include <cstdio>
int cnt[100001];
bool prime[100001];
int main(int argc, const char * argv[]) {
 
    for(int i=2;i<=100000;i++){
        if(!prime[i]){
            for(int j=i*2;j<=100000;j+=i){
                prime[j]=true;
            }
        }
    }
    
    for(int i=3;i<=100000;i+=2){
        if(!prime[i] && !prime[(i+1)/2]) cnt[i]++;
    }
    
    for(int i=3;i<=100000;i++){
        cnt[i] += cnt[i-1];
    }
    
    int q;
    
    scanf("%d",&q);
    
    while(q--){
        
        int l,r;
        
        scanf("%d %d",&l,&r);
        
        printf("%d\n",cnt[r]-cnt[l-1]);
        
    }
    
    return 0;
}


Measured memory_bytes: 1152
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;
int inf = 1e9;

int f(int n) {
  if(n % 10 == 0) { return n; }
  else { return n + (10 - n % 10); }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vec(5);
  REP(i,5) cin >> vec[i];
  int maxi = -1;
  REP(i,5) {
    int a = vec[i];
    if(f(a) - a > maxi) maxi = f(a) - a;
    vec[i] = f(a);
  }
  cout << accumulate(vec.begin(), vec.end(),0) - maxi << endl;
  return 0;
}
//templete by private_yusuke

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

using namespace std;

void usain_bolt()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
}

const int N = 1e2 + 5;

long long dp[2][N * 1000], w[N], p[N];

int main()
{
    usain_bolt();

    int n, W;

    cin >> n >> W;

    for(int i = 1; i <= n; ++i) cin >> w[i] >> p[i];
    int phase = 1;
    for(int i = 1; i <= n; ++i, phase ^= 1) {
        for(int j = 0; j <= W; ++j) {
            dp[phase ^ 1][j] = dp[phase][j];
            if(j >= w[i]) dp[phase ^ 1][j] = max(dp[phase ^ 1][j], dp[phase][j - w[i]] + p[i]);
        }
    }
    cout << dp[phase][W];

    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
   int a,b;
   int add,sub,mul;

   scanf("%d%d",&a,&b);

   add=a+b;
   sub=a-b;
   mul=a*b;
   if(add>=sub && sub>=mul)
     printf("%d",add);
   else if(add>=mul && mul>=sub)
     printf("%d",add);
   else if(sub>=add && add>=mul)
     printf("%d",sub);
   else if(sub>=mul && mul>=add)
     printf("%d",sub);
   else if(mul>=add && add>=sub)
     printf("%d",mul);
   else if(mul>=sub && sub>=add)
     printf("%d",mul);

   return 0;
}


Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextStr() string {
	sc.Scan()
	s := sc.Text()
	return s
}

const (
	mod = 1000000007
)

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	S1 := nextStr()
	S2 := nextStr()
	result := 1
	for i := 0; i < N; i++ {
		if i == 0 {
			if S1[i] != S2[i] {
				result *= 6
			} else {
				result *= 3
			}
		} else {
			if S1[i-1] == S2[i-1] {
				result *= 2
			} else {
				if S1[i] != S2[i] {
					result *= 3
				} else {
					//
				}
			}
		}
		if S1[i] != S2[i] {
			i++
		}
		result %= mod
	}
	fmt.Println(result)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    ll A,B,C;
    cin >> A >> B >> C;
    REP(i,1e8){
        if((B*i+C) % A == 0){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	sort(a.begin(), a.end());
	if (n % 2 == 0) {
		long long sum = 0;
		for (int i = 0; i < n; ++i) {
			if (i < (n / 2) - 1) sum -= a[i] * 2;
			else if (i == (n / 2) - 1) sum -= a[i];
			else if (i == (n / 2)) sum += a[i];
			else sum += a[i] * 2;
		}
		cout << sum << '\n';
	}
	else {
		long long sum0 = 0;
		for (int i = 0; i < n; ++i) {
			if (i < (n / 2)) sum0 -= 2 * a[i];
			else if (i <= (n / 2) + 1) sum0 += a[i];
			else sum0 += 2 * a[i];
		}
		long long sum1 = 0;
		for (int i = 0; i < n; ++i) {
			if (i < (n / 2) - 1) sum1 -= 2 * a[i];
			else if (i <= (n / 2)) sum1 -= a[i];
			else sum1 += 2 * a[i];
		}
		cout << max(sum0, sum1) << '\n';
	}
}


Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

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

    int a,b;cin>>a>>b;

    int s1=0,s2=0;

    //s1
    if(a/2%2==0) s1=0;
    else s1=1;
    if((a-1)%2==0) s1=s1^(a-1);


    //s2
    if((b+1)/2%2==0) s2=0;
    else s2=1;
    if(b%2==0) s2=s2^b;
    
    //show(s1);show(s2);
    cout<<(s1^s2)<<endl;
}   

Measured memory_bytes: 3656
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int H, W; cin >> H >> W;
    vs S(H); REP(i, H) cin >> S[i];

    int black = 0;
    REP(i,H) {
        REP(j,W) {
            if (S[i][j] == '#') black++;
        }
    }

    if (S[H-2][W-1]=='#' && S[H-1][W-2]=='#') {
        cout << -1 << endl;
        return 0;
    }

    queue<pii> que;
    que.push(pii(0, 0));
    int dx[4] = { 0,0,1,-1 };
    int dy[4] = { 1,-1,0,0 };
    vvb vis(H, vb(W, false));
    vvi dist(H, vi(W, INF));
    dist[0][0] = 0;
    while(!que.empty()) {
        pii p = que.front(); que.pop();
        int x = p.first;
        int y = p.second;
        vis[x][y] = true;
        
        if (vis[H - 1][W - 1]) break;

        REP(i,4) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx<0 || H<=nx || ny<0 || W<=ny ||
                S[nx][ny]=='#' || vis[nx][ny]) continue;

            if (dist[nx][ny] > dist[x][y] + 1) {
                dist[nx][ny] = dist[x][y] + 1;
                que.push(pii(nx,ny));
            }
        }
    }

    int ans = 0;
    if (dist[H-1][W-1] == INF) {
        ans = -1;
    } else {
        ans = H * W - black - (dist[H - 1][W - 1] + 1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
		int n,i;
		long long a[21],b[21],c[21],ans=0;
		scanf("%d",&n);
		for(i=0;i<n;i++)scanf("%lld",&a[i]),a[i]--;
		for(i=0;i<n;i++)scanf("%lld",&b[i]);
		for(i=0;i<n-1;i++)scanf("%lld",&c[i]);
		ans=b[a[0]];
		for(i=1;i<n;i++){
				ans+=b[a[i]];
				if(a[i]==a[i-1]+1)ans+=c[a[i-1]];
		}
		printf("%lld\n",ans);
		return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        long[] sum = new long[n+1];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            sum[i+1] = sum[i] + a[i];
        }

        long min = Long.MAX_VALUE;
        for (int i = 1; i < n; i++) {
            long val1 = sum[i];
            long val2 = sum[n] - sum[i];
            min = Math.min(min, Math.abs(val1-val2));
        }
        System.out.println(min);


    }
}


Measured memory_bytes: 61932
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int l, r, d;
    cin, l, r, d;
    int cnt = 0;
    REP(i, l, r + 1) {
        cnt += (i % d == 0);
    }
    print(cnt);
    return 0;
}


Measured memory_bytes: 3604
N, Y = [int(i) for i in input().split()]

a1 = 0
a5 = 0
a10 = 0
s = 1

if 10000*N+1 > Y:
    for i in range(N+1):
        a10 = i
        for j in range(N - a10+1):
            a5 = j
            a1 = N - a5 - a10
            if Y == a1 * 1000 + a5 * 5000 + a10 * 10000:
                s = 0
                break
        else:
            continue
        break


if s == 1:
    print("-1 -1 -1")
else:
    print(a10, a5, a1)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
int rlet;
int n;
int d[255];
vector<int> vec[255],rvec[255];
bool vis[255],rvis[255];

void dfs(int now){
  vis[now]=true;
  for(int i=0;i<vec[now].size();i++){
    if(!vis[vec[now][i]])dfs(vec[now][i]);
  }
}  
void rdfs(int now){
  rvis[now]=true;
  for(int i=0;i<rvec[now].size();i++){
    if(!rvis[rvec[now][i]])rdfs(rvec[now][i]);
  }
}

int main(){

  while(1){
    memset(vis,false,sizeof(vis));
    memset(rvis,false,sizeof(rvis));
    cin>>rlet;
    if(!rlet)break;
    cin>>n;
    for(int i=1;i<=n;i++){
      cin>>d[i];
    }
    
    for(int i=0;i<=n+1;i++){
       vec[i].clear();
       rvec[i].clear();
    }
    /*グラフ化*/
    for(int i=0;i<=n;i++){
      for(int j=1;j<=rlet;j++){
	vec[i].push_back(min(max(i+j+d[i+j],0),n+1));
	rvec[min(max(i+j+d[i+j],0),n+1)].push_back(i);
      }
    }
    
    dfs(0);
    rdfs(n+1);
 
    bool ok=true;
    for(int i=0;i<=n;i++){
      if(vis[i]&&!rvis[i])ok=false;
    }

    if(ok)cout<<"OK"<<"\n";
    else cout<<"NG"<<"\n";
  }
  return 0;
}



Measured memory_bytes: 3188
#include<iostream>

using namespace std;

int main()
{
  int N,i;
  cin >> N;
  long long sum=0;

  for(i=1;i<=N;i++){
    if(i%3 != 0 && i%5 != 0)
    sum += i;
  }

  cout << sum << endl;
  return 0;
}


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

//#define equals( a, b ) (fabs((a) - (b)) < DBL_E)

class Vector2 {
public:
	Vector2(double x_, double y_) : x(x_), y(y_) {}
	Vector2() : x(0), y(0) {}
	Vector2 operator -(Vector2& other) {
		Vector2 vec(x - other.GetX(), y - other.GetY());
		return vec;
	}
	void SetVector2(double x_, double y_) {
		x = x_;
		y = y_;
	}
	double GetX() {
		return x;
	}
	double GetY() {
		return y;
	}

private:
	double x, y;
};

double Dot(Vector2 vecA, Vector2 vecB) {
	return vecA.GetX() * vecB.GetX() + vecA.GetY() * vecB.GetY();
}

double CrossY(Vector2 vecA, Vector2 vecB) {
	return vecA.GetX() * vecB.GetY() - vecA.GetY() * vecB.GetX();
}

bool IsOrthogonal(Vector2 vecA, Vector2 vecB) {
    double ans = Dot(vecA, vecB);
//	return equals(ans, 0.0);
//	return (fabs(ans) < DBL_EPSILON);
	ans = ans > 0 ? ans : -ans;
	return ( ans < 0.1f);
}

bool IsParallel(Vector2 vecA, Vector2 vecB) {
	double ans = CrossY(vecA, vecB);
//	return (fabs(ans) < DBL_EPSILON);
	ans = ans > 0 ? ans : -ans;
	return (ans < 0.1f);
}

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

	for (int i = 0; i < query; i++) {
		Vector2 vecs[4];
		for (int i = 0; i < 4; i++) {
			double x, y;
			cin >> x >> y;
			vecs[i].SetVector2(x, y);
		}

		Vector2 vecA = vecs[1] - vecs[0];
		Vector2 vecB = vecs[3] - vecs[2];
		bool orth = IsOrthogonal(vecA, vecB);
		if (orth) {
			cout << 1 << endl;
			continue;
		}

		bool para = IsParallel(vecA, vecB);
		if (para) {
			cout << 2 << endl;
			continue;
		}
		cout << 0 << endl;
	}

	return 0;
}

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

#UnionFind

Group=[[i,0] for i in range(n)]#グループ分け.Group[i]=jのときiとjは同じグループ

def find(x):#find(a)=find(b)のとき同じグループ
    ANS=Group[x][1]
    while Group[x][0] != x:
        x=Group[x][0]
        ANS+=Group[x][1]
    return x,ANS

def Union(x,y,z):  # xとyが同じグループになるよう更新
    if find(x)[0] != find(y)[0]:
        MIN=min(find(x)[0],find(y)[0])
        if find(x)[0]==MIN:
            Group[find(y)[0]]=[MIN,z+find(x)[1]-find(y)[1]]
        else:
            Group[find(x)[0]]=[MIN,-z+find(y)[1]-find(x)[1]]
            

for query in Q:
    if query[0]==0:
        Union(query[1],query[2],query[3])
        #print(Group)
    else:
        if find(query[1])[0]==find(query[2])[0]:
            print(find(query[2])[1]-find(query[1])[1])
        else:
            print("?")


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll p)
{
    if (p == 0)
        return 1;
    if (!(p % 2))
    {
        ll halfP = p / 2;
        ll half = modpow(a, p);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}

ll comb(int a, int b)
{
    if (b > a - b)
        return comb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;
    for (int i = 0; i < b; i++)
    {
        ansMul *= a - i;
        ansDiv *= i + 1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    ll ans = ansMul * modpow(ansDiv, mod - 2) % mod;
    return ans;
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    deque<int> d;
    rep(i, n) {
        int p = lower_bound(all(d), a[i]) - d.begin();
        if (p == 0) {
            d.push_front(a[i]);
        }
        else {
            d[p-1] = a[i];
        }
    }
    int ans = d.size();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 7 + 10**9
    s = sum(A)
    s %= mod
    r = 0
    for i in range(N):
        s -= A[i]
        r += s * A[i]
        r %= mod
    return r
print(main())


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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> L(m), R(m);
  ll lmax = 0;
  ll rmin = LLONG_MAX;
  for (int i = 0; i < m; i++) {
    cin >> L[i] >> R[i];
    lmax = max(lmax, L[i]);
    rmin = min(rmin, R[i]);
  }
  if (rmin - lmax < 0) {
    cout << 0 << endl;

  } else {

    cout << rmin - lmax + 1 << endl;
  }
}

Measured memory_bytes: 1792
package main

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

var sc = bufio.NewScanner(os.Stdin)

const MOD = 1000000007

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	r := nextInt()

	switch {
	case r < 1200:
		fmt.Println("ABC")
	case r < 2800:
		fmt.Println("ARC")
	default:
		fmt.Println("AGC")
	}
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

const int mod = 1e9 + 7;

bool solve(int s) {
	int l = 1, r = sqrt(1e9);
	while (l <= r) {
		int m = (l + r) / 2;
		if (m * m == s) return true;
		if (m * m < s) l = m + 1;
		else r = m - 1;
	}
	return false;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//cout << INT_MAX - 2 * (int)1e9 << endl;
	int l, r;
	cin >> l >> r;
	int ans = 2020;
	for (int i = l; i <= min(l + 10000, r); i++) {
		for (int j = i + 1; j <= min(l + 10000, r); j++) ans = min(ans, (i % 2019) * (j % 2019) % 2019);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  int N; cin >> N;
  map<int,int> mp;
  rep(i,N) {
    int a; cin >> a;
    mp[a-1]++;
    mp[a]++;
    mp[a+1]++;
  }

  int res = 0;
  for(auto x : mp) {
    res = max(res, x.se);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
typedef		vector<int>				 vi;
typedef 	vector<vi>				vii;
typedef		pair<int,int>			pii;
typedef		unsigned long long		ull;
typedef		long long				ll ;
#define MOD (int)(1e9+7)
#define INF (int)(1<<29) 
#define fori(i,a,b)		for(int i=a ; i <= b ; i++) 			
#define ford(i,a,b)  	for(int i=a ; i >= b ; i-- ) 
#define rep(i,n)   		for(int i=0; i < n ; i++ ) 
#define DEBUG(x)		cout << '>' << #x << ':' << x << endl;

const int maxn = 200005 ;
vii graph ( maxn ) ;

void makegraph ( int a , int b ) 
{
	a-- ;
	b-- ;
	graph[a].push_back( b ) ;
	graph[b].push_back( a ) ;
}

int main()
{
	ios_base::sync_with_stdio(0);	
	int n , m ; 
	cin >> n >> m ;
	int a , b;
	rep( i , m ) 
	{
		cin >> a >> b ;
		makegraph(a,b ) ;
	}
	set <int> s1 , s2 ;
	for(int i = 0 ; i < graph[0].size() ; ++i ) 
	{
		s1.insert ( graph[0][i] ) ;
	}
	for(int i = 0 ; i < graph[n-1].size() ; ++i ) 
	{
		s2.insert ( graph[n-1][i] ) ;
	}
	for( auto i : s2 ) 
	{
		int elem = i ; 
		if ( s1.find(elem) != s1.end()) 
		{
			cout << "POSSIBLE\n";
			return 0 ; 
		}
	}
	cout << "IMPOSSIBLE\n";

	return 0 ;
}



Measured memory_bytes: 21360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull ;
const double PI = acos(-1) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
//#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
//#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
ll a[800001],  b[500009], lastcall[800000], value[500000];
string s;
vector<ll>v;
map<ll, ll>mp;
int main()
{
    CIN;
    ll j=1, n, m, k, kk=1, m1=0, a1=8, grtr=0, a2=20, l, t, ds,r,mx=0, cnt=0, mn=INT_MAX, h=0, mod=1e9+7, i; char ch;
    cin>>n;
    for(i=1; i<=n; i++) {
            cin>>a[i]; cnt^=a[i];
    }

    for(i=1; i<=n; i++){
        cout<<(cnt^a[i])<<' ';
    }
    return 0;
}


Measured memory_bytes: 5172
import sys
import math

def soinsu(dic, x):
  i = 2
  while i*i <= x:
    if x % i == 0 and i in dic.keys():
      return False
    
    while x % i == 0:
      dic.setdefault(i, 0)
      dic[i] += 1
      x //= i
      
    i += 1
      
      
  if x == 1:
    return True
  
  if x in dic.keys():
    return False
  
  dic.setdefault(x, 1)
  return True
    

n = int(input())
a = list(map(int,input().split()))
dic = {}

flag = False
for i in range(n):
  if not soinsu(dic, a[i]):
    flag = True
    break

if not flag:
  print("pairwise coprime")
  sys.exit()
  
tmp = a[0]
for i in range(1,n):
  tmp = math.gcd(tmp, a[i])
  
if tmp == 1:
  print("setwise coprime")
else:
  print("not coprime")

Measured memory_bytes: 197220
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    fastio;
    ll t=1;
    while(t--)
    {
        ll x,n,c=0;
        cin>>x;
        n=100;
        while(n<x)
        {
         n+=n/100;
         c++;
        }
        cout<<c<<endl;
    }
}


Measured memory_bytes: 3644
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 10**9
for i in range(N-K+1):
  if A[i]*A[i+K-1] <= 0:
    if abs(A[i]) < abs(A[i+K-1]):
      ans = min(ans, (abs(A[i]))*2+A[i+K-1])
    else:
      ans = min(ans, abs(A[i])+A[i+K-1]*2)
  else:
    if abs(A[i]) < abs(A[i+K-1]):
      ans = min(ans, abs(A[i+K-1]))
    else:
      ans = min(ans, abs(A[i]))
print(ans)


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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

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

int main(){
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << x2-y2+y1 << " ";
  cout << y2-x1+x2 << " ";
  cout << x1-y2+y1 << " ";
  cout << y1-x1+x2 << endl;
}

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

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

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


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b;
	string s,t,u;
	cin >>s >>t >>a >>b >>u;
	
	if(s==u) a--;
	if(t==u) b--;
	cout <<a <<" "<<b <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	n=25-n;
	printf("Christmas");
	for(int i=0;i<n;i++)
		printf(" Eve");
	printf("\n");
    return 0;
}


Measured memory_bytes: 256