akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
    int a, b, c;
    int x = 0, y = 0;

    while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
        if (a * a + b * b == c * c) {
            x++;
        }
        if (a == b) {
            y++;
        }
    }

    printf("%d\n%d\n", x, y);

    return 0;
}

Measured memory_bytes: 596
def parentNode(k):
    return k // 2

def leftNode(k):
    return 2 * k 

def rightNode(k):
    return 2 * k + 1

H = int(input())
elems = [0] + [int(x) for x in input().split()]

for k in range(1, H+1):
    print(f'node {k}: ', end = '')
    print(f'key = {elems[k]}, ', end = '')
    if parentNode(k) >= 1:
        print(f'parent key = {elems[parentNode(k)]}, ', end = '')
    if leftNode(k) <= H:
        print(f'left key = {elems[leftNode(k)]}, ', end = '')
    if rightNode(k) <= H:
        print(f'right key = {elems[rightNode(k)]}, ', end = '')
    print()



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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

void solve() {
	lli n, m, sum = 0, ans = 0;
	cin >> n >> m;
	
	set<lli> st;
	map<lli,lli> mp;
	vcL num( n, 0 );
	
	for (int i = 0; i < n; ++i) {
		cin >> num[i];
		sum += num[i];
		sum %= m;
		
		if ( st.count(sum) == 0 ) {
			st.insert(sum);
			mp[sum] = 1;
		}
		else {
			mp[sum]++ ;
		}
		
		if ( sum == 0 ) ans++ ;
	}
	
	for (auto x : mp) {
		ans += x.second*(x.second-1)/2;
	}
	
	cout << ans << '\n';
}

int main() {
	precal();
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



Measured memory_bytes: 7936
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    os << "["; 
    for (int i = 0; i < v.size(); ++i) { 
        cout << v[i]; 
        if (i != v.size() - 1) 
            os << ", "; 
    } 
    os << "]"; 
    return os; 
} 
template <typename T> 
ostream& operator<<(ostream& os, const set<T>& v) 
{ 
    os << "["; 
    for (auto it : v) { 
        os << it; 
        if (it != *v.rbegin()) 
            os << ", "; 
    } 
    os << "]"; 
    return os; 
} 
  template <typename T, typename S> 
ostream& operator<<(ostream& os, const map<T, S>& v) 
{ 
    for (auto it : v)  
        cout << it.first << " : " 
           << it.second << "\n"; 
      
    return os; 
} 
template <typename T, typename S> 
ostream& operator<<(ostream& os, const pair<T, S>& v) 
{ 
    os << "("; 
    cout << v.first << ", " 
       << v.second << ")"; 
    return os; 
} 
  
// D

void solve(){
int n,q;
cin>>n;
map<int,int> mp;
int sum = 0;
FOR(i,0,n) {
    int a;
    cin>>a;
    mp[a]++;
    sum+=a;
}
cin>>q;
FOR(i,0,q) {
    int a,b;
    cin>>a>>b;
    debug(a,b);
    int cnt = mp[a];
    sum+=(b*cnt-a*cnt);
    mp[a] = 0;
    mp[b] += cnt;
    cout<<sum<<endl;
}
} 
int32_t main()
{
IOS
int t=1;
// cin>>t;
while(t--) {
    solve();
}

return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

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

int main(){
  int L,R,d,count = 0;
  cin >> L >> R >> d;

  for(int i = L;i <= R; i++){
    if(i%d == 0){
      count += 1;
    }
  }
cout << count <<endl;

  return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <string.h>
#include <cstdlib>
#include <vector>
#include <string>
#include <bitset>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
 
typedef long long ll;
typedef long double ld;
 
const ll MOD = 1e9 + 7, INF = 1e18 + 1;
 
using namespace std;

ll k, n;

vector <ll> a;

ll check (vector <ll>& a)
{
	int x = 0;
	for (int i = 0; i < 50; i++)
		if (a[i] > a[x]) x = i;

	a[x] -= 50;

	if (a[x] < 0) return 0;

	for (int i = 0; i < 50; i++)
		if (x != i) a[i]++;

	return check (a) + 1;
}

int main ()
{
	cin >> k;

	cout << "50\n";

	for (int i = 0; i < 50; i++)
	{
		ll x = 49;

		if (i < k % 50) x = 50;
		else x = 49 - k % 50;
		x += k / 50;

		a.push_back (x);
		cout << x << ' ';
	}

	//cout << check (a);
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    long long int mn=0,an=0,rn=0,cn=0,hn=0,ansm,ansa,ansr;
    int n,i;
    char s[100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",s);
        if(s[0]=='M'){
            mn++;
        }
        if(s[0]=='A'){
            an++;
        }
        if(s[0]=='R'){
            rn++;
        }
        if(s[0]=='C'){
            cn++;
        }
        if(s[0]=='H'){
            hn++;
        }
    }
    ansm=mn*an*rn + mn*an*cn + mn*an*hn + mn*rn*cn + mn*rn*hn + mn*cn*hn;
    ansa=an*rn*cn + an*rn*hn + an*cn*hn;
    ansr=rn*cn*hn;
    printf("%lld\n",ansm+ansa+ansr);
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
char s[300][300];
int main()
{
	LL i;
	for(i=1;i<=3;i++)	scanf("%s",s[i]+1);
	printf("%c%c%c",s[1][1],s[2][2],s[3][3]);
	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);

        while (true) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();

            int sum = m + f;

            String grade = "F";

            if (m == -1 && f == -1 && r == -1) {
                break;
            }

            if (m == -1 || f == -1) {
                grade = "F";
            } else if (sum >= 80) {
                grade = "A";
            } else if (sum >= 65) {
                grade = "B";
            } else if (sum >= 50) {
                grade = "C";
            } else if (sum >= 30) {
                if (r >= 50) {
                    grade = "C";
                } else {
                    grade = "D";
                }
            } else {
                grade = "F";
            }

            System.out.println(grade);
        }

        sc.close();

    }
}


