akhauriyash/Code-Regression huggingface dataset:
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, M = get_ints

nx = (N * (N-1)) / 2
mx = (M * (M-1)) / 2

puts nx + mx


Measured memory_bytes: 14272
#include<bits/stdc++.h>
    #include<vector>
    #include<queue>
#include<string>
#include<cmath>
    using namespace std;
  
   
    int main()
    {
    		ios_base::sync_with_stdio(false);
            cin.tie(NULL);
            cout.tie(NULL);
            char ch;
            cin>>ch;
            if((int)ch>=65 && (int)ch<=90 )
              cout<<"A";
            else
              cout<<"a";
            
            
            
           return 0;
            

    }

    			

Measured memory_bytes: 3648
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner date = new Scanner(System.in);

		int a, b;
		
		while (date.hasNextInt()) {
			a = date.nextInt();
			b = date.nextInt();
			int sum = a + b;
			System.out.println(String.valueOf(sum).length());
		}
		
	
	}

}

Measured memory_bytes: 20560
#include<iostream>
#include<map>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<climits>
#include<cstring>
#include<iomanip>

using namespace std;

int main(void) {
    int a,b,c;cin>>a>>b>>c;
    if(b/a>=c){cout<<c<<endl;}
    else{cout<<b/a<<endl;}
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var S = ReadLine().Select(c => c - '0').ToArray();

        var ans = S.Zip(S[1..], (s1, s2) => (s1, s2)).Zip(S[2..], (s12, s3) => s12.s1 * 100 + s12.s2 * 10 + s3).Select(x => Math.Abs(753 - x)).Min();

        WriteLine(ans);
    }
}


Measured memory_bytes: 26752
N=int(input())
data=[int(input()) for i in range(N)]
count=0
dic={}
for i in data:

    if i-1 in dic:
        num=dic.pop(i-1)
        dic.update({i:num+1})
    else:
        dic.update({i:1})
print(N-max([dic[i] for i in dic]))


Measured memory_bytes: 92504
import heapq

# print('input >>')
X, Y, A, B, C = map(int,(input().split()))
ps = list(map(int,(input().split())))
qs = list(map(int,(input().split())))
rs = list(map(lambda x:int(x)*-1,(input().split())))

ps.sort()
qs.sort()
rs.sort()

ps = ps[-X:]
qs = qs[-Y:]

heapq.heapify(ps)
heapq.heapify(qs)
heapq.heapify(rs)

while True:
    if len(rs) == 0:
        break
    max_r = heapq.heappop(rs)
    min_p = heapq.heappop(ps)
    min_q = heapq.heappop(qs)

    min_pq = min(min_p, min_q)

    if max_r*-1 > min_pq:
        if min_p < min_q:
            heapq.heappush(ps, max_r*-1)
            heapq.heappush(qs, min_q)
        else:
            heapq.heappush(qs, max_r*-1)
            heapq.heappush(ps, min_p)
    else:
        heapq.heappush(qs, min_q)
        heapq.heappush(ps, min_p)
        break

# print('-----output-----')
print(sum(ps) + sum(qs))

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

