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

int main() {
  int n;
  cin >> n;

  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i] >> b[i];

  int mn = 0, mx = 0;
  for (int i = 1; i < n; ++i) {
    if (b[i] < b[mn])
      mn = i;
    if (b[i] > b[mx])
      mx = i;
  }

  cout << a[mx] + b[mn] + (a[mn] - a[mx]) << endl;
}

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

using namespace std;

/*
const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;*/

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

void printV(vi v) {
    for (int i = 0; i<v.size(); ++i) cout << v.at(i) << " ";
    cout << "\n";
}

//g++ -std=c++11 -O2 -Wall c.cpp

void solve() {
    int n; cin >> n;
    int count = 0;
    string result = "No";
    for (int i = 0; i<n; ++i) {
        int num1, num2;
        cin >> num1 >> num2;
        if (num1 == num2) count++;
        else count = 0;
        if  (count == 3) result = "Yes";
    }
    cout << result << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    solve();


    /**
     * ALGORITHME DE TRI ET EN LEVER LES DUPLICATES
     * set<int> s( v.begin(), v.end() );
     * v.assign( s.begin(), s.end() );
     * */
}


Measured memory_bytes: 3648
n=int(input())
s=list(input())
w=s.count("W")
e=s.count("E")
x=[0 for i in range(n)]
for i in range(1,n):
    if s[i-1]=="W":
        x[i]=x[i-1]+1
    else:
        x[i]=x[i-1]
ans=n
for i in range(n):
    z=2*x[i]+e-i
    if s[i]=="E":
        z-=1
    ans=min(ans,z)
print(ans)


Measured memory_bytes: 109944
#include<iostream>
using namespace std;
int main()
{
    int i,n;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
     }
    for(i=n-1;i>=0;i--){
        if(i==0)
           cout<<a[i]<<endl;
        else
        cout<<a[i]<<" ";
     }
    
    return 0;
}


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

int64_t Fsum(int64_t n,int64_t m,int64_t a,int64_t b){
  int64_t ans=0;
  ans+=(b/m)*n+(a/m)*n*(n-1)/2;
  b%=m,a%=m;
  int64_t y=(a*(n-1)+b)/m;
  int64_t x=y*m-b;
  if(y==0){
    return ans;
  }
  ans+=(n-(x-1)/a-1)*y;
  ans+=Fsum(y,a,m,((x+a-1)/a)*a-x);
  return ans;
}

int main() {
  int T;
  cin>>T;
  for(int l=0;l<T;l++){
    int64_t N,M,A,B;
    cin>>N>>M>>A>>B;
    cout<<Fsum(N,M,A,B)<<endl;
  }
}

Measured memory_bytes: 3536
import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
    N = int(input())
    dist = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = map(int,input().split())
        dist[a-1].append(b-1)
        dist[b-1].append(a-1)

    def root(x):
        go = [False for _ in range(N)]
        d = [0 for _ in range(N)]
        go[x] = True
        q = deque([x])
        while q:
            now = q.pop()
            for fol in dist[now]:
                if go[fol]:
                    continue
                else:
                    d[fol] = d[now] + 1
                    go[fol] = True
                    q.append(fol)
        return d
    
    fen = root(0)
    snu = root(N-1)
    fg = sg = 0
    for i in range(N):
        if fen[i] <= snu[i]:
            fg += 1
        else:
            sg += 1
            
    print("Fennec" if fg > sg else "Snuke")

if __name__ == "__main__":
    main()


Measured memory_bytes: 30104
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "Yes\n";
#define no cout << "No\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define round(x, y) ((2 * x + y) / (2 * y))
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    ll a, b, c;
    cin >> a >> b >> c;

    yesno((a == b && b != c) || (c == b && a != c) || (a == c && b != c));
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // freopen("file", "r", stdin);
    // freopen("file", "w", stdout);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
const ul mod = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin >> t;
    vector<ll> ans(t);
    rep(i, t) {
        ll n, m, a, b;
        cin >> n >> m >> a >> b;
        ans[i] = atcoder::floor_sum(n, m, a, b);
    }

    rep(i, t) { cout << ans[i] << endl; }
    return 0;
}



Measured memory_bytes: 3692
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def _cmb(N, mod):
    N1 = N + 1
    fact = [1] * N1
    inv = [1] * N1

    for i in range(2, N1):
        fact[i] = fact[i-1] * i % mod

    inv[N] = pow(fact[N], mod-2, mod)
    for i in range(N-1, 1, -1):
        inv[i] = inv[i+1]*(i+1) % mod

    def cmb(a, b):
        return fact[a] * inv[b] % mod * inv[a-b] % mod
    return cmb