Measured memory_bytes: 26316
#include<bits/stdc++.h>
using namespace std;
#define MAXN	200005
#define PI	acos(-1)
#define EPS	(20 - 5 * PI)
#define EXT	(10 * PI - 20)
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int X1, X2, Y1, Y2, n, m;
int x[MAXN], y[MAXN], home[MAXN];
int value[MAXN], low[MAXN], ans;
bool cmp(int a, int b) {
	return x[a] < x[b];
}
int main() {
	read(X1), read(Y1), read(X2), read(Y2);
	if (X1 > X2) {
		swap(X1, X2);
		swap(Y1, Y2);
	}
	read(m); n = 0;
	for (int i = 1; i <= m; i++) {
		int tx, ty;
		read(tx), read(ty);
		if (tx >= X1 && tx <= X2 && (ty >= Y1 && ty <= Y2 || ty >= Y2 && ty <= Y1)) {
			n++;
			x[n] = tx;
			y[n] = ty;
		}
	}
	for (int i = 1; i <= n; i++) {
		home[i] = i;
		x[i] = x[i] - X1;
		if (Y1 <= Y2) y[i] = y[i] - Y1;
		else y[i] = Y1 - y[i];
	}
	sort(home + 1, home + n + 1, cmp);
	for (int i = 1; i <= n; i++)
		value[i] = y[home[i]] + 1;
	for (int i = 1; i <= n; i++) {
		int l = 0, r = ans;
		while (l < r) {
			int mid = (l + r + 1) / 2;
			if (value[i] > low[mid]) l = mid;
			else r = mid - 1;
		}
		int tans = l + 1;
		if (tans > ans) low[++ans] = value[i];
		else low[tans] = min(low[tans], value[i]);
	}
	int tmp = min(abs(X1 - X2), abs(Y1 - Y2));
	long double finalans = (fabs(X1 - X2) + fabs(Y1 - Y2)) * 100;
	finalans -= EPS * ans;
	if (ans - 1 == tmp) finalans += EXT + EPS;
	printf("%.12Lf", finalans);
	return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c > 21) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}

}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr LL MOD = 924844033LL;
constexpr int MAXN = 2020;
LL dp[MAXN + 1][MAXN + 1], sum[MAXN + 1], factorial[MAXN + 1];
LL dp2[MAXN + 1];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    factorial[0] = 1;
    for (int i = 1; i <= MAXN; i++) {
        factorial[i] = factorial[i - 1] * i % MOD;
    }
    dp[0][0] = sum[0] = 1;
    for (int n = 1; n <= MAXN; n++) {
        for (int i = 0; i <= n; i++) {
            if (i < n) dp[n][i] = sum[n - 1 - i] * 2 - dp[n - 1][i];
            if (i >= 2) dp[n][i] += dp[n - 2][i - 2];
            dp[n][i] %= MOD;
            sum[n - i] = (sum[n - i] + dp[n][i]) % MOD;
        }
    }
    int N, K;
    while (cin >> N >> K) {
        dp2[0] = 1;
        for (int i = 1; i <= N; i++) dp2[i] = 0;
        for (int t = 0; t < K; t++) {
            for (int w = N; w >= 1; w--) {
                LL tmp = 0;
                int AA = t < N % K ? N / K + 1 : N / K;
                for (int i = 0; i <= w && i <= AA; i++) {
                    tmp += dp2[w - i] * dp[AA][i] % MOD;
                }
                dp2[w] = tmp % MOD;
            }
        }
        LL ans = 0;
        for (int i = 0; i <= N; i++) {
            ans += factorial[N - i] * dp2[i] * (i % 2 ? -1 : 1) % MOD;
        }
        ans %= MOD;
        if (ans < 0) ans += MOD;
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 26708
#include<iostream>
#include<vector>
#include<algorithm>
#define F(i,n) for(int i=0;i<n;i++)
#define lli long long int
#define vi vector<int> v
#define vpb(x) v.push_back(x)
#define spb(x) s.push_back(x)
using namespace std;
int ans(vi, int n)
{
    int count=0;
sort(v.begin(),v.end());
for(int i=0;i<n-1;i++)
{
    for(int j=i+1;j<n;j++)
    {
        for(int k=j+1;k<n;k++)
        {
            if(v[i]+v[j]>v[k] and v[i]!= v[j] and v[j]!=v[k])
            {
                // cout<<v[i]<<" "<<v[j]<<" "<<v[k]<<endl;
                count++;
            }
        }
    }
}
return count;
}
int main()
{
   int n; 
   cin>>n;
   if(n<3)
   {cout<<"0";
   exit(0);}
   vi;
   F(i,n)
   {
       int x; cin>>x;
       vpb(x);
   }
   cout<<ans(v,n);
}


Measured memory_bytes: 3200
from collections import deque
h, w, k = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())