int main()
{
  ll x, k, d;
  cin >> x >> k >> d;
  
  
  int isPlus;
  ll cnt = 0;
  ll ans = 0;
  
  bool isEven;
  bool isOver;
  
  ll korn = k;
  
  
  
  //xを正で考える。
  if(x > 0) isPlus = 1;
  else
  { 
    x *= -1;
    isPlus = -1;
  }
  
  cnt = x / d;
  
  if(x % d < -(x%d)+d)
  {
    k -= cnt;
    isOver = false;
  }
  else
  {
    k -= (cnt+1);
    isOver = true;
  }
  
  if(k < 0)
  {
    cout << abs(isPlus * (x-d*korn));
    return 0;
  }
  
  if(k%2 == 0) isEven = true;
  else isEven = false;
  
  if(isOver && isEven) ans = isPlus*(x - (cnt+1)*d);
  else if(isOver && !isEven) ans = isPlus*(x-cnt*d);
  else if(!isOver && isEven) ans = isPlus*(x-cnt*d);
  else ans = isPlus * (x-(cnt+1)*d);
  
  cout << abs(ans);  
  
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <utility>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
using ll = long long;
using VI = vector<int>;


int main() {
    string s;
    cin >> s;
    string t;
    cin >> t;
    bool flag = true;
    for (int i = 0; i < t.size()-1; i++) {
        if (s[i] != t[i]) flag = false;
    }
    if (flag) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(){
	int a,b,c,d;

	scanf("%d %d %d %d",&a,&b,&c,&d);
	
	while(a>0 || c>0){
		c = c - b;
//		printf("c=%d \t",c);
		
		if(c<=0){
			printf("Yes");
			break;
		}
		
		a = a - d;
//		printf("a=%d \t",a);
		
		if(a<=0){
			printf("No");
			break;
		}
	}
	
	return 0;
}


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

int main(){
    int d,n;
    cin>>d>>n;
    if(d==0){
        if(n!=100){
            cout << n << endl;
        }else{
            cout << 101 <<endl;
        }
    }else if(d==1){
        if(n!=100){
            cout << 100 * n << endl;
        }else{
            cout << 10100 << endl; 
        }
    }else{
        if(n!=100){
            cout << 10000 * n << endl;
        }else{
            cout << 1010000 <<endl;
        }
    }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

type priorityQueue []int

func (p priorityQueue) Len() int            { return len(p) }
func (p priorityQueue) Less(i, j int) bool  { return p[i] > p[j] }
func (p priorityQueue) Swap(i, j int)       { p[i], p[j] = p[j], p[i] }
func (p *priorityQueue) Push(x interface{}) { *p = append(*p, x.(int)) }
func (p *priorityQueue) Pop() interface{} {
	old := *p
	n := len(old)
	x := old[n-1]
	*p = old[0 : n-1]
	return x
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	pq := make(priorityQueue, 0, n)
	ans := 0
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		heap.Push(&pq, a)
		ans += a
	}

	for i := 0; i < m; i++ {
		a := heap.Pop(&pq).(int)
		ans -= a
		a /= 2
		ans += a
		heap.Push(&pq, a)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4736
#include <iostream>
using namespace std;
bool helper(int k,int a,int b){
if (a%k==0 || b%k==0)
  return true;
  for (int i=a+1;i<b;i++){
  if (i%k==0)
    return true;
  }
  return false;
}
int main(){
int k,a,b;
  cin>>k>>a>>b;
  bool ans=helper(k,a,b);
  if (ans)
    cout<<"OK";
  else
    cout<<"NG";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
  ll N, M;
  cin >> N >> M;

  vector<ll> div = divisor(M);
  for (ll d : div) {
    if (d >= N) {
      cout << M / d << endl;
      return 0;
    }
  }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

ll dp[105][100010];

int main() {
    int n, w, a, b;
    rep(i, 105)rep(j, 100010)dp[i][j] = INF;
    cin >> n >> w;
    dp[0][0] = 0;
    rep(i, n) {
        cin >> a >> b;
        rep(j, 100010) {
                int g = j - b;
                if (g >= 0)dp[i+1][j] = (dp[i][j] > dp[i][j - b] + a) ? dp[i][j - b] + a : dp[i][j];
                else dp[i+1][j] = dp[i][j];
            }
    }
    ll ans = 0;
    rep(i, 100010)if (dp[n][i] <= w)ans = i;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 82304
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class UnionFind:
    def __init__(self, n):
        self.state = [-1] * n
        self.size_table = [1] * n
        # cntはグループ数
        # self.cnt = n

    def root(self, u):
        v = self.state[u]
        if v < 0: return u
        self.state[u] = res = self.root(v)
        return res

    def merge(self, u, v):
        ru = self.root(u)
        rv = self.root(v)
        if ru == rv: return
        du = self.state[ru]
        dv = self.state[rv]
        if du > dv: ru, rv = rv, ru
        if du == dv: self.state[ru] -= 1
        self.state[rv] = ru
        # self.cnt -= 1
        self.size_table[ru] += self.size_table[rv]
        return

    # グループの要素数
    def size(self, u):
        return self.size_table[self.root(u)]

n,m=MI()
uf=UnionFind(n)
for _ in range(m):
    a,b=MI1()
    uf.merge(a,b)
ans=1
print(max(uf.size_table))


Measured memory_bytes: 79828
import sys
sys.setrecursionlimit(10 ** 7)
N, M = map(int,input().split())
path = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a].append(b)

dp = [-1] * N

def chdp(x):
    if dp[x] != -1:
        return(dp[x]) 
    dp[x] = 0
    for t in path[x]:
        dp[x] = max(dp[x], chdp(t)+1)
    return(dp[x])

for i in range(N):
    chdp(i)

print(max(dp))


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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

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

  cin >> n >> x >> t;

  cout << ((n - 1) / x + 1) * t << endl;
}


Measured memory_bytes: 3672
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val a = readLine()?.split(" ")?.map(String::toInt) ?: return
    val b = readLine()?.split(" ")?.map(String::toInt) ?: return
    val c = readLine()?.split(" ")?.map(String::toInt) ?: return

    var total = 0
    0.until(n).forEach {
        total += b[a[it] - 1]
        if (it > 0 && a[it] - a[it - 1] == 1) {
            total += c[a[it - 1] - 1]
        }
    }
    println(total.toString())
}

Measured memory_bytes: 37792
#include <stdio.h>

int main(void)
{
	int i, j;
	char str[21];
	
	scanf("%s", str);
	
	j = 0;
	while (str[j] != '\0'){
		j++;
	}
	
	j--;
	for (i = j; 0 <= i; i--){
		printf("%c", str[i]);
	}
	printf("\n");
	return (0);
}

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

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;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
const long long INF = 1e9;

int main()
{
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  for(int i = 0; i < N; i++) cin >> w[i] >> v[i];

  //dp[i][w]i-1番目までの品物から重さがwを超えないように選んだ時の最大値
  vector<vector<ll> > dp(N + 1, vector<ll>(100000, 0));
  for (int i = 0; i < N; i++){
    for (int sum_w = 0; sum_w <= W; sum_w++)
    {
      if(sum_w - w[i] >= 0){ //選ぶとき
        chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
      }

      //選ばなかったとき
      chmax(dp[i + 1][sum_w], dp[i][sum_w]);
    }
  }
  
  cout << dp[N][W] << endl;

}


Measured memory_bytes: 80256
# This was written by chizuchizu
import sys
# import collections

# import bisect
# import math
import numpy as np

"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()

    """この下から書いてね"""
    # n, m = ip.IL()
    # a = np.array(ip.IL())
    # for _ in range(m):
    #     a[np.argmax(a)] //= 2
    # print(np.sum(a))
    a, b, c, d = ip.IL()
    ans = "Yes"
    while True:
        c -= b
        if c <= 0:
            ans = "Yes"
            break

        a -= d
        if a <= 0:
            ans = "No"
            break

    print(ans)



main()


Measured memory_bytes: 27152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll maxi(ll a,ll b)
{
    if(a>b)return a;
    return b;
}
int main(void)
{
    ll n,W;
    cin>>n>>W;
    ll ks[n+1][W+1];
    int v[n+1];
    int w[n+1];
    v[0]=w[0]=0;
    int i;
    for(i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    int j;
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=W;j++)
        {
            if(!i||!j)ks[i][j]=0;

       else if(w[i]<=j)
        {
            ks[i][j]=maxi(v[i]+ks[i-1][j-w[i]],ks[i-1][j]);

        }
        else ks[i][j]=ks[i-1][j];
        }
    }
    cout<<ks[n][W];
}


Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <utility>
#include <map>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
vector<ll> a;
const ll INF = 1e16;

int main()
{
    string s;
    cin>>s;
    int a=0;
    int b=0;
    for(int i=0;i<s.length();i++)//white
    {
        if(i%2==0&&s[i]=='0')
            a++;
        if(i%2==1&&s[i]=='1')
            a++;
    }
    for(int i=0;i<s.length();i++)//black
    {
        if(i%2==0&&s[i]=='1')
            b++;
        if(i%2==1&&s[i]=='0')
            b++;
    }
    int ans;
    if(a<=b)
        ans=a;
    else
        ans=b;
    cout<<ans<<endl;
    return 0;
}




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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    // int min_c = 1e6;
    // rep(i, n) {
    //     int count = 0;
    //     rep(j, n) {
    //         if (j < i) {
    //             if (s[j] == 'W') {
    //                 count++;
    //             }
    //         } else if (i < j) {
    //             if (s[j] == 'E') {
    //                 count++;
    //             }
    //         }
    //     }
    //     min_c = min(min_c, count);
    // }
    // cout << min_c << endl;
    vector<int> west(n);
    vector<int> east(n);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'W') {
            if (i == 0) {
                west[i] = 1;
            } else {
                west[i] = west[i-1] + 1;
            }
        } else {
            west[i] = west[i-1];
        }
        if (s[n-1-i] == 'E') {
            if (i == 0) {
                east[n-1-i] = 1;
            } else {
                east[n-1-i] = east[n-i] + 1;
            }
        } else {
            east[n-1-i] = east[n-i];
        }
    }
    int min_c = 1e9;
    rep(i, n) {
        if (i == 0) {
            min_c = min(min_c, east[i+1]);
        } else if (i == n-1) {
            min_c = min(min_c, west[i-1]);
        } else {
            min_c = min(min_c, west[i-1] + east[i+1]);
        }
    }
    cout << min_c << endl;
}