def resolve():
    K = int(input())
    s = input()
    ls = len(s) - 1
    mod = 10**9+7

    cmb = _cmb(ls+K, mod)

    ans = 0
    p25 = 1
    p26 = pow(26, K, mod)
    p26inv = 576923081 #pow(26,  mod-2, mod)
    for i in range(K+1):
        ans = (ans + cmb(ls+i, ls) * p25 * p26) % mod
        p25 = p25 * 25 % mod
        p26 = p26 * p26inv % mod
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 106680
INF = 2**60 # 無限大を表す値
H, N = map(int, input().split())
AB = [map(int, input().split()) for i in range(N)]
dp = [[INF] * (H + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i, (A, B) in enumerate(AB):
    for j in range(H+1):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        dp[i+1][j] = min(dp[i+1][j], dp[i+1][max(j-A, 0)] + B)
print(dp[N][H])

Measured memory_bytes: 148336
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N, tmp;
  cin >> N;
  vector<int> colors;
  for (int i=0; i<N; i++){
    cin >> tmp;
    colors.push_back(tmp);
  }
  
  int p = 0, q = 0, res = 0;
  while (p < N){
    if (colors[p + 1] != colors[p]){
		p++;
    }
    else if (p >= N - 1){
      p++;
      res++;
    }
    else if (colors[p + 1] != colors[p + 2]){
      res++;
      p += 2;
    }
    else {
      res++;
      p += 2;
    }
  }
  
  cout << res << endl;
  
  return 0;
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;

int main()
{
	lli n, a, b;
	scanf("%lld %lld %lld",&n,&a,&b);

	lli ans = n/( a + b );
	ans *= a;

	n %= ( a + b );

	ans += min( n , a );

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

Measured memory_bytes: 256
import java.util.*;
import java.util.Collections;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    if (N == 1) {
      System.out.println(1);
    } else {
      long L0 = 2;
      long L1 = 1;
      long ans = 0;
      for (long i = 2; i <= N; i++) {
        ans = L0 + L1;
        L0 = L1;
        L1 = ans;
      }
      System.out.println(ans);
    }
  }
}


Measured memory_bytes: 23764
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {
	
	int d, n;

	cin >> d >> n;

	if (d == 0) {
		if (n == 100) {
			cout << 101 << endl;
		}
		else {
			cout << n << endl;
		}
	}

	if (d == 1) {
		if (n == 100) {
			cout << 10100 << endl;
		}
		else {
			cout << n * 100 << endl;
		}
	}

	if (d == 2) {
		if (n == 100) {
			cout << 1010000 << endl;
		}
		else {
			cout << n * 10000 << endl;
		}
	}
	
}

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

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{min, max};
use std::collections::{HashMap, HashSet, VecDeque, BinaryHeap};

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let t = v.iter().fold(0, |ac, &x| ac ^ x);
    print!("{}", t ^ v[0]);
    for &x in v.iter().skip(1) {
        print!(" {}", t ^ x);
    }
    println!("");
}


Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	int n,m; cin>>n>>m;
	vl v(n,1);
	vector<bool> ok(n);
	ok[0]=true;
	ll cnt=0;
	rep(i,0,m){
		ll a,b; cin>>a>>b;
		--a,--b;
		if(ok[a])ok[b]=true;
		v[a]--; v[b]++;
		if(v[a]==0)ok[a]=0;
	}
	rep(i,0,n)cnt+=ok[i];
	cout<<cnt<<endl;
	
	return 0;
}

Measured memory_bytes: 4056
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  bool zero = false;
  int cnt = 0;
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    if (a == 0) zero = true;
    if (a < 0) cnt++;
    sum += abs(a);
    A.at(i) = abs(a);
  }
  sort(A.begin(), A.end());
  if (zero || cnt % 2 == 0) cout << sum << endl;
  else cout << sum - 2 * A.at(0) << endl;
}

Measured memory_bytes: 768
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

D, T, S = map(int, input().split())

if D > T * S:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 9156
package main

import (
	"fmt"
)

func main() {
	var N, L int
	fmt.Scan(&N, &L)

	allSum := (L + L + N - 1) * N / 2

	if L+N-1 <= 0 {
		fmt.Println(allSum - (L + N - 1))
	} else if L >= 0 {
		fmt.Println(allSum - L)
	} else {
		fmt.Println(allSum)
	}
}


Measured memory_bytes: 1768
<?php
$S = trim(fgets(STDIN));
$len = strlen($S) - 1;

$ti = [];
$ti[$len] = (int)$S[$len] % 2019;
$mod_table = [];
$mod_table[$ti[$len]] = 1;
$mod_pow_ten_table = [];
$mod_pow_ten_table[0] = 1;

$ans = 0;
for ($i = $len; $i > 0; $i--) {
    $mod_pow_ten_table[$len - $i + 1] = $mod_pow_ten_table[$len - $i] * 10 % 2019;
    $ti[$i - 1] = ((int)$S[$i - 1] * $mod_pow_ten_table[$len - $i + 1] + $ti[$i]) % 2019;
    $mod_table[$ti[$i - 1]] += 1;
}

foreach ($mod_table as $index => $num) {
    if ($index === 0) {
        $num += 1;
    }
    $ans += $num * ($num - 1) / 2;
}