g = []
for i in range(h):
    g.append(input())

inf = 10**9
dp = [[inf for j in range(w)] for k in range(h)]
dp[x1-1][y1-1] = 0
q = deque([(x1-1, y1-1)])

while q:
    x, y = q.popleft()
    if (x, y) == (x2-1, y2-1):
        break
    c = dp[x][y]
    for i in range(x+1, min(x+k+1, h)):
        if g[i][y] == "@":
            break

        if dp[i][y] == inf:
           q.append((i, y))

        if dp[i][y] >= c + 1:
            dp[i][y] = c + 1
        else:
            break


    for i in range(x-1, max(x-k-1, -1), -1):
        if g[i][y] == "@":
            break

        if dp[i][y] == inf:
           q.append((i, y))

        if dp[i][y] >= c + 1:
            dp[i][y] = c + 1
        else:
            break

    for j in range(y+1, min(y+k+1, w)):
        if g[x][j] == "@":
            break

        if dp[x][j] == inf:
            q.append((x, j))

        if dp[x][j] >= c + 1:
            dp[x][j] = c + 1
        else:
            break


    for j in range(y-1, max(y-k-1, -1), -1):
        if g[x][j] == "@":
            break

        if dp[x][j] == inf:
            q.append((x, j))

        if dp[x][j] >= c + 1:
            dp[x][j] = c + 1
        else:
            break

if dp[x2-1][y2-1] == inf:
    print(-1)
else:
    print(dp[x2-1][y2-1])


Measured memory_bytes: 150528
import Data.List
main = getLine >>= print . solve . map read . words

solve :: [Int] -> Int
solve [k, s] = foldl' ff1 0 [0..k]
    where
        ff1 acc x = foldl' (ff2 x) acc [0..k]
        ff2 x acc y
            | x + y <= s && s <= x + y + k = acc + 1
            | otherwise = acc


Measured memory_bytes: 764
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<62;
const double pi=acos(-1);
const long double eps=1e-7;
const ll mod=1e6+3;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int x,y,z;