Measured memory_bytes: 6060
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int a = in.nextInt();
    int b = in.nextInt();
    in.close();
    int ans = b % a == 0 ? a + b : b - a;
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
double P,E,T;

double dfs(int k,double L,double R){
  double H=(R+L)/2,PP=H>=T ?1-P:P;
  if(k==0||(T<R-E||L+E<T)||(L-T<=E&&T-R<=E))return abs(H-T)<=E;
  return PP*dfs(k-1,H,R)+(1-PP)*dfs(k-1,L,H);
}

int main(){
  double K,R,L;
  cin>>K>>R>>L>>P>>E>>T;
  printf("%.10f\n",dfs(K,L,R));
  return 0;
}

Measured memory_bytes: 1240
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max({x,y,z})
#define MX4(x,y,z,p) max({x,y,z,p})
#define MX5(x,y,z,p,q) max({x,y,z,p,q})
#define MN3(x,y,z) min({x,y,z})
#define MN4(x,y,z,p) min({x,y,z,p})
#define MN5(x,y,z,p,q) min({x,y,z,p,q})
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################

void solve() {

    int n;
    SI(n);
    ll ans = -1;
    ll sum = 0;

    REP(i, n) {
        ll x, y;
        SL(x); SL(y);
        ans += y;
        sum += x * y;
        ans += sum / 9;
        sum %= 9;
    }
    if (sum == 0) ans--;
    printf("%lld\n", ans);
}

