akhauriyash/Code-Regression huggingface dataset:
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()



int main() {
	const ll mod = 1000000007;

	string S;
	cin >> S;
	ll N = S.size();

	ll dp[100001][4] = {0};
	dp[N][0] = dp[N][1] = dp[N][2] = 0, dp[N][3] = 1;
	ford(i, 0, N) {
		ford(j, 0, 3 + 1) {
			dp[i][j] = dp[i + 1][j] * (S[i] == '?' ? 3 : 1);
			if (j < 3 && (S[i] == '?' || S[i] == "ABC"[j])) {
				dp[i][j] += dp[i + 1][j + 1];
			}
			dp[i][j] %= mod;
		}
	}
	cout << dp[0][0] << endl;

}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int a,b;

int main(){
	cin>>a>>b;
	b=2*b+1;
	cout<<(a+b-1)/b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    string s = "hello world!", prev;
    int a = 0, b = n, c = n/2, prevc=0;
    cout << a << endl;
    cin >> prev;
    s = prev;
    while (s != "Vacant") {
        cout << c << endl;
        cin >> s;
        if ((prev == s) xor (a%2 == c%2)) {
            b = a;
            a = c;
        } else
            a = c;
        prevc = c;
        c = (a+b) / 2;
        prev = s;
    }
    return 0;
}

Measured memory_bytes: 852
#include<cstdio>
#include<algorithm>


using namespace std;
using ll=long long;


int deg_count(ll x)
{
	int ret=0;

	for(ret=0;x>0;x/=10,ret++)
		;
	return ret;
}


int main(void)
{
	ll n;

	while(scanf("%lld", &n)==1)
	{
		ll a, b;
		int ans=deg_count(n);

		for(a=2,b=n;a*a<=n;a++)
		{
			if(n%a==0)
			{
				b=n/a;
				ans=min(ans, deg_count(b));
			}
		}
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
	int a, b;
	char op;
	while (1) {
		scanf("%d %c %d", &a, &op, &b);
		if (op == '?')break;
		switch (op) {
		case '+':
			printf("%d\n", a + b);
			break;
		case '-':
			printf("%d\n", a - b);
			break;
		case '*':
			printf("%d\n", a * b);
			break;
		case '/':
			printf("%d\n", a / b);
			break;
		}
	}
}


Measured memory_bytes: 3212
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (X, Y, _, _, _) = read!(usize, usize, usize, usize, usize);
    let mut p = read![[i64]];
    let mut q = read![[i64]];
    let r = read![[i64]];

    p.sort();
    p.reverse();

    q.sort();
    q.reverse();

    let mut apples = p[..X]
        .iter()
        .chain(q[..Y].iter())
        .chain(r.iter())
        .cloned()
        .collect::<Vec<_>>();
    apples.sort();
    apples.reverse();

    let total = apples[..X + Y].iter().sum::<i64>();
    println!("{}", total)
}


Measured memory_bytes: 16772
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< string, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


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

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

ll A, B;
ll T, K;
int ans = 0;
vector< ll >p;

ll GCD( ll x, ll y ){
    if( y == 0 ) return x;
    return GCD( y, x%y );
}

