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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w;
    cin >> h >> w;
    string ts;
    bool canvas[h+2][w+2]={};
    for(int i = 0; i < h; i++) {
        cin >> ts;
        for(int j = 0; j < w; j++) {
            if(ts[j]=='#') canvas[i+1][j+1]=true;
        }
    }

//    for(int i = 0; i < h+2; i++) {
//        for(int j = 0; j < w+2; j++) {
//            cout << canvas[i][j];
//        }
//        cout << "\n";
//    }

    bool jud=true;
    for(int i = 0; i < h+2; i++) {
    for(int j = 0; j < w+2; j++) {
        if(canvas[i][j]==true){
            if(canvas[i][j+1]==false && canvas[i][j-1]==false && canvas[i+1][j]==false && canvas[i-1][j]==false) jud=false;
        }
    }
    }

    if(jud) cout << "Yes" << "\n";
    else    cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define MAX_N 100005
struct edge{ int to,cost; };
int N,M,si,ti;
vector< edge > G[MAX_N];
int A[MAX_N];

int main(){
  cin>>N>>M>>si>>ti;
  si--,ti--;
  
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(i){
      G[i].push_back( (edge){i-1,0} );
    }
  }
  for(int i=0;i<M;i++){
    int x,y;
    cin>>x>>y;
    x--,y--;
    G[x].push_back( (edge){y,A[y]} );
  }

  priority_queue< P , vector<P> , greater<P> > Q;
  int d[MAX_N];
  for(int i=0;i<MAX_N;i++)d[i]=1e9;
  
  Q.push( P(0,si) );
  d[si]=0;
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    int pos=p.second;
    int cost=p.first;
    if(d[pos]<cost)continue;
    
    for(int i=0;i<(int)G[pos].size();i++){
      edge e=G[pos][i];
      if(e.cost+cost < d[e.to]){
        d[e.to]=e.cost+cost;
        Q.push( P(d[e.to],e.to) );
      }
    }
  }
  cout<< d[ti] <<endl;
  return 0;
}

Measured memory_bytes: 11296
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  var list = {};
  for(var i = 0; i < N; i++){
    var s = next();
    if(list[s] == null){
       list[s] = 1;
    }else{
       list[s]++;
    }
  }
  var M = nextInt();
  for(var i = 0; i < M; i++){
    var t = next();
    if(list[t] != null){
       list[t]--;
    }
  }
  var output = 0;
  var keys = Object.keys(list);
  for(var i = 0 ; i < keys.length; i++){
    output = Math.max(output,list[keys[i]]);
  }
  myout(output);
}

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

typedef pair<int, int> pii;

const int MN = 500010;

struct Fenwick {
    vector<int> tree;
    void init() {
        tree = vector<int>(MN + 1, 0);
    }
    void upd(int x, int v) {
        for(int i = x + 1; i <= MN; i += (i & -i)) tree[i] += v;
    }
    int quer(int a) {
        if(a >= MN) a = MN - 1;
        int ret = 0;
        for(int i = a + 1; i >= 1; i -= (i & -i)) ret += tree[i];
        return ret;
    }
    int quer(int a, int b) {
        return quer(b) - quer(a - 1);
    }
} fw;

int N, K;
int P[MN], deg[MN], ans[MN];

struct BIT {
    vector<pii> tree;
    vector<int> lazy;
    void init() {
        tree = vector<pii>(4 * N);
        lazy = vector<int>(4 * N, 0);
        build(0, N - 1, 1);
    }
    void build(int l, int r, int n) {
        if(l == r) {
            tree[n] = pii(deg[l], l);
            return;
        }
        int m = (l + r)>>1;
        build(l, m, 2*n);
        build(m + 1, r, 2*n + 1);
        tree[n] = min(tree[2*n], tree[2*n + 1]);
    }
    void prop(int l, int r, int n) {
        if(l != r) {
            tree[2*n].first += lazy[n];
            lazy[2*n] += lazy[n];
            tree[2*n + 1].first += lazy[n];
            lazy[2*n + 1] += lazy[n];
            lazy[n] = 0;
        }
    }
    void upd(int a, int b, int d, int l, int r, int n) {
        if(b < l || r < a) return;
        if(a <= l && r <= b) {
            tree[n].first += d;
            lazy[n] += d;
            return;
        }
        prop(l, r, n);
        int m = (l + r)>>1;
        upd(a, b, d, l, m, 2*n);
        upd(a, b, d, m + 1, r, 2*n + 1);
        tree[n] = min(tree[2*n], tree[2*n + 1]);
    }
    pii quer(int a, int b, int l, int r, int n) {
        if(b < l || r < a) return pii(1e9, 1e9);
        if(a <= l && r <= b) return tree[n];
        prop(l, r, n);
        int m = (l + r)>>1;
        pii L = quer(a, b, l, m, 2*n);
        pii R = quer(a, b, m + 1, r, 2*n + 1);
        return min(L, R);
    }
} bit;

priority_queue<int> pq;