void init() {
    


}

int main () {
    init();
    solve();
    return 0;
}


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

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

    static int[] jumps;
    static int oo = Integer.MAX_VALUE;
    static int[] memo;
    
    
    public static int dp(int i, int N) {
        if (i == N-1) {
            return 0;
        }

        if(memo[i] != -1){
            return memo[i];
        }
        
        int sA= oo, sB = oo;
        if (i + 1 < N) {

            sA = Math.min(oo, dp(i + 1, N) + Math.abs(jumps[i] - jumps[i + 1]));
            //System.out.println("A" + jumps[i] + ", " + jumps[i+1]  + ":" + sA);
        }
        if (i + 2 < N) {

            sB = Math.min(oo, dp(i + 2, N) + Math.abs(jumps[i] - jumps[i + 2]));
            //System.out.println("B" + jumps[i] + ", " + jumps[i+1]);
            
        }
        //System.out.println("escoge = "+ Math.min(sA, sB));
        return memo[i] = Math.min(sA, sB);
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        memo = new int[N];
        
        Arrays.fill(memo, -1);
        
        jumps = Arrays.stream(br.readLine().split(" ")).mapToInt((x) -> Integer.parseInt(x)).toArray();
        System.out.println(dp(0, N));

    }

}


Measured memory_bytes: 50664
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<lli> vi;
typedef vector<vi> vvi;
const int mod = 1e9+7;
#define MAXN 200005
lli st[4*MAXN];

void update(int pos, int ini, int fin, int idx, lli val){
	if(fin < idx || ini > idx) return;

	if(fin == idx && ini == idx){
		st[pos]+=val;
		return;
	}

	int m = (ini+fin)/2;
	update(2*pos+1,ini,m,idx,val);
	update(2*pos+2,m+1,fin,idx,val);
	st[pos] = max(st[2*pos+1],st[2*pos+2]);
}

lli query(int pos, int l ,int r, int ini ,int fin){
	if(fin < l || ini > r){
		return -1;
	}

	if(ini >= l && fin <= r){
		return st[pos];
	}

	int m = (ini+fin)/2;
	return max(query(2*pos+1,l,r,ini,m),query(2*pos+2,l,r,m+1,fin));
}