int main(){
	cin>>x>>y>>z;
	cout<<(x-z)/(y+z)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    ++n;
    VL a(n);
    FOR(i, 1, n) {
        cin >> a[i];
        a[i] += a[i - 1];
    }

    ll ans = 0;
    unordered_map<ll, ll> m;
    FOR(i, 0, n) {
        ans += m[a[i]];
        ++m[a[i]];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 10056
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <deque>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){
    string a, b;
    cin>>a;
    cin>>b;
    
    if(a.size()==b.size()){
        if(a>b){
            cout<<"GREATER"<<endl;
        }else if(a<b){
            cout<<"LESS"<<endl;
        }else{
            cout<<"EQUAL"<<endl;
        }
        
    }else{
        if(a.size()>b.size()){
            cout<<"GREATER"<<endl;
        }else{
            cout<<"LESS"<<endl;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long> >
#define mi map<int,int>
#define pi pair<int,int>

#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 pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

using namespace std;
int main() {
    IOS
    int n, c;
    cin >> n >> c;
    vector<int> v(n+1), w(n+1);
    Fori(i, 1, n+1) {
        cin >> w[i] >> v[i];
    }
    //vector<vector<long>>dp(n+1, vector<long>(c+1));
    vvl dp(n+1, vl(c+1));
    //vvi dp(n+1, vi(c+1));
    Fori(i, 0, n+1) {
        Fori(j, 0, c+1) {
            if(j == 0) {
                dp[i][j] = 0;
                continue;
            }
            if(i == 0) {
                dp[i][j] = 0;
                continue;
            }
            if(j - w[i] < 0) {
                dp[i][j] = dp[i-1][j];
                continue;
            }
            dp[i][j] = max(dp[i-1][j],v[i] + dp[i-1][j - w[i]]);
        }
    }
    cout << dp[n][c] << endl;
    return 0;
}

Measured memory_bytes: 83164
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x,y,ans=0;
    cin>>n;
    vector<pair<ll,pair<ll,ll> > > v;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        v.pb(make_pair(x+y,make_pair(x,y)));
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(int i=0;i<n;i++){
        if(i%2==0){
            ans+=v[i].second.first;
        }
        else{
            ans-=v[i].second.second;
        }
    }
    cout << ans<<endl;

    return 0;
}


Measured memory_bytes: 4724
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N;
int64 A,B,S[MAXN];
struct node {
    int sum[2],l,r,cov[2];
}tr[MAXN * 4];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
void update(int u) {
    for(int i = 0 ; i < 2 ; ++i) tr[u].sum[i] = inc(tr[u << 1].sum[i],tr[u << 1 | 1].sum[i]);
}
void cover(int id,int u) {
    tr[u].cov[id] = 1;
    tr[u].sum[id] = 0;
}
void pushdown(int u) {
    for(int i = 0 ; i < 2 ; ++i) {
        if(tr[u].cov[i]) {
            cover(i,u << 1);cover(i,u << 1 | 1);
            tr[u].cov[i] = 0;
        }
    }
}
void build(int u,int l,int r) {
    tr[u].l = l;tr[u].r = r;
    if(l == r) return;
    int mid = (l + r) >> 1;
    build(u << 1,l,mid);
    build(u << 1 | 1,mid + 1,r);
}
void add(int id,int u,int x,int v) {
    if(tr[u].l == tr[u].r) {
        update(tr[u].sum[id],v);return;
    }
    pushdown(u);
    int mid = (tr[u].l + tr[u].r) >> 1;
    if(x <= mid) add(id,u << 1,x,v);
    else if(x > mid) add(id,u << 1 | 1,x,v);
    update(u);
}
void lid(int id,int u,int l,int r) {
    if(tr[u].l == l && tr[u].r == r) {cover(id,u);return;}
    pushdown(u);
    int mid = (tr[u].l + tr[u].r) >> 1;
    if(r <= mid) lid(id,u << 1,l,r);
    else if(l > mid) lid(id,u << 1 | 1,l,r);
    else {lid(id,u << 1,l,mid);lid(id,u << 1 | 1,mid + 1,r);}
    update(u);
}
int Query(int id,int u,int l,int r) {
    if(tr[u].l == l && tr[u].r == r) return tr[u].sum[id];
    pushdown(u);
    int mid = (tr[u].l + tr[u].r) >> 1;
    if(r <= mid) return Query(id,u << 1,l,r);
    else if(l > mid) return Query(id,u << 1 | 1,l,r);
    else {return inc(Query(id,u << 1,l,mid),Query(id,u << 1 | 1,mid + 1,r));}
}
void Solve() {
    read(N);read(A);read(B);
    for(int i = 1 ; i <= N ; ++i) read(S[i]);
    build(1,0,N);
    add(0,1,0,1);add(1,1,0,1);
    for(int i = 2 ; i <= N ; ++i) {
        int t = upper_bound(S + 1,S + N + 1,S[i] - A) - S - 1;
        int va = Query(1,1,0,t);

        t = upper_bound(S + 1,S + N + 1,S[i] - B) - S - 1;
        int vb = Query(0,1,0,t);
        add(0,1,i - 1,va);
        add(1,1,i - 1,vb);
        if(S[i] - S[i - 1] < A) lid(0,1,0,i - 2);
        if(S[i] - S[i - 1] < B) lid(1,1,0,i - 2);
    }
    out(inc(tr[1].sum[0],tr[1].sum[1]));enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo for(int i=0;i<n;i++)
#define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define loopSolve int t; cin>>t; while(t--){solve();}
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//INT_MAX         2,147,483,647                       <10^10
//U_INT_MAX       4,294,967,295                       <10^10
//LONG_LONG_MAX   9,223,372,036,854,775,807           <10^18
//U_LONG_LONG_MAX 18,446,744,073,709,551,615          <10^18
//ll power(int a, int b){
//    return (ll)(pow(a,b)+0.5);
//}

vector<int> gV(int n){
    vector<int> v(n);
    fo { cin>>v[i];  }
    return v;
}

int* gA(int n){
    int* arr = new int[n];
    fo cin>>arr[i];
    return arr;
}



void solve(){
    int k;
    cin>>k;
    map<int,bool> vis;
    int val=7,pos=1;
    while(1){
        if(val%k==0){
            cout<<pos<<endl;
            return;
        }else{
            if(vis[val%k]){
                cout<<-1<<endl;
                return;
            }
            vis[val%k]=true;
            val=(10*val+7)%k;
            pos++;
        }
    }
}


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

    solve();
    //loopSolve;

	return 0;
}


Measured memory_bytes: 50500
using System;

public class GridColoring
{
    public static void Main(string[] args)
    {
        int[] dimension = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int h = dimension[0];
        int w = dimension[1];
        int n = int.Parse(Console.ReadLine());
        int[] occuranceCountArr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

        int[,] result = new int[h, w];
        int rollingPointer = 0;
        for (int i = 0; i < occuranceCountArr.Length; i++)
        {
            int ai = (i + 1);
            int aiCount = occuranceCountArr[i];
            for (int c = 0; c < aiCount; c++)
            {
                int rollingRow = rollingPointer / w;
                int rollingColumn = ((rollingPointer / w) % 2 == 0) ? (rollingPointer % w) : (w - 1 - (rollingPointer % w));
                //Console.WriteLine("rollingPointer = {0}, rollingRow = {1}, rollingColumn = {2}, ai={3}", rollingPointer, rollingRow, rollingColumn, ai);
                result[rollingRow, rollingColumn] = ai;
                rollingPointer++;
            }
        }

        for (int r = 0; r < h; r++)
        {
            for (int c = 0; c < w; c++)
            {
                Console.Write(result[r, c] + " ");
            }
            Console.WriteLine();
        }
    }
}

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

int main(){
  
  int n; cin>>n;
  vector<int> a(n);
  int cnt{};
  for(auto &i:a) {
    cin>>i;
  }
  for(int i=0; i<n; i++){
    int minj = i;
    for(int j=i; j<n; j++){
      if(a.at(j)<a.at(minj)){
        minj = j;
      }
    }
    if(i!=minj){
        swap(a.at(i),a.at(minj));
        cnt++;
      }
  }
  for(int i=0; i<n-1; i++) cout << a.at(i)<<' ';
  cout << a.back() << endl;
  cout << cnt << endl;
}


Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>

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

using namespace std;



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

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

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {

    int X,Y;
    cin >> X >> Y;
    Y /=2;
    cout << X+Y<< endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n, m, k = 0;
  cin >> n >> m;
  for(int i = 1; i < n; i++){
    k = k + i;
  }
  for(int j = 1; j < m; j++){
    k = k + j;
  }
  cout << k << "\n";
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define per(i,n,a) for(ll i=n-1;i>=a;i--)
#define nl "\n"
#define LLMAX 1e18
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define fastread cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
#define online_judge

const ll MOD=1e9+7;

ll pow(ll n, ll e){
  if(e==0)
    return 1;
  else if(e==1)
    return n;
  else if(e%2==0)
    return pow(n,e/2);
  else
    return pow(n,e/2)*n;
}

bool prime(ll n){
  ll ct=0;
  rep(i,2,sqrt(n)+1){
    if(n%i==0)
      return false;
  }
  return true;
}

void solve(){
  fastread;
  ll n,m,temp,mi,q,ma=0,t;
  cin >> n;
  bool a[n];
  memset(a,0,sizeof(a));
  ll sum=1,rem=7%n;
  while(rem && !a[rem]){
    a[rem]=1;
    rem=rem*10+7;
    rem%=n;
    sum++;
    // cout << rem << nl;
  }
  if(!rem)
    cout << sum;
  else
    cout << -1;
}

int main(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
  #endif
  clock_t start, end;
  start = clock();
  solve();
  end=clock();
  double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    cerr << "Time taken by program is : " << fixed  
         << time_taken << setprecision(5); 
    cerr << " sec " << endl;
  return 0;
}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 100;
int n;
double a[maxn], dp[maxn][maxn];
int main()
{
    cin>>n;
    for(int i = 1; i <= n; i++) cin>>a[i];
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= i; j++){
            dp[i][j] += dp[i-1][j-1]*a[i];
        }
        for(int j = 0; j <= i; j++){
            dp[i][j] += dp[i-1][j]*(1-a[i]);
        }
    }
    double ans = 0;
    for(int i = 1; i <= n; i++){
        if(i > n-i) ans += dp[n][i];
    }
    printf("%.20f\n", ans);
}


Measured memory_bytes: 72320
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 100005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,f[65];
char s[2][65];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void Solve() {
    read(N);
    scanf("%s%s",s[0] + 1,s[1] + 1);
    int ans = 0;
    for(int i = 1 ; i <= N ; ++i) {
        if(s[0][i] == s[0][i + 1]) continue;
        if(s[0][i - 1] == s[0][i]) {
            if(i <= 2) ans = 6;
            else {
                if(f[i - 2] == 0) ans = mul(ans,3);
                else if(f[i - 2] == 1) ans = mul(ans,2);
            }
            f[i] = 0;
        }
        else {
            if(i <= 1) ans = 3;
            else {
                if(f[i - 1] == 1) ans = mul(ans,2);
            }
            f[i] = 1;
        }
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,i,j,product=0;
    cin>>n;
    int arr[n];
    for(i=0;i<n;i++)
    cin>>arr[i];
    
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++)
        {
            product+=arr[i]*arr[j];
        }
    }
    cout<<product<<endl;
}

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

#define MAX_N 2000000

int n, A[MAX_N+1];
int B[MAX_N+1], C[MAX_N+1];
int k;

void countingSort() {
  int i;
  memset(C, 0, sizeof(C));
  for(i = 0; i < n; i++) C[A[i]]++;
  for(i = 1; i <= k; i++) C[i] += C[i-1];
  for(i = n-1; i >= 0; i--) B[C[A[i]]--] = A[i];
}

int main() {
  int i;

  scanf("%d", &n);
  k = 0;
  for(i = 0; i < n; i++) {
    scanf("%d", A+i);
    if(A[i] > k) k = A[i];
  }
  countingSort();
  for(i = 1; i <= n; i++) {
    if(i > 1) putchar(' ');
    printf("%d", B[i]);
  }
  puts("");

  return 0;
}

Measured memory_bytes: 24060
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

long long gcd(long long n, long long m)
{
  if (n%m == 0)
  {
    return m;
  }
  else
  {
    return gcd(m, n%m);
  }
}

long long lcm(long long n, long long m)
{
  return n * m / gcd(n, m);
}

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

  long long A_div, B_div;
  A_div = (A-1) / C + (A-1) / D - (A-1) / lcm(C, D);
  B_div = B / C + B / D - B / lcm(C, D);

  cout << (B - B_div) - ((A - 1) - A_div) << endl;
}

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