echo $ans;

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

int main(){
  int n, min, max, a;
  long total;
  cin >> n;
  cin >> a;
  min = max = total = a;
  
  for ( int i = 2; i <= n; i++ ){
  	cin >> a;
  	if ( a < min ) min = a;
  	if ( a > max ) max = a;
  	total += a;
  }
  
  cout << min << " " << max << " " << total << endl;
  
  return 0;
}


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

int main() {

    int h, w;

    for ( ;; ) {

        std::cin >> h >> w;

        if ( h == 0 && w == 0 ) break;

        for ( int i = 0; i < h; i++ ) {

            for ( int j = 0; j < w; j++ ) {
                i == 0 || i == h - 1 || j == 0 || j == w - 1
                    ? std::cout << "#"
                    : std::cout << "." ;
            }
            std::cout << std::endl;
        }

        std::cout << std::endl;
    }


    return 0;
}



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

using namespace std;
#define ll long long
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;
typedef pair<int,int> P;




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








    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define reg register
#define max(a,b) (a>b?a:b)
typedef long long ll;
char ch[100005];
class Trie{
	private:
		ll len;
		int nxt[100005][2],cnt;
	public:
		void init(){scanf("%lld",&len);cnt=0;}
		void ins(int l,char ch[]){
			for(reg int i=1,pos=0;i<=l;i++){
				if(!nxt[pos][ch[i]^48])nxt[pos][ch[i]^48]=++cnt;
				pos=nxt[pos][ch[i]^48];
			}
		}
		ll query(int l,int dep){
			if(!l&&dep)return (len-dep+1)&(dep-len-1);
			return query(nxt[l][0],dep+1)^query(nxt[l][1],dep+1);
		}
}t;
int main(){
	reg int n;scanf("%d",&n);
	t.init();
	for(reg int i=1;i<=n;i++){
		scanf("%s",ch+1);
		t.ins(strlen(ch+1),ch);
	}
	puts(t.query(0,0)?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 4224
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>

using namespace std;


bool isvertical(int x0, int x1, int x2, int x3, int y0, int y1, int y2, int y3){
    
    return !((x1-x0)*(x3-x2) + (y1-y0)*(y3-y2));
    
}


bool isParallel(int x0, int x1, int x2, int x3, int y0, int y1, int y2, int y3){
    
    return (x3-x2)*(y1-y0) ==  (y3-y2)*(x1-x0);
}


int main(){
    
    int x0, x1, x2, x3, y0, y1, y2, y3;
    int n;
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        
        if
        (
            isvertical(x0, x1, x2, x3, y0, y1, y2, y3)
        )
        {
            cout << 1 << endl;
        }
        else if
        (
            isParallel(x0, x1, x2, x3, y0, y1, y2, y3)
        )
        {
            cout << 2 << endl;
        }
        else
        {
            cout << 0 <<endl;
        }
            
        
    }
    
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define Data_Nerd ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define files freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;
using ll = long long;

const int N = 1e5;

int h[N];

int main() {
	Data_Nerd
	int n, k; scanf("%d%d", &n, &k);

	for(int i = 0; i < n; ++i)
		scanf("%d", h + i);

	sort(h, h + n);

	int ans = 2e9;

	for(int i = 0; i < n - k + 1; ++i) {
		ans = min(ans, h[i + k - 1] - h[i]);
	}

	cout << ans;
}


Measured memory_bytes: 640
#include <stdio.h>
#define QMAX 100000
int is_prime[QMAX+1];
void sieve(int n);
int main(void) {
  int i, q, l, r, lnum[QMAX+1] = {0};
  sieve(QMAX);
  for (i = 1; i <= QMAX; i += 2) lnum[i] = is_prime[i] && is_prime[(i+1)/2];
  for (i = 1; i <= QMAX; i++) lnum[i] += lnum[i-1];
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d %d", &l, &r);
    printf("%d\n", lnum[r] - lnum[l-1]);
  }
  return 0;
}

void sieve(int n)
{
  int i, j;
  for (i = 0; i <= n; i++) is_prime[i] = 1;
  is_prime[0] = is_prime[1] = 0;
  for (i = 2; i * i <= n; i++) {
    if (is_prime[i]) {
      for (j = i * i; j <= n; j += i) is_prime[j] = 0;
    }
  }
}


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

int main() {
	string n;
	int a[10];
	while (cin >> n) {
		for (int i = 0; i < 10; i++)
			a[i] = n[i] - '0';

		for (int i = 1; i <= 9; i++) {
			for (int j = 0; j < 10 - i; j++) {
				a[j] = (a[j] + a[j + 1]) % 10;
			}
		}

		cout << a[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 3192
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s == "Sunny"){
        cout << "Cloudy";
    }else if (s == "Cloudy"){
        cout << "Rainy";
    }else if (s == "Rainy"){
        cout << "Sunny";
    }
    return 0;
}


Measured memory_bytes: 3492
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  int ans = 0;
  while(true){
    int m = 0;
    bool check = false;
    for(int i = 0; i < n; i++){
      m = max(m, h[i]);
      if(h[i] > 0){
        check = true;
        h[i]--;
      }else if(check){
        if(h[i] == 0){
          ans++;
          check = false;
        }
      }

    }

    if(check){
      ans++;
    }
    if(m == 0){
      cout << ans << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(void)
{
	int h, w;
	int i, j;

	for (;scanf("%d%d", &h, &w),h+w;){
		for (i = 1; i <= h; i++){
			for (j = 1; j <= w; j++)putchar((i+j)%2?'.':'#');
			puts("");
		}
		puts("");
	}
	return (0);
}

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


int main(){
    ios_base::sync_with_stdio(0);
    string s;
    cin>>s;
    long long sum=0;
    for(int i=1;i<s.size();i++){
        if(s[i]!=s[i-1])
            sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

void print() {
    cout << endl;
}

// template <class Head, class... Tail>
// void print(Head&& head, Tail&&... tail) {
//     cout << head;
//     if (sizeof...(tail) != 0) cout << " ";
//     print(forward<Tail>(tail)...);
// }

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << " ";
    }
    cout << endl;
}

template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i,k-1)cout << vec[i] << " ";
   cout << vec[k-1] << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    cout << p.first << " " << p.second << "\n";
}


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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n,m; cin >> n >> m;
    vvl table(n, vl(m));
    rep(i,n)rep(j,m){
        cin >> table[i][j];
        table[i][j]--;
    }
    auto c = [&](ll k){
        bitset<n_max> used = 0;
        vector<ll> top(n);
        bool ok = false;
        vector<ll> cnt(m), clear(m);
        Pll max_ = {0, -1};
        while(!ok && used.count() < m){
            max_ = {0,-1};
            rep(i,n){
                // debug(i);
                while(top[i] < m && used[table[i][top[i]]])top[i]++;
                // debug(top[i]);
                // if(top[i] == m)return false;
                cnt[table[i][top[i]]]++;
            }
            rep(i,m)chmax(max_, {cnt[i], i});
            if(max_.first <= k)ok = true;
            else{
                cnt = clear;
                used[max_.second] = 1;
            }
            // print(max_);
            // print(top);
        }
        return ok;
    };

    ll ok = n;
    ll ng = 0;
    while(abs(ok - ng) > 1){
        ll k = (ok + ng) / 2;
        if(c(k))ok = k;
        else ng = k;
    }

    cout << ok << endl;
}

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

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
	os << '{';
	for(int i=0;i<sz(a);i++)
	{
		if(i>0&&i<sz(a)-1)
			os << ", ";
		os << a[i];
	}
	os << '}';
    return os;
}
int N=2e5+5;
vector<ll> fen(N);
void add(int i,ll a)
{
    for(;i<N;i+=i&(-i))
    {
        fen[i]=max(fen[i],a);
    }
}
ll get(int i)
{
    ll m=0;
    for(;i;i-=i&(-i))
        m=max(m,fen[i]);
    return m;
}
int main()
{
    int n;
    scanf("%i",&n);
    vector<int> hh(n);
    vector<ll> aa(n);
    for(int i=0;i<n;i++)
    {
        scanf("%i",&hh[i]);
    }
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&aa[i]);
    }
    for(int i=0;i<n;i++)
    {
        int h=hh[i];
        ll a=aa[i];
        ll best=get(h-1);
        add(h,(ll)a+best);
    }
    printf("%lld\n",get(n));
    return 0;
}


