akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  if(n%2==0) {
    coutd(1.0*n/2/n);
  }
  else {
    coutd((1.0*(n+1)/2)/n);
  }
}


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

#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 1000000


int n,M[100][100],color[100],d[100],p[100];


int prim(){
  int i,u;
  
  for( i = 0; i < 100; i++ ){ 
    color[i] = WHITE;
    d[i] = INFTY;
    p[i] = -1;   
  }

  d[0] = 0;
 
  while(1){
    u = -1;
    int mincost = INFTY;
    
    for( i = 0; i < n; i++ ){
      if( color[i] != BLACK && d[i] < mincost ){
	mincost = d[i];
	u = i;
      }
    }
    
    if( u == -1 ) break;

    color[u] = BLACK;

    for( int v = 0; v < n; v++ ){
      if( color[v] != BLACK && M[u][v] != INFTY ){
	if( M[u][v] < d[v] ){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  int sum = 0;
  for( i = 0; i < n; i++ ){
    if( p[i] != -1 ) sum+= M[i][p[i]];
  }
  return sum;
}

int main(){
  int i,j;
  //,n;
    
  cin >> n;
  for( i = 0; i < n; i++ ){
    for( j = 0; j < n; j++ ){
      cin >> M[i][j];
      if( M[i][j] == -1 ) M[i][j] = INFTY;
    }
  }

  cout << prim() << endl;

  return 0;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
 
using namespace std;
  
int main(){
  int N, K;
  cin >> N >> K;
  
  int ans = 0;
  while(N > 0){
    N /= K;
    ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    x, y = map(int, input().split())
    ans = 0
    for i in range(101):
        for j in range(101):
            if 2 * i + 4 * j == y and i + j == x:
                ans = 1
    print("Yes" if ans else "No")
                
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 38764
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string str1,str2;
    cin>>str1>>str2;
    ll a,b;
    cin>>a>>b;
    string ans;
    cin>>ans;
    if(ans==str1)
        cout<<a-1<<" "<<b<<endl;
    else
        cout<<a<<" "<<b-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

const int MOD = 1e9 + 7;
int add(int x, int y)
{
    x += y;
    if (x >= MOD)
        x -= MOD;
    return x;
}
void vadd(int &x, int y)
{
    x += y;
    if (x >= MOD)
        x -= MOD;
}
int sub(int x, int y)
{
    x -= y;
    if (x < 0)
        x += MOD;
    return x;
}
int mult(int x, int y)
{
    return x * (ll)y % MOD;
}

const int maxN = 402;
int A[maxN], B[maxN];
int pw[maxN][maxN];
int g[maxN][maxN];
int dp[maxN][maxN];

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif

    for (int x = 0; x < maxN; ++x)
    {
        pw[x][0] = 1;
        for (int a = 1; a < maxN; ++a)
            pw[x][a] = mult(pw[x][a - 1], x);
    }

    int N, C;
    cin >> N >> C;
    for (int i = 1; i <= N; ++i) cin >> A[i];
    for (int i = 1; i <= N; ++i) cin >> B[i];
    for (int i = 1; i <= N; ++i)
    {
        for (int y = 0; y <= C; ++y)
        {
            g[i][y] = 0;
            for (int x = A[i]; x <= B[i]; ++x)
                vadd(g[i][y], pw[x][y]);
        }
    }
    dp[0][0] = 1;
    for (int i = 1; i <= N; ++i)
    {
        for (int sum = 0; sum <= C; ++sum)
        {
            for (int a = 0; a <= sum; ++a)
            {
                vadd(dp[i][sum], mult(g[i][a], dp[i - 1][sum - a]));
            }
        }
    }
    cout << dp[N][C] << '\n';
    
    return 0;
}



Measured memory_bytes: 2176
#include<stdio.h>
int main() {
    char s[4];
    scanf("%s", s);
    int i, a=0, b=0, c=0;
    for (i = 0; i < 3; i++) {
        if (s[i] == 'a')
            a = -1;
        if (s[i] == 'b')
            b = -1;
        if (s[i] == 'c')
            c = -1;
    }
    if (a == -1 && b == -1 && c == -1)
        printf("Yes");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 128
<?php
$n = trim(fgets(STDIN));
$x = explode(" ",trim(fgets(STDIN)));
$y = explode(" ",trim(fgets(STDIN)));

$x_sum = 0;
$y_sum = 0;
for($i=0; $i<$n; $i++){
    if(($x[$i]-$y[$i]) > 0){
        $x_sum += $x[$i];
        $y_sum += $y[$i];
    }
}
echo $x_sum - $y_sum;

?>

Measured memory_bytes: 4728
import java.util.*;
public class Main {
    public static void main(String[] args){
         Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        int num = 0;
        if ((N % 2) == 0) {
            num = N;
        } else {
            num = N * 2;
        }

        System.out.println(num);
    }
}

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  rep(i, (int)s.size()-1) {
    if (s[i] != s[i+1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3716
#include <iostream>

using namespace std;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a == b && a !=c && b != c) cout << "Yes" << endl;
  else if (a == c && b !=c && b != a) cout << "Yes" << endl;
  else if (b == c && a !=c && a != b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
    
    char d[11];
    int v = 0;
    
    scanf("%s", d);
    
    for (int i=0; i<strlen(d); i = i + 2) {
        if (d[i] != 'h' || d[i+1] != 'i') {
            v = 0;
            break;
        }
        
        if (d[i] == 'h' && d[i+1] == 'i')
            v = 1;
    }

    if (v == 1)
        printf("%s\n", "Yes");
    else 
        printf("%s\n", "No");

    return 0;
}

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

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

int main(){

    int N, K;
    scanf("%d%d", &N, &K);

    int i;
    int H[N];
    for( i = 0; i < N; i++ ){
        scanf("%d", &H[i]);
    }

    qsort( H, N, sizeof(H[0]), cmp);

    long long int ans=0;
    for( i = K; i < N; i++ ){
        ans += H[i];
    }

    printf("%lld\n", ans);

    return 0;
} 


Measured memory_bytes: 1788
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
    int n,m;
    cin >> n >> m;
    if(n>=m){
        for(int i=0; i<n; i++){
            cout << m;
        }
    }
    else{
        for(int i=0; i<m; i++){
            cout << n;
        }
    }
    
   return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64

#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };

ll dp[3030][3030][4][2];
ll A[3030][3030];
void solve() {
	int R, C, K; cin >> R >> C >> K;
	REP(_, K) {
		int r, c, v; cin >> r >> c >> v;
		r--, c--;
		A[r][c] = v;
	}
	REP(i, R + 1) {
		REP(j, C + 1) {
			REP(k, 4) {
				REP(f, 2) {
					if (f) {
						chmax(dp[i + 1][j][0][0], dp[i][j][k][f]);
						chmax(dp[i][j + 1][k][0], dp[i][j][k][f]);
					}
					else {
						chmax(dp[i][j + 1][k][0], dp[i][j][k][f]);
						chmax(dp[i + 1][j][0][0], dp[i][j][k][f]);
						if (k < 3) {
							chmax(dp[i][j][k + 1][1], dp[i][j][k][0] + A[i][j]);
						}
					}
				}
			}
		}
	}
	ll ans = 0;
	REP(k, 4)REP(f, 2)chmax(ans, dp[R - 1][C - 1][k][f]);
	print(ans);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 642748
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(b, a*n) << endl;
    return 0;
}


Measured memory_bytes: 256
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

int n, m;
string s[25];
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};

int check(int x, int y) {
    return (0 <= x && x < n && 0 <= y && y < m && s[x][y] == '.');
}

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
    	cin >> n >> m;
    	for(int i = 0; i < n; i++)
    		cin >> s[i];
		
		int ans = 0;			
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				if(check(i, j)) {
					vector<pair<int,int>> q;
                    int vis[n][m] = {}, dist[n][m] = {};
					q.push_back({i, j});
					vis[i][j] = 1;
					for(int k = 0; k < q.size(); k++) {
						pair<int, int> p = q[k];
						for(int l = 0; l < 4; l++) {
							int x = p.first + dx[l];
							int y = p.second + dy[l];
							if(check(x, y) && !vis[x][y]) {
								vis[x][y] = 1;
								dist[x][y] = dist[p.first][p.second] + 1;
								ans = max(ans, dist[x][y]);
								q.push_back({x, y});
							}
						}

					}
				}
			}
		}    	

		cout << ans << '\n';
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int answer;
    while(true){
      int n = sc.nextInt();
      int x = sc.nextInt();
      if(n==0&&x==0)
      break;
      int a,b,k;
      a=x/3;
      answer = 0;
      for(int i=1;i<a;i++){
        b=(x-i)/2;
        for(int j=i+1;j<=b;j++){
          k=x-i-j;
          if(j<k&&k<=n)
          answer ++;
        }
      }
      System.out.printf("%d\n",answer);
    }
}
}


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

int main() {
	int n;
	cin >> n;
	vector<int> l(n);
	for (int i = 0; i < n; i++) cin >> l.at(i);

	sort(l.begin(), l.end(), greater<int>());

	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			for (int k = j + 1; k < n; k++) {
				if (l.at(i) < l.at(j) + l.at(k)) ans++;
				else break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
k,n=map(int,input().split())
a=[int(i) for i in input().split()]
len_array=[]
for i in range(n):
    if i==n-1:
        length=a[0]-a[i]+k
    else:
        length=a[i+1]-a[i]
    len_array.append(length)  
print(k-max(len_array))

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

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

int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  if (op == '+') cout << a + b << endl;
  else cout << a - b << endl;
  return 0;
}

Measured memory_bytes: 256
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=2e5+5,MOD=1e9+7;
const ld EPS = 1e-9;

int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=(xx<<3)+(xx<<1)+ch-'0';ch=getchar();}
    return xx*ff;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


ll n,k; 
ll a[LIM];

bool check(ll val){
	ll num = 0;
	forn(i,n){
		num += (a[i]-1)/val;
	}
	if(num <= k) return 1;
	return 0;
}

int main(){
	fastio;

	cin>>n>>k;
	forn(i,n) cin>>a[i];

	ll l = 1, r = 1e9+2;
	ll mid;

	// cout<<check(4)<<ln;

	while(l<r){
		mid = (l+r)/2;
		if(check(mid)) r = mid;
		else l = mid+1;
	}
	cout<<l<<ln;

	return 0;
}

Measured memory_bytes: 5172
N = int(input())

INF = 10**20
max_Lx, max_Rx, max_UDx = -INF, -INF, -INF
min_Lx, min_Rx, min_UDx = INF, INF, INF
max_Uy, max_Dy, max_LRy = -INF, -INF, -INF
min_Uy, min_Dy, min_LRy = INF, INF, INF

for _ in range(N) :
    x, y, d = input().split()
    x, y = int(x), int(y)
    
    if d == 'L' :
        max_Lx = max(max_Lx, x)
        min_Lx = min(min_Lx, x)
        max_LRy = max(max_LRy, y)
        min_LRy = min(min_LRy, y)
    
    elif d == 'R' :
        max_Rx = max(max_Rx, x)
        min_Rx = min(min_Rx, x)
        max_LRy = max(max_LRy, y)
        min_LRy = min(min_LRy, y)
    
    elif d == 'U' :
        max_Uy = max(max_Uy, y)
        min_Uy = min(min_Uy, y)
        max_UDx = max(max_UDx, x)
        min_UDx = min(min_UDx, x)
    
    elif d == 'D':
        max_Dy = max(max_Dy, y)
        min_Dy = min(min_Dy, y)
        max_UDx = max(max_UDx, x)
        min_UDx = min(min_UDx, x)

def calc(t) :
    max_x = max(max_Lx-t, max_UDx, max_Rx+t)
    min_x = min(min_Lx-t, min_UDx, min_Rx+t)
    max_y = max(max_Dy-t, max_LRy, max_Uy+t)
    min_y = min(min_Dy-t, min_LRy, min_Uy+t)
    return (max_x - min_x) * (max_y - min_y)

schedule = [
    0, 
    max_UDx - max_Rx, max_Lx - max_UDx, (max_Lx - max_Rx) / 2,
    min_UDx - min_Rx, min_Lx - max_UDx, (min_Lx - min_Rx) / 2,
    max_LRy - max_Uy, max_Dy - max_LRy, (max_Dy - max_Uy) / 2,
    min_LRy - min_Uy, min_Dy - max_LRy, (min_Dy - min_Uy) / 2
]
min_diff = INF

for t in schedule :
    if 0 <= t < INF / 10 :
        min_diff = min(min_diff, calc(t))
    
print(min_diff)

Measured memory_bytes: 47704
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  REP(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << mp.size() << endl;

  return 0;
}

Measured memory_bytes: 19248
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
 
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
 
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() {
   int N,M,ans;
   ans = 0;
   int adj[52][52] = {};
   cin >> N >> M;
   vector<pair<int,int>> root;
   rep(i,M)
   {
      int a,b;
      cin >> a >> b;
      adj[a][b] = adj[b][a] = 1;
      root.PB(MP(a,b));
   }
   rep(i,M)
   {
      int a = root[i].first;
      int b = root[i].second;
      queue<int> Q;
      int visited[52] ={};
      Q.push(1);
      while(!Q.empty())
      {
         int now = Q.front();
         Q.pop();
         visited[now] = 1;
         FORq (j,1,M)
         {
            if (adj[now][j] == 0) continue;
            if (now == a && j == b) continue;
            if (j == a && now == b) continue;
            if (1 == visited[j]) continue;
            Q.push(j);
         }
      }
      FORq(pppppp, 1, N)
         {
         if ( visited[pppppp] == 0)
            {
            ans += 1;
            break;
            }
         }
   }
   cout << ans << endl;
}

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

long root(long x,long *uf){
    //cout << "x : " << x <<  "  uf : " << uf[x] << "\n";
    if(uf[x]==x){
        return x;
    }
    else{
        return uf[x] = root(uf[x],uf);
    }
}

void ufmerge(long x,long y,long *uf,long *rank_uf){
    x=root(x,uf);
    y=root(y,uf);
    if(x==y){
        return;
    }
    else{
        if(rank_uf[x]<rank_uf[y]){
            uf[x]=y;
        }
        else{
            uf[y]=x;
            if(rank_uf[x]==rank_uf[y]) rank_uf[x]++;
        }
    }
}

int main(){
    long N,K,L;
    long p,q,r,s;
    long road[200002];
    long rank_road[200002];
    long rail[200002];
    long rank_rail[200002];
    map<pair<long,long>,long> mp_count;
    
    cin >> N >> K >> L;
    for(long i=0;i<=N;i++){
        road[i]=i;
        rank_road[i]=1;
        rail[i]=i;
        rank_rail[i]=1;
    }

    for(long i=0;i<K;i++){
        cin >> p >> q;
        ufmerge(p,q,road,rank_road);
    }

    for(long i=0;i<L;i++){
        cin >> r >> s;
        ufmerge(r,s,rail,rank_rail);
    }

    for(long i=1;i<=N;i++){
        root(i,road);
        root(i,rail);
    }

    for(long i=1;i<=N;i++){
        pair<long,long> p_temp=make_pair(road[i],rail[i]);
        auto itr = mp_count.find(p_temp);
        if(itr != mp_count.end()){
            mp_count[p_temp]++;
        }
        else{
            mp_count[p_temp]=1;
        }
    }

    for(long i=1;i<=N;i++){
        if(i!=1) cout << " ";
        pair<long,long> p_temp=make_pair(road[i],rail[i]);
        cout << mp_count[p_temp];
    }
    cout << "\n";
    
    return 0;
}

Measured memory_bytes: 18304
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[M];
		int[] d = new int[M];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for (int i = 0; i < M; i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}

		for (int i = 0; i < N; i++) {
			int checkp = 0;
			int min_distance = Integer.MAX_VALUE;
			for (int j = 0; j < M; j++) {
				int distance = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
				if (distance < min_distance) {
					checkp = j + 1;
					min_distance = distance;
				}
			}
			System.out.printf("%d\n", checkp);
		}
	}
}


Measured memory_bytes: 21972
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });            var N = Sarray()[0];
            var N = Sarray()[0];
            var Bi = Sarray();
            var ans = new long[N];
            for (var i = N - 1; 0 <= i; --i)
            {
                var cnt = 0;
                for (var j = 0; j < N; ++j)
                {
                    if (0 == ans[j])
                    {
                        ++cnt;
                        if (cnt == Bi[i])
                        {
                            ans[j] = Bi[i];
                            break;
                        }
                    }
                    if (j == N - 1)
                    {
                        WriteLine(-1);
                        return;
                    }
                }
            }
            foreach (var a in ans)
                WriteLine(a);
            //Out.Flush();
        }
    }
}

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

