akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int INF = 2e6;
ll MOD = 1e9 + 7;


int main(){
    
    int n; cin >> n;
    vector<vector<pair<int,ll>>> g(n);
    rep(i,n-1){
        int a, b; ll c;
        cin >> a >> b >> c;
        a--; b--;
        g[a].pb(make_pair(b,c));
        g[b].pb(make_pair(a,c));
    }
    
    int q, k; cin >> q >> k;
    k--;
    vector<int> x(q),y(q);
    rep(i,q) {
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }

    queue<int> que;
    que.push(k);
    vector<bool> vis(n,false);
    vis[k] = true;
    vector<ll> dist(n);

    while(que.size()){
        int v = que.front();
        que.pop();
        for(auto i : g[v]){
            if(!vis[i.first]){
                vis[i.first] = true;
                dist[i.first] = dist[v] + i.second;
                que.push(i.first);                
            }
        }
    }

    rep(i,q){
        cout << dist[x[i]] + dist[y[i]] << endl;
    }
}

Measured memory_bytes: 10752
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  ll l = 1, r = 1;
  rep(i,n){
    ll a,t;
    cin >> a >> t;
    ll m = max((l+a-1)/a,(r+t-1)/t);
    l = m*a, r = m*t; 
  }
  cout << l+r << endl;
}


Measured memory_bytes: 3544
import java.awt.geom.Point2D;
import java.util.*;
public class Main {

	private boolean isNotOverlap(double dis, double r1, double r2){
		final double EPS = 1.0e-08;
		double result = dis - (r1 + r2);
		if(result > EPS)
			return true;
		else
			return false;
	}

