akhauriyash/Code-Regression huggingface dataset:
n=int(input())
ta=[[int(i) for i in input().split()] for j in range(n)]

tt=1
aa=1

for i in ta:
    ta=max(-(-tt//i[0]),-(-aa//i[1]))
    
    tt=ta*i[0]
    aa=ta*i[1]

print(tt+aa)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#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
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int a, b, c, d = -1, e = 0;
  scanf("%d %d %d", &a, &b, &c);
  while(d == -1){
    if(a & 1 || b & 1 || c & 1){
      d = e;
      break;
    }
    ++e;
    int f = a/2, g = b/2, h = c/2;
    a = g + h;
    b = f + h;
    c = f + g;
    if(e > 1e5) break;
  }
  printf("%d\n", d);
  return 0;
}

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

using namespace std;

int main() {

	long long int n, cnt = 0, di = 1;
	vector<int> ans;

	cin >> n;

	if (n == 0) {
		cout << "0" << endl;
		return 0;
	}

	while (n != 0) {
		//cout << n << " " << di << endl;
		//if (n == di) break;

		if (abs(n) % (di * 2) != 0) {
			ans.emplace_back(1);
			if (cnt % 2 == 0) n -= di;
			else n += di;
		}
		else ans.emplace_back(0);

		cnt++;
		di *= 2;
	}

	for (int i = ans.size() - 1;i >= 0;i--) cout << ans[i];
	cout << endl;


}


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

double solve() {
    ll N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    int s, t;
    for ( int i = 0; i < M; i++ ) {
        cin >> s >> t;
        s--, t--;
        G[s].push_back(t);
    }

    auto get_d = [&](int nd) {
        vector<double> e(N, 0);
        for ( int v = N-2; v >= 0; v-- ) {
            double m = -1;
            int j;
            for ( int u : G[v] ) {
                e[v] += (1 + e[u])/G[v].size();
                if ( m < e[u] ) {
                    m = e[u];
                    j = u;
                }
            }
            if ( nd == v && G[v].size() > 1 ) {
                double edc = 0;
                for ( int u : G[v] ) {
                    if ( u == j ) continue;
                    edc += (1 + e[u])/(G[v].size()-1);
                }
                e[v] = min(e[v], edc);
            }
        }
        return e[0];
    };

    double ans = 1e9;
    for ( int i = 0; i < N-1; i++ ) {
        double d = get_d(i);
        ans = min(ans, d);
    }
    return ans;
}

int main() {
    cout.precision(15);
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1408
#include <cstdio>

using namespace std;

char s[1000001];
int k[75];

int main() {
    int n, q, i, j, l;
    
    scanf("%d", &n);
    scanf("%s", s);
    scanf("%d", &q);
    
    for (i = 0; i < q; i++) scanf("%d", &k[i]);
    
    for (i = 0; i < q; i++) {
        int m = 0, c = 0;
        long long ans = 0, sum = 0;
        
        for (l = 0; l < k[i]; l++) {
            if (s[l] == 'M') {
                m++;
            } else if (s[l] == 'C') {
                sum += m;
                c++;
            }
        }
        
        for (j = 0; j < n; j++) {
            if (s[j] == 'D') {
                ans += sum;
            } else if (s[j] == 'M') {
                sum -= c;
                m--;
            } else if (s[j] == 'C') {
                c--;
            }
            
            if (l < n) {
                if (s[l] == 'M') {
                    m++;
                } else if (s[l] == 'C') {
                    sum += m;
                    c++;
                }
                
                l++;
            }
        }
        
        printf("%lld\n", ans);
    }
    
    return 0;
}


Measured memory_bytes: 1152
<?php
# 入力部
// fscanf(STDIN, "%s %s", $s, $t);
// fscanf(STDIN, "%d %d", $n, $m);
// fscanf(STDIN, "%s", $u);
// fscanf(STDIN, "%d %d", $k, $x);
// $s1 = fgets(STDIN); //"\n"の2文字
// $s2 = fgets(STDIN);
// fscanf(STDIN, "%d", $r);
// fscanf(STDIN, "%f", $n);
fscanf(STDIN, "%f", $n);
// fscanf(STDIN, "%s", $s);
// fscanf(STDIN, "%c", $c);
// fscanf(STDIN, "%s", $s2);
// fscanf(STDIN, "%d %d %d", $a, $b, $c);


# 処理部
// $arr = str_split($s);
// $arr2 = str_split($s2);
// $arr1 = explode(" ", $s1);
// $arr2 = explode(" ", $s2);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
// $s = "Yes";
// echo count($arr1);
// for ($i = 0; $i < strlen($s1); $i++) {
//   if ($arr1[$i] != $arr2[$i]) {
//     $s = "No";
//   }
// }
// $unit;
// switch ($n % 10) {
//   case 0:
//   case 1:
//   case 6:
//   case 8:
//     $unit = "pon";
//     break;
//   case 3:
//     $unit = "bon";
//     break;
//   default:
//     $unit = "hon";
//     break;
// }
// if ($s == "ABC") {
//   $r = "ARC";
// } else {
//   $r = "ABC";
// }
// $r = "NG";
// $arr = array("SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN");
// for ($i = 0; $i <= count($arr); $i++) {
//   if ($arr[$i] == $s) {
//     break;
//   }
// }
// $r = "safe";
// if ($s <= $w) {
//   $r = "unsafe";
// }
// $r = "No";
// if (strpos($n, "7") !== false) {
//   $r = "Yes";
// }
// $r = "No";
// if ($arr[2] == $arr[3] && $arr[4] == $arr[5]) {
//   $r = "Yes";
// }
// $r = "Yes";
// if ($s == "AAA" || $s == "BBB") {
//   $r = "No";
// }
// if ($n % 2 == 0) {
//   $r = $n / 2 / $n;
// } else {
//   $r = ($n + 1) / 2 / $n;
// }
// if ($n < 10) {
//   $r += (10 - $n) * 100;
// }
// $arr = array($a, $b, $c);
// $arr = array_unique($arr);
// if (count($arr) == 2) {
//   $r = "Yes";
// } else {
//   $r = "No";
// }
// if ($s == $u) {
//   $a--;
// } else {
//   $b--;
// }
// for ($i = 0; $h > 0; $i++) {
//   $h -= $a;
// }
// $r = "No";
// if ($n == $m) {
//   $r = "Yes";
// }
// $r = "win";
// if ($a + $b + $c >= 22) {
//   $r = "bust
// ";
// }
// $arr = array(1, 2, 3);
// unset($arr[$a - 1]);
// unset($arr[$b - 1]);
// $arr = array_values($arr);
// if ($n < 10 && $m < 10) {
//   $r = $n * $m;
// } else {
//   $r = -1;
// }
// switch ($s) {
//   case "Sunny":
//     $r = "Cloudy";
//     break;
//   case "Cloudy":
//     $r = "Rainy";
//     break;
//   case "Rainy":
//     $r = "Sunny";
//     break;
// }

# 出力部
// echo ($n * ($n - 1) / 2) + ($m * ($m - 1) / 2) . "\n";
// echo $z . " " . $x . " " . $y . "\n";
// echo ($i * 1000) - $n . "\n";
// echo json_encode($arr) . "\n";
// echo $arr[0] . "\n";
// echo $i + 1 . "\n";
echo $n ** 3 . "\n";
// echo ++$c . "\n";
// echo $a . " " . $b . "\n";
// echo $t . $s . "\n";


Measured memory_bytes: 16580
n = int(input())
d,x = map(int,input().split())
a = []
for i in range(n):
	temp = int(input())
	a.append(temp)
eat = 0
for i in range(n):
	if (d-1)%a[i] == 0:
		eat += (d-1)//a[i] + 1
	else:
		eat += (d-1)//a[i] + 1
print(x+eat)

Measured memory_bytes: 3064
a = int(input())
ar = []
for i in range(a):
    l = list(map(int,input().split(" ")))
    ar.append([l[1],l[0]])
ar.sort()
b = 0
for r in ar:
    b += r[1]
    if b > r[0]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 36440
#include<bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<n;i++)
int main()
{
	ios_base::sync_with_stdio(false);
	int n,cnt=0;
	cin>>n;
	string ans="No";
	while(n--)
	{
		int a,b;
		cin>>a>>b;
		if(a==b)
			cnt++;
		else
			cnt=0;
		if(cnt==3)
			ans="Yes";
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        int ans = 0;
        for(int i=1;i<=n;i++)ans += i*(n+1-i);
        for(int i=1;i<n;i++)
        {
            int x,y;
            cin>>x>>y;
            if(x>y)swap(x,y);
            ans -= x*(n+1-y);
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3696
n = int(input())

six = []
s = 6
while s <= n:
    six.append(s)
    s *= 6
s = 9
while s <= n:
    six.append(s)
    s *= 9
six.sort()
dp = [i for i in range(n+13)]
for s in six:
    for i in range(n-s+1):
        if dp[i] + 1 < dp[i+s]:
            dp[i+s] = dp[i] + 1

print(dp[n])


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

int main(){
  int N,M,count=0;
  cin >> N;
  vector <int> T(N);
  for(int i=0;i<N;i++){
    cin >> T[i];
  }
  cin >> M;
  vector <int> P(M),X(M);
  for(int i=0;i<M;i++){
    cin >> P[i] >> X[i];
  }
  for(int j=0;j<M;j++){
    for(int i=0;i<N;i++){
      if((i+1)==P[j]){
        count+=X[j];
      }else{
        count+=T[i];
      }
    }
    cout << count << endl;
    count=0;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int square[3][3];
	int a,N;
	int number[10];
	int answer[3][3];
	int i,j,k;
	
 cin>>square[0][0]>>square[0][1]>>square[0][2]>>square[1][0]>>square[1][1]>>square[1][2]>>square[2][0]>>square[2][1]>>square[2][2];
 cin>>N;
 
 while( a < N )
    {
        cin >> number[a];
        a++;
    }
 
 for(i=0;i<=2;i++)
	 { 
	 for(j=0;j<=2;j++)
	 {
	 	answer[i][j]=0;
	 	for(k=0;k<a;k++)
	 	{   
	 	    //answer[i][j]=0; 
	 		if(square[i][j]==number[k])
	 		{
	 			answer[i][j]=1;
			 }
		 }
	 }
	 }
	 
 
	if((answer[0][1]+answer[0][0]+answer[0][2])==3)
	{cout<<"Yes";
	}
	else if((answer[1][0]+answer[1][1]+answer[1][2])==3)
	{cout<<"Yes";
	}
	else if((answer[2][0]+answer[2][1]+answer[2][2])==3)
	{cout<<"Yes";
	}
	else if((answer[0][0]+answer[1][0]+answer[2][0])==3)
	{cout<<"Yes";
	}
	else if((answer[0][1]+answer[1][1]+answer[2][1])==3)
	{cout<<"Yes";
	}
	else if((answer[0][2]+answer[1][2]+answer[2][2])==3)
	{cout<<"Yes";
	}
	else if((answer[0][0]+answer[1][1]+answer[2][2])==3)
	{cout<<"Yes";
	}
	else if((answer[0][2]+answer[1][1]+answer[2][0])==3)
	{cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
  double N, M, A;
  cin >> N >> M;

  vector<double> vec;
  double sum = 0;
  for (auto i = 0; i < N; i ++) {
    cin >> A;
    vec.push_back(A);
    sum += A;
  }
  double ret = 0;
  for (auto i = 0; i < N; i ++) {
    if (vec[i] >= sum / (4*M)) {
      ret ++;
    }
  }
  if (ret >= M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

int N;
int A[1<<20];
int dp1[1<<20][20] = {},dp2[1<<20][20] = {};

int main(){
    cin >> N;
    for(int i=0;i<(1<<N);i++){
        cin >> A[i];
        dp1[i][0] = A[i];
    }
    for(int j=0;j<N;j++){
        for(int i=0;i<(1<<N);i++){
            priority_queue<int> Q;
            if(i&(1<<j)){
                Q.push(dp1[i][j+1]);
                Q.push(dp2[i][j+1]);
                Q.push(dp1[i][j]);
                Q.push(dp2[i][j]);
                Q.push(dp1[i&~(1<<j)][j]);
                Q.push(dp2[i&~(1<<j)][j]);
            }else{
                Q.push(dp1[i][j+1]);
                Q.push(dp2[i][j+1]);
                Q.push(dp1[i][j]);
                Q.push(dp2[i][j]);
            }
            dp1[i][j+1] = Q.top();
            Q.pop();
            dp2[i][j+1] = Q.top();
        }
    }
    int ans = 0;
    for(int i=1;i<(1<<N);i++){
        ans = max(ans,dp1[i][N]+dp2[i][N]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 50176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int W,a,b;
  cin >> W >> a >> b;
  if(a<b){
  	if(b - a - W <= 0){
    	cout << 0 << endl;
    }else{
    	cout << b-a-W << endl;
    }
  }else{
  	if(a - b - W <= 0){
    	cout << 0 << endl;
    }else{
    	cout << a-b-W << endl;
    }
  }
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func binarySearch(colors []int64, num int64) int {
	lo := 0
	hi := len(colors) - 1
	for lo < hi {
		mid := (lo + hi) / 2
		if colors[mid] <= num {
			lo = mid + 1
		} else {
			hi = mid
		}
	}
	return lo
}

func main() {
	n := readInt()
	a := make([]int64, n)
	for i := range a {
		a[n-1-i] = readInt64()
	}

	colors := make([]int64, 0, n)
	for i := range a {
		idx := binarySearch(colors, a[i])
		if len(colors) == 0 || colors[idx] <= a[i] {
			colors = append(colors, a[i])
		} else {
			colors[idx] = a[i]
		}
	}

	fmt.Println(len(colors))
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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 long long INF = 1LL << 60;

typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair

int main(){
  int H, W, m;
  cin >> H >> W >> m;
  vector<int> cnth(H, 0);
  vector<int> cntw(W, 0);
  set<pii> st;
  rep(i, m){
    int h, w;
    cin >> h >> w;
    h--, w--;
    cnth[h]++;
    cntw[w]++;
    st.insert(mp(h, w));
  }

  int mah = 0;
  int maw = 0;
  rep(i, H) chmax(mah, cnth[i]);
  rep(i, W) chmax(maw, cntw[i]);
  vector<int> ih;
  vector<int> iw;
  rep(i, H) if(cnth[i] == mah) ih.push_back(i);
  rep(i, W) if(cntw[i] == maw) iw.push_back(i);

  rep(i, ih.size()){
    rep(j, iw.size()){
      if(!st.count(mp(ih[i], iw[j]))){
        cout << mah + maw << endl;
        return 0;
      }
    }
  }

  cout << mah + maw -1 << endl;

  return 0;
}


Measured memory_bytes: 23752
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//********************************template END****************************************//

void solve(void){
	int w;
	string S;
	cin >> S >> w;
	int i = 0, l = (int)S.length();
	while(i < l)
	{
		cout << S[i];
		i+=w;
	}
	cout << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
using std::priority_queue;
using std::vector;
using std::less;
using std::greater;
#define r register
inline bool isd(r char ch)
{
	return ch<='9'&&ch>='0';
}
template<class temp>
inline temp F()
{
	r temp x=0;
	r bool bo=0;
	r char ch=getchar();
	while(ch!='-'&&!isd(ch))
		ch=getchar();
	(ch=='-')&&(bo=1,ch=getchar());
	x=ch^'0',ch=getchar();
	while(isd(ch))
		x=(x<<1)+(x<<3)+(ch^'0'),ch=getchar();
	bo&&(x=-x);
	return x;
}
int lt[200001],rt[200001];
long long ans,tl,tr,lq,rq;
priority_queue<long long,vector<long long>,less<long long> >L; 
priority_queue<long long,vector<long long>,greater<long long> >R;
int main()
{
    r int n=F<int>();
    for(r int i=1;i<=n;++i)
		lt[i]=F<int>(),rt[i]=F<int>(),lt[i]=rt[i]-lt[i];
    L.push(rt[1]),R.push(rt[1]);
    for(r int i=2;i<=n;++i)
	{
        tl-=lt[i-1],tr+=lt[i];
        lq=L.top()+tl,rq=R.top()+tr;
        if(rt[i]>=lq&&rt[i]<=rq)
			L.push(rt[i]-tl),R.push(rt[i]-tr);
        else
			if(rt[i]>=lq)
            	ans+=rt[i]-rq,R.pop(),L.push(rq-tl),R.push(rt[i]-tr),R.push(rt[i]-tr);
			else
            	ans+=lq-rt[i],L.pop(),R.push(lq-tr),L.push(rt[i]-tl),L.push(rt[i]-tl);
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 2804
import std.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;

const L = -1,
      R = 1;

class Ant {
    int index;
    int dir;
    int pos;
    bool left;
    this(int index, int dir, int pos) {
        this.index = index;
        this.dir = dir;
        this.pos = pos;
        this.left = false;
    }
}

void main() {
    int n, l;
    while (readf("%d %d\n", &n, &l), n || l) {
        Ant[] ants = new Ant[n];
        foreach (i; 1 .. n + 1) {
            char d; int p;
            auto input = readln.chomp.split(" ");
            d = input[0][0];
            p = input[1].to!int;
            ants[i - 1] = new Ant(i, (d == 'L' ? L : R), p);
        }

        Ant[] last;
        void step() {
            last = new Ant[2];
            foreach (ref ant; ants) {
                if (ant.left) continue;
                ant.pos += ant.dir;
            }
            foreach (i, ref ant; ants) {
                if (ant.left) continue;
                if (ant.pos >= l) {
                    ant.left = true;
                    last[1] = ant;
                }
                if (ant.pos <= 0) {
                    ant.left = true;
                    last[0] = ant;
                }
            }
            foreach (i; 0 .. ants.length) {
                if (ants[i].left) continue;
                foreach (j; i + 1 .. ants.length) {
                    if (ants[j].left) continue;
                    if (ants[i].pos == ants[j].pos) {
                        ants[i].dir *= -1;
                        ants[j].dir *= -1;
                    }
                }
            }
        }

        bool finished() {
            foreach (ant; ants) {
                if (!ant.left) return false;
            }
            return true;
        }

        int c = 0;
        while (!finished) {
            //writeln(c, " ", ants.map!((a) => (a.left ? [] : [a.index, a.pos, a.dir])).array);
            step();
            c++;
        }
        writeln(c, " ", (last[0] ? last[0] : last[1]).index);
    }
}

Measured memory_bytes: 1248
n,k = map(int,input().split())
l = [-1]+list(map(int,input().split()))

visited = [-1]+[False]*n

i = 1
while True:
    if visited[i]:
        fragrant = i
        break
    else:
        visited[i] = True
        i = l[i]

i = fragrant
cnt = 1
while l[i] != fragrant:
    cnt += 1
    i = l[i]
# print(cnt)

i = 1
while k > 0:
    i = l[i]
    k -= 1
    if i == fragrant:
        k %= cnt
print(i)

Measured memory_bytes: 101164
#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int n,x,k,ans;
int f(int x,int k){
	while(x%k && x>k) x-=(x/k+1)*((x%k-1)/(x/k+1)+1);
	return x/k;
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);
	FOR(i,1,n) scanf("%d%d",&x,&k),ans^=f(x,k);
	puts(ans?"Takahashi":"Aoki");
}

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

int main(void)
{
  int N, P[1000001], i, j, k, tmp, min, ans = 1;
  double S;

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

  min = P[0];
  for (i = 1; i < N; i++)
  {
    if (P[i] < min)
    {
      ans++;
      min = P[i];
    }
  }

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

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
  int N;
  cin >> N;
  vector<P> itv(N);  // interval
  REP(i,0,N) {
    int A,B;
    cin >> A >> B;
    // 締切B, 所要時間A
    itv[i] = P(B, A);
  }
  sort(ALL(itv));  // 終了時間の早い順

  bool ans = true;  // possible
  int t = 0;
  REP(i,0,N) {
    int A,B;
    tie(B,A) = itv[i];
    t += A;  //時間Aかけて，仕事する
    if (t > B) {
      ans = false;
      break;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;


signed main() {
  int N, K;
  cin >> N >> K;

  vector<pair<int, int>> vec(N);
  map<int, int> saidai;
  REP(i, N){
    cin >> vec[i].first >> vec[i].second;
    chmax(saidai[vec[i].first], vec[i].second);
  }

  sort(ALL(vec),   // dai -> syou
      [](pair<int, int> const & l, pair<int, int> const &  r){
      return l.second > r.second;
      });

  int ans = 0, oisisa = 0, syurui = 0;;
  vector<pair<int, int>> used;
  map<int, int> m;
  int num = 0;
  for(; num < K; num++){
    oisisa += vec[num].second;
    used.push_back(vec[num]);
    m[vec[num].first]++;
  }
  syurui = m.size();
  ans = oisisa+syurui*syurui;

  sort(ALL(used),   // syou -> dai
      [](pair<int, int> const & l, pair<int, int> const &  r){
      return l.second < r.second;
      });

  vector<pair<int, int>> suteru;
  REP(i, K) if(m[used[i].first] > 1){
    suteru.push_back(used[i]);
    m[used[i].first]--;
  }

  vector<pair<int, int>> siyou;
  for(pair<int, int>p:saidai){
    if(m[p.first] == 0) siyou.push_back(p);
  }

  sort(ALL(siyou),   // dai -> syou
      [](pair<int, int> const & l, pair<int, int> const &  r){
      return l.second > r.second;
      });

  REP(i, min(suteru.size(), siyou.size())){
    oisisa -= suteru[i].second;
    oisisa += siyou[i].second;
    syurui++;
    chmax(ans, oisisa+syurui*syurui);
  }
  
  cout << ans << endl;

  return 0;
}

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

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

	int ans = 0;
	int i = 0;
	for (i ; ; i++) 	{	
		if ( b <= a * i - i + 1) { break; }
	}

	cout << i << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a,b,x;cin>>a>>b>>x;
    ll top=b/x;
    ll bot=a/x;
    ll ans=top-bot;
    if(a%x==0)ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int ans=0;
  vector<int> A(N);
  for(int i=0; i<N ; i++)
  {
    cin >> A.at(i);
    if((A.at(i)%2==1) && ((i+1)%2==1))ans++;
  }
 cout << ans << endl; 
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll n , m ;
  cin>>n>>m;
  
  if(n>=m/2) cout<<m/2<<endl;
  else cout<<(m-2*n)/4+n<<endl;
  
}
  



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int main() {
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> hs(h), ws(w);
    set<P> s;
    rep(i,m) {
      int r, c;
      cin >> r >> c;
      r--; c--;
      hs[r]++; 
      ws[c]++;
      s.emplace(r,c);
    }
    int mh = 0, mw = 0;
    rep(i,h) mh = max(mh, hs[i]);
    rep(i,w) mw = max(mw, ws[i]);
    vector<int> is, js;
    rep(i,h) if (mh == hs[i]) is.push_back(i);
    rep(i,w) if (mw == ws[i]) js.push_back(i);
    int ans = mh+mw;
    for (int i : is) {
      for (int j : js) {
        if (s.count(P(i,j))) continue;
        cout << ans << endl;
        return 0;
      }
    }
    ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 23788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int m, k; cin >> m >> k;
	if ((1 << m) <= k) {
		cout << -1 << endl;
		return 0;
	}
	if (k == 0) {
		for (int i = 0; i < (1 << m); i++) {
			cout << i << " " << i << " \n"[i == (1 << m) - 1];
		}
		return 0;
	}
	if (m == 1 && k == 1) {
		cout << -1 << endl; 
		return 0;
	}
	vector<int> v;
	for (int i = 0; i < (1 << m); i++) {
		if (i == k) continue;
		v.push_back(i);
	}
	vector<int> ans;
	ans.push_back(k);
	for (int i : v) ans.push_back(i);
	ans.push_back(k);
	reverse(v.begin(), v.end());
	for (int i : v) ans.push_back(i);
	for (int i = 0; i < (1 << (m + 1)); i++) {
		cout << ans[i] << " \n"[i == (1 << (m + 1)) - 1];
	}
	return 0;
}


Measured memory_bytes: 3444
#include<cstdio>
#include<cstdlib>
#include<cmath>

using namespace std;
int main(void)
{
	int n;
	double x[4],y[4];
	double k[2];
	scanf("%d",&n);
	for(int i = 0;i < n;i++)
	{
		for(int j = 0;j < 4;j++) scanf("%lf%lf",&x[j],&y[j]);
		k[0] = (y[0]-y[1])/(x[0]-x[1]);
		k[1] = (y[2]-y[3])/(x[2]-x[3]);
		if(k[0] == k[1]) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1048
# frozen_string_literal: true

# ABC 083 B - Some Sums

input_n, input_a, input_b = STDIN.gets.split.map(&:to_i)
result = 0

(0..input_n).each do |n|
  n_spl = n.to_s.split('').map(&:to_i)
  n_sum = n_spl.inject(:+)
  result += n if input_a <= n_sum && n_sum <= input_b
end

puts result


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

#define MOD 1000000007

void count_diviser(long long n, vector<long long> &count)
{
    for (long long i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            count[i]++;
            n /= i;
        }
    }
    if (n != 1)
    {
        count[n]++;
    }
}

int main()
{
    long long N;
    cin >> N;

    vector<long long> count(1000, 0);
    for (long long i = 2; i <= N; i++)
    {
        count_diviser(i, count);
    }

    long long ans = 1;
    for (int i = 0; i < 1000; i++)
    {
        ans *= count[i] + 1;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
s = input().rstrip()
evens = ["L", "U", "D"]
odds = ["R", "U", "D"]
is_easy = True
for i, ch in enumerate(s):
    if i % 2 == 0:
        if ch not in odds:
            is_easy = False
    else:
        if ch not in evens:
            is_easy = False
if is_easy:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define sqr(x) (x)*(x)
using namespace std;

int main(){
#ifdef LOCAL
    freopen("inp.txt", "r", stdin );
    freopen("ans.txt", "w", stdout);
#endif
    string t = "ABC";
    int n; cin >> n;
    string s; cin >> s;
    int c = 0;
    for(int i=0; i<=n-3; i++){
    	if(s.substr(i,3)==t) c++;
    }
    cout << c << '\n';
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        try
        {
            checked
            {
                var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
                var res = a.Contains(0) ? 0 : a.Aggregate(1L, (x, y) => x * y);
                if (res > 1000000000000000000) throw new Exception();
                Console.WriteLine(res);
            }
        }
        catch
        {
            Console.WriteLine(-1);
        }
    }
}


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

int main(){
	string S;
	cin >> S;
	int ans1 = 0, ans2 = 0;
	for(int i=0; i<S.size(); i++){
		if(i % 2 == 0){
			if(S[i] == '0') ans2++;
			else ans1++;
		}else{
			if(S[i] == '0') ans1++;
			else ans2++;
		}
	}
	cout << min(ans1, ans2) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

/*==================================================*/

/*==================================================*/

string s;

int main() {
    cin>>s;
    cout<<s.substr(0,s.size()-8)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1000000000000
typedef long long ll;

int main()
{
  int n, ans = 0;
  cin >> n;
  if (n % 10 != 0)
  {
    while (true)
    {
      if (n < 10)
      {
        ans += n;
        break;
      }
      ans += n % 10;
      n /= 10;
    }
  }
  else if (n % 10 == 0)
  {
    ans = 10;
  }
  else
  {
    cout << "error";
  }

  cout << ans << endl;
}

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

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

    int wa = a + w;
    int wb = b + w;


    if(b - wa == 0 || a - wb == 0){
        cout << 0 << endl;
    }
    else if(b - wa > 0){
        cout << b - wa << endl;
    }
    else if(a - wb > 0){
        cout << a - wb << endl;
    } else {
        cout << 0 << endl;
    }
    
}

Measured memory_bytes: 256
n,m=map(int,input().split())

a=sorted([list(map(int,input().split())) for _ in range(n)])

#print(a)
pay=0
i=0
while m>0:
    p=min(m,a[i][1])
    m-=p
    pay+=p*a[i][0]
    i+=1
print(pay)




Measured memory_bytes: 28652
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <cstdlib>
#define PI acos(-1.0)
#define ll long long int
#define db double
#define ull unsigned long long int
#define Fill(x,y) memset(x,y,sizeof(x))
#define bug printf("!!!!!!\n");
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define sz(a) (int)(a).size()
using namespace std;
const db eps = 1e-6;
const int inf = 0x3f3f3f3f; //用这个可以直接mem
const ll INF = 1e18;
const int mod = 1e9+7;
const int maxn = 1e5+5;
int cas=1;
int a[maxn], b[maxn], c[maxn];
ll cb[maxn];
void solve()
{
    int n; scanf("%d", &n);
    for (int i = 1 ; i <= n ; i ++) scanf("%d", a+i);
    for (int i = 1 ; i <= n ; i ++) scanf("%d", b+i);
    for (int i = 1 ; i <= n ; i ++) scanf("%d", c+i);
    sort(b+1, b+1+n);
    sort(c+1, c+1+n);
    for (int i = 1 ; i <= n ; i ++) {
        int pos = upper_bound(c+1, c+1+n, b[i]) - c;
        if (pos > n) continue;
        cb[i] = n - pos + 1;
    }
    for (int i = 1 ; i <= n ; i ++) {
        cb[i] += cb[i-1];
    }
    ll ans = 0;
    for (int i = 1 ; i <= n ; i ++) {
        int pos = upper_bound(b+1, b+1+n, a[i]) - b;
        if (pos > n) continue;
        ans += cb[n] - cb[pos-1];
    }
    printf("%lld\n", ans);
}
int main()
{
    // freopen("in.txt","r",stdin);
    //  freopen("out.txt","w",stdout);
    int t = 1 ;
    //scanf("%d",&t);
    while(t--){
       // printf("Case %d: ", cas++);
        solve();
        //printf("\n");
    }
}









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

using namespace std;

map<pair<int,int>,char> mem[100001];
char str[100001];
int N,A,B,C;
long sum;


char Search(int A,int B,int step);
char memSearch(int A,int B,int step);

char Search(int A,int B,int step){
  int C = sum -A-B;
  if(step == N){
   switch(str[step]){
     case 'A':
       if(B>0)
         return 'C';
       if(C>0)
         return 'B';
       return 0;
       break;
       
     case 'B':
       if(A>0)
         return 'C';
       if(C>0)
         return 'A';
       return 0;
       break;
       
       case 'C':
       if(B>0)
         return 'A';
       if(A>0)
         return 'B';
       return 0;
       break;
   }
  }
  
  switch(str[step]){
     case 'A':
       if(B>0&&memSearch(A,B-1,step+1)!=0)
         return 'C';
       if(C>0&&memSearch(A,B+1,step+1)!=0)
         return 'B';
       return 0;
       break;
       
     case 'B':
       if(A>0&&memSearch(A-1,B,step+1)!=0)
         return 'C';
       if(C>0&&memSearch(A+1,B,step+1)!=0)
         return 'A';
       return 0;
       break;
       
       case 'C':
       if(B>0&&memSearch(A+1,B-1,step+1)!=0)
         return 'A';
       if(A>0&&memSearch(A-1,B+1,step+1)!=0)
         return 'B';
       return 0;
       break;
   }
  	
  return -1;  
}

char memSearch(int A,int B,int step){
 if(mem[step].find(make_pair(A,B))!=mem[step].end())
      return mem[step][make_pair(A,B)];
 else{
   mem[step][make_pair(A,B)] = Search(A,B,step);
  return mem[step][make_pair(A,B)];
 }
}
  



int main(){
  
  
  cin >> N >> A >> B >> C;
  sum = (long)A+B+C;

  for(int i=1; i<=N; i++){
   char buf[3];
   cin >> buf;
   if(buf[0]=='A'){
	if(buf[1] == 'B')
      str[i] = 'C';
     else
       str[i] = 'B';
   }else
     str[i] = 'A';
  }
  
  if(memSearch(A,B,1)==0){
	cout << "No" << endl;
   return 0; 
  }else{
  	cout << "Yes" << endl;
    for(int step = 1; step<=N; step++){
    	cout << memSearch(A,B,step) << endl; 
      	switch(memSearch(A,B,step)){
          case 'A':
            A++;
            if(str[step]=='B')
              C--;
            else
              B--;
            break;
          case 'B':
            B++;
            if(str[step]=='A')
              C--;
            else
              A--;
            break;
          case 'C':
            C++;
            if(str[step]=='B')
              A--;
            else
              B--;
            break;
            
        }
    }
  
  }

  
  
  return 0;
}




Measured memory_bytes: 27692
#include <bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------

int main(void){
    // Your code here!
    int k; cin >> k;
    rep(i,k) cout << "ACL";
}


Measured memory_bytes: 3628
import sys
from collections import Counter
input = sys.stdin.readline
h,w,*a = map(int,input().split())
a = []
for i in range(h):
  a += list(input().strip())
m1 = (h%2)*(w%2)
m2 = (h%2)*(w//2)+(h//2)*(w%2)
c = Counter(a)
c1,c2, = 0,0
for i in c.values():
  dc2,dc1 = divmod(i%4,2)
  c1 += dc1
  c2 += dc2
print("Yes" if m1>=c1 and m2>=c2 else "No")

Measured memory_bytes: 9484
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int d, g;
vector<pair<int, int>> p;
vector<vector<int>> dp;

int dfs(int now, int score){
    if(now == d){
        if(g <= score){
            return 0;
        }else{
            return 1 << 25;
        }
    }
    if(g <= score) return 0;
    if(~dp[now][score]) return dp[now][score];
    int res = 1 << 25;
    for(int i = 0; i <= p[now].first; i++){
        res = min(res, i + dfs(now + 1, score + i * (now + 1) * 100 + (i == p[now].first) * p[now].second));
    }
    return dp[now][score] = res;
}

int main(){
    cin >> d >> g;
    dp.resize(d, vector<int>(g, -1));
    p.resize(d);
    for(auto&& i : p){
        cin >> i.first >> i.second;
    }

    cout << dfs(0, 0) << "\n";
}

Measured memory_bytes: 453504
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
// 公約数
long int gcd(long int a, long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long int lcm(long int a, long int b){
  return a * b / gcd(a, b);
}


// min
int main(void){
  long long int n;
  int ans = 0;
  int keta = 0;

  scanf("%lld", &n);
  //約数を求める。その時の桁数を求める。一番桁数が小さくなる組合せを求める。

  long long int k = n;
  while(k != 0){
    k /= 10;
    ans++;
  }

  // i = 0から始めると(n%i == 0)のところで落ちている
  for(long int i  = 1; i * i <= n; i++){
    fprintf(stderr, "i = %ld\n", i);
    if(n % i == 0){
      long int j = n / i;
      while(j != 0){
	j /= 10;
	keta++;
      }
      fprintf(stderr, "ans = %d, keta = %d\n", ans, keta);
      if(ans > keta){
	ans = keta;
      }
      keta = 0;
    }
  }
  
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
// C - Distinct or Not
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
template<class T> vector<T> inarr(int s,int e, T init=0){
	vector<T> v;T x;
	for(int i=0;i<s;++i)v.push_back(init);
	for(int i=s;i<e;++i){cin>>x;v.push_back(x);}
	return v;
}

int N;
vi A;

int main(){
	cin>>N;
	A = inarr<int>(0,N);
	sort(all(A));
	rp(i,1,N) if(A[i-1] == A[i]){ puts("NO"); return 0; }
	puts("YES");
}

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

int main(){
  string S;
  cin >> S;
  
  int answer = 0;
  for(int i=0;i<4;i++){
  if(S.at(i)=='+'){
    answer++;
  }else{
    answer--;
  }
  }
      cout << answer << endl;
    }

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

max_nood = sum(A)
count_nood = 0
corrent_nood = 0
ans = True

for i in range(N+1):
    if i == 0:
        corrent_nood = 1
        count_nood += corrent_nood
        max_nood -= A[i]
    else:
        corrent_nood = min(2*(corrent_nood-A[i-1]), max_nood)
        max_nood -= A[i]
        count_nood += corrent_nood
    if corrent_nood <= 0 or A[i] > corrent_nood:
        ans = False
        # print(i)
        break
if ans:
    print(count_nood)
else:
    print(-1)


Measured memory_bytes: 20136
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}





int main(){
    ll n;
    cin>>n;
    vector<ll> A(n);
    cin>>A;
    ll sum=0;
    for(auto &I:A){sum+=abs(I);}
    ll mi=abs(A[0]),w=0;
    ll pls=-1,mns=-1;
    auto D=[&](ll a){
        if(A[a]<0){mns=a;}
        if(A[a]>=0){pls=a;}
        if(mi>abs(A[a])){
            mi=abs(A[a]);
            w=a;
        }
    };
    for(int i=0;i<n;i++){D(i);}
    if(pls==-1){
        cout<<sum-mi*2<<endl;
        for(int i=0;i<n;i++){
            if(i!=w){
                cout<<A[w]<<" "<<A[i]<<endl;
                A[w]-=A[i];
            }
        }
    }
    else if(mns==-1){
        cout<<sum-mi*2<<endl;
        for(int i=2;i<n;i++){
            if(i!=w){
                cout<<A[w]<<" "<<A[i]<<endl;
                A[w]-=A[i];
            }
        }
        if(w==0){
            cout<<A[1]<<" "<<A[w]<<endl;
        }
        else if(w==1){
            cout<<A[0]<<" "<<A[w]<<endl;
        }
        else{
            cout<<A[w]<<" "<<A[1]<<endl;
            A[w]-=A[1];
            cout<<A[0]<<" "<<A[w]<<endl;
        }
    }
    else{
        cout<<sum<<endl;
        for(int i=0;i<n;i++){
            if(i!=mns && i!=pls){
                if(A[i]<0){
                    cout<<A[pls]<<" "<<A[i]<<endl;
                    A[pls]-=A[i];
                }
                else{
                    cout<<A[mns]<<" "<<A[i]<<endl;
                    A[mns]-=A[i];
                }
            }
        }
        cout<<A[pls]<<" "<<A[mns]<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 2688