akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PI;

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

// Self settings
// clang-format off
#define MAX_N 200
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N;
bool F[MAX_N][5][2];
int P[MAX_N][11];
int cnt[MAX_N];

void resetcnt()
{
  for (int i = 0; i < N; i++) cnt[i] = 0;
}

int cntSum()
{
  int sum = 0;
  for (int i = 0; i < N; i++) sum += cnt[i];
  return sum;
}

vector<PI> workingDays(int n)
{
  vector<PI> wds;
  for (int i = 0; i < 10; i++) {
    int c = 1 << i;
    if ((c & n) > 0) {
      int date = i % 5;
      int time = i % 2;
      wds.push_back(PI(date, time));
    }
  }
  return wds;
}

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

  cin >> N;
  REP(i, N) REP(j, 5) REP(k, 2) cin >> F[i][j][k];
  REP(i, N) REP(j, 11) cin >> P[i][j];

  int ans = -INT_MAX;
  for (int i = 0; i < (1 << 10); i++) {
    // 1 2 3 4 5 6 7 8 9 10
    resetcnt();
    int p = 0;

    vector<PI> wds = workingDays(i);
    if (wds.size() == 0) continue;
    for (int j = 0; j < N; j++) {
      for (auto wd : wds) {
        // printf("%d %d ", wd.first, wd.second);
        if (F[j][wd.first][wd.second]) {
          cnt[j]++;
        }
      }
      p += P[j][cnt[j]];
      // printf(" => %d ", p);
      // cout << endl;
    }
    // cout << p << " ";
    ans = max(ans, p);
  }
  // cout << endl;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
typedef unsigned long long int ull;

using namespace std;

int main(void){
  int A,B,sum=1;
  cin >> A >> B;
  int ans=0;
  while(sum<B) ans++,sum+=(A-1);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int dat[100];
int main()
{
	int num;
	scanf("%d", &num);
	int m = 0;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		dat[z]++;
		m = max(m, z);
	}	
	int x = (m + 1) / 2;
	bool f = true;
	for (int i = 1; i <= m; i++)
	{
		if (i < x)
		{
			if (dat[i] != 0)f = false;
		}
		else if (i == x)
		{
			if (m % 2 == 0)
			{
				if (dat[i] != 1)f = false;
			}
			else
			{
				if (dat[i] != 2)f = false;
			}
		}
		else
		{
			if (dat[i] < 2)f = false;
		}
	}
	if (f)printf("Possible\n");
	else printf("Impossible\n");
}

Measured memory_bytes: 128
#include <stdio.h>
int main(){
int a,s,d,q;
  scanf("%d %d %d",&a,&s,&d);
 for(q=0;q<s;q++){
  printf("%d ",d);
  }if(d>10){d--;
  for(q=a-s;q>0;q--){
  printf("%d ",d);}
  }
  else{d++;
    for(int q=a-s;q>0;q--){
  printf("%d ",d);}
  }
return 0;
}

Measured memory_bytes: 1280
import java.io.*;
import java.util.*;

public class Main {


    public static void main(String[] args) throws Exception {

        FastReader fs = new FastReader();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = fs.nextInt() ;
      int x = fs.nextInt() ;
      int t = fs.nextInt() ;
      
      float nf = n ;
      float xf = x;
      
      out.println((int)Math.ceil(nf/xf)*t);

        out.close();

    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //--------------------------------------------------------
}


Measured memory_bytes: 32920
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int[] NHW = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		List<long[]> list = new ArrayList<>(NHW[0]);
		br.lines().forEach(s -> {
			long[] ab = Arrays.stream(s.split(" ")).mapToLong(Long::parseLong).toArray();
			list.add(ab);
		});
		br.close();
		System.out.println(list.stream().filter(n -> n[0] >= NHW[1] && n[1] >= NHW[2]).count());
	}

}


Measured memory_bytes: 26708
use std::collections::HashSet;