int main(){
    
    cin>>A>>B;
    T = GCD( A, B );
    K = sqrt( T );
    
    FOR( i, 1, K+1 ){
        if( T % i == 0 ){
            p.push_back( i );
            if( i*i != T ) p.push_back( T/i );
        }
    }
    
    sort( p.begin(), p.end() );
    
    REP( i, p.size() ){
        bool flag = true;
        FOR( j, 1, i ){
            if( p[i]%p[j] == 0 ){
                flag = false;
                break;
            }
        }
        if( flag ) ans++;
    }
    
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main{

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

	private Scanner scan;
	private int n,k,min,max;
	private int[] W;

	private void mainrun() {
		scan = new Scanner(System.in);

		n = scan.nextInt();
		k = scan.nextInt();

		min = 0;
		max = Integer.MAX_VALUE;

		W = new int[n];

		for(int i = 0;i < n;i++) {
			int w = scan.nextInt();

			W[i] = w;
			min = Math.max(min, w - 1);
		}

		max -= min;
		
		while(true) {
			if(max > min + 1) {
				int mid = ( max + min ) / 2;

				int K = k - 1;
				int state = 0;

				for(int w : W) {
					if(state + w > mid) {
						state = w;
						K--;
					}else {
						state += w;
					}
				}
				if(K >= 0) {
					max = mid;
				}else {
					min = mid;
				}
			}else{
				System.out.println(min + 1);
				break;
			}
		}

	}
}


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

const int INF = 1 << 28;

int num[100];
int in[100];
int out[100];
int Time[100];

int pos[100];

int res[100];

int main()
{
	for (int i = 0; i < 100; i++){
		num[i] = (i % 5 == 1) ? 5 : 2;
		in[i] = i * 5;
		out[i] = INF;
		Time[i] = 17 * (i % 2) + 3 * (i % 3) + 19;
 	}
	
	int seat = 0;
	int cnt = 0;
	int t = 0;
	queue<int> que;
	while (cnt < 100){
		for (int i = 0; i < 100; i++){
			if (out[i] == t){
				int x = (1 << num[i]) - 1;
				x <<= pos[i];
				seat -= x;
				cnt++;
				//printf("%d out %d\n", t, i);
			}
		}
		
		for (int i = 0; i < 100; i++){
			if (in[i] == t){
				que.push(i);
				//printf("%d in %d\n", t, i);
			}
		}
		
		while (que.size()){
			int p = que.front();
			bool f = false;
			for (int i = 0; i < 18 - num[p]; i++){
				int x = (1 << num[p]) - 1;
				x <<= i;
				if (seat & x) continue;
				seat += x;
				pos[p] = i;
				out[p] = t + Time[p];
				res[p] = t - in[p];
				que.pop();
				f = true;
				break;
			}
			if (!f) break;
		}
		t++;
	}
	
	int n;
	while (~scanf("%d", &n)){
		printf("%d\n", res[n]);
	}
}

Measured memory_bytes: 1188
import bisect
import sys,io
import math
from collections import deque
from heapq import heappush, heappop

input = sys.stdin.buffer.readline

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7
#DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    N,X,T = isRaw()
    print(((N+X-1)//X) *T)

main()


Measured memory_bytes: 66208
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

int main(){
	int n;
	cin>>n;
	vector<int> d(n);
	rep(i,n) cin>>d[i];
	ll ans = 0;
	for(int i = 0; i < n-1; i++){
		for(int j = i + 1; j < n; j++){
			ans += d[i] * d[j];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;




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

	int a, b, c, d, ans;
	cin >> a >> b >> c >> d;
	ans = min(a, b) + min(c, d);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

//istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
//ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int r[100100], q[100100];
int cnt[100100];

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> X(N);
	rep(i,N) {
		cin >> X[i];
		cnt[X[i]]++;
	}
	rep(i,100100) {
		r[i%M] += cnt[i]%2;
		q[i%M] += cnt[i]/2;
	}
	int res = 0;
	for(int i = 1; ; i++) {
		int j = M-i;
		if(i >= j) break;
		int qa, qb, ra, rb;
		if(r[i] < r[j]) {
			ra = r[i];
			rb = r[j];
			qa = q[i];
			qb = q[j];
		}
		else {
			ra = r[j];
			rb = r[i];
			qa = q[j];
			qb = q[i];
		}
		// a < b
		res += ra;
		rb -= ra;
		ra = 0;
		res += min(rb, qa*2);
		qa = max(0, (qa*2 - rb)/2);
		res += qa;
		res += qb;
	}
	if(M % 2 == 0) {
		res += q[M/2];
		res += r[M/2]/2;
	}
	res += (q[0]*2+r[0])/2;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1792
import Control.Monad
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Data.Char (isSpace)
import Data.List

main = do
  n <- readLn :: IO Int
  as <- VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine 
  let bucket = makeBuckets as n
  let (a,b) = solve bucket 1 (0,0)
  putStrLn $ show a ++ " " ++ show b

solve :: VU.Vector Int -> Int -> (Int,Int) -> (Int,Int)
solve vec n (a,b) 
  | n == 9 = if a == 0 && b == 0 then (1,b+s') else (a,b+s')
  | otherwise = solve (VU.drop 400 vec) (n+1) (a+k,b+k)
    where 
      s = VU.sum $ VU.take 400 vec
      s' = VU.sum vec
      k = if s > 0 then 1 else 0

makeBuckets :: VU.Vector Int -> Int -> VU.Vector Int
makeBuckets xs n =
  VU.create $ do
    buckets <- VUM.replicate 4801 (0::Int)
    forM_ [0..n-1] $ \i -> do
      let rate = xs VU.! i
      v <- VUM.read buckets rate
      VUM.write buckets rate (v+1)
    return buckets

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
struct state{

  int step;
  int x;
  int y;

};

int n;
vector<pair<int, int> > v;
int sx, sy;
int xkeokeo[12] = {0, 1, -1, 0, -1, 1, 2, 2, 2, -2, -2, -2};
int ykeokeo[12] = {2, 2, 2, -2, -2, -2, 0, 1, -1, 0, 1, -1}; 
int xsprnc[9] = {0, 0, 1, 1, 1, -1, -1, -1, 0};
int ysprnc[9] = {1, -1, 0, 1, -1, 0, 1, -1, 0};
int d[11][11][11];
queue<state> quuu;
int x, y;
bool flag;



void wide(){

  quuu.push((state){0,x,y});
  d[0][x][y] = 1;

  while(!quuu.empty()){

    state st = quuu.front();
    quuu.pop();
    x = st.x;
    y = st.y;
    // cout << x << " " << y << " " << st.step <<endl;
    for(int i = 0; i < 12; i++){
      int nxk = x + xkeokeo[i], nyk = y + ykeokeo[i];
      for(int j = 0; j < 9; j++){
	int nsx = v[st.step].first + xsprnc[j], nsy = v[st.step].second + ysprnc[j];

	if(nxk == nsx && nyk == nsy && nxk >= 0 && nyk >= 0 && nxk < 10 && nyk < 10){
	  if(d[st.step+1][nxk][nyk] == 0){
	  quuu.push((state){st.step+1,nxk,nyk});
	  d[st.step+1][nxk][nyk] = 1;

	  }
	}

      }
    }


  }
  flag = false;  
  for(int i = 0; i < 11; i++){
    for(int j = 0; j < 11; j++){
      if(d[n][i][j] == 1){
	flag = true;
	  break;
      }
    }
    
  }
  if(flag == true) cout << "OK" << endl;
  else cout << "NA" << endl;

  v.clear();
  memset(d,0,sizeof(d));
}


int main(){

 
  while(cin >> x >> y && (x || y)){

    cin >> n;
    // v.push_back(make_pair(x, y));
    for(int i = 1; i <= n; i++){
      cin >> sx >> sy;
      v.push_back(make_pair(sx, sy));
    }

    wide();

  }


}

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

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


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

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

string s;
int w;

int main(){
  cin>>s>>w;
  int i=0;
  while(i<s.size()){
    cout<<s[i];
    i+=w;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, a, b int
	fmt.Fscan(r, &n)
	fmt.Fscan(r, &a)
	fmt.Fscan(r, &b)

	//偶奇？

	diff := b - a
	if diff%2 == 0 {
		fmt.Println(diff / 2)
	} else {
		mna := abs(a - 1)
		mnb := abs(n - b)
		if mna < mnb {
			tmp := mna + 1
			fmt.Println(tmp + (b-tmp-1)/2)
		} else {
			tmp := mnb + 1
			fmt.Println(tmp + (n-(a+mnb))/2)
		}
	}
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
    int a,b,c[15],d[15],i,f;
	scanf("%d",&a);
	while(a!=0){
	    f=0;
	    scanf("%d",&b);
	    for(i=0;i<b;i++){
		    scanf("%d %d",&c[i],&d[i]);
		}
		for(i=0;i<b;i++){
		    f=f+(d[i]-c[i]);
		}
		if(f>=a) printf("OK\n");
		else if(f<a) printf("%d\n",a-f);
		scanf("%d",&a);
	}
	return 0;
}

Measured memory_bytes: 2708
#include<bits/stdc++.h>
        using namespace std;
        long long m=1000000007;
     
        #define boost ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        #define MAX(a,b) ((a)>(b)?(a):(b))
        #define MIN(a,b) ((a)<(b)?(a):(b))
        #define pb  push_back
        #define p2  second
        #define p1  first
        typedef long long ll;
        typedef long double ld; 
        long long M=1e9+7;			
        #define deb_(x)       cerr<< #x <<" : "<< x << endl;
        #define deb(A,N)    cerr <<" :[";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
        #define deb2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}																				
        #define rep(n) for(int i=0;i<n;i++)																		
        #define range(a,b) for(int i=a;i<=b;i++)																	
        #define loop(i,n) for(int i=0;i<n;i++)
    	void code();
     	ll dp[105][100005];
        int main()
        {   
        	boost;
           ll t=1;
           // cin>>t;
           while(t--){
           	code();
           }
         
           return 0;
        }
     
       
        void code(){
        	ll n,W;
        	cin>>n>>W;
        	ll A[n],wt[n];
        	rep(n){
        		cin>>A[i]>>wt[i];
        	}

        	loop(i,n){
        		loop(j,W){
        			if(A[i]>j+1){
        				dp[i+1][j+1]=dp[i][j+1];
        			}
        			else
        			    dp[i+1][j+1]=MAX(dp[i][j+1],dp[i][j-A[i]+1]+wt[i]);
        		}
        	}
        	// deb2(dp,n+1,W+1);
        	cout<<dp[n][W];
       	
        }

Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll x;
int main()
{
  cin>>x;
  for(ll i=-120;i<=120;i++)
    for(ll j=-120;j<=120;j++)
	{
		if(i*i*i*i*i-j*j*j*j*j==x)
		{
			 cout<<i<<" "<<j;
			 return 0;
		}
	 } 


return 0;
}


Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define all(c) begin(c),end(c)
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using vi = vector<int>; using vs = vector<string>;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	int x, y, s;
	while (cin >> x >> y >> s, x)
	{
		int m = 0;
		for (int i = 1; i < s; i++) {
			for (int j = 1; j < s; j++) {
				double tr = 1 + (double)x / 100;
				double sr = 1 + (double)y / 100;
				int sum = (int)(i * (100 + x) / 100) + (int)(j * (100 + x) / 100);
				if (sum == s)
				{
					//cout << i << " " << j << " " << sum;
					sum = (int)(i * (100 + y) / 100) + (int)(j * (100 + y) / 100);
					//cout << " " << sum << endl;
					m = max(m, sum);
				}

			}
		}
		cout << m << endl;
	}
}

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


Measured memory_bytes: 3128
'use strict';
function main(input) {
    var args = input.split('\n')[1].split(' ').map((n) => parseInt(n, 10));
	var sorted = args.sort((a,b)=>a-b).reverse()
    let alice = 0
    let bob = 0
    sorted.forEach((a,i)=>{
      if(i%2 === 0) {
        alice += a
      }else{
        bob+=a
      }
    })
  	console.log(alice-bob)
  	
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11468
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0;i < n;i++)cin >> a[i];
    vector<bool> priyes(1000);
    for(int i = 2;i < 1000;i++){
        bool nowprime = true;
        for(int j = 2;j < i;j++){
            if(i % j == 0)nowprime = false;
        }
        if(nowprime)priyes[i] = true;
    }
    vector<ll> prime;
    for(int i = 0;i < 1000;i++){
        if(priyes[i])prime.push_back(i);
    }

    ll allgcd = a[0];
    for(int i = 1;i < n;i++){
        allgcd = __gcd(a[i],allgcd);
    }

    map<ll,ll> insuu;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < (int)prime.size();j++){
            if(a[i] % prime[j] == 0){
                insuu[prime[j]]++;
                while(a[i] % prime[j] == 0)a[i] /= prime[j];
            }
        }
        if(a[i] > 1)insuu[a[i]]++;
    }
    bool pairone = true;
    for(auto i:insuu){
        if(i.second > 1)pairone = false;
      //cout << i.first << " " << i.second << endl;
    }
  //cout << prime[0] << " " << prime[1] << " " << prime[2] << endl;

    if(pairone){
        cout << "pairwise coprime" << endl;
    }
    else if(allgcd == 1){
        cout << "setwise coprime" << endl;
    }
    else{
        cout << "not coprime" << endl;
    }
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;


signed main() {
    int N, R;
    cin >> N >> R;
    if (N >= 10) {
        cout << R << endl;
    } else {
        cout << R + 100 * (10 - N) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long ans = 0;
 
    //Search for all i
    for (int i = 0; i < N; i++)
    {
        //Update the values of A[i+1] ... A[N]
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 3980
#include<stdio.h>
#include<iostream>
using namespace std;


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

    int b[100];
    int a = 0;

    for(int i = 0; i < n; i++) {
        cin >> b[i+1];
        if(i == n-1) {
            b[i+1] = 100000000;
        }
    }

    for(int i = 0; i < n; i++) {
        if(i == 0){
            a += b[i+1];
        } else {
            if(b[i] <= b[i+1]) {
                a += b[i];
            } else {
                a += b[i+1];
            }
        }
    }

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


Measured memory_bytes: 256
import sys
import numpy as np
import itertools as it

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

n = I()
F, P = [], []
for _ in range(n):
    F.append(LI())

for _ in range(n):
    P.append(LI())

F = np.array(F)

b = (0, 1)
b10 = (b,)*10
iter_ = it.product(*b10)

Fdotx = [F.dot(x) for x in iter_][1:]

print(max([sum([P[i][val] for i, val in enumerate(row)]) for row in Fdotx]))

Measured memory_bytes: 22292
N = input()
if N[-1] == "2" or N[-1] == "4" or N[-1] == "5" or N[-1] == "7" or N[-1] == "9":
    print("hon")
elif N[-1] == "0" or N[-1] == "1" or N[-1] == "6" or N[-1] == "8":
    print("pon")
elif N[-1] == "3":
    print("bon")


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

using namespace std;


bool sortbysec(const tuple<string,int,int> &x,const tuple<string,int,int> &y)
{
  return get<0>( x ) == get<0>( y ) ? get<1>( x ) < get<1>( y ) : get<0>( x ) > get<0>( y );
}

int main()
{
  int n;
  cin >> n;
  vector<tuple<string,int,int>> a;
  vector<string> s(n);
  vector<int> num(n);
  for(int i=0;i<n;i++)
  {
    cin >> s.at(i) >> num.at(i);
  }
  for(int i=0;i<n;i++)
  {
    a.push_back(make_tuple(s.at(i),num.at(i),i+1));
  }
  
  sort(a.begin(),a.end(),sortbysec);
  reverse(a.begin(),a.end());
  for(tuple<string,int,int> t:a){
    string x;
    int y,z;
    tie(x,y,z)=t;
    cout << z << endl;
    //cout << x << " " << y << " " << z << endl;
  }
  
  
  
  
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから

void solve(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int ans=1e9;
  rep(i,n){
    int cnt=0;
    while(a[i]%2==0){
      a[i]/=2;
      ++cnt;
    }
    chmin(ans,cnt);
  }
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
/*
 * Aizu Online Judge
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 *
 * @author yoshkur
 */
public class Main {

	/**
	 * @param args the command line arguments
	 */
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			InputData inputData = new InputData();
			inputData.setDataFromLines(br);
			inputData.setValues();
			Processing processing = new Processing(inputData);
			System.out.println(processing.getResult());

		} catch (IOException | NumberFormatException e) {
			System.err.println(e.getLocalizedMessage());
		}
	}
}

class InputData {

	public static final String SEPARATOR = " ";

	private List<String> rows = new ArrayList<>();
	private String row;

	public InputData() {
	}

	public void setDataFromLine(BufferedReader br) throws IOException {
		this.row = br.readLine().trim();
	}

	public void setDataFromLines(BufferedReader br) throws IOException {
		String line;
		while ((line = br.readLine()) != null) {
			this.rows.add(line.trim());
		}
	}

	public void setValues() {

	}

	public List<String> getRows() {
		return rows;
	}

	public void setRows(List<String> rows) {
		this.rows = rows;
	}

}

class Processing {

	private static final String RETCODE = System.getProperty("line.separator");

	private InputData inputData;

	public Processing(InputData inputData) {
		this.inputData = inputData;
	}

	public String getResult() {
		String result = null;
		StringBuilder sb = new StringBuilder();
		for (String str : this.inputData.getRows()) {
			String[] values = str.split(InputData.SEPARATOR);
			Integer num0 = Integer.valueOf(values[0]);
			Integer num1 = Integer.valueOf(values[1]);
			if (num0 == 0 && num1 == 0) {
				break;
			}
			if (num0 > num1) {
				Integer temp = num0;
				num0 = num1;
				num1 = temp;
			}
			
			sb.append(num0);
			sb.append(InputData.SEPARATOR);
			sb.append(num1);
			sb.append(RETCODE);
		}
		result = sb.toString().trim();
		return result;
	}
}

Measured memory_bytes: 26668
import Data.Bool
import Data.Vector.Generic ((!))
import qualified Data.Vector as V

main = interact $ sol . lines

sol as = bool "No" "Yes" $ bingo v
  where
  v = V.fromList $ V.fromList . fmap (`elem` bs) . words <$> take 3 as
  bs = words . unwords $ drop 4 as

bingo v = V.any V.and v
  || any (\j -> V.all (!j) v) [0..2]
  || all (\i -> v!i!i) [0..2]
  || all (\i -> v!i!(2-i)) [0..2]

Measured memory_bytes: 508
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

bool judge(string sleft, string sright, int l, int r)
{
  if (sleft == sright)
    return (r - l) % 2 == 1;
  else
    return (r - l) % 2 == 0;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  string sleft, sright;
  int left = 0, right = N / 2;
  cout << left << endl;
  cin >> sleft;
  if (sleft == "Vacant")
    return 0;
  cout << right << endl;
  cin >> sright;
  if (sright == "Vacant")
    return 0;
  if (!judge(sleft, sright, left, right))
  {
    swap(sleft, sright), left = right, right = N;
  }
  string str;
  while (right - left > 1)
  {
    int mid = (left + right) / 2;
    cout << mid << endl;
    cin >> str;
    if (str == "Vacant")
      return 0;
    if (judge(sleft, str, left, mid))
      sright = str, right = mid;
    else
      sleft = str, left = mid;
  }
  return 0;
}

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

int main(){
  int n,h[100000],dp[100000];
  
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  
  for(int i=2;i<n;i++){
    dp[i] = min( dp[i-2] + abs(h[i]-h[i-2]),
                 dp[i-1] + abs(h[i]-h[i-1]));
  }
  
  cout << dp[n-1] << endl;
  
  return 0;
}

Measured memory_bytes: 1024
//B-Great Ocean View

#include <iostream>
using namespace std;

int main(void){
    int N;
    cin >> N;
    int H[N];
    int CanView=1;
    
    for(int i=0;i<N;++i){
        cin >> H[i];
    }
    
    for(int i=1;i<N;++i){
        int Point=H[i];
        bool Flag=true;
        for(int j=i;j>=0;--j){
            if(Point<H[j]){
                Flag=false;
                break;
            }
        }
        if(Flag){
            CanView++;
        } 
    }
    cout << CanView << endl;
    return 0;
}

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

int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test=1;
// 	cin>>test;	
	while(test--)
	{
	    long a,b=0,c=0,k,i,n,j,temp,mini,maxi,ans,q,sum,x,y,count=0,next,prev;
	    cin>>a>>b>>n;
	    int arr[n];
	    cout<<(a+b)*n/2;
	    
	
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N; cin >> N;
  if(N==1){
    cout << 1 << endl;
    return 0;
  }
  vector<string> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  int count=1;
  for(int i=N-2;i>=0;i--){
    if(A[i]!=A[i+1]){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
      

Measured memory_bytes: 9544
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int main(){
    int n; cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    vector<ll> cnt(5);
    rep(i,n){
        string c = s[i];
        if(c[0] == 'M') cnt[0]++;
        if(c[0] == 'A') cnt[1]++;
        if(c[0] == 'R') cnt[2]++; 
        if(c[0] == 'C') cnt[3]++;
        if(c[0] == 'H') cnt[4]++;
    }
    int p[10] = {0,0,0,0,0,0,1,1,1,2};
    int q[10] = {1,1,1,2,2,3,2,2,3,3};
    int r[10] = {2,3,4,3,4,4,3,4,4,4};
    ll ans = 0;
    rep(i,10){
        ans += cnt[p[i]] * cnt[q[i]] * cnt[r[i]];
    }
    cout << ans << endl;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << min(A, B) + min (C, D) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;

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

	int N, K;
	cin >> N >> K;
	vector<int> a(N);
	for (int i = 0; i < N; i++)
		cin >> a[i];
	vector<int> dp(N, INF);
	dp[0] = 0;
	for (int i = 0; i < N; i++)
		for (int j = i + 1; j <= i + K; j++)
			if (j < N)
				dp[j] = min(dp[j], dp[i] + abs(a[j] - a[i]));
	cout << dp[N - 1] << endl;

}

Measured memory_bytes: 4004
#include<cstdio>

bool include3(int x){
	if(x % 10 == 3){
		return true;
	}else{
		x /= 10;
		if(x){
			return include3(x);
		}
		return false;
	}
}

bool judge(int x){
	if(!(x % 3)){
		return true;
	}else{
		return include3(x);
	}
}

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		if(judge(i)){
			printf(" %d", i);
		}
	}
	printf("\n");
}

Measured memory_bytes: 1028
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <deque>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 1000000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,N);
  IN(ll,M);
  ll L = 0;
  ll R = INF;
  REP(i,M){
    ll x, y;
    cin >> x >> y;
    chmax(L,x);
    chmin(R,y);
  }
  if(L <= R){
    OUT(R-L+1);
  }else{
    OUT(0);
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long D = sc.nextLong();

        long lcm = C * D / gcd(Math.max(C, D), Math.min(C, D));
        long c = B / C - (A - 1) / C;
        long d = B / D - (A - 1) / D;
        long e = B / lcm - (A - 1) / lcm;
        long ans = B - A + 1 - c - d + e; 
        System.out.println(ans);
    }
    public static long gcd(long max, long min){
        if(max%min==0){
            return min;
        }
        min = gcd(min, max % min);
        return min;
    }
}

Measured memory_bytes: 23508
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N, A;
    cin >> N >> A;

    cout << N*N - A << endl;

}

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

#define MAXV 100000
#define INF 200000
typedef vector<int> vi;
vector< vi > adj(MAXV, vi());;
vi visited(MAXV,0);
int dp[MAXV+1];
int n, m;

void dfs_visit(int u) {
  visited[u]=1;
  for (int v : adj[u]) {
    if (!visited[v]) { 
      dfs_visit(v);
    }
    dp[u]=max(dp[u],1+dp[v]);
  }
}

int main() {
  int x,y,i, respuesta;
  scanf("%d %d",&n,&m);
  for (i = 0; i < m; i++) {
    scanf("%d %d",&x,&y);
    adj[x - 1].push_back(y - 1);
    
  }
  for (i=0; i<n; i++) {
  	if (!visited[i]) {
  		dfs_visit(i);
  	}
  }
  for (respuesta=i=0; i<n; i++) {
  	respuesta=max(respuesta,dp[i]);
  }

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

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


int main() {
	int N,R;
	cin>>N>>R;

	if(N>10){
		cout<<R<<endl;
	}
	else{
		cout<<R+((100)*(10-N))<<endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char s[4],s2[4];
    int i,count=0;
        scanf("%s",s);
        scanf("%s",s2);
        toupper(s);
        toupper(s2);

    for(i=0;i<3;i++){
        if(s[i]==s2[i])
            count++;
    }
    printf("%d\n",count);
    return 0;
}



Measured memory_bytes: 128
N = int(input())
S = input()
cnt = 0
alpha = []
ans = []

for i in range(1, N):
    alpha = []
    cnt = 0
    X = S[:i]
    Y = S[i:]
    for j in X:
        if j in alpha: continue
        if Y.count(j) > 0:
            cnt += 1
            alpha.append(j)

    ans.append(cnt)

print(max(ans))

Measured memory_bytes: 9156
import collections

n = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))
a_L = []
max_num = 0

for _ in range(n):
    s = input()
    a_L.append(s)

c = collections.Counter(a_L)

# for k,v in c:
#     print(k,v)
c = sorted(c.items(),key=lambda x: x[1],reverse=True)

max_num = c[0][1]

c = sorted(c,key=lambda x:x[0])
for k,v in c:
    if v == max_num:
        print(k)

Measured memory_bytes: 115180
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
A=Counter(A).most_common()
A.sort(key=lambda x:x[0])
flag=1
if len(A)==3:
    for i in range(2):
        if A[i][1]==A[i+1][1]:
            continue
        else:
            flag=0
    for i in range(2):
        if i==0 :
            if A[i][0]==(A[i+1][0]^A[-1][0]):
                continue
            else:
                flag=0
        elif i==2:
            if A[i][0]==(A[i-1][0]^A[0][0]):
                continue
            else:
                flag=0
        else:
            if A[i][0]==(A[i-1][0]^A[i+1][0]):
                continue
            else:
                flag=0
    if flag==1:
        print("Yes")
    else:
        print("No")
else:
    if A[0][0]==0:
        if len(A)==1 or (len(A)==2 and A[0][1]==A[1][1]//2):
            print("Yes")
        else:
            print("No")
    else:
        print("No")


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

int main(){
  int h,w;
  cin>>h>>w;
  vector<std::string> masu(h);
  for(int i=0;i<h;i++){
    cin>>masu.at(i);
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(masu.at(i).at(j)=='.'){
        int bomb=0;
        std::string ch;
        if(i!=0){
          if(masu.at(i-1).at(j)=='#'){
            bomb++;
          }
        }
        if(i!=h-1){
          if(masu.at(i+1).at(j)=='#'){
            bomb++;
          }
        }
        if(j!=0){
          if(masu.at(i).at(j-1)=='#'){
            bomb++;
          }
        }
        if(j!=w-1){
          if(masu.at(i).at(j+1)=='#'){
            bomb++;
          }
        }
        if(i!=0&&j!=0){
          if(masu.at(i-1).at(j-1)=='#'){
            bomb++;
          }
        }
        if(i!=0&&j!=w-1){
          if(masu.at(i-1).at(j+1)=='#'){
            bomb++;
          }
        }
        if(i!=h-1&&j!=0){
          if(masu.at(i+1).at(j-1)=='#'){
            bomb++;
          }
        }
        if(i!=h-1&&j!=w-1){
          if(masu.at(i+1).at(j+1)=='#'){
            bomb++;
          }
        }
        std::string x=std::to_string(bomb);
        masu.at(i).at(j)=x.at(0);
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout<<masu.at(i).at(j);
      if(j==w-1){
        cout<<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<vector>

using namespace std;

typedef pair<int, int> i_i;

#define rep(i, n) for(i = 0;i < n;++i)
#define int(x) int x; scanf("%d",&x)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second

struct rsqsegtree{
  vector<int> t;
  int re;
  int n;
  void use(int N){
    re = 0; n = N;
    int i, j;
    for(i = 0;;++i)if((1 << i) >= n)break;
    ++i; t.resize(1 << i); t[0] = 1 << i;
    for(i = 1;i < t[0];++i)t[i] = re;
    t[0] >>= 1;
    return;
  }
  void update(int at, int data){
    t[t[0] + at] += data;
    int tmp;
    for(int x = t[0] + at;x >= 2;x >>= 1)
    t[x >> 1] = (t[(x >> 1) << 1] + t[((x >> 1) << 1) + 1]);
    return;
  }
  int query(int l, int r, int k, int kl, int kr){
    if(k >= t.size())return re;
    if(kl >= r || kr <= l)return re;
    if(l <= kl && kr <= r)return t[k];
    return query(l, r, k * 2, kl, (kl + kr) >> 1) + query(l, r, k * 2 + 1, (kl + kr) >> 1, kr);
  }
  int getsum(int l, int r){ return query(l, r, 1, 0, t[0]); }
  void deb(void){
    int x = 1;
    t[0] *= 2;
    printf("t[0] : %d\n", t[0]);
    for(int i = 1;i < t[0];++i){
      printf("%11d", t[i]);
      if(i == (1 << x) - 1){ puts(""); ++x; }
    }
    t[0] /= 2;
    return;
  }
};

struct query{
  int q, y, l, r;
};
bool ysort(query qwe, query rty){
  if(qwe.y != rty.y)return qwe.y < rty.y;
  return qwe.q > rty.q;
}

rsqsegtree ST;
query Q[300000];
vector<int> x;
int qh = 0;

int inv(int d){
  int l = 0, r = x.size(), m;
  for(;l + 1 < r;){
    m = l + (r - l) / 2;
    if(d == x[m])return m;
    if(d > x[m])l = m;
    else r = m;
  }
  return l;
}

signed main(void){
  int i, j;
  int(n);
  rep(i, n){
    int4(x1, y1, x2, y2);
    if(x1 == x2){
      Q[qh++] = (query){1, min(y1, y2), x1, 0};
      Q[qh++] = (query){-1, max(y1, y2), x1, 0};
      x.pb(x1);
    }else{
      Q[qh++] = (query){0, y1, min(x1, x2), max(x1, x2)};
      x.pb(x1);
      x.pb(x2);
    }
  }
  sort(Q, Q + qh, ysort);
  sort(all(x));
  x.erase(unique(all(x)), x.end());

  ST.use(x.size());
  int res = 0;
  rep(i, qh){
    if(Q[i].q == 0){
      //printf("%d : %d : %d %d\n", i, Q[i].y, Q[i].l, inv(Q[i].l));
      //printf("%d : %d : %d %d\n", i, Q[i].y, Q[i].r, inv(Q[i].r));
      res += ST.getsum(inv(Q[i].l), inv(Q[i].r) + 1);
    }else{
      ST.update(inv(Q[i].l), Q[i].q);
    }
  }
  printf("%d\n", res);

  return 0;
}

Measured memory_bytes: 6408
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

using namespace std;

/**
 * amazingly fast input
 */
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
  if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
  return *ci++;
}
inline int getint() {
  int A = 0;
  if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
  else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
  return A;
}
inline void flus() {
  while (getcha() != ' ');
}

/**
 * main
 */
int main () {
  double A = getint();
  double B = getint();
  double C = getint();
  double X = getint();

  int ans = 0;
  int a_max = min(floor(X / 500), A);
  for (int a = 0; a <= a_max; a++) {
    int b_min = max( ceil(X / 100 - 5 * a - C / 2), 0.0);
    int b_max = min(floor(X / 100 - 5 * a), B);
    ans += (b_max >= b_min) ? b_max - b_min + 1 : 0;
  }

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


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args){
		// input
		//  A V
		//  B W
		//  T
		Scanner inData = new Scanner(System.in);
		StringTokenizer line1 = new StringTokenizer(inData.nextLine());
		long a = Long.parseLong(line1.nextToken());
		long v = Long.parseLong(line1.nextToken());
		StringTokenizer line2 = new StringTokenizer(inData.nextLine());
		long b = Long.parseLong(line2.nextToken());
		long w = Long.parseLong(line2.nextToken());
		long t = Long.parseLong(inData.nextLine());

		if (v <= w) {
			System.out.println("NO");
		}else {
			if (Math.abs((b-a)) <=  t*(v-w)) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
		inData.close();
	}
}


Measured memory_bytes: 27000