	private boolean isInclude(double dis, double r1, double r2){
		final double EPS = 1.0e-08;
		double result = dis + r1 - r2;
		if(result < (EPS * (-1)))
			return true;
		else
			return false;
	}

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=0; i < n; i++){
			double xa = sc.nextDouble();
			double ya = sc.nextDouble();
			double ra = sc.nextDouble();
			double xb = sc.nextDouble();
			double yb = sc.nextDouble();
			double rb = sc.nextDouble();
			double dis = Point2D.distance(xa, ya, xb, yb);
			if(isNotOverlap(dis, ra, rb))
				System.out.println(0);
			else if(isInclude(dis, ra, rb))
				System.out.println(-2);
			else if(isInclude(dis, rb, ra))
				System.out.println(2);
			else
				System.out.println(1);
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}

}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	string c;
	vector<int> conW,  conR;
	int ans = INF;
	
	cin>>N;
	
	conW.resize(N+1);
	conR.resize(N+1);
	
	cin>>c;
	
	for(int i = 0; i < N; i++){
		conW[i+1] += conW[i];
		conR[i+1] += conR[i];
		
		if(c[i] == 'W') conW[i+1]++;
		if(c[i] == 'R') conR[i+1]++;
	}
	
	for(int i = 0; i <= N; i++){
		int lR = conR[i] - conR[0];
		int lW = conW[i] - conW[0];
		
		int rR = conR[N] - conR[i];
		int rW = conW[N] - conW[i];
		
		// cout<<lW<<" "<<rR<<endl;
		int temp = 0;
		int minimum = min(lW, rR);
		
		temp += minimum;
		
		temp += lW - minimum;
		temp += rR - minimum;
		
		ans = min(ans, temp);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

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

using namespace std;
using ll = long long;

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

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

    int N;
    std::cin >> N;
    std::vector<pair<int, int>> A(N);
    REP(i, N) {
        int a;
        std::cin >> a;
        A[i]= make_pair(a, i + 1);
    }

    SORT(A);

    REP(i, N) {
        std::cout << A[i].second << " ";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
int main(){
    int a,b,i=0;
    cin >> a >> b;
    if((a+b)%2 == 0){
        cout << (a+b)/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
h = list(map(int, input().split()))
cnt = n
ng = {}
for i in range(m):
  a,b = map(int, input().split())   
  if h[a-1] >= h[b-1]:
    ng[b] = 1
  if h[a-1] <= h[b-1]:
    ng[a] = 1
print(n -len(ng))

Measured memory_bytes: 20100
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

#include <bits/stdc++.h>
using namespace std;






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

    char c; cin >> c;

    int n = (int)c;
    n += 1;
    c = (char)n;
    cout << c;
    


    return 0;
}


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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   200005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/









int main()
{
    ll a,b,n=0,i;
    cin>>a>>b;
    if(b==1)
    {
        cout<<0<<endl;
        return 0;
    }
    for(i=0;;i++)
    {
        if(i==0)
            n+=a;
        else
            n+=(a-1);
        if(n>=b)
            break;
    }
    cout<<i+1<<endl;
	return 0;
}
































Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main( String[] args ) throws IOException
    {
        BufferedReader br = new BufferedReader(
                                new InputStreamReader( System.in ) );
        String  s = br.readLine();
        int N = Integer.parseInt(s);
        System.out.println((N*(N+1))/2);
	}

}


Measured memory_bytes: 8020
#include<bits/stdc++.h>
#define int long long
#define nl '\n'
 using namespace std;

const int mod = 998244353;
const int N = 3E5 + 1;
int n, k;
int a[N], tree[4 * N];

void update(int node, int st, int en, int idx, int val){
   if(st == en){
      tree[node] = val;
      return;
   }
   int mid = (st + en) / 2;
   if(idx <= mid)
     update(2 * node, st, mid, idx, val);
   else
     update(2 * node + 1, mid + 1, en, idx, val);

   tree[node] = max(tree[2 * node], tree[2 * node + 1]);
}

int query(int node, int st, int en, int l, int r){
    if(st > r || en < l)
       return 0;

    if(l <= st && en <= r)
       return tree[node];
     
    int mid = (st + en) / 2;
    int left = query(2 * node, st, mid, l, r);
    int right = query(2 * node + 1, mid + 1, en, l, r);

    return max(left, right); 
}

int32_t main() 
{

  cin >> n >> k;

  for(int i = 1; i <= n; i++){
     cin >> a[i];
     a[i]++;
  }
 
  for(int i = 1; i <= n; i++){
      int x = a[i];
      int l = max(1LL, x - k), r = min(N, x + k);
      int mx = query(1, 1, N, l, r);
      update(1, 1, N, x, 1 + mx);
  }

  int ans = query(1, 1, N, 1, N);
 
  cout << ans;

  return 0;
}



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


void solve(long long N, long long M, long long X, long long Y, std::vector<long long> x, std::vector<long long> y){
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    for(long long i = -100; i <= 100; ++i){
        if((X < i) && (i <= Y) && (x[N-1] < i) && (y[0] >= i)){
            cout << "No War" << endl;
            return;
        }else{
            continue;
        }
    }
    cout << "War" << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    std::vector<long long> x(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
    }
    std::vector<long long> y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&y[i]);
    }
    solve(N, M, X, Y, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    int a[n];
    long long ans = 1000000000;
    REP(i, n)
    {
        cin >> a[i];
    }
    for (int i = -100; i <= 100; i++)
    {
        long long tmp = 0;
        REP(j, n)
        {
            tmp += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

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

const int N = 100005;

int n, a[N];
long long res;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];

	int cur = 1;
	for (int i = 1; i <= n; ++i) {
		int rem = a[i] % cur;
		if (rem == 0) {
			res += a[i] / cur - 1;
			if (a[i] == cur || cur == 1) {
				++cur;
			}
		} else {
			res += a[i] / cur;
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define MAXN 200000
#define DEBUG false

int N;
LL K, A[MAXN + 3];

int main() {
    cin >> N >> K;
    for (int i = 1; i <= N; i++)
        cin >> A[i];

    sort(A + 1, A + N + 1);

    LL lo = -1e18, hi = 1e18, mid;
    while (hi >= lo) {
        mid = (lo + hi)/2;

        LL numBelowMid = 0;
        for (int i = 1; i <= N; i++) {
            if (A[i] > 0) {
                int l = i + 1, r = N, m;
                while (r >= l) {
                    m = (l + r)/2;
                    if (A[i] * A[m] <= mid)
                        l = m + 1;
                    else
                        r = m - 1;
                }

                numBelowMid += (r - i);

                if (DEBUG) {
                    cout << "positive " << mid << " " << A[i] << " " << r << endl;
                }

            } else if (A[i] < 0) {
                int l = i + 1, r = N, m;
                while (r >= l) {
                    m = (l + r)/2;
                    if (A[i] * A[m] > mid)
                        l = m + 1;
                    else
                        r = m - 1;
                }

                numBelowMid += (N - l + 1);

                if (DEBUG) {
                    cout << "negative " << mid << " " << A[i] << " " << l << endl;
                }
            } else if (A[i] == 0) {
                if (mid >= 0)
                    numBelowMid += (N - i);
            }
        }

        if (DEBUG)
            cout << "numBelowMid " << mid << " " << numBelowMid << endl;

        if (numBelowMid < K)
            lo = mid + 1;
        else
            hi = mid - 1;
    }

    cout << lo << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

ll abs_(ll x){
    if(x > 0) return x;
    else return -x;
}

int main(){
    ll a[2], c[2];
    cin >> a[0] >> a[1] >> c[0] >> c[1];
    ll ans = -1000000000000000001;
    rep(i, 2){
        rep(j, 2){
            ans = max(ans, a[i] * c[j]);
        }
    }
    // ans = max(max(abs(a), abs(b)), max(abs(c), abs(d)));
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void solve()
{
   ll x;
   cin>>x;
   ll d=(x/500);
   ll ans=d*1000;
   x%=500;
   d=(x/5);
   ans+=(d*5);
   cout<<ans;
}
int main()
{
  ll t=1;
 // cin>>t;
  while(t--)
  {
    solve();
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
	fastio; string s;
  cin >> s; cout << s.substr(0, 3);
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;

int n;
int a, b, c;
vector<int> l;

int mp = 1e9;
int func(int pos, int la, int lb, int lc, int p) {
  if(pos == n) {
    if(la == 0 || lb == 0 || lc == 0) return 0;
    mp = min(mp, p + abs(a-la) + abs(b-lb) + abs(c-lc) - 30);
    return 0;
  }

  func(pos + 1, la + l[pos], lb, lc, p + 10);
  func(pos + 1, la, lb + l[pos], lc, p + 10);
  func(pos + 1, la, lb, lc + l[pos], p + 10);
  func(pos + 1, la, lb, lc, p);
  return 0;
}

int main() {
  cin >> n;
  cin >> a >> b >> c;
  l.resize(n);
  for(int i=0; i<n; i++) cin >> l[i];
  func(0, 0, 0, 0, 0);
  cout << mp << endl;

  return 0;
}


//EOF


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# スペース区切りの整数の入力
a = list(map(int, input().split()))

inv_sum = 0
for i in range(n):
    inv_sum += 1 / a[i]

result = 1 / inv_sum

print(str(result))


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  if ( N*A < B ){
   cout << N*A << endl; 
  }
  
  else {
    cout << B << endl; 
  }
  // ここにプログラムを追記
}


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

//Compiler version g++ 6.3.0

int main()
{
    //cout << "Hello, Dcoder!";
    string s;
    cin >> s;
    int o = 0;
    for(auto &c:s){
      if(c=='R'){
        o++;
      }
    }
    if(s == "RSR") {
      cout << 1 << endl;
    } else
    cout << o << endl;
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
	fast;
	int n;
	int ans = 0;
	cin >> n;
	f(i,1,n+1){
		f(j,1,n+1){
			f(k,1,n+1){
				ans += __gcd(i , __gcd(j,k));
			}
		}
	}

	cout << ans;
}

Measured memory_bytes: 3640
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,m;
  cin>>n>>m;
  vector<int> g(n);
  rep(i,m){
    int x,y;
    cin>>x>>y; --x; --y;
    ++g[x]; ++g[y];
  }
  for(int x:g) cout<<x<<endl;
  return 0;
}


Measured memory_bytes: 256
n,C = map(int,input().split())
st = [[] for _ in range(C)]
st2 = [[] for _ in range(C)]

for _ in range(n):
    s,t,c = map(int,input().split())
    st[c-1].append((s,t))

for i in range(C):
    st[i].sort()

for i,e in enumerate(st):
    s1 = -1
    t1 = -1
    for j in e:
        if s1 == -1:
            s1 = j[0]
            t1 = j[1]
        else:
            if j[0] == t1:
                t1 = j[1]
            else:
                st2[i].append((s1-1,t1))
                s1 = j[0]
                t1 = j[1]
    if s1 != -1:
        st2[i].append((s1-1,t1))

imos = [0]*(2*10**5+10)

for i in st2:
    for j in i:
        imos[int(j[0]*2)] += 1
        imos[int(j[1]*2)] -= 1

for i in range(2*10**5+5):
    imos[i+1] += imos[i]

print(max(imos))


Measured memory_bytes: 59480
S = list(input())
N = len(S)-1
ans = int("".join(S))
for i in range(1,2**N):
    s = []
    n = i
    for j in range(N):
        s.append(n%2)
        n//=2
    m = S[0]
    for j in range(N):
        if s[j]:m+="+"
        m+=S[j+1]
    ans+=eval(m)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n; int ex=0;
	for(int i=0;i<n;i++)
	{
		int x; cin>>x; 
		if(x&1) ex=1;
	}
	cout<<(ex==0?"second":"first")<<'\n';
}


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



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

int main() {
  int n;
  cin >> n;
  vector<int> p(50);
  for (int i; i < n; i++) cin >> p.at(i);
  
  int counter = 0;
  for (int i=1; i < n-1; i++) {
    int M_p = max(p.at(i-1), p.at(i+1));
    int m_p = min(p.at(i-1), p.at(i+1));
    if (p.at(i) < M_p && p.at(i) > m_p) counter++;
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll ans;
    if(n%2){
        ans=0;
    }else{
        n/=2;
        ans=0;
        while(n){
            ans+=(n/5);
            n/=5;
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var A,B,C int
	var count int
	
	numberArray := []int{A,B,C}
	
	for index,_ := range numberArray {
		fmt.Scan(&numberArray[index])
	}

	A = numberArray[0]
	B = numberArray[1]
	C = numberArray[2]

	if A != B || B != C {
		max := maxIndex(numberArray)
		mid := midIndex(numberArray)
		min := minIndex(numberArray)

		for count = 0;arrayHasDiffElements(numberArray);count++ {
			max = maxIndex(numberArray)
			mid = midIndex(numberArray)
			min = minIndex(numberArray)

			switch {
			case numberArray[max] == numberArray[mid]:
				addToOne(&numberArray[min])
			default:
				addToBoth(&numberArray[mid],&numberArray[min])
			}
		}
	}
	fmt.Print(count)
}

func arrayHasDiffElements(array []int) bool{
	number := array[0]
	for _,val := range array {
		if number != val {
			return true
		}
	}
	return false
}

func midIndex(numberArray []int) int {
	highIndex := maxIndex(numberArray)
	lowIndex := minIndex(numberArray)
	for index,_ := range numberArray {
		if !(highIndex == index || lowIndex == index) {
			return index
		}
	}
	return -1
}

func maxIndex(numberArray []int) int {
	high := int(math.Max(math.Max(float64(numberArray[0]),float64(numberArray[1])),float64(numberArray[2])))
	for index,value := range numberArray {
		if high == value {
			return index
		}
	}
	return -1
}

func minIndex(numberArray []int) int {
	low := int(math.Min(math.Min(float64(numberArray[0]),float64(numberArray[1])),float64(numberArray[2])))
	for index,value := range numberArray {
		if low == value {
			return index
		}
	}
	return -1
}

func addToBoth(num1,num2 *int) {
	*num1++
	*num2++
}

func addToOne(num *int) {
	*num += 2
}



Measured memory_bytes: 512
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);
  
  if(n==2){
    printf("-1");
    return 0;
  }
  
  int i,j,p,q;
  
  if(n%3==0){
    for(i=0;i<=n-1;i++){
      for(j=1;j<=i/3;j++){
        printf("...");
      }
      if(i%3==0){
        printf("aa.");
      }else{
        printf("..a");
      }
      for(j=i/3+2;j<=n/3;j++){
        printf("...");
      }
      printf("\n");
    }
    return 0;
  }
  
  p=n/6;
  q=n%6;
  
  if(q==1){
    for(i=1;i<=7;i++){
      if(i==1){
        printf("aabbcc.");
      }else if(i==2){
        printf("d..e..f");
      }else if(i==3){
        printf("d..e..f");
      }else if(i==4){
        printf("gghh..i");
      }else if(i==5){
        printf(".jj.kki");
      }else if(i==6){
        printf("....lmn");
      }else{
        printf("....lmn");
      }
      for(j=8;j<=n;j++){
        printf(".");
      }
      printf("\n");
    }
  }else if(q==2){
    for(i=1;i<=8;i++){
      if(i==1){
        printf("aacd....");
      }else if(i==2){
        printf("bbcd....");
      }else if(i==3){
        printf("efgg....");
      }else if(i==4){
        printf("efhh....");
      }else if(i==5){
        printf("....iikl");
      }else if(i==6){
        printf("....jjkl");
      }else if(i==7){
        printf("....mnoo");
      }else{
        printf("....mnpp");
      }
      for(j=9;j<=n;j++){
        printf(".");
      }
      printf("\n");
    }
  }else if(q==4){
    for(i=1;i<=4;i++){
      if(i==1){
        printf("aacd");
      }else if(i==2){
        printf("bbcd");
      }else if(i==3){
        printf("efgg");
      }else{
        printf("efhh");
      }
      for(j=5;j<=n;j++){
        printf(".");
      }
      printf("\n");
    }
  }else{
    for(i=1;i<=5;i++){
      if(i==1){
        printf("aabbc");
      }else if(i==2){
        printf("d.e.c");
      }else if(i==3){
        printf("d.eff");
      }else if(i==4){
        printf("gg.ij");
      }else{
        printf(".hhij");
      }
      for(j=6;j<=n;j++){
        printf(".");
      }
      printf("\n");
    }
  }
  
  if(q==1||q==2){
    q=q+6;
    p=p-1;
  }
  
  for(i=0;i<=n-q-1;i++){
    for(j=1;j<=q;j++){
      printf(".");
    }
    for(j=1;j<=i/6;j++){
      printf("......");
    }
    if(i%6==0){
      printf("aabcc.");
    }else if(i%6==1){
      printf("d.b..f");
    }else if(i%6==2){
      printf("dee..f");
    }else if(i%6==3){
      printf("gg.hhi");
    }else if(i%6==4){
      printf("..jk.i");
    }else{
      printf("..jkll");
    }
    for(j=i/6+2;j<=p;j++){
      printf("......");
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<limits>
using namespace std;

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

typedef long long ll;

int main() {
	char b;
	cin >> b;
	if (b == 'A') cout << 'T' << endl;
	if (b == 'T') cout << 'A' << endl;
	if (b == 'G') cout << 'C' << endl;
	if (b == 'C') cout << 'G' << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;

llint n;
llint l[100005], r[100005];
set<P> lset, rset;

llint calc(llint dir)
{
	for(int i = 1; i <= n; i++){
		lset.insert(P(l[i], i));
		rset.insert(P(r[i], i));
	}
	llint x = 0, y, id, ret = 0;
	while(lset.size()){
		if(dir == 0){
			y = lset.rbegin()->first;
			id = lset.rbegin()->second;
			if(y <= x) break;
		}
		else{
			y = rset.begin()->first;
			id = rset.begin()->second;
			if(y >= x) break;
		}
		ret += abs(x-y), x = y;
		lset.erase(P(l[id], id));
		rset.erase(P(r[id], id));
		dir = 1 - dir;
	}
	ret += abs(x);
	return ret;
}

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> l[i] >> r[i];
	
	llint ans = max(calc(0), calc(1));
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  string s;
  cin >> s;
  vector <ll> a;
  vector <ll> b;
  rep(i, s.size()) {
    if (s.at(i) == 'A') a.push_back(i);
    if (s.at(s.size()-1-i) == 'Z') b.push_back(s.size()-1-i);
  }
  cout << b.at(0)-a.at(0)+1 << endl;
}

Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int m=pow(2,n);
    vec s(m);
    rep(i,m) cin>>s[i];
    sort(all(s),greater<ll>());
    priority_queue<int> Q;
    Q.push(m);
    int i=0;
    while(i<m){
        int a=s[i],b=0;
        while(a==s[i]&&i<m) i++,b++;
        if(b>Q.size()){
            cout<<"No\n";
            return 0;
        }
        vec A;
        rep(j,b){
            int c=Q.top();Q.pop();
            int p=log2(c);
            rep(k,p) A.push_back(c/2),c/=2;
        }
        for(auto a:A) Q.push(a);
    }
    cout<<"Yes\n";
}

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

int n, d, x, a, r;

int main() {
	cin >> n >> d >> x;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		for (int j = 1; j <= d; j += a) r++;
	}
	r += x;
	cout << r << endl;
}

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

using namespace std;

const int N = 2e5 + 5;

vector<int> g[N];

int d[N];

void dfs(int v, int par = -1) {
  if (par == -1)
    d[v] = 0;
  else
    d[v] = d[par] + 1;
  for (int u : g[v]) {
    if (u == par) continue;
    dfs(u, v);
  }
}

int grund[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n-1; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0);
  int root = 0;
  for (int i = 0; i < n; ++i)
    if (d[i] > d[root])
      root = i;
  dfs(root);
  int dia = 0;
  for (int i = 0; i < n; ++i)
    dia = max(dia, d[i]);
  ++dia;
  grund[0] = 0;
  grund[1] = 1;
  for (int i = 2; i <= dia; ++i) {
    grund[i] = 0;
    set<int> st;
    if (i > 2)
      st.insert(grund[i-2]);
    st.insert(grund[i-1]);
    for (int x : st)
      grund[i] += x == grund[i];
  }
  puts(grund[dia] ? "First" : "Second");

  return 0;
}


Measured memory_bytes: 22144
#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

#[macro_export]
macro_rules! minimum {
    ($($e:expr),+) => {
        {
            let mut res = Vec::new();
            $(
                res.push($e);
            )+
            res.into_iter().min().unwrap()
        }
    };
}

pub const MOD: usize = 1000000007;

fn main() {
    let s: String = input();
    println!("{} {}", &s[..4], &s[4..]);
}

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}

pub fn input_matrix<T: FromStr + Clone>(h: usize) -> Vec<Vec<T>> {
    let mut res = vec![Vec::new(); h];
    for i in 0..h {
        res[i] = input_vec();
    }
    res
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
template <class T> T min2(T a,T b){if(a<b) return a;return b;};

typedef long long ll;

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll k;
    cin>>k;
    ll ans=0;
    if(a>= b && a>= c)
    {
        ans+=b+c+a*(1L<<k);
    }
    else if( b>= a && b>= c)
    {
        ans+=a+c+b*(1L<<k);
    }
    else
    {
        ans+=a+b+c*(1L<<k);
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

void solve(int test_case) {
	int d,t,s;
	cin>>d>>t>>s;
	if(t*s>=d)cout<<"Yes";
	else cout<<"No";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3608
<?php
$W=strtolower(trim(fgets(STDIN)));
$C=0;
while(1){
  $T=trim(fgets(STDIN));
  if($T=='END_OF_TEXT') break;
  foreach(explode(' ',strtolower($T)) as $t) if($t==$W) ++$C;
}
echo $C;
?>

Measured memory_bytes: 15300
#include <stdio.h>
int main(void)
{
  int x,cube; //変数xの宣言(int型の整数)
  scanf("%d",&x); //キーボード入力
  if(1<=x&&x<=100)
  {
    cube=x*x*x;
    printf("%d\n",cube);
  }
	return 0;
}



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

long long N, A[1 << 17], dp[1 << 17]; vector<pair<long long, long long>> vec, G; vector<int> X[1 << 17];
long long dist[1 << 17], par[1 << 17], dp2[1 << 17];

void dfs(int pos, int dst) {
	dist[pos] = dst; dp2[pos] = 1;
	for (int i = 0; i < X[pos].size(); i++) {
		if (dist[X[pos][i]] != -1) continue;
		par[X[pos][i]] = pos; dfs(X[pos][i], dst + 1);
		dp2[pos] += dp2[X[pos][i]];
	}
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) { cin >> A[i]; vec.push_back(make_pair(A[i], i)); }
	sort(vec.begin(), vec.end());

	// 1 個正しい木を構築する
	for (int i = vec.size() - 1; i >= 0; i--) {
		int pos = vec[i].second;
		dp[pos] += 1;
		if (dp[pos] != N) {
			long long SA = A[pos] + (dp[pos] - (N - dp[pos]));
			int pos1 = lower_bound(vec.begin(), vec.end(), make_pair(SA, 0LL)) - vec.begin();
			pos1 = vec[pos1].second;
			dp[pos1] += dp[pos];
			G.push_back(make_pair(pos1, pos));
			X[pos1].push_back(pos); X[pos].push_back(pos1);
		}
	}

	// この木が正しいか判定する
	for (int i = 1; i <= N; i++) dist[i] = -1;
	dfs(1, 0);
	long long S = 0; for (int i = 1; i <= N; i++) { S += dist[i]; if (dist[i] == -1) S = (1LL << 60); }
	if (S != A[1]) {
		cout << "-1" << endl;
		return 0;
	}
	for (int i = 2; i <= N; i++) {
		long long SA = dp2[i] - (N - dp2[i]);
		if (A[i] + SA != A[par[i]]) {
			cout << "-1" << endl;
			return 0;
		}
	}

	for (int i = 0; i < G.size(); i++) { if (G[i].first > G[i].second) swap(G[i].first, G[i].second); }
	sort(G.begin(), G.end());
	for (int i = 0; i < G.size(); i++) cout << G[i].first << " " << G[i].second << endl;
	return 0;
}

Measured memory_bytes: 19952
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define NL << endl

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

signed main() {
	int n;
	ll ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}

	cout << ans NL;

	return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += sc.nextInt();
            w[i] = sum;
        }
        
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int r = Math.abs(w[i] - (sum - w[i]));
            if (r < min) {
                min = r;
            }
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;

int main(){

  ll n, a[200000];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  if(n==1){
    cout << a[0] << endl;
    return 0;
  }
  if(n%2==0){
    for(int i=n-1; 0<=i; i-=2){
      cout << a[i] <<" ";
    }
    for(int i=0; i<n; i+=2){
      cout << a[i] <<" ";
    }
    cout << endl;
  } else {
    for(int i=n-1; 0<=i; i-=2){
      cout << a[i] <<" ";
    }
    for(int i=1; i<n; i+=2){
      cout << a[i] <<" ";
    }
    cout << endl;
  }

	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define P 1000000007
#define LL long long
using namespace std;
int n,m;
int f[123123][14];
char s[123123];
int main()
{
	int i,j,k,t;
  scanf("%s",s+1),n=strlen(s+1);
  t=1;
  f[n+1][0]=1;
  for(i=n;i>=1;i--)
    {
      if(s[i]>='0' && s[i]<='9')
        {
          for(j=0;j<=12;j++)
            f[i][((LL)t*(s[i]-'0')+j)%13]=f[i+1][j];
		}
	  else
	    {
		  for(k=0;k<=9;k++)
		    for(j=0;j<=12;j++)
            f[i][((LL)t*(k)+j)%13]=(f[i][((LL)t*(k)+j)%13]+f[i+1][j])%P;
		}
	  t=(LL)t*10%13;
	}  
	printf("%d\n",f[1][5]);
} 

Measured memory_bytes: 6400
#include<cstdio>
using namespace std;

int main(){
  int A, B;

  scanf("%d %d", &A, &B);

  int n;

  n = (B-1) / (A-1);

  int ans = 0;

  if (B-1 == n * (A-1)) ans = n;
  else ans = n+1;

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
  int h, w, occ[50][50] = {};
  cin >> h >> w;
  char s[h][w];
  for (int i = 0; i < h; i++) {
    string str;
    cin >> str;
    for (int j = 0; j < w; j++) {
      s[i][j] = str[j];
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        for (int k = i - 1; k <= i + 1; k++) {
          for (int l = j - 1; l <= j + 1; l++) {
            if (k >= 0 && k < h && l >= 0 && l < w) {
              occ[k][l]++;
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        cout << '#';
      } else {
        cout << occ[i][j];
      }
    }
    cout << endl;
  }
  return 0;
}


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

main(){
  string s,ans;
  cin >> s;
  
  if(s=="Sunny"){
    ans = "Cloudy";
  }else if(s=="Cloudy"){
    ans = "Rainy";
  }else{
    ans = "Sunny";
  }
  
  cout << ans << endl;
}


  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb() push_back()
#define INF 1000000000
using namespace std;
const ll num = 1e18;
const int mod = 1e9+7;

int main(){
	ll x;
	cin>>x;
	ll vec[x+1];
	int flag = false;
	for(int i = 0; i < x; i++){
		cin>>vec[i];
		if(vec[i] == 0) flag = true;
	}
	if(flag){
		cout<<0;
		return 0;
	}
	ll p = 1;
	for(int i = 0; i < x; i++){
		
		if(num/p < vec[i]){
			
			cout<<-1;
			return 0;
		}
		p*= vec[i];
	}
	cout<<p;
	
	
	
		return 0;
}


Measured memory_bytes: 4364
#include<iostream>
#include<map>

using namespace std;

int main(){
    int n;
    map<int,int> m;
    long long ans = 1,cnt = 0;

    cin >> n;

    for(int i = 0;i < n;i++){
        int a;
        cin >> a;
        m[a]++;
        if(m[a] > 1)cnt++;
    }

    for(int i = 0;i < cnt;i++){
        ans *= 2;
        ans %= 1000000007;
    }

    if(n%2 == 0){
        for(int i = 0;i < n;i+=2){
            if(m[i+1] != 2){
                cout << 0 << endl;
                return 0;
            }
        }
    }else{
        if(m[0] != 1){
            cout << 0 << endl;
            return 0;
        }
        for(int i = 2;i < n;i+=2){
            if(m[i] != 2){
                cout << 0 << endl;
                return 0;
            }
        }
    }

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

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring>
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
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> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));
const ll MOD = 1e9+7;
long long powmod(long long x,long long n){
    long long ret=1;
    while(n>0){
        if(n&1){
            ret*=x;
            ret%=MOD;
            n-=1;
        }else{
            x*=x;
            x%=MOD;
            n>>=1;
        }
    }
    return ret;
}
signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int n; cin >> n;

    ll ans=powmod(10,n);
    ans-=powmod(9,n); ans=(ans+MOD)%MOD;
    ans-=powmod(9,n); ans=(ans+MOD)%MOD;
    ans+=powmod(8,n); ans=(ans+MOD)%MOD;
    cout << ans << endl;
}




Measured memory_bytes: 3660
n1,a1,b1=input().split()
n2,a2,b2=input().split()
n3,a3,b3=input().split()
n4,a4,b4=input().split()
n5,a5,b5=input().split()
n6,a6,b6=input().split()
n7,a7,b7=input().split()
n8,a8,b8=input().split()
n9,a9,b9=input().split()

c1=int(a1)+int(b1)
c2=int(a2)+int(b2)
c3=int(a3)+int(b3)
c4=int(a4)+int(b4)
c5=int(a5)+int(b5)
c6=int(a6)+int(b6)
c7=int(a7)+int(b7)
c8=int(a8)+int(b8)
c9=int(a9)+int(b9)

d1=int(a1)*200+int(b1)*300
d2=int(a2)*200+int(b2)*300
d3=int(a3)*200+int(b3)*300
d4=int(a4)*200+int(b4)*300
d5=int(a5)*200+int(b5)*300
d6=int(a6)*200+int(b6)*300
d7=int(a7)*200+int(b7)*300
d8=int(a8)*200+int(b8)*300
d9=int(a9)*200+int(b9)*300

print(n1,c1,d1)
print(n2,c2,d2)
print(n3,c3,d3)
print(n4,c4,d4)
print(n5,c5,d5)
print(n6,c6,d6)
print(n7,c7,d7)
print(n8,c8,d8)
print(n9,c9,d9)




Measured memory_bytes: 5616