Measured memory_bytes: 4096
#include<iostream>
#include<cctype>
using namespace std;
int main(){
        int a,b;
        string x;
        cin>>a>>b>>x;
        for(int i=0;i<a+b+1;i++){
                if(i>x.size()){
                        cout<<"No";
                        return 0;
                }
                if(i<a){
                        if(!isdigit(x[i])){
                                cout<<"No";
                                return 0;
                        }
                }
                if(i==a){
                        if(x[i]!='-'){
                                cout<<"No";
                                return 0;
                        }
                }
                else{
                        if(!isdigit(x[i])){
                                cout<<"No";
                                return 0;
                        }
                }
        }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
import numpy as np

C1 = input().split(' ')
C2 = input().split(' ')
C3 = input().split(' ')

C = np.array([C1,C2,C3], np.int)

r1 = C[0,:]-C[1,:]
r2 = C[1,:]-C[2,:]
r3 = C[2,:]-C[0,:]

c1 = C[:,0]-C[:,1]
c2 = C[:,1]-C[:,2]
c3 = C[:,2]-C[:,0]

if np.all(r1 == r1[0]) and np.all(r2 == r2[0]) and np.all(r2 == r2[0]):
    if np.all(c1 == c1[0]) and np.all(c2 == c2[0]) and np.all(c3 == c3[0]):
        print('Yes')
else: print('No')


Measured memory_bytes: 14556
MOD = 10 ** 9 + 7


def power_expo(x, y):
    """Returns x^y.

    <https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6>

    結局, 組み込み関数の `pow()` のほうが速そう. 第3引数でmodもできる.
    """
    if y == 0:
        return 1
    elif y % 2 == 0:
        return power_expo(x, y // 2) ** 2 % MOD
    else:
        return power_expo(x, y // 2) ** 2 * x % MOD


def combinations_mod(n, r, mod=1000000007):
    """Returns nCr in mod."""
    combs = 1
    for i, j in zip(range(n - r + 1, n + 1), range(1, r + 1)):
        combs = combs % mod * i % mod * pow(j, mod - 2, mod) % mod
    return combs


def main():
    x, y = [int(x) for x in input().split()]
    if (x + y) % 3 != 0:
        return 0
    summ = (x + y) // 3     # d + r
    diff = x - y  # d - r
    if summ % 2 != diff % 2:
        return 0
    d = (summ + diff) // 2  # Down
    r = (summ - diff) // 2  # Right
    if d < 0 or r < 0:
        return 0
    chosen = min(d, r)

    patterns = combinations_mod(summ, chosen)

    return patterns


if __name__ == '__main__':
    print(main())

# やはり難しい，再び解説。割り算のときは mod 10^9+7 が厄介。
# とりあえず，割る方は 10^9+5 乗して掛ければいいらしい。
# でかい累乗, pow() なら間に合うな. Python3 1310 ms; Pypy3 457 ms.


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

int main() {
double a , b;
cin >> a >> b;
double A = (a + b)/2 ;
int B = (a+b)/2;
if(A - B >= 0.5)
cout << B + 1 << endl;
else if (A - B < 0.5)
cout << B << endl;
}

Measured memory_bytes: 3716
#include<stdio.h>
#include<algorithm>
using namespace std;

#define x first
#define y second
#define MOD 1000000007
#define NMAX 3005

int n, m, d[NMAX][NMAX], ones;
char s[NMAX];
pair<int,int> interval[NMAX];

struct segTree{
    int sum, lazy;
};

segTree aintL[4 * NMAX], aintR[4 * NMAX];

void updateNode(segTree aint[], int n, int left, int right, int val){
    aint[n].sum= (right - left + 1) * val;
    aint[n].lazy = val;    
}

void update(segTree aint[], int n, int left, int right, int a, int b, int val){
    if(a > b)
        return ;
    if(a <= left  && right <= b){
        updateNode(aint, n, left, right, val);
        return ;
    }
    int mid = (left + right) / 2;
    if(aint[n].lazy != -1){
        updateNode(aint, 2 * n, left, mid, aint[n].lazy);
        updateNode(aint, 2 * n + 1, mid + 1, right, aint[n].lazy);
        aint[n].lazy = -1;
    }
    if(a <= mid)
        update(aint, 2 * n, left, mid, a, b, val);
    if(b > mid)
        update(aint, 2 * n + 1, mid + 1, right, a, b, val);
    aint[n].sum = aint[2 * n].sum + aint[2 * n + 1].sum;
}

int queryCount(segTree aint[], int n, int left, int right, int a, int b){
    if(a <= left && right <= b){
        return aint[n].sum;
    }
    int mid = (left + right) / 2, ans1 = 0, ans2 = 0;
    if(aint[n].lazy != -1){
        updateNode(aint, 2 * n, left, mid, aint[n].lazy);
        updateNode(aint, 2 * n + 1, mid + 1, right, aint[n].lazy);
        aint[n].lazy = -1;
    }
    if(a <= mid)
        ans1 = queryCount(aint, 2 * n, left, mid, a, b);
    if(b > mid)
        ans2 = queryCount(aint, 2 * n + 1, mid + 1, right, a, b);
    return ans1 + ans2;
}

int main (){
    pair<int,int> seg;
    
    scanf("%d%d\n",&n,&m);
    scanf("%s",s + 1);
    for(int i = 1; i <= n; i++){
        update(aintL, 1, 1, n, i, i, s[i] - '0');
        update(aintR, 1, 1, n, i, i, s[i] - '0');
    }
    for(int i = 1; i <= m; i++){
        scanf("%d%d",&seg.x,&seg.y);
        int cnt = queryCount(aintL, 1, 1, n, seg.x, seg.y);
        update(aintL, 1, 1, n, seg.x, seg.x + cnt - 1, 1);
        update(aintL, 1, 1, n, seg.x + cnt, seg.y, 0);
        
        cnt = queryCount(aintR, 1, 1, n, seg.x, seg.y);
        update(aintR, 1, 1, n, seg.x, seg.y - cnt, 0);
        update(aintR, 1, 1, n, seg.y - cnt + 1, seg.y, 1);
    }
    
    for(int i = 1; i <= n; i++){
        if(queryCount(aintL, 1, 1, n, i, i)){
            interval[++ones].x = i;
        }
    }
    ones = 0;
    for(int i = 1; i <= n; i++){
        if(queryCount(aintR, 1, 1, n, i, i)){
            interval[++ones].y = i;
        }
    }
    
    d[0][0] = 1;
    for(int i = 1; i <= n; i++)
        for(int j = 0; j <= ones; j++){
            d[i][j] = d[i - 1][j];
            if(j && interval[j].x <= i && i <= interval[j].y)
                d[i][j] += d[i - 1][j - 1];
            if(d[i][j] >= MOD)
                d[i][j] -= MOD;
        }
    printf("%d\n", d[n][ones]);
    return 0;
}



Measured memory_bytes: 35200
N, K = map(int, input().split())
l = []
for i in range(N):
  l.append(int(input()))
  
cnts = [1] * N
for i in range(N):
  for j in range(max(0, i-200), i):
    if abs(l[i]-l[j]) <= K:
      cnts[i] = max(cnts[i], cnts[j]+1)
print(max(cnts))

Measured memory_bytes: 94704
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
s = input()

r = []
g = []
b = []
for i in range(n):
    if s[i] == "R":
        r.append(i)
    if s[i] == "G":
        g.append(i)
    if s[i] == "B":
        b.append(i)

ans = len(r)*len(g)*len(b)

for i in range(1,n):
    for j in range(n):
        k = j + 2 * i
        if k < n and s[j] != s[j + i] and s[j] != s[j + 2 * i] and s[j + i] != s[j + 2 * i]:
            ans -= 1

print(ans)

Measured memory_bytes: 75992
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  R s;
  int ans=MAX;
  rep(k,26) {
    char c=(char)('a'+k);
    string r=s;
    int cnt=0;
    while(1) {
      bool f=1;
      rep(i,r.size()) {
        if(r[i]!=c) f=0;
      }
      if(f) {
        ans=min(ans,cnt);
        break;
      }
      string t="";
      rep(i,r.size()-1) {
        if(r[i]==c||r[i+1]==c) t+=c;
        else t+=r[i];
      }
      cnt++;
      r=t;
    }
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
using namespace std;
using ll = long long int;
ll a, b, c, d;
ll ret = 0;

ll gcd(ll a, ll b) {
	while (b) {
		ll m = a % b;
		a = b;
		b = m;
	}
	return	a;
}

ll lcm(ll a, ll b) {
	return	(a * b) / gcd(a, b);
}

int main(void) {
	cin >> a >> b >> c >> d;
	ret += b / c - (a - 1) / c;
	ret += b / d - (a - 1) / d;
	ll g = lcm(max(c, d), min(c, d));
	ret -= b / g - (a - 1) / g;
	ret = b - a + 1 - ret;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
int main(){
	int n;
	int a[100];
	int i,j;
	int mini;
	int counter = 0;

	std::cin >> n;
	for(i=0;i<n;i++){
		std::cin >> a[i];
	}

	for(i=0;i<n;i++){
		mini = i;
		for(j=i;j<n;j++){
			if(a[j] < a[mini]){
				mini = j;
			}
		}
		std::swap(a[i],a[mini]);
		if(i!=mini)counter++;
	}

	for(i=0;i<n;i++){
		if(i>0){
			std::cout << " ";
		}
		std::cout << a[i];
	}
	std::cout << "\n" << counter << "\n";

	return (0);
}

Measured memory_bytes: 3096
/**
 * 
1 quicksort(A, p, r)
2   if p < r
3     q = partition(A, p, r)
4     quickSort(A, p, q-1)
5     quickSort(A, q+1, r)
 *
 */

import java.util.*;
import java.io.*;

/**
 * C
 */
public class Main {

    void run() throws IOException {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());

        String[] A = new String[n+1];
        String[] A_copy = new String[n+1];

        for(int i=0; i<n; i++) {
            A[i] = br.readLine();
            A_copy[i] = A[i];
        }

        mergeSort(A_copy, 0, n);
        quickSort(A, 0, n-1);
        System.out.println(Arrays.equals(A, A_copy) ? "Stable" : "Not stable");
        show(A, n);

        br.close();

    }

    
    void quickSort(String[] A, int p, int r) {
        
        if(p<r) {
            
            int q = partition(A, p, r);
            quickSort(A, p, q-1);
            quickSort(A, q+1, r);
            
        }
    }
    
    int partition(String[] A, int p, int r) {
        
        int x = Integer.parseInt(A[r].substring(2));
        int i = p - 1;
        for (int j=p; j<r; j++) {
            if (Integer.parseInt(A[j].substring(2))<=x) {
                i++;
                String tmp = A[i];
                A[i] = A[j];
                A[j] = tmp;
            }
        }
        
        String tmp = A[i+1];
        A[i+1] = A[r];
        A[r] = tmp;
        
        return i+1;
        
    }

    /*
    void bubbleSort(String[] c, int n) {
        for(int i=0; i<n-1; i++) {
            for(int j=n-1; j>i; j--) {
                if(c[j].charAt(2)<c[j-1].charAt(2)) {
                    String tmp = c[j];
                    c[j] = c[j-1];
                    c[j-1] = tmp;
                }   
            }
        }
    }
    */

    void mergeSort(String[] A, int l, int r) {

        if(l+1<r) {
            int m = (l+r)/2;
            mergeSort(A, l, m);
            mergeSort(A, m, r);
            merge(A, l, m, r);
        }

    }

    void merge(String[] A, int l, int m, int r) {
        
        int n1 = m-l;
        int n2 = r-m;

        String[] L = new String[n1+1];
        String[] R = new String[n2+1];

        for(int i=0; i<n1; i++) {
            L[i] = A[l+i];
        }

        for(int i=0; i<n2; i++) {
            R[i] = A[m+i];
        }

        L[n1] = R[n2] = "I 1000000001";

        int i = 0;
        int j = 0;

        for(int k=l; k<r; k++) {

            if(Integer.parseInt(L[i].substring(2))<=Integer.parseInt(R[j].substring(2))) {
                A[k] = L[i];
                i++;
            } else {
                A[k] = R[j];
                j++;
            }

        }

    }
    
    void show(String[] c, int n) {
        
        for(int i=0; i<n; i++) {
            System.out.println(c[i]);
        }

    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

}


Measured memory_bytes: 116680
N = int(input())
Data = []
for _ in range(N):
    Data.append(list(map(int,input().split())))

ctime = 0
cx = 0
cy = 0
ans = True

for i in range(N):
    nt,nx,ny = Data[i]
    dist = abs(nx-cx)+abs(ny-cy)
    dtime  = nt-ctime 

    if dist > dtime or (dtime-dist) % 2 == 1:
        ans = False
        break

    ctime = nt
    cx = nx
    cy = ny

if ans :
    print('Yes')
else:
    print('No')


Measured memory_bytes: 27324
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }

vector<int> G[100100];

vector<bool> used(100100, false);
vector<int> ans = {0};

void build() {
  int v = 0;
  while (1) {
    used[v] = true;
    bool f = true;
    for (int u: G[v]) {
      if (used[u]) continue;
      ans.push_back(u);
      v = u;
      f = false;
      break;
    }
    if (f) return;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  build();
  reverse(ans.begin(), ans.end());
  build();
  cout << ans.size() << '\n';
  rep(i, ans.size()) cout << ans[i] + 1 << (i == ans.size() - 1 ? '\n' : ' ');






  
  return 0;
}

Measured memory_bytes: 6904
#include<bits/stdc++.h>
using namespace std;
typedef struct{
    int pathL;
    int flag;
    vector<int> from;
    vector<int> to;
}POINT;
vector<POINT> point;
void dfs(int p){
    int t;
    point.at(p).flag=1;
    for(int i=0; i<point.at(p).to.size(); i++){
        t=point.at(p).to.at(i);
        if(point.at(t).flag==0){
            dfs(t);
        }
        point.at(p).pathL=max(point.at(p).pathL,point.at(t).pathL+1);
    }
}
int main(){
    int N,M,f,t;
    cin >> N >> M;
    point.resize(N);
    for(int i=0; i<N; i++){
        point.at(i).flag=0;
        point.at(i).pathL=0;
    }
    for(int i=0; i<M; i++){
        cin >> f >> t;
        point.at(f-1).to.push_back(t-1);
        point.at(t-1).from.push_back(f-1);
    }
    for(int i=0; i<N; i++){
        if(point.at(i).flag==0){
            dfs(i);
        }
    }
    int ans=0;
    for(int i=0; i<N; i++){
        //cout << point.at(i).pathL << " ";
        ans = max(ans,point.at(i).pathL);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 14720
#include <iostream>


int main() {
    int n, x, t;
    int i, time;

    std::cin >> n >> x >> t;
    i = n / x;
    if ((n%x) > 0) {
        i++;
    }
    time = i * t;
    std::cout << time << std::endl;

    return 0;
}

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

int main(){
    int N,K;
    vector<int> l;
    cin >> N >> K;
    REP(i,N){
        int input;
        cin >> input;
        l.push_back(input);
    }
    sort(l.begin(),l.end(),greater<int>());
    int sum = 0;
    REP(i,K) sum += l[i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <type_traits>
#include <limits>
#include <tuple>

template <class Tp>
class lines {
  // based on Li Chao tree
  std::map<Tp, size_t> enc;
  std::vector<Tp> dec;
  std::vector<std::pair<Tp, Tp>> c;
  size_t m = 1;
  Tp inf = std::numeric_limits<Tp>::max() / 8;

private:
  void init_resize(size_t n) {
    while (m < n+n) m <<= 1;
    c.assign(m, {0, inf});
  }

  void inspect() const {
    for (size_t i = 1; i < m; ++i) {
      std::string s = (c[i].first < inf? std::to_string(c[i].first) : "inf");
      std::string t = (c[i].second < inf? std::to_string(c[i].second) : "inf");
      fprintf(stderr, "(%s, %s)%c", s.c_str(), t.c_str(), (i&(i+1))? ' ':'\n');
    }
  }

public:
  template <class ForwardIt>
  lines(ForwardIt first, ForwardIt last): dec(first, last) {
    static_assert(std::is_same<typename ForwardIt::value_type, Tp>::value, "Type mismatch");
    std::sort(dec.begin(), dec.end());
    size_t n = dec.size();
    init_resize(n);
    // while (dec.size() < m/2) dec.push_back(dec.back()+1);
    dec.resize(m/2, dec.back());
    for (size_t i = 0; i < m/2; ++i) enc.emplace(dec[i], i);
  }

  void append(Tp a, Tp b) {
    size_t l = 0;
    size_t j = 1;
    size_t h = 1;
    size_t w = m/2;
    while (w > 0 && l+w-1 < dec.size()) {
      Tp xl = dec[l];
      Tp xm = dec[l+w/2];
      Tp xr = dec[l+w-1];

      Tp a0, b0;
      std::tie(a0, b0) = c[j];

      Tp yl0 = a0*xl + b0;
      Tp yr0 = a0*xr + b0;

      Tp yl = a*xl + b;
      Tp yr = a*xr + b;

      if (yl0 <= yl && yr0 <= yr) break;
      if (yl0 >= yl && yr0 >= yr) {
        c[j] = {a, b};
        break;
      }

      h <<= 1;
      w >>= 1;
      Tp ym0 = a0*xm + b0;
      Tp ym = a*xm + b;

      if (ym0 >= ym) {
        c[j] = {a, b};
        a = a0;
        b = b0;
        j <<= 1;
        if (yr0 < yr) {
          j |= 1;
          l += w;
        }
      } else {
        j <<= 1;
        if (yr0 >= yr) {
          j |= 1;
          l += w;
        }
      }
    }
  }

  Tp min_at(Tp x) const {
    size_t i = enc.at(x) + m/2;
    Tp y = inf;
    while (i > 0) {
      Tp a, b;
      std::tie(a, b) = c[i];
      y = std::min(y, a*x+b);
      i >>= 1;
    }
    return y;
  }
};

int main() {
  size_t N;
  intmax_t C;
  scanf("%zu %jd", &N, &C);

  std::vector<intmax_t> h(N);
  for (auto& hi: h) scanf("%jd", &hi);

  lines<intmax_t> cht(h.begin(), h.end());

  std::vector<intmax_t> dp(N);
  for (size_t i = 0; i+1 < N; ++i) {
    cht.append(-2*h[i], h[i]*h[i]+dp[i]);
    dp[i+1] = cht.min_at(h[i+1]) + h[i+1]*h[i+1] + C;
  }

  printf("%jd\n", dp[N-1]);
}


Measured memory_bytes: 26992
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  int K[N];
  int A[N][M];
  int count[M];
  for(int i=0;i<M;i++) count[i]=0;
  for(int i=0;i<N;i++){
    cin >> K[i];
    for(int j=0;j<K[i];j++){
      cin >> A[i][j];
      count[A[i][j]-1]++;
    }
  }
  int ans=0;
  for(int i=0;i<M;i++){
    if (count[i]==N) ans++;
  }
  cout << ans;
}


Measured memory_bytes: 3528
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
#include<cctype>
using namespace std;

int main() {
    string s;
    cin>>s;
    for(int bit=0; bit<(1<<3); bit++){
        int ans=s[0]-'0';
        for(int i=0; i<3; i++){
            if(bit&1<<i)ans+=s[i+1]-'0';
            if(!(bit&1<<i)) ans-=s[i+1]-'0';
        }
        if(ans==7){
            cout<<s[0];
            for(int i=0; i<3; i++){
                if(bit&1<<i)cout<<'+'<<s[i+1];
                if(!(bit&1<<i)) cout<<'-'<<s[i+1];
            }
            cout<<'='<<7<<endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[0].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int N; cin >> N;

    map<int, int> m;
    FOR(i, 1, N + 1){
        int i0 = i;
        FOR(r, 2, i + 1){
            while(i0 % r == 0){
                i0 /= r;
                m[r] += 1;
            }
        }
    }
    vec dp(76, 0);
    dp[75] = 1;
    for(auto p: m){
        vec dq(76, 0);
        FOR(i, 1, 76){
            FOR(j, 1, 76){
                if(i % j == 0 && j <= p.second + 1) dq[i / j] += dp[i];
            }
        }
        dp = dq;
    }
    cout << dp[1];
    
    return 0;
}

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>;

int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> p(n);
    rep(i, n) p[i] = k;
    rep(i, q)
    {
        int a;
        cin >> a;
        a--;
        p[a]++;
    }
    rep(i, n)
    {
        if (p[i] - q > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3760