int main(){__
	int n;
	cin >> n;
	vi a(n),b(n);
	for(int i=0; i < n; i++) cin >> a[i];
	for(int i=0; i < n; i++) cin >> b[i];

	for(int i =0; i < n; i++){
		int x = a[i]-1;
		lli best =0ll;
		if(x != 0){
			best = query(0,0,x-1,0,n-1);
		}
		update(0,0,n-1,x,best+b[i]);
	}

	cout << query(0,0,n-1,0,n-1) << endl;
	return 0;
}


Measured memory_bytes: 9472
#include<stdio.h>
#include<stdlib.h>

#define ll long long

int main(void){
    int n, a, b, i = -1;
    ll k;
    ll x[100001] ={};

    scanf("%d %lld", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d %d", &a, &b);
        x[a] += b;
    }

    while(k > 0) if(x[++i] != 0) k -= x[i];
    printf("%d", i);
    
    return 0;
}

Measured memory_bytes: 2516
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

left = [0] * (N + 2)
right = [0] * (N + 2)

for i in range(N):
    left[i + 1] = left[i] + (1 if S[i] == 'E' else 0)
    right[-i - 2] = right[-i - 1] + (1 if S[-i - 1] == 'W' else 0)

ans = N
for i in range(1, N + 1):
    ans = min(ans, N - left[i] - right[i])

print(ans)

Measured memory_bytes: 27700
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int n, m;
    cin>>n>>m;
    Yes(n == m);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
d = 0