fn main() {
    let _ = read::<usize>();
    let v = read_vec::<usize>();
    let mut map: HashSet<usize> = HashSet::new();
    let size = v.len();
    for a in v {
        map.insert(a);
    }

    if size == map.len() {
        println!("YES");
    } else {
        println!("NO");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 13996
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; 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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll N, M;
ll S[2010], T[2010];
ll dp[2010][2010];
ll cum[2010][2010];

int main() {
  cin >> N >> M;
  rep(i, 0, N) { cin >> S[i]; }
  S[N] = -1;
  rep(i, 0, M) { cin >> T[i]; }
  T[M] = -1;

  dp[0][0] = 1;
  cum[0][0] = dp[0][0];
  repe(i, 1, N) { cum[i][0] = cum[i - 1][0]; }
  repe(i, 1, M) { cum[0][i] = cum[0][i - 1]; }

  repe(i, 0, N) {
    repe(j, 0, M) {
      if (S[i] != T[j]) {
        dp[i + 1][j + 1] = 0;
      } else {
        dp[i + 1][j + 1] = cum[i][j];
      }
      cum[i + 1][j + 1] =
          dp[i + 1][j + 1] + cum[i + 1][j] + cum[i][j + 1] - cum[i][j] + MOD;
      cum[i + 1][j + 1] %= MOD;
    }
  }

  cout << dp[N + 1][M + 1];
}


Measured memory_bytes: 66468
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define INF 1e9+7
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int m,n;

int f(ll mx,vector<int>a){
    for(int j=1;mx*j<=2*m;j+=2){
        bool ok=true;
        rep(i,n){
            if(mx*j%a[i]!=0||mx*j/a[i]%2==0){
                ok=false;
                break;
            }
        }
        if(ok)return mx*j;
    }
    return 0;
}
int main(){
    cin>>n>>m;
    vector<int>a(n);
    ll mx=0;
    rep(i,n){
        cin>>a[i];
        mx=max(mx,(ll)a[i]);
    }
    //cout<<mx<<endl;
    
    mx=f(mx,a);
    if(mx==0){
        cout<<0<<endl;
        return 0;
    }
    mx/=2;
    //cout<<mx<<endl;
    ll ans=0;
    for(int i=1;mx*i<=m;i+=2){
        ans++; 
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long x;
	register long long i,q=100;
	cin>>x;
	for(i=1;i<=10000;++i){
		q*=1.01;
		if(q>=x)break;
		//cout<<x<<" "<<i<<" "<<q<<endl; 
	}
	cout<<i;
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}

func init() {
	nextReader = newScanner()
}

func main() {
	N, K := nextInt(), nextInt()
	var A = make([]int, N)
	for i := 0; i < K; i++ {
		d := nextInt()
		for j := 0; j < d; j++ {
			A[nextInt()-1] += 1
		}
	}
	var ans int
	for i := 0; i < N; i++ {
		if A[i] == 0 {
			ans++
		}
	}
	fmt.Println(ans)
}



Measured memory_bytes: 1760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		ABC11X_A();
		// ABC11X_B();
		// ABC11X_C();
		// ABC11X_D();
	}

	private static void ABC11X_A() {
		Scanner scanner = null;
		int nenrei = 0;

		try {
			scanner = new Scanner(System.in);
			nenrei = scanner.nextInt();

			switch (nenrei) {
			case 1:
				System.out.println("Hello World");
				break;
			case 2:
				int numA = scanner.nextInt();
				int numB = scanner.nextInt();
				System.out.println(numA + numB);
				break;
			default:
				break;
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC11X_B() {
		Scanner scanner = null;
		int lineAB = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println();

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC11X_C() {
		Scanner scanner = null;
		int lineAB = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println();

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC11X_D() {
		Scanner scanner = null;
		int lineAB = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println();

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;

int main()
{
    int n; cin >> n;
    ll s(0),x;
    for(int i=0;i<n;++i) cin >> x, s+=(x-1);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string.h>
#include <vector>
//#include <unordered_map>
//#include <unordered_set>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T1, class T2> inline int chkmin(T1& a, const T2& val) {return val < a ? a = val, 1 : 0;}
template<class T1, class T2> inline int chkmax(T1& a, const T2& val) {return a < val ? a = val, 1 : 0;}
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
template<class T> inline T icbrt(T k) {T r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return (int) fpow(a, p - 2, p);}

const int maxn = 3000 + 10;
int n, a, b, c, d;
int dp[maxn][maxn];
int fac[maxn];
int ifac[maxn];

void solve() {
    fac[0] = 1; FOR(i, 1, maxn) fac[i] = mult(fac[i - 1], i);
    FOR(i, 0, maxn) ifac[i] = inv(fac[i]);
    cin >> n >> a >> b >> c >> d;
    dp[b + 1][0] = 1;
    FORd(i, b + 1, a) {
        FOR(j, 0, n + 1) {
            dp[i][j] = dp[i + 1][j];
            for (int k = 1; j - k * i >= 0; k++) if (k >= c && k <= d){
                addmod(dp[i][j], mult(dp[i + 1][j - k * i], mult(mult(ifac[k], fac[j]), mult(ifac[j - k * i], fpow(ifac[i], k)))));
            }
        }
    }
    cout << dp[a][n] << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (fopen("in.txt", "r")) {
        freopen("in.txt", "r", stdin);
    }
    solve();
    cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
    return 0;
}


Measured memory_bytes: 8192
#pragma GCC optimize("O2")
#pragma GCC optimize("O3")

#include<bits/stdc++.h>

signed main() {
	for (int i = 1; i <= 9; ++i)
		for (int j = 1; j <= 9; ++j)
			printf("%dx%d=%d\n", i, j, i * j);
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    vector<char> L(3);
    char tmp, tmp2;
    string S, S2, S3;
    bool flag=true;
    
    cin >> A >> B >>C;
    
    if(A>C)
	flag=false;
    if(A+B<C)
	flag=false;
    
    // ans = min(A, B) + min(C, D);
    // cout << ans<< endl;

    // if(S[1]==S[2] &&(S[0]==S[1] | S[2]==S[3]))
    // 	cout << "Yes" <<endl;
    // else
    // 	cout << "No" <<endl;

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    if(flag)
	puts("YES");
    else
    	puts("NO");
}


Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc075
// status:

#define SUBMIT
//#define DEBUG

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <queue>
#include <numeric>
#include <limits>
#include <set>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_N = 50;
int N, M;
bool adj[MAX_N][MAX_N];
bool done[MAX_N];
vector<pair<int, int>> edge;

void dfs(int i) {
    if (done[i]) return;
    done[i] = true;
    for (int j = 0; j < N; ++j) {
        if (i == j) continue;
        if (adj[i][j]) dfs(j);
    }
}

int start_dfs() {
    auto ans = M;

    for (int e = 0; e < M; ++e) {
        adj[edge[e].first][edge[e].second] = false;
        adj[edge[e].second][edge[e].first] = false;
        for (int i = 0; i < N; ++i) done[i] = false;

        dfs(0);
        bool complete = true;
        for (int i = 0; i < N; ++i) {
            if (!done[i]) complete = false;
        }

        if (complete) ans--;

        adj[edge[e].first][edge[e].second] = true;
        adj[edge[e].second][edge[e].first] = true;
    }

    return ans;
}

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    auto program_input = std::string(R"(6 5
1 2
2 3
3 4
4 5
5 6
)");
    stringstream stream(program_input);
#endif
    stream >> N >> M;
    // initialization
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j) adj[i][j] = true;
            else adj[i][j] = false;
        }
    }
    int a, b;
    for (int i = 0; i < M; ++i) {
        stream >> a >> b;
        edge.emplace_back(a - 1, b - 1);
        adj[a - 1][b - 1] = true;
        adj[b - 1][a - 1] = true;
    }

    auto ans = start_dfs();
    cout << ans << endl;

#ifdef DEBUG
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cout << adj[i][j] << " ";
        }
        cout << endl;
    }


    cout << "revisited:" << endl;
    for (auto r : revisited_nodes) cout << r << " ";
    cout << endl;

#endif
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
import           Data.Ord
import qualified Data.Vector.Unboxed           as UV

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  [n, k, x, y] <- forM [1..4] (const readInt)
  print $ if n <= k then n * x else k * x + (n - k) * y


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;
struct Edge { int from, to; long long cost; };
using Graph = vector<vector<Edge>>;

struct DisjointSets {
    vector<int> d;
    DisjointSets(int n): d(n, -1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

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

    int n,q;
    cin>>n>>q;
    DisjointSets ds(n);
    for(int i=0;i<q;i++){
        int com,x,y;
        cin>>com>>x>>y;
        if(com==0)ds.unite(x,y);
        else cout<<ds.same(x,y)<<endl;
    }
}


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

int main(){
  vector<char> a(3);
  string ans="No";
    for(int i=0; i<3; i++) cin >> a[i];

    sort(a.begin(), a.end());
    if(a[0]=='a' && a[1]=='b' && a[2]=='c') ans = "Yes";
    cout << ans << endl;
}


Measured memory_bytes: 256
from heapq import heappop, heappush

n, m = map(int, input().split())
jobs = [[] for _ in range(10 ** 5 + 1)]

for _ in range(n):
    day, reward = map(int, input().split())
    jobs[day].append(reward)

q = []
ans = 0
for i in range(m + 1):
    if jobs[i]:
        for reward in jobs[i]:
            heappush(q, -reward)
    if q:
        ans += -heappop(q)

print(ans)

Measured memory_bytes: 18496
#include<iostream>
#include<algorithm>
using namespace std;
typedef unsigned long long ullong;
#define MAX 10

ullong gcd(ullong a, ullong b){
    return ( b == 0 ) ? a : gcd(b, a%b);
}

ullong lcm( ullong a, ullong b ){
    if ( b > a ) swap(a, b);
    return a/gcd(a, b)*b;
}

void compute(int n){
    ullong d1, d2, v1, v2, G;
    pair<ullong, ullong> S[MAX];
    for ( int i = 0; i < n ; i++ ){
	cin >> S[i].first >> S[i].second;
	G = gcd(S[i].first, S[i].second);
	S[i].first /= G;
	S[i].second /= G;
    }

    ullong l = lcm(S[0].first, S[1].first);
    for ( int i = 2; i < n; i++ ) l = lcm(l, S[i].first);
    
    ullong A[MAX];
    for ( int i = 0; i < n; i++ ) A[i] = S[i].second*(l/S[i].first);
    G = gcd(A[0], A[1]);
    for ( int i = 2; i < n; i++ ) G = gcd(G, A[i]);
    for ( int i = 0; i < n; i++ ) cout << A[i]/G << endl;
}

main(){
    int n;
    while( cin >> n && n ) compute(n);
}

Measured memory_bytes: 0
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf8");

var reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on("line", line => {
  let word = line;
  let len = word.length - 1;
  let arr = ["k", "e", "y", "e", "n", "c", "e"];
  let keyence = "keyence";

  if (word.indexOf("keyence") == 0 || word.lastIndexOf("keyence") == len - 6) {
    console.log("YES");
    return;
  }
  
  let str = "";
  let ans = false;
  for (let i = 0; i < 6; i++) {
    str += arr.shift();
    let tmp = keyence.slice(i + 1);
    let index = word.indexOf(str)
    
    if (index == 0 && word.lastIndexOf(tmp) == len - (tmp.length - 1)) {
     ans = true;
     break;
    }
  }

  if (ans) console.log("YES");
  else console.log("NO");
});


Measured memory_bytes: 7500
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

//??????????¨±???
const double EPS = 1e-9;
bool equals(double a,double b){     //??????????¨±???????????????
    return (fabs(a-b) < EPS);
}

//???
class Point{
public:
    double x,y;
    Point (double x=0,double y=0) : x(x),y(y){}

    Point operator + (Point p){ return Point( x+p.x , y-p.y );}
    Point operator - (Point p){ return Point( x-p.x , y-p.y ); }
    Point operator * (double a){ return Point( a*x , a*y ); }
    Point operator / (double a){ return Point( x/a , y/a ); }

    double abs(){   //??§??????
        return sqrt(norm());
    }

    double norm(){  //?????????
        return x*x+y*y;
    }

    bool operator == (const Point &p) const{
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }
};

//??????
class Segment{
public:
    Point p1,p2;
    Segment(Point a,Point b) : p1(a) , p2(b){}
};

//??´???
typedef Segment Line;

//????????????
typedef Point Vector;

// ?????????????????????????????? --------------
//?????? : Vector
double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}
//?????? : Vector
double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}
//Vector : ??´?????????
bool isOrthogonal(Vector a, Vector b){
    return equals(dot(a,b),0.0);
}

//Vector : ????????????
bool isParalell(Vector a,Vector b){
    return equals(cross(a,b),0.0);
}

// ??´????????????????????? ------------------
// ??´?????????
bool isOrthogonal(Line L1,Line L2){
    return equals(dot(L1.p2-L1.p1 , L2.p2-L2.p1) , 0.0);
}
// ????????????
bool isParalell(Line L1,Line L2){
    return equals(cross(L1.p2-L1.p1 , L2.p2-L2.p1) , 0.0);
}

// ?????????????????????????????? --------------
bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){     //??´???
    return isOrthogonal(a1-a2,b1-b2);
}
bool isParalell(Point a1,Point a2,Point b1,Point b2){       //??????
    return isParalell(a1-a2,b1-b2);
}


void solve(){
    double p0x,p0y,p1x,p1y,p2x,p2y,p3x,p3y;
    cin>>p0x>>p0y>>p1x>>p1y>>p2x>>p2y>>p3x>>p3y;

    Point a(p0x,p0y),b(p1x,p1y),c(p2x,p2y),d(p3x,p3y);
    Line l1(a,b);
    Line l2(c,d);
   bool f = isOrthogonal(l1,l2);
    bool g = isParalell(l1,l2);

    if(f) cout << 1 << endl;
    else if(g) cout << 2 << endl;
    else cout << 0 << endl;
}

int main(){
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        solve();
    }
}

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

using namespace std;
using ll = long long;

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

int main() {
  ll n;
  cin >> n;
  ll a[5];
  rep(i, 5) cin >> a[i];

  ll mn = 1e15 + 1;
  rep(i, 5) mn = min(mn, a[i]);

  ll g = (n + mn - 1) / mn;
  cout << 5 + g - 1 << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  string s,t; cin >> s >> t;
  rep(i,s.size()){
    bool equal = true;
    int  j=0;
    while(j<s.size()){
      if(s.at((i+j)%(s.size()))!=t.at(j)) equal = false;
      j++;
    }
    if(equal){
      puts("Yes");
      return 0;
    }
  }
  puts("No");
}


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

int main() {
  
  int A,B;
  int i,a,j,k,l;
  int count=0;
  cin >> A >> B;
  for(int i=A;i<=B;i++){
  	a=i%10;
    j=i/10000%10;
    k=i/10%10;
    l=i/1000%10;
      if(a==j&&k==l){
    count++;
  }
  }
  cout << count;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    char a[4]={'Y','A','K','I'};
    char b[20];
    int g=0;
    cin>>b;
    for(int i=0;i<4;i++)
    {
        if(a[i]!=b[i]){g=1;break;}
    }
    if(g==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n = int(input())
ret = 0
cnt_ab = 0
cnt_a = 0
cnt_b = 0

for i in range(n):
    s = input()
    ret += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        cnt_ab += 1
    elif s[0] == 'B':
        cnt_b += 1
    elif s[-1] == 'A':
        cnt_a += 1

if cnt_ab == 0:
    ret += min(cnt_a, cnt_b)
else:
    if cnt_a + cnt_b > 0:
        ret += cnt_ab + min(cnt_a, cnt_b)
    else:
        ret += (cnt_ab - 1)


print(ret)


Measured memory_bytes: 44008
def remaining(s1, s2):
    if not("R" in [s1, s2]):
        return "R"
    elif not("B" in [s1, s2]): 
        return "B"
    else:
        return "G"

N = int(input())
S = list(input())

num_R = [0 for _ in range(N)]
num_G = [0 for _ in range(N)]
num_B = [0 for _ in range(N)]
if S[-1] == "R":
    num_R[-1] = 1
elif S[-1] == "B":
    num_B[-1] = 1
else:
    num_G[-1] = 1

for i in range(N-2, -1, -1): 
    if S[i]=="R":
        num_R[i] = num_R[i+1]+1
        num_G[i] = num_G[i+1]
        num_B[i] = num_B[i+1]
    elif S[i]=="G":
        num_R[i] = num_R[i+1]
        num_G[i] = num_G[i+1]+1
        num_B[i] = num_B[i+1]
    else:
        num_R[i] = num_R[i+1]
        num_G[i] = num_G[i+1]
        num_B[i] = num_B[i+1]+1

if __name__ == "__main__":
    ans = 0
    for i in range(0, N-2):
        for j in range(i+1, N-1):
            if S[i] == S[j]:
                continue
            target = remaining(S[i], S[j])
            if target == 'R':
                num = num_R
            elif target == 'G':
                num = num_G
            else:
                num = num_B

            ans += num[j+1]
            if j+(j-i) < N:
                if S[j+(j-i)]==target:
                    ans -= 1
    print(ans)

Measured memory_bytes: 69340
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    res = 0
    if sum(A) < sum(B):
        print(-1)
        exit()

    # まず不足している準備度を求める
    # また、余ってたら余ってる量をCにブチこんでいく
    C = list()
    missing = 0
    ans = 0
    for i in range(N):
        if A[i] < B[i]:
            missing += (B[i] - A[i])
            ans += 1
        else:
            C.append(A[i]-B[i])

    if missing == 0:
        print(0)
        exit()

    C.sort(reverse=True)

    for c in C:
        if missing <= c:
            ans += 1
            break
        else:
            missing -= c
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 19060
import sys
s = input()
n = len(s)//2
l = n-1//2
m = n+3//2

def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True

a = s[:l]
b = s[m:]

if is_kaibun(s):
    if is_kaibun(a):
        if is_kaibun(b):
            print("Yes")
            sys.exit()
            
print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int64_t func1 (int64_t k){
    if (k == 1){
        return 1;
    }
    int64_t s = 1 + 2 * (func1 (k / 2));
    return s; 

}
int main(){
    int64_t H;
    cin >> H;
    cout << func1 (H) << endl;
}

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

int main()
{
	int A,B,C,D;
	cin >> A >> B >> C >> D;
	if (A+B>C+D) {
		cout << "Left" << endl;
	}
	else if(A+B==C+D){
		cout << "Balanced" << endl;
	}
	else{
		cout << "Right" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

int main() {
    string s, t;
    cin >> s >> t;

    int n = s.size();

    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] != t[i]) ans++;
    }

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

Measured memory_bytes: 3920
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main(){
  int n;
  cin >> n;
  for(int i = 0;i<n;i++){
    double x1,y1,x2,y2,x3,y3,a1,b1,c1,a2,b2,c2,x,y,ab;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    a1 = 2*(x2-x1);
    b1 = 2*(y2-y1);
    c1 = (x1 * x1) - (x2 * x2) + (y1 * y1) - (y2 * y2);
    a2 = 2*(x3 - x1);
    b2 = 2*(y3 - y1);
    c2 = (x1 * x1) - (x3 * x3) + (y1 * y1) - (y3 * y3);
    x = ((b1*c2) - (b2 * c1))/((a1 * b2) - (a2 * b1));
    y = ((c1*a2) - (c2 * a1))/((a1 * b2) - (a2 * b1));
    ab = sqrt(((x2 - x) * (x2 - x)) + ((y2 - y) * (y2 - y)));
    cout << fixed << setprecision(3) << x <<" "<< y <<" "<< ab << endl;
  }
}
  

Measured memory_bytes: 1288
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  int k; string s;
  cin >> k >> s;
  int n = s.size();
  if (n<=k) cout << s << endl;
  else cout << s.substr(0, k) << "..." << endl;
  return 0;
}


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

int main(){
  long long AAA, BBB;
  long long AA = 1, BB = 1;
  long long A, B;
  cin >> AAA >> BBB;
  A = AAA;
  B = BBB;
  
  bool isDivA, isDivB;
  long long cur = 1;
  long long gd = 1;
  
  if (A<=B){
    if (B % A == 0) {
      cout << A << endl;
      return 0;
    } else if ( A % B == 0) {
      cout << B << endl;
      return 0;
    }
  }
  
  while (true){
    if (A % cur == 0){
      isDivA = true;
      A /= cur;
      AA *= cur;
    } else isDivA = false;
    
    if (B % cur == 0){
      isDivB = true;
      B /= cur;
      BB *= cur;
    } else isDivB = false;
    
    if (isDivA && isDivB) gd *= cur;
    
    //cout << cur << " " <<  A << ":" << AA << " " << B << ":" << BB << endl;
    if (cur * cur > AAA || cur * cur > BBB) break;
    
    if (isDivA == false && isDivB == false) cur++;
  	else if (cur == 1) cur++;
  }
  
  cout << gd << endl;
  return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  char a; cin >> a;
  if (a-'a' >= 0) {
    COUT('a');
  } else {
    COUT('A');
  }
  return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
#define LL long long
#define MAXN 300000
#define INF 100000000000000000
#define DB double
#define PI acos(-1.0)
int a,b,x,L;
LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
  return x*F;
}
int main()
{
  a=read(),b=read(),x=read();
  L=a*a*b;
  if(x>L/2){
    DB p=2.0*(L-x)/(a*a);
    printf("%.10f\n",90.0-atan(a/p)/PI*180.0);
  }else{
    DB p=2.0*x/(b*a);
    printf("%.10f\n",atan(b/p)/PI*180.0);
  }
}


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

int main(){
    long N;
    long long int prevA=0,nowA;
    long long int ans = 0;

    cin >> N;
    cin >> prevA;
    if(prevA != 0){
        cout << -1 << endl;
        return 0;
    }

    for(long i = 1; i < N; i++){
        cin >> nowA;
        if(nowA > prevA+1){
            cout << -1 << endl;
            return 0;
        }
        
        if(nowA == prevA+1){
            ans++;
        }
        else{
            ans += nowA;
        }
        prevA = nowA;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int sum(int n){
	int ret=0;
	while(n){
		ret+=n%10;
		n/=10;
	}
	return ret;
}

int main()
{
	//IOS;
	int n;
	int ans=INF;
	cin>>n;

	for(int i=1;i<n;i++) ans=min(ans,sum(i)+sum(n-i));
		cout<<ans;

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main {
	
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		
		int n=sc.nextInt();
		
		int x[]=new int[n+1];
		x[0]=sc.nextInt();
		for (int i = 1; i < n+1; i++) {
			x[i]=sc.nextInt();
		}
		
		int d[]=new int[n];
		for (int i = 0; i < n; i++) {
			d[i]=Math.abs(x[i+1]-x[i]);
		}
		for (int i = 0; i <= n-2; i++) {
			while(d[i]!=d[i+1]) {
			
				if(d[i]>d[i+1]) {
					if(d[i]%d[i+1]==0) {
						d[i]=d[i+1];
					}else {
				
					d[i]%=d[i+1];
					}
				}else {
					if(d[i+1]%d[i]==0) {
						d[i+1]=d[i];
					}else {
					
					d[i+1]%=d[i];
					}
				}
				
			}
		}
		System.out.println(d[n-1]);
			
	}
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}


Measured memory_bytes: 36432
n,k = map(int, input().split()) 
a_list = list(map(int, input().split())) 

min_cost = 10**15
for i in range(2 ** n):
    see_a_ids = []
    for j in range(n):
        if ((i >> j) & 1):
            see_a_ids.append(j)
    
    if len(see_a_ids) < k:
        continue

    curr_max_h = 0
    curr_cost = 0
    for a_i in range(n):
        if a_i in see_a_ids:
            if a_list[a_i] <= curr_max_h:
                h_plus = curr_max_h + 1 - a_list[a_i]
                curr_cost += h_plus
                curr_max_h = curr_max_h+1
            else:
                curr_max_h = a_list[a_i]
        else:
            curr_max_h = max(curr_max_h, a_list[a_i])
    min_cost = min(min_cost, curr_cost)
print(min_cost)

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

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}


int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << max(2 * a - 1, max(2 * b - 1, a + b)) << endl;
	return 0;
}


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

constexpr int MAX = 100;
constexpr int M = 100000;

// S -> 0: up, cannot turn
//      1: up, can
//      2: right, cannot
//      3: right, can
int main() {
    vector<vector<vector<int>>> dp(MAX, vector<vector<int>>(MAX, vector<int>(4)));
    for(int i = 0; i < MAX; ++i) {
        dp[i][0][1] = dp[0][i][3] = 1;
    }
    for(int i = 1; i < MAX; ++i) {
        for(int j = 1; j < MAX; ++j) {
            dp[i][j][0] = dp[i - 1][j][3] % M;
            dp[i][j][1] = (dp[i - 1][j][0] + dp[i - 1][j][1]) % M;
            dp[i][j][2] = dp[i][j - 1][1] % M;
            dp[i][j][3] = (dp[i][j - 1][2] + dp[i][j - 1][3]) % M;
        }
    }

    int w, h;
    while(cin >> w >> h, w) {
        int ans = 0;
        for(int i = 0; i < 4; ++i) {
            ans += dp[w - 1][h - 1][i];
        }
        cout << ans % M << endl;
    }
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int j,k;
  int s = 0;    // number of occupied seat
  cin >> N;
 
  for(int i = 0; i < N; i++) {
    cin >> j >> k;
    s += k - j + 1;
  }
  cout << s << endl;
}

Measured memory_bytes: 256
s = str(input())

flag = False

for i in range(len(s)):
#     print("aaa",s[i])
    if i % 2 == 0:
        if s[i] == "R" or s[i] == "U" or s[i] == "D":
#             print(s[i],"1")
            flag = True
        else:
            flag = False
            break
    elif i % 2 == 1:
        if s[i] == "L" or s[i] == "U" or s[i] == "D":
#             print(i,"2")
            flag = True
        else:
            flag = False
            break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import random
import time
import copy

t1=time.time()
d=int(input())
c=input()
cl=[int(n) for n in c.split()]
sl=list()
for i in range(d):
    s=input()
    sl=sl+[int(n) for n in s.split()]
tl=list()
for i in range(d):
    tl.append(random.randint(1,26))
sat=0
for i in range(d):
    sat+=sl[i*26+tl[i]-1]
last=list()
for i in range(26):
    last.append([a for a, x in enumerate(tl) if x==i+1])
dec=0
for i in range(26):
    if last[i]==list():
        dec+=(d*(d+1)/2)*cl[i]
    else:
        for v in range(len(last[i])):
            if v!=len(last[i])-1:    
                dec+=cl[i]*(last[i][v+1]-last[i][v]-1)*(last[i][v+1]-last[i][v])/2
            else:
                dec+=cl[i]*(d-last[i][v]-1)*(d-last[i][v])/2
        dec+=cl[i]*(last[i][0])*(last[i][0]+1)/2
        
def dechf(i,last):
    dech=0
    if last[i]==list():
        dech+=(d*(d+1)/2)*cl[i]
    else:
        for v in range(len(last[i])):
            if v!=len(last[i])-1:    
                dech+=cl[i]*(last[i][v+1]-last[i][v]-1)*(last[i][v+1]-last[i][v])/2
            else:
                dech+=cl[i]*(d-last[i][v]-1)*(d-last[i][v])/2
        dech+=cl[i]*(last[i][0])*(last[i][0]+1)/2
    return(int(dech))


oldlast=copy.deepcopy(last)
oldans=sat-int(dec)
oldtl=copy.copy(tl)
t2=time.time()
newans=0
while t2-t1<1.85:
    if round(t2)%2==0:
        d1=random.randint(1,d)
        d2=random.randint(1,d)
        if d1==d2:
            continue
        q1=tl[d2-1]
        q2=tl[d1-1]
        cha=sl[(d1-1)*26+q1-1]-sl[(d1-1)*26+tl[d1-1]-1]+sl[(d2-1)*26+q2-1]-sl[(d2-1)*26+tl[d2-1]-1]
        i=tl[d1-1]-1
        dech=dechf(i,last)
        i=tl[d2-1]-1
        dech+=dechf(i,last)
        last[tl[d2-1]-1].remove(d2-1)
        last[tl[d1-1]-1].remove(d1-1)
        last[tl[d1-1]-1].append(d2-1)
        last[tl[d1-1]-1].sort()
        last[tl[d2-1]-1].append(d1-1)
        last[tl[d2-1]-1].sort()
        tl[d2-1]=q2
        tl[d1-1]=q1
        i=tl[d1-1]-1
        dech-=dechf(i,last)
        i=tl[d2-1]-1
        dech-=dechf(i,last)
        newans=oldans+cha-dech
    else:
        da=random.randint(1,d)
        q=random.randint(1,26)
        cha=sl[(da-1)*26+q-1]-sl[(da-1)*26+tl[da-1]-1]
        i=tl[da-1]-1
        dech=dechf(i,last)
        last[tl[da-1]-1].remove(da-1)
        last[q-1].append(da-1)
        last[q-1].sort()
        tl[da-1]=q
        i=tl[da-1]-1
        dech-=dechf(i,last)
        newans=oldans+cha-dech
    r=0
    if newans<oldans:
        if 2.7**((newans-oldans)/(1.85-(t2-t1)))<random.random():
            r=1
    if r==1:
        tl=copy.copy(oldtl)
        last=copy.deepcopy(oldlast)
    else:
        oldans=newans
        oldtl=copy.copy(tl)
        oldlast=copy.deepcopy(last)
    t2=time.time()
for i in range(d):
    print(tl[i])
        


Measured memory_bytes: 115432
import sys
from itertools import permutations
N = int(input())
target_list = []
for i in range(2):
  target_list.append(tuple(map(int,input().split())))
  
list=[_ + 1 for _ in range(N)]
per=permutations(list,N)

ans = 0
counter = 1
if target_list[0] == target_list[1]:
  print("0")
  sys.exit()
for i in per:
  if i in target_list:
    #print(counter)
    if ans == 0:
      ans -= counter
    else:
      ans += counter
    
  counter += 1
print(ans)
    
  

Measured memory_bytes: 9048
#include <iostream>
#include <algorithm>
#include <cmath>
#define OPEN 0
using namespace std;
int main(){

	int N, K;
	cin >> N >> K;
	double nf = (double)N;
	double kf = (double)K;
	double sum = 0;
	double ans = 0;
	for (int i = 1; i <= N; i++) {
		if ((double)i >= K) { ans += (1 - sum); break; }
		else {
			sum += 1 / nf;
			ans += (1 / nf) * pow((double)1/(double)2,( ceil(log(K / (double)i) / log(2))));
		}
	}
	printf("%.12f\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb push_back 
#define mp make_pair
using namespace std;

const int maxn=1e5+7;
typedef long long ll;

int n,m,ans;
ll a;

int t1,t2;

int main()
{
	int i,j=0,k,T;
	scanf("%lld",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%lld",&a);
		if(a%2==0&&a%4!=0){
			j=1;
			continue;
		}
		if(a%4==0) t1++;
		else t2++;
	} 
	
	if(j==0)
	{
		if(t1+1>=t2) printf("Yes\n");
		else printf("No\n");
		return 0;
	}
	else
	{
		if(t1>=t2) printf("Yes\n");
		else printf("No\n");
		return 0;
	}
	
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define MOD(x) ((x % MOD_N) + MOD_N) % MOD_N
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SIZE(c) (int)((c).size())
#define EACH(i,v) for(auto i=v.begin();i!=v.end();++i)
#define REACH(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
#define LB(c,x) distance((c).begin(),lower_bound(ALL(c),x))
#define UB(c,x) distance((c).begin(),upper_bound(ALL(c),x))
#define COUNT(c,x) (upper_bound(ALL(c),x)-lower_bound(ALL(c),x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;
#define NL cerr<<endl;
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T sum(vector<T>&v){return accumulate(ALL(v),T());}
template<typename T>T sum(vector<T>&v,int a,int b){return accumulate(v.begin()+a,v.begin()+b,T());}
template<typename T>T max(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T min(vector<T>&v){return *min_element(ALL(v));}
template<typename T>T max_index(vector<T>&v){return distance((v).begin(),max_element(ALL(v)));}
template<typename T>T min_index(vector<T>&v){return distance((v).begin(),min_element(ALL(v)));}

struct edge { int to, cost; };

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}

const int INF = 1e18;
const int MOD_N = 1e9+7;

signed main()
{
   string s; cin >> s;

   const int CHAR_SIZE = 26;
   V<int> cnt(CHAR_SIZE);
   REP(i, SIZE(s)) {
      cnt[s[i] - 'a']++;
   }
   int ans = 0;
   REP(i, CHAR_SIZE) {
      ans += (sum(cnt) - cnt[i]) * cnt[i];
   }
   cout << ans / 2 + 1 << endl;

   return 0;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 0
for i in range(N):
    ans += min(A[i],B[i])
    B[i] -= min(A[i],B[i])
    ans += min(A[i+1],B[i])
    A[i+1] -= min(A[i+1],B[i])

print(ans)

Measured memory_bytes: 82148