int main() {
    scanf("%d %d", &N, &K);

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

    fw.init();
    for(int i = N - 1; i >= 0; i--) {
        deg[ P[i] ] = fw.quer(P[i] - K + 1, P[i] + K - 1);
        fw.upd(P[i], 1);
    }

    bit.init();
    for(int i = N - 1; i >= 0; i--) {
        while(1) {
            pii t = bit.tree[1];
            if(t.first) break;

            bit.upd(t.second, t.second, 1e9, 0, N - 1, 1);
            pq.push(t.second);
        }

        int t = pq.top(); pq.pop();
        ans[t] = i;

        bit.upd(max(0, t - K + 1), min(N - 1, t + K - 1), -1, 0, N - 1, 1);
    }
    for(int i = 0; i < N; i++) {
        printf("%d\n", ans[i] + 1);
    }
}


Measured memory_bytes: 36848
#include<cstdio>  
#include<cstdlib>
#include<cstring>

struct Node{
int key;
Node *next,*prev;
};

Node *nil;

Node* listSearch(int key){
Node *cur=nil->next;
while(cur!=nil&&cur->key!=key){
cur=cur->next;
}
return cur;
}

void init(){
nil=(Node *)malloc(sizeof(Node));
nil->next=nil;
nil->prev=nil;
}

void printList(){
Node *cur=nil->next;
int isf=0;
while(1){
if(cur==nil) break;
if(isf++>0) printf(" ");
printf("%d",cur->key);
cur=cur->next;
}
printf("\n");
}

void deleteNode(Node *t){
if(t==nil) return;
t->prev->next=t->next;
t->next->prev=t->prev;
free(t);
}

void deleteFirst(){
deleteNode(nil->next);
}

