akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int MyABS( int x, int y )
{
	return ( x < y ? y - x : x - y );
}

int main()
{
	int a, b, c, d, e, k;
	std::cin >> a >> b >> c >> d >> e >> k;

	int ab, ac, ad, ae;
	int bc, bd, be;
	int cd, ce;
	int de;

	ab = MyABS( a, b );
	ac = MyABS( a, c );
	ad = MyABS( a, d );
	ae = MyABS( a, e );
	bc = MyABS( b, c );
	bd = MyABS( b, d );
	be = MyABS( b, e );
	cd = MyABS( c, d );
	ce = MyABS( c, e );
	de = MyABS( d, e );

	bool bConnect = true;
	if ( ab > k )
	{
		bConnect = false;
	}

	if ( ac > k )
	{
		bConnect = false;
	}

	if ( ad > k )
	{
		bConnect = false;
	}

	if ( ae > k )
	{
		bConnect = false;
	}

	if ( bc > k )
	{
		bConnect = false;
	}

	if ( bd > k )
	{
		bConnect = false;
	}

	if ( be > k )
	{
		bConnect = false;
	}

	if ( cd > k )
	{
		bConnect = false;
	}

	if ( ce > k )
	{
		bConnect = false;
	}

	if ( de > k )
	{
		bConnect = false;
	}

	if ( bConnect )
	{
		std::cout << "Yay!" << std::endl;
	}
	else
	{
		std::cout << ":(" << std::endl;
	}

	return ( 0 );
}


Measured memory_bytes: 256
A = 1
B = 0
C = 0
while True:
    try:
        x = list(map(str,input().split(',')))
    except EOFError:
        break
    x.sort()
    if x [0] == 'A' and x [1] == 'B':
        A,B = B,A
    elif x [0] == 'A' and x [1] == 'C':
        A,C = C,A
    else:
        B,C = C,B

if A:
    print('A')
elif B:
    print('B')
else:
    print('C')

Measured memory_bytes: 7448
#include <bits/stdc++.h>
 
using namespace std;
 
const long long mod = 1e9 + 7ll ;
 
long long modpower(long long a , long long b)
{
    if(b == 0)
        return 1ll ;
    long long x = modpower(a , b / 2ll) ;
    x = (x * x) % mod ;
    if(b & 1)
        return (x * a) % mod ;
    return (x % mod) ;
}
 
struct combination
{
    vector<long long>fact , inv ;
    combination(int sz) : fact(sz + 1) , inv(sz + 1)
    {
        fact[0] = 1ll ;
        inv[0] = 1ll ;
        for(long long i = 1 ; i <= sz ; ++i)
        {
            fact[i] = (fact[i-1] * i) % mod ;
            inv[i] = modpower(fact[i] , mod - 2ll) ;
        }
    }
    long long choose(int n , int k) const
    {
        if(k < 0 || n < k)
            return 0 ;
        return ((((fact[n] * inv[k]) % mod) * inv[n - k]) % mod) ;
    }
};
 
combination comb(1e6+5) ;

int main()
{
    ios_base::sync_with_stdio(0) ;
    cin.tie(0) ;
    int x , y ;
    cin>>x>>y ;
    int curx = 0 , cury = 0 , moves = 0 ;
    long long ans = 0ll ;
    for(int i = 0 ; i <= x ; ++i)
    {
        curx = i ;
        cury = 2 * i ;
        if(curx > x || cury > y)
            break ;
        moves = y - cury ;
        curx += 2 * moves ;
        cury += moves ;
        if(curx != x || cury != y)
            continue ;
        ans = (ans + comb.choose(moves + i , i)) % mod ;
    }
    return cout<<ans<<"\n" , 0 ;
}