if n % 2 == 0:
    for i in range(n//2):
        d += (2*i + 1) * 2
    if d != sum(a):
        print(0)
        exit()
else:    
    for i in range(1, n//2+1):
        d += 4 * i
    if d != sum(a):
        print(0)
        exit()

print(2**(n//2) % (10**9+7))

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


//SHORTCUTS

#define ll long long
#define endl '\n'
#define i1(a) cin>>a
#define i2(a,b) cin>>a>>b
#define i3(a,b,c) cin>>a>>b>>c
#define o1(a) cout<<a<<endl
#define o2(a,b) cout<<a<<" "<<b<<endl
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define f(i,a,b) for(int i = a;i<b;i++)
#define fe(i,a,b) for(int i = a;i<=b;i++)
#define fi(i,a,b) for(i=a;i<b;i++)
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair


// DEBUG CODE & FAST OUTPUT

#define printv(a) for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
#define printvl(a) for (int i = 0; i < a.size(); i++) cout << a[i] << endl;
#define printa(a, n) for (int i = 0; i< n; i++) cout << a[i] << ' ';
#define printal(a, n) for (int i = 0; i < n; i++) cout << a[i] << endl;


//DATA STRUCTURES

#define pq priority_queue
#define ms multiset
// #define y0 _y0_
// #define y1 _y1_
// #define div divi

typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;


//IMP CONSTANT
const int mod = 1e9 + 7, inf = 1e9 + 7;
const ll infll = 1e18 + 7;
bool google_contest = false;

//MODULAR OPERATIONS
ll myadd(ll a,ll b){
    ll ans = a+b;
    ans-= ans>=mod ? mod : 0;
    return ans; 
}
ll mysub(ll a, ll b){
    return (a-b+mod)%mod;
}
ll mymul(ll a,ll b){
    return (a*b)%mod;
}
ll mypow(ll a, ll b){
    ll ans = 1;
    while(b>0)
        if(b&1) ans = mymul(ans,a),b--;
        else a = mymul(a,a),b >>= 1;
    return ans;
}
ll nCr(ll n,ll r){
    if(r==0)return 1;
    if(r==1)return n;
    if(n==0)return 0;
    return mymul(n,mymul(nCr(n-1,r-1),mypow(r,mod-2)));
}




const int dx[4] = {1, -1, 0,  0};
const int dy[4] = {0, 0,  1, -1};
//    /\    |  |\  /|                      
//   /__\   |  | \/ |           
//  /    \  |  |    | 



int main(){

ios_base::sync_with_stdio(0);
cin.tie(0); 
cout.tie(0);

int t,tt;
t=1;
// i1(t);
if(google_contest)tt=1;

while(t--){

int n,k;
i2(n,k);

vi arr(n);

f(i,0,n)i1(arr[i]);
vi prefix(n,0);
vi suffix(n,0);

auto makep = [&](){
    prefix.assign(n,0);
    suffix.assign(n,0);
    f(i,0,n){
        if(i-arr[i]>=0)prefix[i-arr[i]]++;
        else prefix[0]++;
        if(i+arr[i]<n)suffix[i+arr[i]]--;
        else suffix[n-1]--;
    }
};

auto make_arr = [&](){
    int sum=0;
    f(i,0,n){
        sum+=prefix[i];
        arr[i] = sum;
        sum+=suffix[i];
    }
};

if(k<50){
    f(i,0,k){
        makep();
        make_arr();
    }
    printv(arr);
    cout<<endl;
}else{
    f(i,0,n){
        cout<<n<<" ";
    }
    cout<<endl;
}
if(google_contest){
    cout<<"Case "<<tt++<<": ";
}
}

return 0;   
}


//    /\    |  |\  /|                      
//   /__\   |  | \/ |           
//  /    \  |  |    |   OVER!!!!


Measured memory_bytes: 5576
#!/usr/bin/env python3
import sys
from itertools import count, islice

MOD = 1000000007  # type: int

def mod_factorial_iter():
    acc = 1
    yield 1
    for i in count(1):
        acc = acc * i % MOD
        yield acc

def solve(n: int, k: int):
    mod_factorials = tuple(islice(mod_factorial_iter(), n+2))
    def comb(a, b):
        return (mod_factorials[a] * (pow(mod_factorials[a-b], MOD-2, MOD) * pow(mod_factorials[b], MOD-2, MOD)) % MOD) % MOD
    ans = 1
    for i in range(1, min(n-1, k)+1):
        t = (comb(n-1, i) * comb(n, i)) % MOD
        ans = (ans + t) % MOD
    return ans


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    k = int(next(tokens))  # type: int
    print(solve(n, k))

if __name__ == '__main__':
    main()
    
            


Measured memory_bytes: 53840
N = int(input())

tmp = [[1]]
answer = tmp

for i in range(N - 1):
    tmp = []
    for a in answer:
        max_a = max(a)
        for j in range(1, max_a + 2):
            tmp.append(a + [j])
    answer = tmp

answer.sort()

def alpha(l):
    res = ""
    for ll in l:
        res += chr(ll + ord("a") - 1)
    return res

for a in answer:
    print(alpha(a))

Measured memory_bytes: 25292
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 1e5 + 5;
vector<pii> g[N];
bool vis[N];
int val[N];
bool pos = 1;
void dfs(int u, int gg){
	vis[u] = 1;
	val[u] = gg;
	for(pii v : g[u]){
		if(vis[v.fi]){
			if(val[v.fi] != gg + v.se){
				pos = 0;
			}
		}
		else{
			dfs(v.fi, gg + v.se);
		}
	}
}
void solve(){
	int n, m;
	cin >> n >> m;
	fr(i, 1, m){
		int l, r, d;
		cin >> l >> r >> d;
		g[l].pb({r, d});
		g[r].pb({l, -d});
	}
	fr(i, 1, n){
		if(!vis[i]){
			dfs(i, 0);
		}
	}
	cout << ((pos)? "Yes" : "No");
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

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

int main() {
    char c;
    cin >> c;
    
    set<char> boin = {'a', 'i', 'u', 'e', 'o'};
    if (boin.count(c)) {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}

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

int main(){
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;

	if (((x - r) >= 0 && (x + r) <= w) && ((y - r) >= 0 && (y + r) <= h))
		cout << "Yes\n";
	else
		cout << "No\n";
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(2*1e5)+5
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << fim
#define max3(x, y, z) max(x, max(y, z))
#define ull unsigned long long
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll MOD = 1e9+7;
 
using namespace std;
 
int main() {
  	FAST;
    int n;
    cin >> n;
    string v;
    cin >> v;
 
    int sum[4][n+5];
    memset(sum, 0, sizeof sum);
    for(int i = 0; i < n; i++) {
        if(i) {
            sum[0][i] += sum[0][i-1];
            sum[1][i] += sum[1][i-1];
            sum[2][i] += sum[2][i-1];
        }
        if(v[i] == 'R') {
            v[i] = 0;
            sum[0][i]++;
        }
        if(v[i] == 'G') {
           v[i] = 1;
           sum[1][i]++;
        }
        if(v[i] == 'B'){
         v[i] = 2;
         sum[2][i]++;
        }
    }
 
    ll ans = 0;
    for(int i = 0; i < n; i++)
        for(int j = i+1; j < n-1; j++) {
            if(v[i] == v[j])
                continue;
            for(int k = 0; k < 3; k++) {
 
                if(k == v[i] or k == v[j])
                    continue;
 
                ans += sum[k][n-1]-sum[k][j];
 
 
 
                if(j+(j-i) < n && v[j+(j-i)] == k) 
                    ans--;
 
                
            }
 
 
        }
    cout << ans << endl;
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    ostr << p.first << " " << p.second;
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
// vll x(n); x[i]=a;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;
typedef vector<vector<ll>> vvll;
// vvll x(m,vi(n)); x[i][j]=a;

#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    ll n, ans = 0, tmp = 0;
    cin >> n;
    vll a(n), b(n), c(n-1);
    cin >> a >> b >> c;
    REP(i,n) a[i]--;
    ans += b[a[0]];
    REP(i,n-1){
        ans += b[a[i+1]];
        if(a[i+1]-a[i]==1) ans += c[a[i]];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int bubblesort(int A[], int N)
{
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++){
		flag = 0;
		for (int j = N - 1; j >= i + 1; j--){
			if (A[j] < A[j - 1]){
				swap(A[j], A[j - 1]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}
int main(){
	int A[100], N, sw;
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	sw = bubblesort(A, N);
	for (int i = 0; i < N; i++){
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	return 0;
}

Measured memory_bytes: 1164
n = int(input())
h = [int(i) for i in input().split()]


def main():
    h[0] -= 1
    print("Yes" if detect() else "No")


def detect():
    for i in range(1, n):
        if h[i] > h[i-1]:
            h[i] -= 1
        elif h[i] < h[i-1]:
            return False

    return True


main()


Measured memory_bytes: 14396
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(n):
        a = [LI() for _ in range(n)]
        q = []
        d = [0] * 2
        for t,c in a:
            heapq.heappush(q, (0,0,t,c*2))

        while q:
            ct, l, t, c = heapq.heappop(q)
            nx = l ^ 1
            nt = ct + t
            if d[nx] > nt:
                nt = d[nx]
            else:
                d[nx] = nt
            if c > 1:
                heapq.heappush(q, (nt,nx,t,c-1))

        return max(d)


    while 1:
        n = I()
        if n == 0:
            break
        rr.append(f(n))

    return '\n'.join(map(str, rr))


print(main())



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

using namespace std;

#define gc getchar_unlocked
#define foi(i,n) for(int i=0;i<n;i++)
#define Foi(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define fol(i,n) for(ll i=0;i<n;i++)
#define Fol(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
        if (exp & 1) result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
        g[u-1].pb(v-1);
        g[v-1].pb(u-1);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}


ll NcR(ll n,ll r)
{
    long long p = 1, k = 1; 
    if (n - r < r)
        r = n - r;
    if (r != 0) { 
        while (r) {
            p *= n;
            long long m = __gcd(p, k);
            p /= m;
            k /= m;
            n--;
            r--;
            k *= r; 
        }
    }
    else
        p = 1;
    return p;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int d,t,s;
    cin>>d>>t>>s;
    if(t>=float(d)/s)
        cout<<"Yes";
    else
    {
        cout<<"No";
    }
       
    return 0;
}

Measured memory_bytes: 10692
<?php

//$_input = explode(
//    "\n",
//    '7
//50
//30
//50
//100
//50
//80
//30
//'
//);

function getNext() {
    return trim(
        isset($GLOBALS['_input'])
            ? array_shift($GLOBALS['_input'])
            : fgets(STDIN)
    );
}


$n = (int) getNext();
$disks = [];
for ($i = 0; $i < $n; ++$i) {
    $temp = (int) getNext();
    if (!in_array($temp, $disks, true)) {
        $disks[] = $temp;
    }
}

printf("%d\n", count($disks));


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

using namespace std;

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

  string s;
  cin >> s;
  map<int, int> cnt;
  ++cnt[0];
  int p = 0;
  int t = 1;
  long long ans = 0;
  reverse(s.begin(), s.end());
  for (int i = 0; i < s.size(); ++i) {
    p += t * (s[i] - '0');
    p %= 2019;
    t *= 10;
    t %= 2019;
    ans += cnt[p]++;
  }
  cout << ans;

  return 0;
}


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

int main()
{
   /* string s="ABC";
    int n;
    cin>>n;
    cout<<s<<n<<endl;*/

    int n,p=1;
    cin>>n;
    while(p<=n)
    {
        p*=2;
    }
    cout<<p/2<<endl;
}


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

int main() {
  int n;
  cin >> n;
  int sum = 0;	//各桁の和

  int rem = n;
  for (int i = 8; i >= 0; i--) {
    int digit = 1;
    for (int j = 0; j < i; j++) {
      digit *= 10;
    }
//cout << "digit:" << digit << endl;
    int digitNum = rem / digit;
//cout << "digitNum:" << digitNum << endl;
    sum += digitNum;
//cout << "sum:" << sum << endl;
    rem -= digitNum * digit;
//cout << "rem:" << rem << endl;
  }
//cout << "n:" << n << endl;
//cout << "sum:" << sum << endl;
  
  if (n % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static int MergeSort(final int[] A, final int left, final int right){ //[left, right)		
		if(left + 1 < right){
			final int mid = (left + right) / 2;
			
			int ret = 0;
			ret += MergeSort(A, left, mid);
			ret += MergeSort(A, mid, right);
			
			final int l_size = mid - left;
			final int r_size = right - mid;
			final int size = l_size + r_size;
			int[] ls = new int[l_size + 1];
			ls[l_size] = Integer.MAX_VALUE;
			for(int i = 0; i < l_size; i++){
				ls[i] = A[left + i];
			}
			int[] rs = new int[r_size + 1];
			rs[r_size] = Integer.MAX_VALUE;
			for(int i = 0; i < r_size; i++){
				rs[i] = A[mid + i];
			}
			
			int l_pos = 0, r_pos = 0;
			int count = 0;
			while(count < size){
				if(ls[l_pos] <= rs[r_pos]){
					A[left + count] = ls[l_pos];
					l_pos++;
				}else{
					A[left + count] = rs[r_pos];
					r_pos++;
				}
				ret++;
				count++;
			}
			
			return ret;
		}
		
		return 0;
	}
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		int[] array = new int[n];
		for(int i = 0; i < n; i++){
			array[i] = sc.nextInt();
		}
		
		final int ret = MergeSort(array, 0, array.length);
		
		for(int i = 0; i < n; i++){
			if(i != 0){
				System.out.print(" ");
			}
			System.out.print(array[i]);
		}
		System.out.println();
		System.out.println(ret);
	}
	
	public static class Scanner {
	    private BufferedReader br;
	    private StringTokenizer tok;

	    public Scanner(InputStream is) throws IOException {
	        br = new BufferedReader(new InputStreamReader(is));
	    }

	    private void getLine() throws IOException {
	        while (!hasNext()) { tok = new StringTokenizer(br.readLine()); }
	    }

	    private boolean hasNext() {
	        return tok != null && tok.hasMoreTokens();
	    }

	    public String next() throws IOException {
	        getLine(); return tok.nextToken();
	    }

	    public int nextInt() throws IOException {
	        return Integer.parseInt(next());
	    }
	    
	    public long nextLong() throws IOException {
	    	return Long.parseLong(next());
	    }
	    
	    public void close() throws IOException {
	        br.close();
	    }
	}

}

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

int main()
{
  int A, B, C; cin >> A >> B >> C;
  if (A + B + C > 21)cout << "bust" << endl;
  else cout << "win" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> grid(h);
    for (int i = 0; i < h; i++)
    {
        cin >> grid[i];
    }
    // 二次元方向のbit全探索
    ll ans = 0;
    for (int i = 0; i < (1 << h); i++)
    {
        for (int j = 0; j < (1 << w); j++)
        {
            // cout << "i:" << i << " j:" << j << endl;
            bitset<10> tate(i);
            bitset<10> yoko(j);
            vector<string> cp = grid;
            for (int ii = 0; ii < h; ii++)
            {
                if (tate.test(ii))
                {
                    for (int m = 0; m < w; m++)
                    {
                        cp[ii][m] = '.';
                    }
                }
            }
            for (int jj = 0; jj < w; jj++)
            {
                if (yoko.test(jj))
                {
                    for (int n = 0; n < h; n++)
                    {
                        cp[n][jj] = '.';
                    }
                }
            }
            int cnt = 0;
            for (int ii = 0; ii < h; ii++)
            {
                for (int jj = 0; jj < w; jj++)
                {
                    if (cp[ii][jj] == '#')
                    {
                        ++cnt;
                    }
                }
            }
            if (cnt == k)
            {
                ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3604