void deleteLast(){
 deleteNode(nil->prev);
 }
 
 void deleteKey(int key){
 
 deleteNode(listSearch(key));
 }
 
 void insert(int key){
 Node *x=(Node *)malloc(sizeof(Node));
 x->key=key;
 x->next=nil->next;
 nil->next->prev=x;
 nil->next=x;
 x->prev=nil;
 }
 
 int main(){
 int key,n,i;
 int size=0;
 char com[20];
 int np=0,nd=0;
 scanf("%d",&n);
 init();
 	for(i=0;i<n;i++){
 scanf("%s%d",com,&key);
 if(com[0]=='i'){ insert(key);np++;size++;
}
else if(com[0]=='d'){
if(strlen(com)>6){
if(com[6]=='F') deleteFirst();
else if(com[6]=='L') deleteLast();
}else{
deleteKey(key);nd++;
}
size--;
}
}

printList();

return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> P(N);
  for (int i = 0; i < N; i++) {
    int X, L;
    cin >> X >> L;
    P.at(i).first = X + L;
    P.at(i).second = X - L;
  }
  sort(P.begin(), P.end());
  int ans = 0, T = -1100000000;
  for (int i = 0; i < N; i++) {
    if (T <= P.at(i).second) {
      ans++;
      T = P.at(i).first;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4004
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int H, W, i, j;
        Scanner sc = new Scanner(System.in);
        while (true) {
            H = sc.nextInt();
            W = sc.nextInt();
            if (H == 0 && W == 0) break;
            for (i = 0; i < H; i++) {
                for(j = 0; j < W; j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 37640
#include <bits/stdc++.h>
#define lld unsigned long long int
#define MAX 10000000
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
using namespace std;

int n, w[150], suma, sumb, m=MAX, aux;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i<=n; i++)cin>>w[i];


    for(int i = 1; i < n; i++){
        suma = 0; sumb = 0;
        for(int j = 1; j<=n; j++){
            if(j>i)sumb+=w[j];
            else suma+=w[j];

        }

        aux=abs(suma-sumb);

        if(aux<m)m=aux;
    }
    cout<<m<<endl;


}


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

using namespace std;

int g0[7] = { 1,3,5,7,8,10,12 };
int g1[4] = { 4,6,9,11 };
int g2[1] = { 2 };

int main()
{
	int x, y, xg = -1, yg = -1;
	cin >> x >> y;
	for (int i = 0; i < 7; i++)
	{
		if (g0[i] == x) xg = 0;
		if (g0[i] == y) yg = 0;
	}
	for (int i = 0; i < 4; i++)
	{
		if (g1[i] == x) xg = 1;
		if (g1[i] == y) yg = 1;
	}
	for (int i = 0; i < 1; i++)
	{
		if (g2[i] == x) xg = 2;
		if (g2[i] == y) yg = 2;
	}

	if (xg == yg)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


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

int main() {
   int N ;
  cin >> N ;
  long sum = 0 ;//合計用
  for(long i=1 ; i<N+1 ; i++){
   if(i%3!=0 && i%5!=0){
     sum += i;
   }
  }
  cout << sum << endl;
    
}


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

typedef long long ll;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    cout << s[0] << n - 2 << s[n -1] << "\n";
}

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

typedef long long ll;

#define all(x) x.begin(), x.end()
#define sz(x) (ll) x.size()
#define deb(x) cout << (#x) << " is " << (x) << "\n";
#define debv(v) for (auto usb: v) cout << usb << " "; cout << "\n";

// n == (1 || 0) ???? memory?


void solve(){
	string s;
	cin >> s;
	ll ans = 0LL;
	for (int i = 0; i < sz(s); i++)
	{
		ans += (ll) (s[i] - '0');
	}
	if(ans%9 == 0) cout << "Yes\n";
	else cout << "No\n";
}

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.precision(20);	
	solve();
	return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vvin=vector<vector<int>>;
using vll=vector<long long>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;
vin dy={0,1,0,-1};
vin dx={1,0,-1,0};

int main(){
    int n,k;cin>>n>>k;
    vll a(n);rep(i,n)cin>>a[i];
    rep2(i,k,n){
        if(a[i]<=a[i-k])cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
}

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

int dp[100000];
int high[100000];
int main(int argc, char *argv[]){
  int N,h;
  cin>>N;
  for(int i=0; i<N; i++){
    cin>>h;
    high[i]=h;
    dp[i]=0;
  }
  for(int i=1; i<N; i++){
    if(i==1){
      dp[i]=dp[i-1]+abs(high[i]-high[i-1]);
    }
    else{
      dp[i]=min(dp[i-2]+abs(high[i-2]-high[i]),dp[i-1]+abs(high[i-1]-high[i]));
    }
    
  }
  cout<<dp[N-1]<<endl;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define ul unsigned long long

int main() {
  ll A;
  double B;
  cin >> A>>B;

  cout << (A*(int)(B*100+0.5))/100  << endl;

}

Measured memory_bytes: 3712
package main

import "fmt"

func main() {
	var n, ans int
	fmt.Scan(&n)
	v := make([]int, n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&c[i])
	}
	for i := 0; i < n; i++ {
		if v[i]-c[i] > 0 {
			ans += v[i] - c[i]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x;
    while(true){
        cin>>n>>x;
        if(n==0 && x==0 )break;
        int ans=0;
        for(int i=1; i<=n-2; i++){
            for(int j=i+1; j<=n-1; j++ ){
                for(int k=j+1; k<=n; k++){
                    if(i+j+k==x) ans++;
                }
            }
        }
        cout<<ans<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3208
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
A, B, T = MAP()
 
bis = 0
for i in range(1, 100):
  if A*i <= T:
    bis += B
  else:
    break
print(bis)

Measured memory_bytes: 5188
import java.util.*;

public class Main {
    static long GOSENCHOU = 5000000000000000l;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int n = str.length();
        int[] s = new int[n];
        long k = sc.nextLong();
        int answer = -1;
        for (int i = 0; i < n; i++) {
            s[i] = Integer.parseInt(String.valueOf(str.charAt(i)));
            if (s[i] == 1) {
                if (i + 1 == k) {
                    answer = 1;
                    break;
                }
            } else {
                answer = s[i];
                break;
            }
        }
        
        System.out.println(answer);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;
    ll resT = 1, resA = 1;
    for (int i = 0; i < N; ++i) {
        int T, A;
        cin >> T >> A;
        ll tmp = max((resT + T - 1) / T, (resA + A - 1) / A);
        resT = tmp * T;
        resA = tmp * A;
    }
    cout << resT + resA << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
long long C(int N, int M){
    if(M == 0 || N == M) return 1;
    double c = 1, n = N, m = M;

    for(int i=0; i<N-M; i++){
        c *= (n-i) / (n-m-i);
    }

    long long ans = c+0.5;
    return ans;
}
int main()
{
    int n, p, n1=0, n2=0, a[55];
    scanf("%d%d", &n, &p);

    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
        if(a[i]%2 == 1) n1++;
        else n2++;
    }

    long long cnt = 0;
    for(int i=p; i<=n1; i+=2)
        for(int j=0; j<=n2; j++)
            cnt += C(n1, i) * C(n2, j);

    printf("%lld\n", cnt);

    return 0;
}


Measured memory_bytes: 128
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()

    ans = INF
    for i in range(len(S) - 2):
        ans = min(abs(753 - int(S[i:i+3])), ans)

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9992
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  while(cin >> n && n){
    vector<int>data(n+1);
    vector<int>temp;
    for(int i=0;i<=n;i++){
      cin >> data[i];
    }
    for(int i=0;i<=n;i++){
      temp = data;
      temp.erase(temp.begin()+i);
      
      int sa=temp[1]-temp[0]; bool ok=false;
      for(int j=1;j<n;j++){
	if(temp[j]-temp[j-1]!=sa){
	  ok = true;
	  break;
	}
      }
      if(!ok){
	cout << data[i] << endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 1224
#include <stdio.h>

int main()
{
  int n, m, i, l, r = 0;
  if (scanf("%d %d", &n, &m) == -1) return -1;
  int left = 1;
  int right = 1000000;
  for(i = 0;i < m;i++) {
    if (scanf("%d %d", &l, &r) == -1) return -1;
    if (left < l) left = l;
    if (right > r) right = r;
  }
  int ans = right - left + 1;
  printf("%d\n", ans < 0 ? 0 : ans);
  return 0;
}

Measured memory_bytes: 128
private fun getInts() : List<Int> {
    return readLine()!!.split(" ").map {it.toInt()}
}

fun main(args: Array<String>) {
    var N = getInts()[0] / 2
    var pt = 0
    while (N > 0) {
        pt++
        N /= 2
    }

    var ans = 1
    (0..pt - 1).forEach {
        ans *= 2
    }
    println(ans)
}


Measured memory_bytes: 37912
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,k,a[N],ans;
int main(){
    ios::sync_with_stdio(false);ans=0x3f3f3f3f;
    cin>>n>>k;for(int i=1;i<=n;++i)cin>>a[i];sort(a+1,a+1+n);
    for(int i=1;i<=n-k+1;++i)ans=min(ans,a[i+k-1]-a[i]);
    cout<<ans<<endl;return 0;
}

Measured memory_bytes: 640
#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> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

#include <atcoder/all>
using namespace atcoder;


ll a[60][60];

int main(){
    int n,k;
    cin >> n >> k;
    rep(i,n)rep(j,n) cin >> a[i][j];
    int s = 2*n,t = 2*n+1;

    mcf_graph<int,ll> G(2*n+2);

    G.add_edge(s,t,n*k,LINF);

    rep(i,n){
        G.add_edge(s,i,k,0);
        G.add_edge(i+n,t,k,0);
    }

    rep(i,n)rep(j,n){
        G.add_edge(i,j+n,1,LINF-a[i][j]);
    }

    pair<int,ll> ans = G.flow(s,t,n*k);

    cout << (ll)ans.first * LINF - ans.second << endl;

    vector<vector<char>> maze(n,vector<char>(n,'.'));

    auto edges = G.edges();
    for(auto e:edges){
        if(e.from == s || e.to == t || e.flow == 0) continue;

        maze[e.from][e.to-n] = 'X';
    }

    rep(i,n){
        rep(j,n){
            cout << maze[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3976
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, h;
	cin >> n >> h;
	vector<int> a(n), b(n);
	rep(i,n) cin >> a[i] >> b[i];
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	int ans = 0;
	rep(i,n){
		if(h <= 0) break;
		if(b[i] < a[0]) break;
		h -= b[i];
		ans++;
	}
	chmax(h, 0);
	ans += (h + a[0] - 1) / a[0];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string a,b;
    cin>>a>>b;
    vector<int> l(0);
    for(int i=0;i<a.size()-b.size()+1;i++)
    {
        int d=0;
        for(int j=0;j<b.size();j++)
        if(b[j]!=a[i+j])
        d++;
        l.push_back(d);
    }
    int res=1e9;
    for(int i=0;i<l.size();i++)
    res=min(res,l[i]);
    cout<<res;
    return 0;
}


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


int main()
{
   ll n,sum,maxx;
   cin>>n;
   ll arr[n];
   for(int i=0;i<n;i++)
    cin>>arr[i];
    maxx=arr[0];
    sum=0;
   for(int i=1;i<n;i++)
   {
       if(arr[i]<=maxx)
        sum=sum+(maxx-arr[i]);
       else
       {
           maxx=arr[i];
       }
   }
   cout<<sum;
}


Measured memory_bytes: 5100
package main

import (
        "fmt"
        "sort"
)

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

        x := make([]int, n)
        for i := range x {
                fmt.Scan(&x[i])
        }

        s := make([]int, n)
        copy(s, x)
        sort.Ints(s)

        for i := range x {
                if x[i] < s[n/2] {
                        fmt.Println(s[n/2])
                        continue
                }
                fmt.Println(s[n/2-1])
        }
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
template <class T1, class T2>
void vadd(vector<T1> &v, T2 x);

#define int long long int
lli dp[200005][2] = {}; // dp[i]から働いたときの最大
// dp[i+1] =
lli sum[200005] = {};
lli work[200005] = {};
void solve(long long N, long long K, long long C, std::string S)
{
  int cur = 0;
  vector<int> v1, v2;
  while (cur < N)
  {
    if (S[cur] == 'o')
    {
      v1.push_back(cur);
      cur += C;
    }
    cur++;
  }
  cur = N - 1;
  while (cur >= 0)
  {
    if (S[cur] == 'o')
    {
      v2.push_back(cur);
      cur -= C;
    }
    cur--;
  }
  reverse(v2.begin(), v2.end());
  if (v1.size() != K)
  {
    cout << endl;
    return;
  }
  rep(i, v2.size())
  {
    if (v2[i] == v1[i])
      cout << v2[i] + 1 << endl;
  }
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  long long C;
  scanf("%lld", &C);
  std::string S;
  std::cin >> S;
  solve(N, K, C, S);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2>
void vadd(vector<T1> &v, T2 x)
{
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 6132
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int n,flag,anslen,ans;
char str1[20][20],str2[20][20],s1[20],s2[20];
bool Yes(char s[],int pos,char s2[]){
	int len=strlen(s2);
	for(int i=0;i<len;i++)
		if(s[pos+i]==s2[i]) continue;
			else return 0;
	return 1;
}
void Dfs(char s[],int cnt){
	if(flag) return;
	if(!strcmp(s,s2)){
		ans=cnt;
		flag=1;
		return;
	}
	int len=strlen(s);
	int m,ff,len2;
	char now[20];
	if(len>=anslen) return;
	for(int i=0;i<n;i++){
		memset(now,0,sizeof(now));
		m=ff=0;
		for(int j=0;j<len;){
			if(Yes(s,j,str1[i])){
				len2=strlen(str2[i]);
				for(int k=0;k<len2;k++) now[m++]=str2[i][k];
				j+=strlen(str1[i]);
				ff=1;
			}else now[m++]=s[j],j++;
		}
		if(ff) Dfs(now,cnt+1);
	}
}
int main(){
	//freopen("test.in","r",stdin);
	while(scanf("%d",&n)&&n){
		for(int i=0;i<n;i++) scanf("%s %s",&str1[i][0],&str2[i][0]);
		scanf("%s\n%s",&s1[0],&s2[0]);
		anslen=strlen(s2);
		flag=0;
		Dfs(s1,0);
		if(flag) printf("%d\n",ans);
			else printf("-1\n");
	}
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
#define ll long long
#define inf int(1e9+7)
#define pb push_back
#define mp make_pair
vector<int>g[2005];
int dfs(int v,int f,int k)
{
	if(k==0)
		return 0;
	int ans=1;
	for(int i=0;i<g[v].size();i++)
		if(g[v][i]!=f)
			ans+=dfs(g[v][i],v,k-1);
	return ans;
}
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int maxn=0,sum=1;
		for(int j=0;j<g[i].size();j++)
		{
			int t1=dfs(g[i][j],i,k/2);
			int t2=dfs(g[i][j],i,(k+1)/2);
			sum+=t1;
			maxn=max(maxn,t2-t1);
		}
		ans=max(ans,sum+maxn);
	}
	cout<<n-ans;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll ans, n;
ll cnt[111111];

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n; int i, x, ev=0;
	for(i=1 ; i<=n ; i++)
	{
		cin>>x;
		cnt[x]++;
	}
	for(i=1 ; i<=100000 ; i++) if(cnt[i]%2==1) ans++;
	for(i=1 ; i<=100000 ; i++) if(cnt[i] && cnt[i]%2==0) ev++;
	if(ev%2) ev--; ans+=ev; cout<<ans; return 0;
}


// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    string A, B;
    int na, nb, i;

    cin >> A >> B;

    na = A.size();
    nb = B.size();

    if(na > nb){
        cout << "GREATER" << endl;
    }

    else if(na < nb){
        cout << "LESS" << endl;
    }

    else{
        for(i=0; i<na; i++){
            if(A[i] > B[i]){
                cout << "GREATER" << endl;
                break;
            }

            else if(A[i] < B[i]){
                cout << "LESS" << endl;
                break;
            }

            else if(A[i] == B[i] && i == na-1){
                cout << "EQUAL" << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
import math
from math import cos, sin

a,b,C=map(float,input().split())
C = math.radians(C)
S = 0.5*a*b*sin(C)
L = math.sqrt(b**2+a**2-2*a*b*cos(C))+a+b
h = 2*S / a

print(S)
print(L)
print(h)

Measured memory_bytes: 7784
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        String s = scanner.next();
        if(a >= 3200){
            System.out.println(s);
        } else {
            System.out.println("red");
        }
    }
}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  string S; cin>>S;
  string ans="NO";
  rep(i,0,S.size()){
    rep(j,i,S.size()){
      string X;
      X+=S.substr(0,i+1);
      X+=S.substr(j,S.size()-j);
      if(X=="keyence"){
        ans="YES";
        break;
      }
    }
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 256
import java.util.*;
// warm-up
// Do i have to? Donuts? Cake? 
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt(), A = sc.nextInt(), B = sc.nextInt();
		System.out.println(X-A-(((X-A)/B)*B));
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35680
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n,k;
int a[501];
ll b[505];
int sum=0;
bool check(int s){
    FOR(i,1,n+1) b[i]=a[i-1]%s;
    sort(b,b+(n+1));
    FOR(i,1,n+1) b[i]+=b[i-1];
    ll mn=k+1;
    rep(i,n){
        mn=max(b[i],((ll)n-i)*s-(b[n]-b[i]));
        if(mn<=k) return true;
    }
    return false;
}
ll ans=0;
int main(){
    cin>>n>>k;
    rep(i,n) cin>>a[i],sum+=a[i];
    for(ll i=1;i*i<=sum;++i)if(sum%i==0){
        if(check(i)) ans=max(ans,i);
        if(check(sum/i)) ans=max(ans,sum/i);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(void) {
  
  int n;
  int q;
  int S[16384];
  int T[512];

  std::cin >> n;
  for(int i = 0; i < n; ++i) {
    std::cin >> S[i];
  }
  std::cin >> q;
  for(int i = 0; i < q; ++i) {
    std::cin >> T[i];
  }

  int ans = 0;
  for(int i = 0; i < q; ++i) {
    int num = T[i];
    for(int j = 0; j < n; ++j) {
      if( S[j] == num ) {
        ans += 1;
        break;
      }
    }
  }

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

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll x,y;
	//rl2(x,y);
	cin>>x>>y;
	if(x<=9&&y<=9)
	{
		cout<<x*y<<endl;

	}
	else
	{
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n,h,w=gets.chomp.split(" ").map { |e| e.to_i }

a=[]
b=[]

n.times do |i|
  a[i],b[i] = gets.chomp.split(" ").map { |e| e.to_i }
end

ans = 0

for i in 0..n-1 do
  if a[i] >= h && b[i] >= w
      ans += 1
  end
end

puts ans


Measured memory_bytes: 1788
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [N, K] = input[0].map(Number);

  return N % K === 0 ? 0 : 1;
};

console.log(main(read()));


Measured memory_bytes: 29592
line = input().split()
n = int(line[0])
x = int(line[1])

L = input().split()
l = [int(s) for s in L]

t = 1
d = 0

for i in range(n):
    d += l[i]
    if d <= x:
        t += 1
    else:
        break
print(t)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,n) for(int i = 0;i<n;i++)

int main(){
	ll x;
	cin >> x;
	ll money = 100;
	ll count = 0;

	while(x > money){
		money *= 1.01;
		count++;
	}
	cout << count << endl;


	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

#define MAX_H 2000001
#define INF (-100)

int parent(int );
int left(int );
int right(int );
void maxHeapify(int *,int);
void insert(int,int *);
void increaseK(int *,int ,int);
int extract(int *);

int H=0;

int main(){
  int A[MAX_H];
  int i=0;
  char word[7];
  int k;
  int max=0;

  while(1){
    scanf("%s",word);
    if(word[0]=='e' && word[1]=='n') break;
    if(word[0]=='i'){
      scanf("%d",&k);
      insert(k,A);
    }
    else if(word[0]=='e'){
      max=extract(A);
      printf("%d\n",max);
    }
  }

 return 0;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

void maxHeapify(int *A,int i){
  int l=0;
  int r=0;
  int largest=0;
  int swap=0;
  l=left(i);
  r=right(i);

  if( (l<=H) && (A[l]>A[i]) ) largest=l;
  else largest=i;

  if( (r<=H) && (A[r]>A[largest]) ) largest=r;

  if(largest!=i){
    swap=A[i];
    A[i]=A[largest];
    A[largest]=swap;
    maxHeapify(A,largest);
  }

}

void insert(int key,int *A){
   H++;
  A[H]=INF;
  increaseK(A,H,key);
}

void increaseK(int *A,int i,int key){
  if(key<A[i]) return;
  int change=0;
  A[i]=key;
  while(i>1 && A[parent(i)] < A[i]){
    change=A[i];
    A[i]=A[parent(i)];
    A[parent(i)]=change;
    i=parent(i);
  }
}
int extract(int *A){
  int max=0;
  if(H<1) return INF;
  max=A[1];
  A[1]=A[H];
  H--;
  maxHeapify(A,1);

  return max;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

const char W = '.', B = '#';
const ll INF = 1010101010;
ll Y, X;
vector<string> s;
ll dp[200][200][2];
ll dx[2] = {0, 1};
ll dy[2] = {1, 0};

signed main() {
  rep(y, 200) rep(x, 200) rep(k, 2) {
    dp[y][x][k] = INF;
  }
  cin >> Y >> X;
  s.resize(Y);
  rep(y, Y)
    cin >> s[y];
  if (s[0][0] == W) {
    dp[0][0][0] = 0;
  } else {
    dp[0][0][1] = 1;
  }
  rep(y, Y) rep(x, X) rep(k, 2) rep(t, 2) {
    ll ny = y + dy[t], nx = x + dx[t];
    ll nk = 0, inc = 0;
    if (y >= Y || ny >= Y || x >= X || nx >= X)
      continue;
    if (dp[y][x][k] == INF)
      continue;
    if (s[ny][nx] == B)
      nk = 1;
    if (nk == 1 && k ==0)
      inc = 1;
    chmin(dp[ny][nx][nk], dp[y][x][k] + inc);
  }
  cout << min({dp[Y-1][X-1][0], dp[Y-1][X-1][1]}) << endl;
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

vector<ll> Kbin(55, 0);
vector<ll> num_one(55, 0);
ll dp[55][2];
ll N, K;

ll rec(ll k, bool tight){
	if(k==-1) return 0;
	if(dp[k][tight]>=0) return dp[k][tight];

	ll x = Kbin[k];
	ll r = (tight?x:1);

	ll res = -1;

	if(r==0){
		res = max(res, rec(k-1, tight) + (num_one[k])*(1ll<<k));	
	}else{
		res = max(res , rec(k-1, false) + (num_one[k])*(1ll<<k));
		res = max(res , rec(k-1, tight) + (N-num_one[k])*(1ll<<k));
	}

	dp[k][tight] = res;
	return res;
}

int main(){
	cin >> N >> K;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	REP(i, 50){
		Kbin[i] = (K>>i&1);
		REP(j, N){
			num_one[i] += (A[j]>>i&1);
		}
	}

	REP(i, 55)REP(j, 2) dp[i][j] = -1;

	cout << rec(50, true) << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter output = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(input.readLine());
        int N = Integer.parseInt(st.nextToken());
      	int K = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(input.readLine());
        int[] arr = new int[N];
        int[] dp = new int[N+1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for(int i = 0; i<N; i++){
            arr[i] = Integer.parseInt(st.nextToken());
        }
        for(int i = 0; i<N; i++){
          for(int k = 1; k<K+1; k++){
            if(i+k<N) dp[i+k] = Math.min(dp[i+k], dp[i] + Math.abs(arr[i] - arr[i+k]));
          }
        }
        output.println(dp[N-1]);
      	output.close();
    }
}

Measured memory_bytes: 33676
#include<iostream>
#include<stdio.h>

int main(){
	int  a, b;
	int  d, r;
	double f;
	std::cin >> a;
	std::cin >> b;
	d = a / b;
	r = a%b;
	double x = a;
	double y = b;
	f = x / y;
	std::cout << d << " ";
	std::cout << r << " ";
	printf("%f\n",f);
}

Measured memory_bytes: 1232
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        ArrayList<String> param = new ArrayList<String>();
        
        for (int i = 0; i < k; i++) {
            int num = sc.nextInt();
            for (int h = 0; h < num; h++) {
                String input = sc.next();
                param.add(input);
            }
        }
        
        int fc = 0;
        for (int i = 1; i <= n; i++) {
            int count = 0;
            for (int h = 0; h < param.size(); h++) {
                
                if (Integer.parseInt(param.get(h)) == i) {
                    count++;
                }
            }
            if (count == 0) {
                fc++;
            }
        }
        
        System.out.println(fc);
    }
}
                    
            

Measured memory_bytes: 42024
N, W = map(int, input().split())
v = [0] * N
w = [0] * N

for i in range(N):
    v[i], w[i] = list(map(int, input().split()))

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
dp = [0 for _ in range(W+1)]

for i in range(N):
    for j in range(W+1):
        if j >= w[i]:
            dp[j] = max(dp[j], dp[j-w[i]] + v[i])
            #print(dp)
            pass

print(dp[W])



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


void solve(std::string b){
  if (b == "A") {
    cout << 'T' << endl;
  }
  if (b == "T") {
    cout << 'A' << endl;
  }
  if (b == "G") {
    cout << 'C' << endl;
  }
  if (b == "C") {
    cout << 'G' << endl;
  }
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string b;
    std::cin >> b;
    solve(b);
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

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

queue<vector<ll>> bfs;
char a[1010][1010];
int h,w;

void search(vector<ll> pos) {
    for (int i = 0; i < 4; i++) {
        int x = pos[0] + dx[i];
        int y = pos[1] + dy[i];
        if (x < 0 || x >= h || y < 0 || y >= w) {
            continue;
        }
        if (a[x][y] != '#') {
            a[x][y] = '#';
            bfs.push({x, y, pos[2] + 1});
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
            if (a[i][j] == '#') {
                bfs.push({i, j, 0});
            }
        }
    }
    ll ans;
    while(bfs.size()) {
        vector<ll> tmp = bfs.front();
        bfs.pop();
        search(tmp);
        ans = tmp[2];
    }
    
    
    cout<<ans<<endl;
}

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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 998244353
#define debug(x) cerr<<#x<<"="<<x<<'\n'

ll x;

bool check(ll a) {
	ll tmp=x;
	while (tmp%a==0) tmp/=a;
	return tmp%a==1;
}

int main(){
	scanf("%lld",&x);
	if (x==2) {
		puts("1");
		return 0;
	}
	int cnt=0;
	// factors of x
	for (ll i=2;i*i<=x;i++) {
		if (x%i) continue;
		if (check(i)) cnt++;
	}
	// factors of x-1
	for (ll i=2;i*i<=x-1;i++) {
		if ((x-1)%i) continue;
		cnt++;
		if (i*i!=x-1) cnt++;
	}
	printf("%d",cnt+2);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define N 101
using namespace std;

int g[N][N]; 
int d[N];
int f[N];
int n;
int times=0;
bool us[N];

//dfs
void dfs(int x){
  
  times++;
  d[x]=times;

  for(int i=1;i<=n;i++){
    if(g[x][i]==1 &&us[i]==false){
      us[i]=true;
      // cout <<"i "<<i<<endl;
      dfs(i);
    }
  } 
  f[x]=times=times+1;

}


int main(){
  
  int n2,data,u;

  //load n
  cin >>n;
  
  //initialize
  for(int i=0;i<N;i++){
    us[i]=false;
    for(int j=0;j<N;j++){
      g[i][j]=0;
    }
  }
  
  //load data
  for(int i=0;i<n;i++){
    scanf("%d%d",&u,&n2);
    for(int j=0;j<n2;j++){
      scanf("%d",&data);
      g[u][data]=1;
    }
  }
  
  //execute
  for(int i=1;i<=n;i++){
    if(us[i]==false) {
      us[i]=true;
      dfs(i);
    } 
 }
  //print
  for(int i=1;i<=n;i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }
  
  return 0;
}

Measured memory_bytes: 0
(let* ((s (read-line))
       (n (length s))
       (10^ (make-array (list n) :initial-element 1))
       (dp (make-array (list (1+ n)) :initial-element 0))
       (c (make-array (list 2019) :initial-element 0))
       (ans 0))
  ;
  (setf (aref c 0) 1)
  ;
  (loop :for i :from 1 :to (1- n)
        :do (setf (aref 10^ i) (mod (* (aref 10^ (1- i)) 10) 2019)))

  (loop :for i :downfrom (1- n) :to 0
        :do (setf (aref dp i)
                  (mod (+ (aref dp (1+ i))
                          (* (aref 10^ (- n i 1))
                             (- (char-code (aref s i)) #x30)))
                       2019))
        :do (incf (aref c (aref dp i))))
  (setf ans (loop :for i :from 0 :to 2018
                  :sum (/ (* (aref c i) (1- (aref c i))) 2)))
  (format t "~A~%" ans))


Measured memory_bytes: 30416
def C(x,y):
    M=1
    for i in range(1,x+y+2):
        M=M*i
    for i in range(1,x+2):
        M=M//i
    for i in range(1,y+1):
        M=M//i
    return M


N, A, B = map(int, input().split())
v = [int(i) for i in input().split()]
v.sort(reverse=True)
v.append(0)
S=0
p=0
for i in range(A,B+1):
    T=sum(v[:i])/i
    if S<T:
        S=T
        p=0
        x=0
        y=0
        for j in range(i-1):
            if v[i-j-2]==v[i]:
                x+=1
            else:
                break
        for j in v[i:]:
            if j==v[i-1]:
                y+=1
            else:
                break
        #print(i,x,y,"a")
        p+=C(x,y)
    elif S==T:
        x=0
        y=0
        for j in range(i-1):
            if v[i-j-2]==v[i]:
                x+=1
            else:
                break
        for j in v[i:]:
            if j==v[i-1]:
                y+=1
            else:
                break
        #print(i,x,y,"b")
        p+=C(x,y)
print(S)
print(p)



Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>

int main() {
	int n, k;
	cin >> n >> k;
	vector<int>a(n+k);
	rep(i, n) {
		cin >> a[i];
	}
	vector<double>b(n+k);

	rep(i, n) {
		b[i] = ((1 + double(a[i])) / 2);
		//cout << b[i] << endl;
	}
	double sum(0);
	double kk;
	sum = accumulate(b.begin(), b.begin()+k, 0.0);
	rep(i,n-1){
		if (i == 0) {
			kk = sum;
		}
		kk = kk - b[i] + b[i+k];
			//cout << buffer << endl;;
		
		sum = max(sum, kk);
	}
	cout << fixed<<setprecision(12)<<sum;
	return 0;
}

Measured memory_bytes: 4992
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		char a[][]=new char[n][n];
		char b[][]=new char[m][m];
		for(int i=0;i<n;i++)
		{
			String s=sc.next();
		for(int j=0;j<n;j++)
		{
			a[i][j]=s.charAt(j);
			
		}
		}
		for(int i=0;i<m;i++)
		{
			String s=sc.next();
		for(int j=0;j<m;j++)
		{
			b[i][j]=s.charAt(j);
			
		}
		}
		
		boolean ans=false;
		for(int i=0;i<n-m+1;i++)
		{
		for(int j=0;j<n-m+1;j++)
		{
			if(b[0][0]==a[i][j])
			{
				ans=ch(n,m,a,b,i,j);
				//System.out.println(i+" "+j+" "+b[0][0]+" "+a[i][j]);
			}
			if(ans) break;
		}
		if(ans) break;
		}
		//System.out.println(ans);
		if(ans) System.out.println("Yes");
		else System.out.println("No");
		
	}
	
	public static boolean ch(int n,int m,char a[][],char b[][],int i,int j)
	{
		int ii=i;
		for(int x=0;x<m;x++)
		{ 
			int jj=j;
			for(int y=0;y<m;y++)
			{
				if(b[x][y]!=a[ii][jj]) return false;
				jj++;
			}
			ii++;
		}
		return true;
	}
	
}


Measured memory_bytes: 35636
#include <stdio.h>

int main () {
	int n, a;
	1 < n < 10000;
	0 < a < 1000;
	scanf ("%d %d", &n, &a);
	if (n%500 <= a) {
		printf ("Yes");}
		else {
			printf ("No");
		}
	return 0;
	}

Measured memory_bytes: 128
q = int(input())

# エラストネスの篩
n = 10**5+1
flag = [True]*n
flag[1] = False
for i in range(4, n, 2): flag[i] = False
for i in range(3, int(n**0.5)+1, 2):
  if flag[i]:
    for j in range(i+i, n, i): flag[j] = False

# 2017に似た数の累積和
nums = [0]*n
for i in range(1,n):
  if i%2 == 1:
    if flag[i] and flag[(i+1)//2]: nums[i] = nums[i-1]+1
    else: nums[i] = nums[i-1]
  else: nums[i] = nums[i-1]

for _ in range(q):
  l,r = map(int, input().split())
  print(nums[r]-nums[l-1])

Measured memory_bytes: 10888