int main(){
	string a,b;	cin>>a>>b;
	if(a.length()<b.length()) cout<<"LESS"<<endl;
	else if(a.length()>b.length()) cout<<"GREATER"<<endl;
	else{
		if(a<b)cout<<"LESS"<<endl;
		else if(a>b)cout<<"GREATER"<<endl;
		else cout<<"EQUAL"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	int K, N;
	cin >> N >> K;
	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	sort(H.begin(), H.end(), greater<int>());
	long long sum = 0;
	for (int i = K; i < N; i++) sum += H[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4040
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);
		long k = Long.parseLong(str[2]);

		long a[] = new long[n];
		long b[] = new long[m];

		str = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);
		}
		str = br.readLine().split(" ");
		for (int i = 0; i < m; i++) {
			b[i] = Long.parseLong(str[i]);
		}

		ArrayList<Long> s1 = new ArrayList<>();
		ArrayList<Long> s2 = new ArrayList<>();

		s1.add(a[0]);
		s2.add(b[0]);

		for (int i = 0; i < n - 1; i++) {
			s1.add(s1.get(i) + a[i + 1]);
		}
		for (int i = 0; i < m - 1; i++) {
			s2.add(s2.get(i) + b[i + 1]);
		}
		int nowj = m - 1;
		while (nowj >= 0 && s2.get(nowj) > k) {
			nowj--;
		}

		int maxi = n - 1;
		while (maxi >= 0 && s1.get(maxi) > k) {
			maxi--;
		}
		int count = Math.max(nowj + 1, maxi + 1);
		for (int i = 0; i <= maxi; i++) {
			while (nowj >= 0 && s1.get(i) + s2.get(nowj) > k) {
				nowj--;
			}
			if (nowj + 2 + i > count) {
				count = nowj + 2 + i;
			}
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 81012
#include <stdio.h>

int main(void){
    int a,b;
    char op[2];

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

    if(op[0]=='+'){
        printf("%d\n",a+b);
    }else{
        printf("%d\n",a-b);
    }
    return 0;
}


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

int main(){
    long long ans=0,sum=0;
    int n,m;
    cin >>n>>m;
    int x[m],d[m-1];

    cin >>x[0];
    int mn=x[0],mx=x[0];

    for (int i = 1; i < m; i++){
        cin >>x[i];
        mn = min(mn,x[i]);
        mx = max(mx,x[i]);
    }

    sort(x,x+m);

    for (int i = 1; i < m; i++){
        d[i-1] = abs(x[i]-x[i-1]);
    }

    sum = mx-mn;
    sort(d,d+m-1,greater<int>());


    if(n >= m){
        ans = 0;
    }else{
        for (int i = 0; i < n-1; i++){
            sum -= d[i]; 
        }
        ans = sum;
    }



    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 1024
N = input()

ans = ""

while True:
  if abs(N) % 2 == 1:
    ans += "1"
    N -= 1
  else:
    ans += "0"
  N /= -2
  if N == 1:
    ans += "1"
    print(ans[::-1]) 
    break

  if N == 0:
    print (0)
    break


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    ll N;
    std::cin >> N;
    std::vector<ll> A(N);
    REP(i, N) {
        std::cin >> A[i];
        A[i] -= (i + 1);
    }

    SORT(A);

    auto med = A[N / 2];
    ll   ans = 0;
    REP(i, N) {
        A[i] -= med;
        ans  += abs(A[i]);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 1792
//p9t6g
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<bitset>
#include<map>
#include<vector>
#include<set>
#define ll long long
#define db double
#define si short int
#define mem(a) memset(a,0,sizeof(a))
#define maxn
#define maxm
#define inf 0x7fffffff
#define mod
#define eps
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
using namespace std;
ll read(){
	ll a=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){a=a*10+c-'0';c=getchar();}
	return a*f;
}
ll a,b,c;
int main(){
	a=read();
	b=read();
	c=read();
	if(a+b+c>=22)puts("bust");
	else puts("win");
	return 0;
}

Measured memory_bytes: 256
class String:
    def __init__(self,letter):
        self.letter=letter
        self.memory=''
    def println(self,start,end):
        print(self.letter[start:(end+1)])
    def replace(self,start,end,alt):
        self.memory=''
#         obj=self.letter[start:(end+1)]
        if(start!=0 and end!=(len(self.letter)-1)):
            self.memory=self.letter[0:start]+alt+self.letter[(end+1):]
        elif(start==0):
            self.memory=alt+self.letter[(end+1):]
        elif(end==(len(self.letter)-1)):
            self.memory=self.letter[:start]+alt
        self.letter=self.memory
#         self.letter=self.letter.replace(obj,alt)
    def reverse(self,start,end):
        self.memory=''
        if(start==0):
            obj=self.letter[end::-1]
            self.memory=obj+self.letter[(end+1):]
        else:
            obj=self.letter[end:(start-1):-1]
            self.memory=self.letter[0:start]+obj+self.letter[(end+1):]
        self.letter=self.memory
    def check(self):
        return self.letter
    
##main##
val=input()
q=int(input())
my_str=String(val)
for i in range(q):
    command=input().split()
    if(command[0]=="print"):
        my_str.println(int(command[1]),int(command[2]))
    elif(command[0]=="replace"):
        my_str.replace(int(command[1]),int(command[2]),command[3])
    elif(command[0]=="reverse"):
        my_str.reverse(int(command[1]),int(command[2]))




Measured memory_bytes: 5624
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int[] nSecs = new int[4];
    for (int i = 0; i < 3; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      nSecs[a]++;
      nSecs[b]++;
    }

    int numOdds = 0;
    for (int i = 0; i < 4; i++) {
      if (nSecs[i] % 2 == 1) numOdds++;
    }
    if (numOdds == 2) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,k;
  cin>>n>>m>>k;
  int p=998244353;
  vector<int64_t> f(n,1);
  for(int i=1;i<n;i++)
    f.at(i)=f.at(i-1)*i%p;
  vector<int64_t> fi(n,1);
  int q=p-2;
  vector<int> b;
  while(q>0){
    b.push_back(q%2);
    q/=2;
  }
  reverse(b.begin(),b.end());
  for(int i=1;i<n;i++){
    for(int d:b){
      fi.at(i)=fi.at(i)*fi.at(i)%p;
      if(d==1)
        fi.at(i)=fi.at(i)*f.at(i)%p;
    }
  }
  int64_t s=0;
  int64_t a=m;
  for(int i=0;i<n-k-1;i++)
    a=a*(m-1)%p;
  int64_t mp=1;
  for(int i=0;i<=k;i++){
    int64_t c=f.at(n-1)*fi.at(n-1-(k-i))%p*fi.at(k-i)%p;
    s=(s+a*mp%p*c%p)%p;
    mp=mp*(m-1)%p;
  }
  cout<<s<<endl;
}

Measured memory_bytes: 6320
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

int main(){
    double a, b;
    cin >> a >> b;

    cout <<fixed << setprecision(10) <<  1 / (1 / a + 1 / b) << endl;
}


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

int main() {
    string s;
    int cnt = 0;
    cin >> s;
    if (s[0] == '1') cnt++;
    if (s[1] == '1') cnt++;
    if (s[2] == '1') cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int n = sc.nextInt();

		int[] a = new int[n];

		int i = 0;
		while(i < n) {
			a[i] = sc.nextInt();
			i++;
		}

		int distance = a[n-1]-a[0];
		for(i = 1; i < n;i++) {
			distance = Math.min(distance, k - (a[i] -a[i-1]));
		}

		System.out.println(distance);
	}

}