Measured memory_bytes: 15872
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
    string s;
    cin>>s;
    int ans=0;
    rep(i,4){
        
        if(s[i]=='+')ans++;
        else{ans--;}
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import itertools
import numpy as np

num = int(input())
x = []
y = []
for i in range(num):
  x_N, y_N = map(int, input().split())
  x.append(x_N)
  y.append(y_N)

index = [str(i) for i in range(num)]
index_permut = list(itertools.permutations(index))

distance_all = 0
for l in index_permut:
  distance = 0
  index = list(map(int, l))

  for pos in range(num-1):
    x_diff = (x[index[pos+1]] - x[index[pos]]) ** 2
    y_diff = (y[index[pos+1]] - y[index[pos]]) ** 2
    distance += np.sqrt(x_diff + y_diff)

  distance_all += distance
res = distance_all / len(index_permut)
print(res)

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

int main(){

int c=2;
string s;
cin >> s;
if(s=="RRR") c=3;
if(s=="SRS"||s=="RSR"||s=="RSS"||s=="SSR") c=1;
if(s=="SSS") c=0;
cout << c << endl;

}

Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderB
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();

        bool[,] opens = new bool[n, 10];
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                opens[i, j] = sc.NextLong() == 1;
            }
        }

        long[,] prices = new long[n, 11];
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < 11; j++)
            {
                prices[i, j] = sc.NextLong();
            }
        }

        long answer = long.MinValue;

        for (int i = 1; i < Math.Pow(2, 10); i++)
        {
            long[] count = new long[n];
            for (int j = 0; j < 10; j++)
            {
                if ((1 & (i >> j)) == 1)
                {
                    for (int k = 0; k < n; k++)
                    {
                        if (opens[k, j])
                        {
                            count[k]++;
                        }
                    }
                }
            }
            long sum = 0;
            for (int j = 0; j < n; j++)
            {
                sum += prices[j, count[j]];
            }
            answer = Math.Max(answer, sum);
        }

        Console.Write(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28756
#include<stdio.h>
int main(void)
{
	int r,g,b,x,y,z;
	scanf("%d %d %d",&r,&g,&b);
	r=r*100;
	g=g*10;
	x=r+g+b;
	y=x%4;
	if(y==0){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;


int main(){
    ll N, K; cin >> N >> K;
    string S; cin >> S;
    ll num=0;
    for(int i = 0; i < N-1; i++) if(S[i] == 'R' && S[i+1] == 'R') num++;
    for(int i = N-1; i > 0; i--) if(S[i] == 'L' && S[i-1] == 'L') num++;
    cout << min(num+2*K, N-1) << endl;

}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

int main() {
    SS(ll,n)
    if(n%2==0)p(n/2);
    else p(n/2+1);
    


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int result = 0;
        result += n * (n-1) / 2;
        result += m * (m-1) / 2;
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N,K;
    cin >> N >> K;
    lint A[N];
    rep(i,N) cin >> A[i];
    sort(A,A+N);
    lint ans=0;
    rep(i,K) ans+=A[i];
    cout << ans << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string s;
  cin >> s;
  int ans[100005] = {};
  int sum, gu, ki;
  sum = gu = ki = 0;
  rep(i, s.size()){
    if(s[i] == 'R'){
      sum ++;
      if(sum % 2 == 0){
	gu ++;
      } else {
	ki ++;
      }
    } else {
      ans[i - 1] += ki;
      ans[i] += gu;
      ki = gu = sum = 0;
    }
  }
  for(int i = s.size() - 1;i >= 0;i --){
    if(s[i] == 'L'){
      sum ++;
      if(sum % 2 == 0){
	gu ++;
      } else {
	ki ++;
      }
    } else {
      ans[i] += gu;
      ans[i + 1] += ki;
      gu = ki = sum = 0;
    }
  }
  rep(i, s.size()){
    cout << ans[i];
    if(i == s.size() - 1){
      cout << '\n';
    } else {
      cout << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 1104
#include<stdio.h>
int main(){
  int n,i,j,total,ans;
  int a[5000];
  while(1){
    scanf("%d",&n);
    ans = -100000000;
    if(n==0) break;
    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
      total = 0;
      for(j=i;j<n;j++){
	total += a[j];
	if(total > ans){
	  ans = total;
	}
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

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

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

    // x, yをソート
    vector<pair<int, int>> xy(N);
    vector<pair<int, int>> yx(N);
    for (int i = 0; i < N; ++i) {
        xy[i] = make_pair(x[i], y[i]);
        yx[i] = make_pair(y[i], x[i]);
    }
    sort(xy.begin(), xy.end());
    sort(yx.begin(), yx.end());
    for (int i = 0; i < N; ++i) {
        x[i] = xy[i].first;
        y[i] = yx[i].first;
    }

    // mapで探索済みか管理
    map<pair<int, int>, int> mp;
    for (int i = 0; i < N; ++i) {
        mp[xy[i]] = 0;
    }

    ll ans = 0; // 操作後の点の数
    set<int> setX;
    set<int> setY;
    stack<pair<int, int>> st;
    stack<int> coY; // stの点とx座標が同じ点のy座標
    for (int i = 0; i < N; ++i) {
        if(mp[xy[i]] == 0){
            st.push(xy[i]);
            while (! st.empty()){
                while (! st.empty()){
                    auto top = st.top();
                    st.pop();
                    if(setX.count(top.first) == 0){
                        setX.insert(top.first);
                        auto iter1 = lower_bound(x.begin(), x.end(), top.first);
                        auto iter2 = upper_bound(x.begin(), x.end(), top.first);
                        for (int j = iter1 - x.begin(); j < iter2 - x.begin(); ++j) {
                            if(mp[xy[j]] == 0){
                                mp[xy[j]] = 1;
                                coY.push(xy[j].second);
                            }
                        }
                    }
                }
                while (! coY.empty()){
                    int top = coY.top();
                    coY.pop();
                    if(setY.count(top) == 0){
                        setY.insert(top);
                        auto iter1 = lower_bound(y.begin(), y.end(), top);
                        auto iter2 = upper_bound(y.begin(), y.end(), top);
                        for (int j = iter1 - y.begin(); j < iter2 - y.begin(); ++j) {
                            pair<int, int> rev = make_pair(yx[j].second, yx[j].first);
                            if(mp[rev] == 0){
                                mp[rev] = 1;
                                st.push(rev);
                            }
                        }
                    }
                }
            }

            ll temp = setX.size();
            temp *= setY.size();
            ans += temp;
            setX.clear();
            setY.clear();
        }
    }

    ans -= N;
    cout << ans;
    return 0;
}

Measured memory_bytes: 13568
#include<stdio.h>
#include<string.h>
#include <iostream>
#include<algorithm>
using namespace std;
 
typedef long long LL;
 
const int INF = 0x3f3f3f3f;
const int maxn = 100 + 10;
LL F[maxn][maxn];
LL P[maxn][maxn];
LL D[maxn];
 
int main()
{
    LL n;
    while(scanf("%lld",&n) == 1)
    {
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= 10; j++)
                scanf("%lld",&F[i][j]);
 
        for(int i = 1; i <= n; i++)
            for(int j = 0; j <= 10; j++)
                scanf("%lld",&P[i][j]);
 
        LL Max = -1 * INF;
        for(int s = 1; s < (1 << 10); s++)
        {
            for(int i = 1; i <= n; i++)
            {
                D[i] = 0;
                for(int j = 1; j <= 10; j++)
                {
                    if((F[i][j] << (j - 1)) & s) D[i]++;
                }
            }
 
            LL ans = 0;
            for(int i = 1; i <= n; i++)
                ans += P[i][D[i]];
 
            Max = max(Max,ans);
        }
        cout<< Max <<endl;
    }
}

Measured memory_bytes: 3868
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,k,a[200000];
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int ub=mod*mod,lb=-(mod*mod);
    while(ub-lb>1){
        int mid=(ub+lb)/2,cnt=0;
        for(int i=0;i<n;i++){
            if(a[i]>0)
                cnt+=upper_bound(a,a+n,(long double)mid/a[i])-a;
            else if(a[i]<0)
                cnt+=n-(lower_bound(a,a+n,(long double)mid/a[i])-a);
            else if(mid>=0)
                    cnt+=n;
            if(a[i]*a[i]<=mid)
                cnt--;
        }
        (cnt>=2*k?ub:lb)=mid;
    }
    cout<<ub<<endl;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int s = 0;
		int temp = n;
		
		for (int i = 9; i >= 0; i--) {
			s += temp / (int)Math.pow(10, i);
			temp = temp % (int)Math.pow(10, i);
		}
		
		System.out.println(n % s == 0 ? "Yes" : "No");
	}
}

Measured memory_bytes: 21844
//**KEEP IT SHORT AND SIMPLE**
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a)* (b)).imag()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
typedef tuple<ll, ll, ll> line;
typedef complex<double> point;
const double pi = 2 * acos(0.0);
const int OO = 0x3f3f3f3f;
int main()
{
    IO
    ll a, b, t;
    cin >> a >> b >> t;
    ll x = (t + 0.5) / a;
    cout << x * b;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX 100001
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;
}



 
int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    int ans = INT_MAX;
    for (int i = 0; i < n - m + 1; i++) {
        int cnt = 0;
        for (int j = 0; j < m; j++) {
            if (s.at(i + j) != t.at(j)) {
                cnt++;
            }
        }
        chmin(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b;
    
    scanf("%d %d", &a, &b);
    if (a<b) {
        printf("a < b\n");
    }
    else if (a>b){
        printf("a > b\n");
    }
    else if (a==b){
        printf("a == b\n");
    }
    
    return 0;
}

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


int abs(int a){
	if(a<0){
		return -a;
	}
	return a;
}
int dfs(int index,vector<int>&vec,vector<int>&dp,int k){
	int n=vec.size();
	if(index==n-1){
		return 0;
	}
	if(index==n-2){
		dp[index]=abs(vec[n-1]-vec[n-2]);
		return dp[index];
	}
	if(dp[index]!=-1){
		return dp[index];
	}

	int ans=INT_MAX;
	for(int i=1;i<=k && index+i<n;i++){
		int p=abs(vec[index+i]-vec[index]);
		int temp=p+dfs(index+i,vec,dp,k);
		ans=min(ans,temp);
	}
	
	dp[index]=ans;
	return dp[index];
}
int32_t main(){
	int n,k;
	cin>>n>>k;
	vector<int> vec(n);
	for(int i=0;i<n;i++){
		cin>>vec[i];
	}
	vector<int> dp(n,-1);
	// dfs(0,vec,dp);
	cout<<dfs(0,vec,dp,k);
	return 0;
}


Measured memory_bytes: 10368
import collections

N,K,Q=map(int, input().split())
List=[int(input()) for i in range(Q)]
cc=collections.Counter(List)

points=[K-Q for i in range(N)]
for j in range(N):
    points[j]+=cc[j+1]

for p in points:
    if p>0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 15096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int pair(int num) {
  return (num * (num - 1) / 2);
}

int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);

  printf("%d\n", pair(n) + pair(m));

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
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; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if (a > b) {
		cout << 0 << endl;
		return 0;
	}
	if (n == 1) {
		if (a != b) cout << 0 << endl;
		else cout << 1 << endl;
		return 0;
	}
	if (n == 2) {
		cout << 1 << endl;
		return 0;
	}
	else {
		ll mini = a * (n - 1) + b;
		ll maxi = b * (n - 1) + a;
		cout << maxi - mini + 1 << endl;
	}
	return 0;
}

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

int main(int argc, char const *argv[])
{
    // 頂点数
    int cnt_vertex(0);

    cin >> cnt_vertex;
    vector<vector<int>> vecGraph(cnt_vertex,vector<int>(cnt_vertex,0));

    int num_vertex(0), cnt_exit_vertex(0);

    for (int i = 0; i < cnt_vertex; i++)
    {
        cin >> num_vertex >> cnt_exit_vertex;
        int num_next_vertex(0);
        for (int j = 0; j < cnt_exit_vertex; j++)
        {
            cin >> num_next_vertex;
            // cout << endl;
            // cout << cnt_vertex << endl;
            vecGraph[i][num_next_vertex-1] = 1;
        }
    }

    for (int i = 0; i < cnt_vertex; i++)
    {
        for (int j = 0; j < cnt_vertex; j++)
        {
            if(j == cnt_vertex-1) {
                cout << vecGraph[i][j] << "\n";
            } else {
                cout << vecGraph[i][j] << " ";
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <algorithm>

using std::cout;
using std::endl;
using std::cin;
using std::max;

long calculateRemaining(long initial, long time)
{
  long result =  max(initial - time, 0L);
  return result;
}

int main() {

  long X;
  long t;

  cin >> X >> t;

  long remaining = calculateRemaining(X, t);

  cout << remaining << endl;

  return 0;
}


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

m = N//K 
if m == 0:
    a = N
    b = abs(a-K)
    while b < a:
        a = min(a,b)
        b = abs(a-K)
else:
    a = N
    b = abs(a-K*m)
    while b < a:
        a = min(a,b)
        b = abs(a-K)

print(a)    

Measured memory_bytes: 3064
import math,sys

n,p=map(int,sys.stdin.readline().split())
limit = int(p ** (1/n))+1
if limit==1:
    print(1)
elif n==1:
    print(p)
else:
    cnt,ans=0,1

    while p % 2 == 0:
        p /= 2
        cnt += 1
    ans *= pow(2, cnt//n)
    
    for div in range(3, limit, 2):
        cnt = 0
        while p % div == 0:
            cnt += 1
            p /= div
        if cnt >= n:
            ans *= pow(div, cnt // n)
    print(ans)

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    int A, B, C;
    cin >> A >> B >> C;

    cout << max(C-(A-B), 0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MAXN 200005
#define REP(temp, init_val, end_val) for (int temp = init_val; temp <= end_val; ++temp)
#define REPR(temp, init_val, end_val) for (int temp = init_val; temp >= end_val; --temp)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while (c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
inline int lowbit(int x){
    return x & (-x);
}
inline int modadd(int x, int y){
    return (x + y >= MOD ? x + y - MOD: x + y);
}
inline int sgn(int x){
    return (x < 0 ? -1: (x > 0 ? 1: 0));
}
template<typename T>
T gcd(T a, T b){
    return (!b) ? a: gcd(b, a % b);
}
int poww(int a, int b){
    int res = 1;
    while (b > 0){
        if (b & 1) res = 1ll * res * a % MOD;
        a = 1ll * a * a % MOD, b >>= 1;
    }
    return res;
}
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
const int ddx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, ddy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/

int n;
int fac[1000005], inv[1000005], invfac[1000005];
int f[1000005] = {0};
void init(){
    n = read();
    fac[0] = fac[1] = 1;
    inv[1] = 1;
    invfac[0] = invfac[1] = 1;
    for (int i = 2; i <= n; ++i){
        fac[i] = 1ll * fac[i - 1] * i % MOD;
        inv[i] = 1ll * (MOD - MOD / i) * inv[MOD % i] % MOD;
        invfac[i] = 1ll * invfac[i - 1] * inv[i] % MOD;
    }
}
inline int C(int nn, int mm){
    return 1ll * fac[nn] * invfac[mm] % MOD * invfac[nn - mm] % MOD;
}
void solve(){
    int hf = n >> 1;
    for (int i = hf; i >= 1; --i)
        f[i] = 1ll * C(n - i - 1, i - 1) * fac[n - i] % MOD, 
        f[i] = 1ll * f[i] * fac[i - 1] % MOD;
    for (int i = 1; i < hf; ++i)
        f[i] = modadd(f[i], MOD - f[i + 1]);
    int ans = 0;
    for (int i = 1; i <= hf; ++i)
        ans = modadd(ans, 1ll * (n - i) * f[i] % MOD);
    printf("%d\n", ans);
}
int main(){
    int T = 1;
    while (T--){
        init();
        solve();
    }
    return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a < 2 * b) {
		cout << 0 << endl;
	}
	else {
		cout << a - b * 2 << endl;
	}

}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N;
    cin >> N;
    vector<int> a(N+1,0);
    FOR(i,1,N+1) cin >> a[i];
    ll ans = 0;
    ll now = 0;
    REP(i,N+1) {
        if (a[i]==now) {
            now++;
            continue;
        }
        ans++;
    }
    if (ans==N) ans=-1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define endl  '\n'
#define ll long long
using namespace std;

int main() {
	ios::sync_with_stdio(0);cin.tie(0), cout.tie(0);
   	int n;cin>>n;
   	vector<int>a(n,0);
   	for(int i=0;i<n;i++)
   	cin>>a[i];
   	sort(a.begin(),a.end(),greater<int>());
   	ll ans=0;
	for(int i=0,j=0;i<n;i+=2,j++)
	{
		if(i+1==n)ans+=a[j];
		else ans+=a[j]*2; 
	}
	cout<<ans-a[0];
    return 0;
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	int t=1;
	while(t--)
	{
		int n;
		cin >> n;
		cout << n*(n-1)/2;
	}
}




Measured memory_bytes: 3624
/*
AtCoder Beginner Contest 086 A - Product
Ver1

結果:
*/

#include<stdio.h>
#define DEBUG1

int main() {

	int a, b, y;

	scanf("%d %d", &a, &b);
	y = (a*b) % 2;

	if(y == 0) {
		puts("Even");
	}
	else {
		puts("Odd");
	}
//	getch();
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;

const ll MOD = 1000000007;

ll powMod(ll n, ll p) {
	if (p == 0) return 1;
	if (p == 1) return n;
	ll e = powMod(n, p / 2);
	e = (e * e) % MOD;
	if (p & 1)
		e = (e * n) % MOD;
	return e;
}

int main() {FIN
	
	ll h, w, a, b, n, m, i, j, c = 0;
	cin >> h >> w >> a >> b;
	n = (h - a - 1) + b;
	m = a + (w - b - 1);
	vll cmb(n + 1), mt(m + 1);
	cmb[0] = cmb[n] = 1;
	for (i = 1; i <= n / 2; i++) {
		cmb[i] = (((cmb[i - 1] * (n - i + 1)) % MOD) * powMod(i, MOD - 2)) % MOD;
		cmb[n - i] = cmb[i];
	}
	
	mt[0] = mt[m] = 1;
	for (i = 1; i <= m / 2; i++) {
		mt[i] = (((mt[i - 1] * (m - i + 1)) % MOD) * powMod(i, MOD - 2)) % MOD;
		mt[m - i] = mt[i];
	}
	
	c = 0; j = a;
	for (i = b; i <= min(n, w); i++)
		c = (c + (cmb[i] * (j <= m ? mt[j++] : 0)) % MOD) % MOD;
	
	cout << c << "\n";
	
	return 0;
}


Measured memory_bytes: 4768
#include <stdio.h>

int main() {
    int k;

    scanf("%d", &k);

    if (k%2 == 0) {
        printf("%d\n", (k/2) * (k/2));
    } else {
        printf("%d\n", (k/2) * (k/2 + 1));
    }

    
    return 0;
}

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

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define pi 3.1415926536
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

vector<pair<int, int>> grp[100005];
int vis[100005], ans[100005];

void dfs(int x, int clr)
{
    vis[x] = 1;
    ans[x] = clr;
    for (auto n : grp[x])
    {
        if (!vis[n.F])
        {
            if (n.S & 1)
                dfs(n.F, 1 - clr);
            else
                dfs(n.F, clr);
        }
    }
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i)
    {
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        grp[u].pb(make_pair(v, w));
        grp[v].pb(make_pair(u, w));
    }
    dfs(1, 0);
    for (int i = 1; i <= n; ++i)
        cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
long long int INF = 1e9 + 1;

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

    multiset<long long int> small, large;
    small.insert(-INF);
    large.insert(INF);
    long long int sum1 = 0, sum2 = 0, sum3 = 0;

    for(int i=0; i<q; i++){
        int type;
        long long int a, b;
        cin >> type;
        
        if(type == 1){
            cin >> a >> b;
            sum3 += b;

            long long int s = *prev(small.end());
            long long int l = *large.begin();

            if(small.size() == large.size()){
                if(a > l){
                    large.erase(large.find(l)); large.insert(a);
                    small.insert(l);
                    sum1 += l;
                    sum2 += a - l;
                }
                else{
                    small.insert(a);
                    sum1 += a;
                }
            }
            else if(small.size() != large.size()){
                if(a < s){
                    small.erase(small.find(s)); small.insert(a);
                    large.insert(s);
                    sum1 += a - s;
                    sum2 += s;
                }
                else{
                    large.insert(a);
                    sum2 += a;
                }
            }
        }
        if(type == 2){
            long long int xmin = *prev(small.end());
            cout << xmin << " ";

            long long int ans = -sum1 + sum2 + sum3;
            if(small.size() == large.size()) cout << ans << endl;
            if(small.size() != large.size()) cout << ans + xmin << endl;
        }

        /*
        cout << "small : ";
        for(auto ss : small) cout << ss << " ";
        cout << endl << "large : ";
        for(auto ll : large) cout << ll << " ";
        cout << endl;
        */
    }
    return 0;
}

Measured memory_bytes: 12956
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;

struct Node{
    ll size;
    ll repeat;
    string s;
    vector<Node> v;
    Node(){
        size = 0;
        repeat = 0;
        s = "";
    }
    Node(ll size, ll repeat, string s){
        this->size = size;
        this->repeat = repeat;
        this->s = s;
    }
};

ll fetch(const string &s, ll index){
    ll po = 1;
    for(ll i = index + 1; i < s.size(); i++){
        if(s[i] == '(') po++;
        else if(s[i] == ')') po--;
        if(!po) return i;
    }
}

Node dfs(const string &s){
    ll num = 0;
    string t = "";
    Node ret(0, 1, "");
    auto f = [&]{
        if(t != ""){
            ret.v.push_back(Node(t.size(), 1, t));
            t = "";
        }
    };

    for(ll i = 0; i < s.size(); i++){
        if('0' <= s[i] && s[i] <= '9'){
            f();
            num = 10 * num + s[i] - '0';
        }else if('A' <= s[i] && s[i] <= 'Z'){
            for(ll j = 0; j < max<ll>(1, num); j++) t += s[i];
            num = 0;
        }else if(s[i] == '('){
            f();
            ll fe = fetch(s, i);
            Node tmp = dfs(s.substr(i + 1, (fe - 1) - (i + 1) + 1));
            tmp.repeat = max<ll>(1, num);
            i = fe;
            num = 0;
            ret.v.push_back(tmp);
        }
    }
    if(t != "") f();
    for(auto child : ret.v){
        ret.size += child.size * child.repeat;
        if(ret.size > 1000002) ret.size = 1000002;
    }
    if(ret.size < 1000002) ret.size = ret.repeat * (ret.size + ret.s.size());
    return ret;
}

char solve(const Node &n, ll i){
    if(n.s.size() > i) return n.s[i];
    for(auto child : n.v){
        if(child.size * child.repeat <= i){
            i -= child.size * child.repeat;
        }else{
            return solve(child, i % child.size);
        }
    }
    //return n.s[i];
}

int main(){
    while(1){
        string S;
        ll I;
        cin >> S >> I;
        if(S == "0" && !I) break;
        S = "(" + S + ")";
        auto node = dfs(S);
        if(node.size <= I) cout << 0 << endl;
        else cout << solve(node, I) << endl;
    }
    return 0;
}



Measured memory_bytes: 3176
import math

def distance(a,b,D):
    sum = 0
    for i in range(D):
        sum += (a[i]-b[i]) ** 2
    tmp = math.sqrt(sum)
    if tmp % 1 == 0:
        return 1
    else:
        return 0 

N,D = map(int,input().split())
X = []
count = 0

for i in range(N):
    tmp = list(map(int,input().split()))
    X.append(tmp)

for i in range(N-1):
    for j in range(i+1,N):
        #点iと点j間の距離を求める
        count += distance(X[i],X[j],D)

print(count)

Measured memory_bytes: 3064
n = gets.chomp.to_i
ary1 = gets.chomp.split("")
ary2 = [0,ary1[0..n-1]].flatten
#p ary1
#p ary2
if n ==1
  puts 1
else
p ary1.zip(ary2).select{|elem| elem[0] !=elem[1]}.length
end

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    REP(i,5){
        ll a ;
        cin >> a ;
        if(a!=i+1){
            cout << i + 1 <<endl;
        }
    }

    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int ans=0;
  int n;cin>>n;
  int mx=0;
  for(int i=0;i<n;i++){
    int t;cin>>t;
    if(t>=mx){
      ans++;
      mx = max(t,mx);
    }
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(a) cout<<#a<<":"<<a<<endl;
const int INF=0x3f3f3f3f;
const int N=1e6+7;
const int mod=1e9+7;
int maxn,minn;
int T,n;
int arr[N];
int dp[N];

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",arr+i);
	} 
	dp[1]=0;
	dp[2]=abs(arr[2]-arr[1]); 
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	cout<<dp[n]<<endl; 
		

	return 0;
}





Measured memory_bytes: 4736
data = input().split()
for i in range(len(data)):
  data[i] = int(data[i])
K = int(input())
for i in range(K):
  if data[0] >= data[1]:
    data[1] = data[1]*2
  elif data[1] >= data[2]:
    data[2] = data[2]*2
if data[0] >= data[1]:
  print('No')
elif data[1] >= data[2]:
  print('No')
else:
  print('Yes')

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

#define LL long long

#define FOR(INDEX, START, END) for (int INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (int INDEX = 0; INDEX < (COUNT); ++INDEX)

struct Range {
    LL L;
    LL R;
};

template <class T>
class Array2D {
public:
    Array2D(LL w, LL h, T v = T()) {
        m_vec.resize(w * h, v);
        m_width = w;
        m_height = h;
    }
    
    T& at(LL x, LL y) {
        return m_vec[y * m_width + x];
    }
    
    T const& at(LL x, LL y) const {
        return m_vec[y * m_width + x];
    }
    
    LL width() const {
        return m_width;
    }

    LL height() const {
        return m_height;
    }

private:
    vector<T> m_vec;
    LL m_width;
    LL m_height;
};

template <class T>
class TotalArray2D : public Array2D<T> {
public:
    TotalArray2D(Array2D<T> const& values) : Array2D<T>(values.width(), values.height(), T()) {
        for (LL y = 0; y < values.height(); ++y) {
            for (LL x = 0; x < values.width(); ++x) {
                LL total = 0;
                total += values.at(x, y);
                if (x > 0) {
                    total += this->at(x - 1, y);
                }
                if (y > 0) {
                    total += this->at(x, y - 1);
                }
                if (x > 0 && y > 0) {
                    total -= this->at(x - 1, y - 1);
                }
                this->at(x, y) = total;
            }
        }
    }
    
    // left <= x < right, top <= y < bottom の範囲の総和
    T total(LL left, LL top, LL right, LL bottom) const {
        T total = T();

        if (right > 0 && bottom > 0) {
            total += this->at(right - 1, bottom - 1);
        }
        if (left > 0 && bottom > 0) {
            total -= this->at(left - 1, bottom - 1);
        }
        if (right > 0 && top > 0) {
            total -= this->at(right - 1, top - 1);
        }
        if (left > 0 && top > 0) {
            total += this->at(left - 1, top - 1);
        }
        
        return total;
    }
};


int main()
{
    LL N, M, Q;
    cin >> N >> M >> Q;
    
    vector<Range> trains(M);
    for (int i = 0; i < M; ++i) {
        cin >> trains[i].L >> trains[i].R;
    }

    vector<Range> questions(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> questions[i].L >> questions[i].R;
    }

    Array2D<LL> valueMap(N+1, N+1, 0);
    for (const auto& train : trains) {
        valueMap.at(train.L, train.R) += 1;
    }
    
    TotalArray2D<LL> totalMap(valueMap);
    for (const auto& question : questions) {
        cout << totalMap.total(question.L, 0, N + 1, question.R + 1) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 9600
abcd = list(input())
for x in range(2):
    for y in range(2):
        for z in range(2):
            op1 = '+'
            if x == 0:
                op1 = '-'
            op2 = '+'
            if y == 0:
                op2 = '-'
            op3 = '+'
            if z == 0:
                op3 = '-'
            s = str(abcd[0]) + op1 + str(abcd[1]) + op2 + str(abcd[2]) + op3 + str(abcd[3])
            if eval(s) == 7:
                print(s + '=7')
                break
        else:
            continue
        break
    else:
        continue
    break


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
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 powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int n, k;
std::vector<ll> v;
ll x;
int main()
{
	//freopen("D:\\code\\text\\input.txt","r",stdin);
	//freopen("D:\\code\\text\\output.txt","w",stdout);
	n = readint();
	k = readint();
	repd(i, 1, n)
	{
		x = readll();
		v.push_back(x);
	}
	sort(ALL(v), greater<ll>());
	ll ans = 0ll;
	for (auto y : v)
	{
		if (k)
		{
			k--;
		} else
		{
			ans += y;
		}
	}
	printf("%lld\n", ans );
	return 0;
}




Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b,c,k;
  scanf("%d%d%d%d", &a, &b,&c,&k);
  int mx=max(a,max(b,c));
  int sum = a+b+c-mx;
  for(int i=0;i<k;i++){
    mx*=2;
  }
  printf("%d\n", mx+sum);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String O = scanner.next();
        String E = scanner.next();

        scanner.close();

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < O.length(); i++) {
            sb.append(O.charAt(i));
            if (i < E.length()) {
                sb.append(E.charAt(i));
            }
        }
        System.out.println(sb.toString());

    }
}


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

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

int main()
{
    ll i,j;
    ll N;
    cin >> N;
    ll h,w,n;
    for(h = 1;h <= 3500;++h){
        for(w = 1;w <= 3500;++w){
            ll tmp1 = N*h*w;
            ll tmp2 = 4*h*w - N*(w + h);
            if(tmp2 <= 0) continue;
            else if(tmp1%tmp2 == 0){
                ll n = tmp1/tmp2;
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3636