int main(){
    long long n;
    cin>>n;
    long long count=0;
    
    for (int i =1;i<=n; i++) {
        if(i%3==0 or i%5==0 )
        continue;
        else{
            count+=i;
        }
        /* code */
    }
    cout<<count<<endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int ans = N%1000; 
  if(N%1000 == 0){
  cout << ans << endl;
  }
  else{
  ans = 1000 -ans;
   cout << ans << endl;
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <queue>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <functional>
using namespace std;

long long N, W, w[109], v[109], minx = (1 << 30); vector<long long>D[4], E[4];

int main() {
	cin >> N >> W;
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> v[i]; minx = min(minx, w[i]);
	}
	for (int i = 0; i < N; i++) D[w[i] - minx].push_back(v[i]);
	for (int i = 0; i <= 3; i++) {
		sort(D[i].begin(), D[i].end(), greater<int>());
		E[i].push_back(0); int ret = 0;
		for (int j = 0; j < D[i].size(); j++) {
			ret += D[i][j]; E[i].push_back(ret);
		}
	}
	long long maxn = 0;
	for (int i = 0; i < E[0].size(); i++) {
		for (int j = 0; j < E[1].size(); j++) {
			for (int k = 0; k < E[2].size(); k++) {
				for (int l = 0; l < E[3].size(); l++) {
					long long Total = 1LL * i * (minx + 0LL) + 1LL * j * (minx + 1LL) + 1LL * k * (minx + 2LL) + 1LL * l * (minx + 3LL);
					
					if (Total > W) continue;
					maxn = max(maxn, E[0][i] + E[1][j] + E[2][k] + E[3][l]);
				}
			}
		}
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
mylist = np.array(list(map(int, input().split())))
#print(N, mylist)
mydic = {}

mysumpari = 0
for i in mylist:
    if i not in mydic:
        mydic[i] = 1
    else:
        mydic[i] += 1
        mysumpari += 1
#print(mydic, mysumpari)

mysum = 0
for d in mydic:
    if mydic[d] >= 2:
        a = mydic[d]
        b = mydic[d] - 1
        #print(a*b)
        mysum +=  (a*b)//2
    #print(mysum)
    
for i in mylist:
    if mydic[i] >= 2:
        a = mydic[i]
        b = mydic[i] - 1
        
        if b > 1:
            print(mysum - (a*b)//2 + ((a-1)*(b-1))//2)
        else:
            print(mysum - (a*b)//2)
        
        #print(mysum - (a*b)//2)

    else:
        print(mysum)

Measured memory_bytes: 34164
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<string> s(n);
    vint t(n);
    rep(i,n){
        cin>>s[i]>>t[i];
    }
    int count=0;
    bool flag=false;
    string x;
    cin>>x;
    rep(i,n){
        if(flag){
            count+=t[i];
        }
        if(s[i]==x){
            flag=true;
        }
    }
    cout<<count<<'\n';
    return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll d, n;
    cin >> d >> n;
    ll ans, num = 1;
    while (d--) {
        num *= 100;
    }
    ans = n * num;
    if (n == 100) ans += num;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

ll dp[309][309][309];

vector<int> a;
int cnt = 0;
int d[309];

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

    string s;
    int K;
    cin >> s >> K;

    for(char c : s) {
        if(c == '0')
            cnt++;
        else
            a.push_back(cnt);
    }
    for(int i : a)
        d[i]++;

    chmin(K, a.size());

    dp[cnt + 1][0][0] = 1;

    for(int i = cnt + 1; i; i--)
        rep(j, K + 1) rep(k, a.size() + 1) {
            if(dp[i][j][k] == 0) continue;
            rep(t, d[i - 1] + k + 1) {
                int nj = j + max(0, int(d[i - 1] - t));
                dp[i - 1][nj][d[i - 1] + k - t] += dp[i][j][k];
                dp[i - 1][nj][d[i - 1] + k - t] %= Mod;
            }
        }

    ll ans = 0;
    rep(i, K + 1) ans += dp[0][i][0];

    cout << ans % Mod;

    return 0;
}

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

typedef long long ll;
static const int MOD = 1e9+7;
static const int INF = 1<<30;

int main(){
    int mask = 0b0 ;
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin>>A[i];
    for(int i=0; i<N; i++){
        mask ^= A[i];
    }    

    for(int i=0; i<N; i++){
        cout<<(mask ^ A[i])<<" ";
    }

    cout<<endl;
    
    return 0;
}

Measured memory_bytes: 4004
#include<bits/stdc++.h>
using namespace std;
string s;
int mn=1e9;
int main()
{
	cin>>s;
	for(int i=2;i<s.size();i++)
	{
		int num=((int)s[i]-'0')+((int)s[i-1]-'0')*10+((int)s[i-2]-'0')*100;
		int val=abs(num-753);
		mn=min(mn,val);
	}
	cout<<mn<<endl;
	return 0;
}

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

using namespace std;

void Main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int x = 0;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'I') {
            ++x;
        }
        else {
            --x;
        }
        ans = max(ans, x);
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

using namespace std;

#define MOD 100000
#define MAX_N 50
#define MAX_S 3001
typedef long long ll;

int main(){
    int N,M,S;
    while(cin >> N >> M >> S, N){
        ll dp[MAX_N][MAX_S] = {{}};
        dp[0][0] = 1;
        for(int i = 1 ; i <= M ; i++){
            for(int j = N*N ; j > 0 ; j--){
                for(int k = 0 ; k <= S-i ; k++){
                    dp[j][k+i] += dp[j-1][k];
                    dp[j][k+i] %= MOD;
                }
            }
        }
        cout << dp[N*N][S] << endl;
    }
    return 0;
}

Measured memory_bytes: 2336
//#pragma GCC optimize(2)


#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#include<ext/rope>*/
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
//void err(istream_iterator<string> it){cerr<<endl;}
//template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args){cerr << *it << " = " << a << " , ";err(++it, args...);}
//#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mem(a,b) memset((a),b,sizeof((a)))
#define fpre(x) cout<<fixed<<setprecision(x)
#define clr(v) (v).clear()
#define pii pair<int,int>
#define pdd pair<double,double>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp make_pair
#define eb emplace_back
#define pb emplace_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define uint unsigned int
#define ushort unsigned short
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lowbit(i) (i&(-i))
#define lson rt<<1
#define rson lson|1
#define fi first
#define se second
const double eps=1e-7;
const double pi=acos(-1);
inline int dcmp(double x)
{
    if(x<-eps)
        return -1;
    if(x>eps)
        return 1;
    return 0;
}
//-----------------------------------------------head

const int maxn=2e5+5;
const ll mod=1e9+7;
ll f[maxn+5],invf[maxn+5];
ll qp(ll x,ll n)
{
    x%=mod;
    ll r=1;
    while(n)
    {
        if(n&1)
            r=r*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return r;
}
void init()
{
    f[0]=1;
    for(int i=1;i<=maxn;++i)
        f[i]=f[i-1]*i%mod;
    invf[maxn]=qp(f[maxn],mod-2);
    for(int i=maxn-1;~i;--i)
        invf[i]=invf[i+1]*(i+1)%mod;
}
ll c(int n,int m)
{
    return f[n]*(invf[m]*invf[n-m]%mod)%mod;
}
int main()
{
    init();
    int h,w,a,b;
    while(~scanf("%d%d%d%d",&h,&w,&a,&b))
    {
        ll r=0;
        for(ll i=b+1;i<=w;++i)
        {
            ll tmp=c(h-a+i-2,h-a-1)*c(w-i+a-1,w-i)%mod;
            r=(r+tmp)%mod;
        }
        printf("%lld\n",r);
    }
}

/*
























*/









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

int rank[128];
char trump;
string card[4][13];

int main(void){
	for(int i=2;i<10;i++) rank['0'+i] = i;
	rank['T'] = 10;
	rank['J'] = 11;
	rank['Q'] = 12;
	rank['K'] = 13;
	rank['A'] = 14;

	while(cin>>trump,trump!='#'){
		for(int i=0;i<4;i++){
			for(int j=0;j<13;j++){
				cin>>card[i][j];
			}
		}

		int first = 0;
		int win[] = {0,0};

		for(int i=0;i<13;i++){
			int winner = 0, max = 0;
			bool flg = false; //trumpツつェツ出ツつスツつゥツづ個フツδ可グ
			char led = card[first][i][1];

			for(int j=0;j<4;j++){
				int r = rank[card[j][i][0]];
				char s = card[j][i][1];

				if(flg){
					if(s == trump && r > max){
						max = r;
						winner = j;
					}
				}
				else{
					if(s == trump){
						flg = true;
						max = r;
						winner = j;
					}
					else if(s == led && r > max){
						max = r;
						winner = j;
					}
				}
			}

			first = winner;
			win[winner%2]++;
		}

		if(win[0] > win[1])
			cout<<"NS "<<win[0]-6<<endl;
		else
			cout<<"EW "<<win[1]-6<<endl;
	}

	return 0;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    int c[3], sum = 0;
    rep(i,3){
        cin >> c[i];
        sum += c[i];
    }
    rep(i,3){
        if(sum - c[i] == c[i]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

using namespace std;

int main() {
  int n;
  cin >> n;
  ll total = 0;
  rep(i, n) {
    int l, r;
    cin >> l >> r;
    total += r - l + 1;
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main() {
	int n, i, a;
	scanf("%d",&n);
	int b[n];
	for(i=0;i<n;i++) {
		b[i]=0;
	}
	for(i=0;i<n-1;i++){
		scanf("%d",&a);
		b[a-1]=b[a-1]+1;
	}
	for(i=0;i<n;i++) {
		printf("%d\n",b[i]);
	}
	return 0;
}


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

int main() {
  int N,M;
  string S;
  cin >> N >> M >> S;
  
  vector<int> ans(0);
  int now = N;
  while(now-M>0){
    int x = M;
    while(true){
      if(S[now-x]=='0') break;
      x--;
      if(x==0){
        cout << -1 << endl;
        return 0;
      }
    }
    now -= x;
    ans.push_back(x);
  }
  if(now!=0) ans.push_back(now);
  
  int A = ans.size();
  cout << ans[A-1];
  for(int i=A-2;i>=0;i--) cout << " " << ans[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 1144
A, B, C = list(sorted(map(int, input().split())))

ans = 0
while (C-A) > 1:
    A += 2
    ans += 1

while (C-B) > 1:
    B += 2
    ans += 1

if A == C:
    if B != C:
        B += 2
        A += 1
        C += 1
        ans += 2
else:
    if B == C:
        A += 2
        B += 1
        C += 1
        ans += 2
    else:
        A += 1
        B += 1
        ans += 1
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){
			int a=sc.nextInt();
			String op=sc.next();
			int b=sc.nextInt();
			switch(op){
			case "+":
				System.out.println(a+b);
				break;
			case "-":
				System.out.println(a-b);
				break;
			case "*":
				System.out.println(a*b);
				break;
			case "/":
				System.out.println(a/b);
				break;
			case "?":
				return;
			}
		}
	}

}



Measured memory_bytes: 26292
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> ps(n), qs(n);
    for(int i=0; i<n; ++i){
        cin >> ps[i];
    }
    for(int i=0; i<n; ++i){
        cin >> qs[i];
    }
    vector<int> cand(n);
    for(int i=0; i<n; ++i){
        cand[i]=i+1;
    }
    int a=-1, b=-1;
    int cnt=0;
    do{
        if(cand==ps) a=cnt;
        if(cand==qs) b=cnt;
        ++cnt;
    }while(next_permutation(cand.begin(), cand.end()));
    cout << abs(a-b) << endl;
    return 0;
}


Measured memory_bytes: 256
import collections
n = int(input())
a_l = list(map(int, input().split()))
cnt = collections.Counter(a_l)
q = int(input())

s = sum(a_l)
for _ in range(q):
  b,c = map(int, input().split())
  s += cnt[b] * (c-b)
  cnt[c] += cnt[b]
  cnt[b] = 0
#  print(cnt)
  print(s)

Measured memory_bytes: 24140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  bool bingo = false;
 
  vector<vector<int>> sheet(3,vector<int>(3));
 
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>sheet.at(i).at(j);
    }
  }//シートの入力
 
  int N;

  cin>>N;

  vector<int> ans(N); 
 
  for(int i=0;i<N;i++){
    cin>>ans.at(i);
  }//抽選番号の入力
 
 
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(sheet.at(j).at(k)==ans.at(i)){
          sheet.at(j).at(k)=0;
        }
      }
    }
  }//あたり数を0に置き換え
 
 
  if(!(sheet.at(0).at(0)+sheet.at(0).at(1)+sheet.at(0).at(2))){
    bingo=true;
  }
  
  if(!(sheet.at(1).at(0)+sheet.at(1).at(1)+sheet.at(1).at(2))){
    bingo=true;
  }
 
  if(!(sheet.at(2).at(0)+sheet.at(2).at(1)+sheet.at(2).at(2))){
    bingo=true;
  }
 
  if(!(sheet.at(0).at(0)+sheet.at(1).at(0)+sheet.at(2).at(0))){
    bingo=true;
  }
 
  if(!(sheet.at(0).at(1)+sheet.at(1).at(1)+sheet.at(2).at(1))){
    bingo=true;
  }
 
  if(!(sheet.at(0).at(2)+sheet.at(1).at(2)+sheet.at(2).at(2))){
    bingo=true;
  }
 
  if(!(sheet.at(0).at(0)+sheet.at(1).at(1)+sheet.at(2).at(2))){
    bingo=true;
  }
 
  if(!(sheet.at(0).at(2)+sheet.at(1).at(1)+sheet.at(2).at(0))){
    bingo=true;
  }
 
 
 
  if(bingo==true){
      cout<<"Yes"<<endl;      
  }
  else{
      cout<<"No"<<endl;      
  }//答えの出力
 
 
 
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI acos(-1) 
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define eb(a) emplace_back(a)
#define print(x) for(auto it:x) cout<<it<<' '; cout<<"\n";

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

int main()
{
	FAST_IO ;
	ll n;
	cin >> n;
	if(n)
		cout << "0\n" ;
	else
		cout << "1\n" ;
	return 0;
}

/*
If u haven't come up with an approach yet ,skip this one
  Try this when feeling stuck -
  1. Int overflow, array bounds
  2. Special cases (n=1?)
  3. Prove your approach to yourself(mathematical induction,counter-intuitive or stronger test cases)
  4. Calm down and don't look at standings and stop thinking about rating and think about the question
  5. Just do it! 
*/ 

//Benq's advice - 
/* 
	And following advices are must for me -
	* do something instead of nothing and stay organized
	* WRITE STUFF DOWN 
*/

//#define _GLIBCXX_DEBUG 
// It will convert WA verdict to runtime error if that error is caused due to out of bound excess , declare it at the top
//#pragma GCC optimize "trapv" 
// It will convert WA to runtime error if WA was caused due to int overflow error,declare it anywhere

Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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;}

int main(){
  ll N,cnt=0,ans=0;
  string S;
  cin>>N>>S;
  REP(i,N){
    if(S[i]=='R') cnt++;
  }
  REP(i,cnt){
    if(S[i]=='W') ans++;
  }
  co(ans);
  return 0;
}

Measured memory_bytes: 3752