Measured memory_bytes: 65052
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>

using namespace std;

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

#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))

#define pb push_back
#define mp make_pair

#define ALL(a) (a).begin(), (a).end()

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#define INF 1001001001
#define LLINF 1001001001001001001LL

typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

#define PQ priority_queue

#define FST first
#define SEC second

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

//------------------HEAD---------------------

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c;
    a=1;
    b=-INF;
    c=-INF;

    int n;
    cin>>n;

    int f;

    cin>>f;
    int ans=a;
    FOR(i,1,n){
        f=!f;
        int t;
        cin>>t;
        if(f==t){
          ++a;
        }else{
            f=t;
            ans=max(ans,max(a,0)+max(b,0)+max(c,0));
            swap(a,b);swap(b,c);
            a=1;
        }
    }
    ans=max(ans,max(a,0)+max(b,0)+max(c,0));
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}


int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    ll a;
    double  b;
    cin>>a>>b;
    ll x = b;
    //cout<<x<<endl;
    ll ans = a*x;
    string s = "";
    s = to_string(b);
    //cout<<s<<endl;
    ll y =0;
    bool fl=false;
    int c=0;
    for(ll i=0;i<s.length() and c<=2; i++){
        if(!fl){
            if(s[i]=='.'){
                fl=true;
                c++;
            }
            continue;
        }
        y = y*10 + (s[i]-'0');
        c++;
    }
    //cout<<y<<endl;
    y *= a;
    y/=100;
    ans += y;
    cout<<ans<<endl;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A>>B;
  double N=A/0.08;
  int M=(int) N;
  for(int i=0;i<=13;i++){
    if((int)((M+i)*0.08)==A and (int)((M+i)*0.1)==B){
      cout << M+i <<endl;
      break;
    }
    else if(i==13){
      cout << -1<<endl;
    }
  }
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

int N;
int main()
{
	cin>>N;
	cout<<N/3<<endl;
}

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

keymax = 10**6
keymin = 0
for i in range(M):
	if X[i][0] > keymin:
		keymin = X[i][0]
	if X[i][1] < keymax:
		keymax = X[i][1]

if keymax >= keymin:
	print(keymax-keymin+1)
else:
	print("0")

Measured memory_bytes: 27332