akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;


public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        String s = sc.next();
        if(s.charAt(0)==s.charAt(s.length()-1)){
            if(s.length()%2==0){
                System.out.println("First");
            }
            else{
                System.out.println("Second");
            }
        }
        else{
            if(s.length()%2==0){
                System.out.println("Second");
            }
            else{
                System.out.println("First");
            }
        }
    }    
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 21588
N = int(input())
dic = {}
for _ in range(N):
    vals = input().split()
    if vals[1] not in dic:
        dic[vals[1]] = float(vals[0])
    else:
        dic[vals[1]] += float(vals[0])
tot = 0  
for k in dic:
    if k == "JPY":
        tot += dic[k]
    else:
        tot += dic[k] * 380000.0
print(tot)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <fstream>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v; ll w; };

const int MOD = 1000000007;
const int _MOD = 1000000009;
double EPS = 1e-10;
const int INF = INT_MAX / 2;

int main() {
	int N, C, K;
	cin >> N >> C >> K;
	vector<int> a(N);
	rep(i, N) scanf("%d", &a[i]);
	priority_queue<int, vector<int>, greater<int> > pq;
	rep(i, N) pq.push(a[i]);
	int ans = 0;
	while (pq.size()) {
		int x = pq.top(), cnt = 0;
		for (; cnt < C && pq.size() && pq.top() <= x + K; cnt++, pq.pop());
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1276
import static java.lang.Math.max;
import static java.lang.Math.min;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Locale;
import java.util.Scanner;

public class Main {

	final static int INF = Integer.MAX_VALUE;

	public static void main(String[] args) {
		Locale.setDefault(Locale.ENGLISH);
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		solve(in, System.out);
		in.close();
	}

	protected static void solve(Scanner in, PrintStream out) {
//		int n = in.nextInt();
//		int w = in.nextInt();
//		int[] a = new int[n];
//		int[] wt = new int[n];
//		for (int j = 0; j < n; j++) {
//			wt[j] = in.nextInt();
//			a[j] = in.nextInt();
//		}
		String s = in.next();
		String t = in.next();
		String ret = solveLine(s, t);
		out.printf(Locale.ENGLISH, "%s%n", ret);
	}

	private static String solveLine(String s, String t) {
		int lens = s.length(), lent = t.length();
		int[][] dp = new int[lens+1][lent+1];
		for (int i = 1; i <= lens; i++) {
			for (int j = 1; j <= lent; j++) {
				dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
				if (s.charAt(i-1) == t.charAt(j-1)) dp[i][j] = dp[i - 1][j - 1] + 1;
			}
		}
		String ans = "";
		int col = lent, row = lens;
		while (dp[row][col] > 0) {
			if (dp[row][col] > dp[row - 1][col - 1] && t.charAt(col-1)== s.charAt(row-1)) {
				ans = s.charAt(row-1)+ans;
				row--;
				col--;
			} else {
				if (dp[row][col]==dp[row][col-1]) col--;
				else row--;
			}
		}
 		return ans;
	}

}

Measured memory_bytes: 86516
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
#include <climits>

using namespace std;

int main()
{
    int numm[30] = { 0 };
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        numm[s[i] - 'a'] += 1;

    }

    for (int i = 0; i < 26; i++)
    {
        if (numm[i]%2 != 0)
        {
            cout << "No";
            return 0;

        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
int A[100][100];
int main(void){
  int k,j,n,u,v,uv,V;
  scanf("%d",&V);
  for(n=0;n<V;n++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      A[u-1][v-1]=1;
    }
  }
  for(v=0;v<V;v++){
    
    for(uv=0;uv<V;uv++){
      if(uv!=0){
	printf(" ");
      }
      printf("%d",A[v][uv]);
    }
    printf("\n");
  }
  
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MOD = 1000000007;

ll add(ll a, ll b){
    return (a+b)%MOD;
}

ll mul(ll a, ll b){
    return ((ll)a*b)%MOD;
}

vector <ll> graf[1000005];
ll dp[1000005];

ll n, k;

void dfs(ll v, ll parent){
    dp[v] = 1;
    for(auto c : graf[v]){
        if(c == parent) continue;
        dfs(c, v);
    }
    if(v == 1) k++;
    for(ll i=1; i<graf[v].size(); i++){
        dp[v] = mul(max(0LL, k-i), dp[v]);
    }
    if(v == 1 && graf[v].size() > 0){
        dp[v] = mul(max(0LL, ll(k-graf[v].size())), dp[v]);
    }
    for(auto c1 : graf[v]){
        if(c1 == parent) continue;
        ll tren = 1;
        if(v == 1) tren = 2;
        for(auto c2 : graf[c1]){
            if(c2 == v) continue;
            dp[v] = mul(dp[v], dp[c2]);
            dp[v] = mul(dp[v], max(0LL, k-tren));
            tren++;
        }
    }
    //cout << dp[v] << " " << v << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    cin >> n >> k;
    for(ll i=1; i<n; i++){
        ll a, b;
        cin >> a >> b;
        graf[a].push_back(b);
        graf[b].push_back(a);
    }
    k--;
    dfs(1, 0);
    //cout << dp[1] << "\n";
    cout << mul(dp[1], k);
    return 0;
}


Measured memory_bytes: 35200
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()
#define MP(n, m) make_pair(n, m);
#define COUT(d) cout<<std::setprecision(10)<<d<<endl;
#define CIN(n) getline(cin,n);
 
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;
using ul = unsigned long;
 
typedef long long ll;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(VI& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
 
int vtotal(VI& v){
  int total=0;
  REP(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
	
  //init(); // mint初期化
  char b;
  cin>>b;
  char ans='A';
  if(b=='A')ans='T';
  if(b=='C')ans='G';
  if(b=='G')ans='C';
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 125696
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int arr[200005];
int main()
{
     ll t,v,sum=0,a;
     cin>>t;
     for(int i=0;i<t-1;i++)
     {
         cin>>a;
         arr[a]++;
     }
     for(int i=1;i<=t;i++)
        cout<<arr[i]<<endl;
}


Measured memory_bytes: 4368
#define errOut(s) \
  { std::cerr << __LINE__ << ":" << #s << ":" << (s) << std::endl; }

#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

static std::string const YES = "Yes";
static std::string const NO = "No";

bool solve(std::string n) {
  int64_t sum = 0;
  for (auto ch: n) {
    auto const c = ch - '0';
    sum += c;
  }
  return (sum % 9) == 0;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::string n;
  std::cin >> n;
  auto const res = solve(n);
  std::cout << (res ? YES : NO) << std::endl;
  return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 1000000000
#define MOD 1000000007LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 105
int n, m;
int a[MN];

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

    cin >> n >> m;
    int sm=0;
    F0R(i, n){
        cin >> a[i];
        sm += a[i];
    }
    int tot = (sm+4*m-1)/(4*m);
    int cnt = 0;
    F0R(i, n){
        if(a[i] >= tot) ++cnt;
    }

    if(cnt >= m) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


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

const double BTC = 380000.0;

int main(){
    int n;
    std::cin >> n;
    double sum = 0.0;
    for(int i = 0; i < n; i++){
        double x;
        std::string UNIT;
        std::cin >> x >> UNIT;
        if(UNIT == "BTC"){
            sum += x * BTC;
        }else{
            sum += x;
        }
    }
    printf("%.6f\n", sum);
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
import numpy as np
from bisect import bisect_right
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, M, K = map(int, readline().split())
    A = [0] + list(map(int, readline().split()))
    B = list(map(int, readline().split()))

    A = np.array(A, np.int64)
    B = np.array(B, np.int64)

    A = A.cumsum()
    B = B.cumsum()
    ans = 0

    for i in range(N+1):
        a = A[i]
        rest = K - a
        if rest<0:
            break
        result = bisect_right(B,rest)
        ans = max(ans,result+i)

    print(ans)



if __name__ == '__main__':
    main()


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

int main() {
    ll K, S; cin >> K >> S;

    ll ans = 0;
    for(int i = 0; i <= min(S,K); i++){
        for(int j = 0; j <= min(S-i,K); j++){
            if(S-i-j<=K) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
let () =
  let n,quantum = Scanf.scanf "%d %d\n" (fun a b -> a,b) in
  let q = Queue.create () in
  for i=1 to n do
    Queue.push (Scanf.scanf "%s %d\n" (fun a b -> a,b)) q
  done;
  let rec round_robin sum = match Queue.is_empty q with
      true -> ()
    | false ->
      match Queue.pop q with
        p,t when t <= quantum ->
        let s = sum + t in
        Printf.printf "%s %d\n" p s;
        round_robin s
      | p,t ->
        Queue.push (p,t-quantum) q;
        round_robin (sum+quantum)
  in
  round_robin 0

Measured memory_bytes: 12684
#include<bits/stdc++.h>
#define in inline
#define reg register
#define int long long
#define MAX 20030813
#define f(i,l,r) for(reg int i=l;i<=r;++i)
#define F(i,l,r) for(reg int i=l;i>=r;--i)
using namespace std;
namespace qwq{
	in void read(int &o)
	{
		o=0;
		int w=1;
		char c=getchar();
		while(c<'0'||c>'9')
		{
			if(c=='-')w*=-1;
			c=getchar();
		}
		while(c>='0'&&c<='9')
		{
			o=(o<<3)+(o<<1)+(c^48);
			c=getchar();
		}
		o*=w;
	}
	in void write(int x)
	{
	   	if(x<0)putchar('-'),x=-x;
    	if(x>9)write(x/10);
    	putchar(x%10+48);
	}
	in int max(int x,int y)
	{
		return x>y?x:y;
	}
	in int min(int x,int y)
	{
		return x<y?x:y;
	}
}
using namespace qwq;
int N,M,a,ans;
priority_queue<int>q;
signed main()
{
	read(N);read(M);
	f(i,1,N)read(a),q.push(a);
	f(i,1,M)
	{
		a=q.top();q.pop();
		q.push(a>>1);
	}
	while(!q.empty())
	{
		ans+=q.top();q.pop();
	}
	write(ans);
}




Measured memory_bytes: 1400
#include <stdio.h>
int main(void){
    int n,c[200000],i,p[200001]={},dp[200001],MO=1000000007;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&c[i]);
    dp[1]=1;
    p[c[0]]=1;
    for(i=2;i<=n;i++){
        int col = c[i-1];
        if(i-p[col]==1||p[col]==0){
            dp[i]=dp[i-1];
        }else{
            dp[i]=(dp[i-1]+dp[p[col]])%MO;
        }
        p[col]=i;
    }
    printf("%d",dp[n]);
}

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

namespace Algorithm
{
    class Program
    {
        const int NumberOfAntennas = 5;

        static void Main(string[] args)
        {
            var read = "";
            var sb = new StringBuilder();
            while (!string.IsNullOrEmpty(read = Console.ReadLine()))
            {
                sb.Append(read.ToLower());
            }

            for (var c = 'a'; c <= 'z'; c++)
            {
                Console.WriteLine($"{c} : {sb.ToString().Count(v => v == c)}");
            }

        }
    }
}



Measured memory_bytes: 18092
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;

//conversion
//------------------------------------------
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(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

inline ll floor(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return a / llb;
	}
	else
	{
		return - ( (-a + llb - 1) / llb);
	}
}

inline ll ceil(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return (a + llb - 1) / llb;
	}
	else
	{
		return - (-a / llb);
	}
}

inline ll getLowestOneBit(ll a)
{
	return a & (-a);
}

inline ll getHighestOneBit(ll a)
{
	while ((a & (a - 1)) != 0)
	{
		a = a & (a - 1);
	}
	return a;
}

inline bool isPower2(ull a)
{
	if (a == 0)
	{
		return false;
	}
	return !(a & (a - 1));
}

inline ll getSpecifiedBit(ll a, unsigned bit)
{
	return (a & (1LL << bit)) >> bit;
}

// computational complexity: o(log(max(a, b))) 
inline ull getGcd(ull a, ull b)
{
	if (b == 0)
	{
		return a;
	}
	return getGcd(b, a % b);
}

template<class Integer>
inline Integer getPower(Integer base, ull exponential)
{
	Integer result = 1;
	while (exponential >= 1)
	{
		if (exponential & 1)
		{
			result = result * base;
		}
		base = base * base;
		exponential >>= 1;
	}

	return result;
}

int main()
{
	ll N, K, Q;
	cin >> N >> K >> Q;
	vector<ll> points(N, K - Q);
	ll a;
	for (ll i = 0; i < Q; ++i)
	{
		cin >> a;
		++points[a - 1];
	}

	for (ll i = 0; i < N; ++i)
	{
		cout << (points[i] > 0 ? "Yes" : "No") << endl;
	}

	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  stack<int> down;
  stack<pair<int,int> > pond;
  cin>>S;
  int nowh = 0, ls = S.size();
  vector<int> hei(ls+1,0);
  rep(i,ls){
    char s = S.at(i);
    if(s == '/'){
      if(down.size()){
	int d = down.top();
	down.pop();
	while(pond.size()){
	  pair<int,int> pa = pond.top();
	  pond.pop();
	  if(d > pa.fi) {
	    pond.push(pa);
	    break;
	  }
	}
	pond.push(make_pair(d,i+1));
      }
      ++nowh;
      hei.at(i+1) = nowh;
      continue;
    }
    if(s == '_') {
      hei.at(i+1) = nowh;
      continue;
    }
    --nowh;
    hei.at(i+1) = nowh;
    down.push(i);
  }
  //cout<<"check"<<endl;
  int k = pond.size(),a = 0;
  vector<int> area(k,0);
  int h;
  rep(i,k){
    pair<int,int> np = pond.top();
    pond.pop();
    reps(j,np.fi,np.se){
      if(j == np.fi){
	h = hei.at(j);
	if(h != hei.at(np.se)) cout<<"wrong"<<endl;
	continue;
      }
      area.at(i) += h - hei.at(j);
    }
    a += area.at(i);
  }
  reverse(area.begin(),area.end());
  cout<<a<<endl;
  cout<<k;
  rep(i,k) cout<<' '<<area.at(i);
  cout<<endl;
  //rep(i,ls+1) cout<<i<<' '<<hei.at(i)<<endl;
}



Measured memory_bytes: 3320
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	x := make([]int, n)
	y := make([]int, n)
	o := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i], &y[i])
		o[i] = i
	}

	var sum float64
	var cnt int
	for {
		var dist float64
		for i := 1; i < n; i++ {
			dx := x[o[i-1]] - x[o[i]]
			dy := y[o[i-1]] - y[o[i]]
			dist += math.Sqrt(float64(dx*dx) + float64(dy*dy))
		}
		sum += dist
		cnt++

		if !nextPermutation(sort.IntSlice(o)) {
			break
		}
	}
	fmt.Println(sum / float64(cnt))
}

func nextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

struct point {
  ll x, y;
};

ll sp(const point& a, const point& b) {
  return a.x * b.x + a.y * b.y;
}

ll vp(const point& a, const point& b) {
  return a.x * b.y - a.y * b.x;
}


int sign(ll x) {
  return (x > 0) - (x < 0);
}

struct line {
  ll a, b, c;
  line(const point &p1, const point& p2) {
    a = p2.y - p1.y;
    b = p1.x - p2.x;
    c = -a * p1.x - b * p1.y;
    assert(side(p1) == 0);
    assert(side(p2) == 0);
  }

  int side(const point &p1) {
    return sign(a * p1.x + b * p1.y + c);
  }
};

int main() {
#ifdef LOCAL
  freopen("b.in", "r", stdin);
  freopen("b.out", "w", stdout);
#endif

  int n;
  while (scanf("%d", &n) == 1) {
    vector<point> v(n);
    for (point& p : v) {
      scanf("%lld%lld", &p.x, &p.y);
      p.x *= 2;
      p.y *= 2;
    }

    vector<point> lf(n);
    vector<point> rg(n);

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i == j) continue;
        line l(v[i], v[j]);
        bool bad = false;
        for (int k = 0; k < n; k++) {
          if (k == i || k == j) continue;
          if (l.side(v[k]) < 0) {
            bad = true;
            break;
          }
          if (l.side(v[k]) == 0) {
            bool ok = false;
            if (min(v[i].x, v[j].x) <= v[k].x && v[k].x <= max(v[i].x, v[j].x)) {
              if (min(v[i].y, v[j].y) <= v[k].y && v[k].y <= max(v[i].y, v[j].y)) {
                ok = true;
              }
            }
            if (!ok) {
              bad = true;
            }
          }
        }
        if (bad) continue;
        lf[i] = rg[j] = {l.a, l.b};
      }
    }

    for (int i = 0; i < n; i++) {
      printf("%.18lf\n", atan2(vp(lf[i], rg[i]), sp(lf[i], rg[i])) / (2 * M_PI));
    }
  }

  return 0;
}


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

int main(){
    int N;
    cin>>N;
    vector<int> H(N);
    bool flag = true;
    for(int i=0;i<N;i++){
        cin>>H.at(i);
    }
    int max = H.at(0);
    for(int i=1;i<N;i++){
        if(max<H.at(i)){
            max = H.at(i);
        }else if(max-H.at(i)>=2){
            flag = false;
        }
    }
    
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long int
using namespace std;

void desperate_optimization(bool submitting=true,int precision=10)
{
  if(!submitting) return;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}
int32_t main()
{
  desperate_optimization(false);
  //freopen("input.txt","r",stdin);
  int n,w;
  cin>>n>>w;
  int maxanswer=0;
  int weights[n+1],values[n+1];
  weights[0]=w+1;
  values[0]=0;
  for(int i=1;i<=n;i++)
  {
    cin>>weights[i]>>values[i];
    maxanswer+=values[i];
  }

  int dp[n+1][maxanswer+1];
  for(int i=0;i<=n;i++) for(int j=0;j<=maxanswer;j++) dp[i][j]=w+1;
  for(int i=0;i<=n;i++) dp[i][0]=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=maxanswer;j++)
    {
      if(j>=values[i])
      {
        dp[i][j]=min(dp[i-1][j-values[i]]+weights[i],dp[i][j]);
      }
      dp[i][j]=min(dp[i][j],dp[i-1][j]);
    }
  }

  int maxval=0;
  for(int j=0;j<=maxanswer;j++) if(dp[n][j]<=w) maxval=max(maxval,j);
  cout<<maxval;




  return 0;
}


Measured memory_bytes: 79104
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int w,h,img[50][50],m[8][8],u[8],c,rectck;
bool upper(int u,int d){
	if(m[u][d]>=0)return m[u][d];
	int t=h,b=0,l=w,r=0;
	rep(i,h)rep(j,w)if(img[i][j]==u){
		if(t>i)t=i; if(b<i)b=i; if(l>j)l=j; if(r<j)r=j;
	}
	rep(i,b-t+1)rep(j,r-l+1){
		if(img[i+t][j+l]==0){
			rectck=0;
		}
		if(img[i+t][j+l]==d){
			m[u][d]=0; return 0;
		}
	}
	m[u][d]=1; return 1;
}
bool rec(){
	if(!rectck)return 0;
	int suc=0,finish=1;
	rep(i,c+1)finish=finish&&u[i];
	if(finish)return 1;
	rep(i,c+1)if(!suc&&!u[i]){
		int fail=0;
		rep(j,c+1)if(i!=j&&u[j]&&!upper(i,j))fail=1;
		if(fail)continue;
		u[i]=1; suc=suc||rec(); u[i]=0;
	}
	return suc;
}
int main(){
	int n; cin>>n;
	while(n--){
		int alpha[26]={0},f=0; c=0;
		cin>>h>>w; rep(i,h)rep(j,w){
			char t; cin>>t;
			if(t=='.'||alpha[t-'A'])img[i][j]=t=='.'?0:alpha[t-'A'];
			else img[i][j]=alpha[t-'A']=++c;
		}
		rep(i,8)rep(j,8)m[i][j]=-1; rep(i,8)u[i]=0; u[0]=1;
		rectck=1;
		rep(i,c)if(rectck&&!f){
			u[i+1]=1; f=rec(); u[i+1]=0;
		}
		cout<<(rectck&&(c==0||f)?"SAFE":"SUSPICIOUS")<<endl;
	}
	return 0;
}

Measured memory_bytes: 864
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    ans = 0
    base = 1
    for i in range(60):
        counter = [0, 0]
        buf = 0
        for j in range(N):
            if A[j] & (1 << i):
                buf += counter[0]
                counter[1] += 1
            else:
                buf += counter[1]
                counter[0] += 1
        ans += buf * base
        ans %= MOD
        base = (base * 2) % MOD
    print(ans)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
	int num,a,b;
	int flag = 0;
	cin >> num;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i % num == 0) {
			cout << "OK"<<endl;
			flag = 1;
			break;
		}
	}
	if (flag == 0)cout << "NG" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

string s;
char t[5] = "AABB";
int r = 0;

struct Graph {
    struct Vertex { int n, p[4]; };
    struct Edge { int i, n; };
    Graph(int n, int m) : v(n, { -1, { 0, 0, 0, 0 } }), e(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n };
        v[i].n = m;
        m++;
    }
    void dfs(int i, int x) {
        if (s[i] != t[x]) return;
        if (v[i].p[x]) {
            if (v[i].p[x] & 2) r = 1;
            return;
        }
        v[i].p[x] = 3;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            dfs(o.i, (x + 1) % 4);
        }
        v[i].p[x] = 1;
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    int n, m;
    cin >> n >> m;

    cin >> s;

    Graph g(n, m * 2);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b);
        g.add_edge(b, a);
    }

    for (int i = 0; i < n; i++) {
        for (int x = 0; x < 4; x++) {
            g.dfs(i, x);
        }
    }

    cout << (r ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 9680
x, y = map(int, input().split())
ans = 0
if x % y == 0:
  ans = -1
else:
  for i in range(1, (10 ** 18 + 1) // x):
    if x * i % y != 0:
      ans = x * i
      break
  if ans == 0:
    ans = -1
print(ans)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (long long i = 0; i < N; i++)

vector<int> to[200005];
vector<int> ans;
void dfs(int v, int p = -1) {
    for (int u : to[v]) {
        if (u == p) continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main() {
    long long N, Q;
    cin >> N >> Q;
    rep(i, N - 1) {
        long long a, b;
        cin >> a >> b;
        cerr << "a: " << a << ", b: " << b << endl;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(N);
    rep(i, Q) {
        long long p, x;
        cin >> p >> x;
        cerr << "p: " << p << ", x: " << x << endl;
        p--;
        ans[p] += x;
    }
    dfs(0);
    rep(i, N) { cout << ans[i] << " "; }
    cout << endl;
    return 0;
}


Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string days[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string S;
  cin >> S;
  for (int i = 0; i < 7; i++)
    if (S == days[i]) {
      cout << 7 - i << '\n';
      break;
    }
  return 0;
}


Measured memory_bytes: 3644
#!/usr/bin/env python3
import sys
import collections

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, K: int, Q: int, A: "List[int]"):
    d = collections.Counter(A)
    for i in range(N):
        print(YES if K - Q + d[i + 1] > 0 else NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(Q)]  # type: "List[int]"
    solve(N, K, Q, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 11996
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

struct L {
	vector<int> ss;
	int on;
};

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

	int n, m; cin >> n >> m;

	vector<L> ls(m);

	FOR_LT(i, 0, m) {
		int k; cin >> k;
		FOR_LT(j, 0, k) {
			int s; cin >> s;
			ls[i].ss.push_back(s - 1);
		}
	}
	FOR_LT(i, 0, m) {
		int p; cin >> p;
		ls[i].on = p;
	}

	int ans = 0;
	for(int s = 0; s < (1 << n); s++) {
		bool is_ok = true;
		for (auto& elem : ls) {
			int c = 0;
			for(auto cur : elem.ss) {
				if (s & (1 << cur)) {
					c++;
				}
			}
			if ((c & 1) != elem.on) {
				is_ok = false;
				break;
			}
		}
		if (is_ok) ans++;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

int n;
set<string> strs;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    cin>>n;
    rep(i, n) {
        string s; cin>>s;
        strs.insert(s);
    }
    cout << strs.size() << '\n';

    return 0;
}


Measured memory_bytes: 19204
s=input()
i=0
j=len(s)-1
c=0
while i<j:
    if s[i]!=s[j]:
        c+=1
        if s[i]=="x":
            i+=1
        elif s[j]=="x":
            j-=1
        else:
            print(-1)
            break
    else:
        i+=1
        j-=1
else:
    print(c)

Measured memory_bytes: 3316
program ABC080B
    implicit none
    integer(8)::N,N1
    integer(8)::d_sum=0
    read(5,*)N

    N1=N
    do
        d_sum=d_sum+mod(N1,10)
        N1=N1/10
        if(N1==0)then
            exit
        end if
    end do

    if(mod(N,d_sum)==0)then
        print'(A)',"Yes"
    else
        print'(A)',"No"
    end if
    
end program ABC080B

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long N = long.Parse(str);
		string[] str2 = Console.ReadLine().Split();
		long[] A = new long[N];
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str2[i]);
		}
		long ans = 0;
		for(var i=0;i<N;i++){
			ans += A[i]-1;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13188
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N;
int X[100010], L[100010];
pair<int, int> ps[100010];

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

    cin >> N;
    REP (i, N) {
        cin >> X[i] >> L[i];
        ps[i] = make_pair(X[i] + L[i], i);
    }
    sort(ps, ps + N);
    int ans = 0, p = -1;
    REP (i, N) {
        if (p == -1 || X[p] + L[p] <= X[ps[i].second] - L[ps[i].second]) {
            p = ps[i].second;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<stdio.h>
#define N 101

int M[N][N];
int d[N];
int flg[N];

typedef struct QQ{
        int num[N];
        int top;
}Que;

Que Q;

void enqueue(int x){
        Q.num[Q.top++]=x;
        return;
}

int dequeue(){
    int x=Q.num[0];
    for(int i=0;i<Q.top-1;i++){
        Q.num[i]=Q.num[i+1];
    }
    Q.top--;
    return x;
}

void bs(int u,int n){
    Q.top=0;
    enqueue(u);
    d[u]++;
    flg[u]=1;
    while(Q.top>0){
        int v=dequeue();     
        for(int i=1;i<=n;i++){        
            if(M[v][i]==1 && !flg[i]){
                enqueue(i);                                                                           d[i]=d[v]+1;
                flg[i]=1;
            }
        }
    }
    return;
}

int main(){
    int n,i,j;
    int x,y,z;
    scanf("%d",&n);
    for(i=0;i<=n;i++){
        d[i]=-1;
        flg[i]=0;
        for(j=0;j<=n;j++){
            M[i][j]=0;
        }
    }
    for(i=0;i<n;i++){
        scanf("%d %d",&x,&y);
        for(j=0;j<y;j++){
            scanf("%d",&z);
            M[x][z]=1;
        }
    }
    bs(1,n);
    for(i=1;i<=n;i++){
        printf("%d %d\n",i,d[i]);
    }
    return 0;
}



Measured memory_bytes: 2140
import java.util.*;import java.io.*;import java.math.*;

public class Main
{

    public static void process()throws IOException
    {
        int n=ni();
        long res=0l;

        for(int i=1;i<=n;i++){
            if(i%3==0 || i%5==0)
                continue;
            res+=i*1l;
        }
        pn(res);
    }


    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

       // oj = System.getProperty("ONLINE_JUDGE") != null;
        if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
        int t=1;
        while(t-->0)
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;



/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
    
    
    

Measured memory_bytes: 32984
#!/usr/bin/env python
"""AtCoder Beginner Contest 081: A - Placing Marbles
https://atcoder.jp/contests/abc081/tasks/abc081_a
"""

__author__ = 'bugttle <bugttle@gmail.com>'


def main():
    s = input()
    print(s.count('1'))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define N 100010
#define ff first
#define ss second 
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
	
	int n;
	cin>>n;
	int ans=0;
	for (int i=0,l,r;i<n;i++){
		scanf("%d%d",&l,&r);
		ans+=r-l+1;
	}
	cout<<ans;
	return 0;
}

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

namespace _0220
{
    class Program
    {
        static void Main(string[] args)
        {
            const int INTEGRAL_LEN = 8;
            const int DECIMAL_LEN = 4;

            while (true)
            {
                double n = RDouble();
                if (n < 0) break;

                int IPart = (int)n;
                double DPart = n - IPart;
                double DPartShifted = DPart * Math.Pow(2, DECIMAL_LEN);

                if (IPart - Math.Pow(2, INTEGRAL_LEN) >= 0 || DPartShifted % 1 > 0)
                {
                    Console.WriteLine("NA");
                }
                else
                {
                    string IPartSt = Convert.ToString(IPart, 2).PadLeft(INTEGRAL_LEN,'0');
                    string DPartSt = Convert.ToString((int)DPartShifted, 2).PadLeft(DECIMAL_LEN, '0');
                    Console.WriteLine("{0}.{1}", IPartSt, DPartSt);
                }
            }
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 20084
#include<cstdio>
using namespace std;
int main(void)
{
	int co[4]={10,50,100,500};
	int kin,mai[4],harai,ma2;
	int i,j,k,ii,i2,j2,k2,ii2,cnt1,cnt2,mn;
	int mi[4];
	int flg;
	flg=1;
	while(1)	{
		scanf("%d",&kin);
		if(kin==0)	break;
		cnt1=0;
		for(i=0;i<4;i++)	{
			scanf("%d",&mai[i]);
			cnt1+=mai[i];
		}
		mn=10000000;
		for(i=0;i<=mai[0];i++)	{
			for(j=0;j<=mai[1];j++)	{
				for(k=0;k<=mai[2];k++)	{
					for(ii=0;ii<=mai[3];ii++)	{
						harai=i*co[0]+j*co[1]+k*co[2]+ii*co[3];
//						printf("harai=%d i=%d j=%d k=%d ii=%d\n",harai,i,j,k,ii);
						
						harai-=kin;
						if(harai<0)	continue;
						ii2=harai/co[3];
						harai%=co[3];
						k2=harai/co[2];
						harai%=co[2];
						j2=harai/co[1];
						i2=harai%co[1];
						ma2=cnt1-i-j-k-ii+i2+j2+k2+ii2;
						if(ma2<mn)	{
							mn=ma2;
							mi[0]=i-i2;	mi[1]=j-j2;	mi[2]=k-k2;	mi[3]=ii-ii2;
						}
					}
				}
			}
		}
		if(flg==0)	printf("\n");
		for(i=0;i<4;i++)	{
			if(mi[i]>0)	{
				printf("%d %d\n",co[i],mi[i]);
			}
		}
		if(flg==1)	flg=0;
	}
	return 0;
}


Measured memory_bytes: 1032
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    int H, N;
    cin >> H >> N;
    int tmp;
    REP(i, N){
        cin >> tmp;
        H -= tmp;
    } 
    string s = "Yes";
    if (H > 0) s = "No";

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
N,x = map(int, input().split())
A = list(map(int, input().split()))


ans = 0
for i in range(N):
    if i == 0:
        if A[i] > x:
            ans += A[i] - x
            A[i] = x

    else:
        if A[i-1] + A[i] > x:
            ans += A[i-1] + A[i] - x
            A[i] = x - A[i-1]

print(ans)

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

int main()
{
	int n,b,ans=0;
	cin >> n;
	vector<int> p;
	for(int i=0;i<n;i++){
		cin >> b;
		p.push_back(b);
	}
	sort(p.rbegin(),p.rend());
	p[0]=p[0]/2;
	for(int i=0;i<n;i++){
		ans+=p[i];
	}
	cout << ans;
	return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

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

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) ;
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

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



int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll a, b, c; cin >> a >> b >> c;
	ll s = (a + b + c) / 2;
	std::cout << (ll)sqrt(s*(s-a)*(s-b)*(s-c))<< std::endl;
	
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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(){
    vector<ll> var(6);
    rep(i,6) cin>>var[i];
    pair<double,double> res={100*min(var[0],var[1]), 0};
    for(ll x=0; 100*x*var[0]<=var[5]; x++){
        for(ll y=0; 100*(x*var[0]+y*var[1])<=var[5]; y++){
            if(x==0 && y==0) continue;
            ll water=100*(var[0]*x+var[1]*y);
            if(water>var[5]) continue;
            ll tmp = min(var[5]-water, var[4]*(var[0]*x+var[1]*y));

            for(ll i=0; var[2]*i<=tmp; i++){
                for(ll j=0; var[2]*i+var[3]*j<=tmp; j++){
                    double sugar=var[2]*i+var[3]*j;
                    if(sugar>tmp) continue;
                    if( (res.first==0 && res.second==0) || res.second/res.first < sugar/(water+sugar)){
                        res.first=water+sugar;
                        res.second=sugar;
                    }
                }
            }
            
        }
    }
    cout<<res.first<<' '<<res.second<<endl;
    return 0;
}

Measured memory_bytes: 256