akhauriyash/Code-Regression huggingface dataset:
/*
 */
#include <iostream>
#include <algorithm>
#include <queue>
#define INF 200000

using namespace std;

struct edge {
  int to, cost;
};
typedef pair<int, int> P;

int iN;
int iM;
int iL;
int iK;
int iA;
int iH;
vector<edge> G[101];
bool bLa[101];

bool input() {
  int i, a, b, c;
  edge e;

  scanf("%d %d %d %d %d %d", &iN, &iM, &iL, &iK, &iA, &iH);
  if (iN == 0 && iM == 0 && iL == 0 && iK == 0 && iA == 0 && iH == 0) return false;

  fill(bLa, bLa + 101, false);
  for (i = 0; i < iL; i++) {
    scanf("%d", &a);
    bLa[a] = true;
  }


  for (i = 0; i < iN; i++) {
    G[i].clear();
  }
  for (i = 0; i < iK; i++) {
    scanf("%d %d %d", &a, &b, &c);
    e.cost = c;
    e.to = b;
    G[a].push_back(e);
    e.to = a;
    G[b].push_back(e);
  }

  return true;
}

void dijkstraQueue() {
  int i, j, output;
  priority_queue<P, vector<P> , greater<P> > que;
  int d[101][101];

  fill(d[0], d[0] + 101 * 101, INF);
  d[iA][iM] = 0;
  que.push(P(0, iA));

  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    for (j = 0; j <= iM; j++) {
      if (d[v][j] < p.first)
        continue;
      if (bLa[v]) {
        if (j + 1 <= iM && d[v][j + 1] > d[v][j] + 1) {
          d[v][j + 1] = d[v][j] + 1;
          que.push(P(d[v][j + 1], v));
        }
      }
      for (i = 0; i < (int) G[v].size(); i++) {
        edge e = G[v][i];
        if (j - e.cost >= 0 && d[e.to][j - e.cost] > d[v][j] + e.cost) {
          d[e.to][j - e.cost] = d[v][j] + e.cost;
          que.push(P(d[e.to][j - e.cost], e.to));
        }
      }
    }
  }
  output = d[iH][0];
  for (j = 1; j <= iM; j++) {
    output = min(output, d[iH][j]);
  }
  if (output != INF)
    printf("%d\n", output);
  else
    printf("Help!\n");
}

int main() {
  while(1) {
    if (!input()) break;
    dijkstraQueue();
  }
  return 0;
}

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

int main(){

	int n,m,count,tmp_count;

	while(true){
		scanf("%d %d",&n,&m);
		if(n == 0 && m == 0)break;

		count = n;
		int array[n];
		for(int i=0; i < n; i++)array[i] = 1;

		tmp_count = 0;
		for(int i=0;count > 1;){
			if(array[i] == 1){
				tmp_count++;
				if(tmp_count == m){
					array[i] = 0;
					count--;
					tmp_count = 0;
					i = (i+1)%n;
				}else{
					i = (i+1)%n;
				}
			}else{
				i = (i+1)%n;
			}
		}

		for(int i=0; i < n; i++){
			if(array[i] == 1)printf("%d\n",i+1);
		}

	}

    return 0;
}

Measured memory_bytes: 2620
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int cnt = 0;
        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();
            if (n == 0 && x == 0) {
                break;
            }
            for (int i = 1; i <= n - 2; i++) {
                for (int j = 2; j <= n - 1; j++) {
                    for (int k = 3; k <= n; k++) {
                        if (i >= j) {
                            j = i + 1;
                        }
                        if (i >= k) {
                            k = i + 1;
                        }
                        if (j >= k) {
                            k = j + 1;
                        }
                        if ((i + j + k) == x) {
                            cnt++;
                        }
                    }
                }
            }
             System.out.println(cnt);
             cnt = 0;
        }
       
    }

}

Measured memory_bytes: 26840
n = int(input())
c = input()
towhite = 0
tored = 0
#まずは石は全部白にすると考えた場合、赤を白にしないといけない数を計算（赤の数を数える）
for i in range(n):
    if c[i] == "R":
        towhite += 1
change = max(towhite, tored)
#仕切りを移動していく
for j in range(n):
    #仕切りを移動した先が赤なら変えなくていいからtowhiteから1引く。白なら仕切りの手前を赤に変えないといけないからtoredに1足す
    if c[j] =="R":
        towhite -= 1
    else:
        tored +=1
    #現在の仕切りでの操作数
    now = max(towhite, tored)
    #現在の仕切りでの操作数が少なくなったらchangeを更新
    change = min(change, now)

print(change)

Measured memory_bytes: 9420
import java.io.*;
import java.util.Set;
import java.util.TreeSet;
public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		String s = in.readLine();
		Set<Character> a  = new TreeSet<>();
		for (int i = 0; i < s.length(); i++) {
			a.add(s.charAt(i));
			if(a.size() == 4) break;
		}
		
		int x = 0;
		int y = 0;
		if(a.contains('N')) x++;
		if(a.contains('S')) x++;
		if(a.contains('W')) y++;
		if(a.contains('E')) y++;
		
		if(x % 2 == 0 && y % 2 == 0) System.out.println("Yes");
		else System.out.println("No");

	}
}


Measured memory_bytes: 23508
H,W = [int(x) for x in input().split()]
a = []
H2 = 0
W2 = 0
count = [0] * W
for i in range(H):
    l = list(input())
    if l != ["."]*W:
        a.append(l)
        H2 += 1
for i in range(W):
    flag = 1
    for j in range(H2):
        if a[j][i] != ".":
            flag = 0
            break
    count[i] = flag
for i in range(H2):
    an = []
    for j in range(W):
        if count[j] == 0:
            an.append(a[i][j])
    print("".join(an))



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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

int main(){
    string s;
    cin >> s;
    vector<int> distance_;

    int min_ = 200;
    REP(i, 26) {
        int cnt = 0;
        distance_.resize(0);
        REP(j, s.size()) {
            if(s[j] - 'a' == i) {
                distance_.push_back(cnt);
                cnt = 0;
            } else {
                cnt++;
            }
        }
        distance_.push_back(cnt);
        sort(distance_.begin(), distance_.end());
        min_ = min(min_, distance_[distance_.size() - 1]);
    }

    cout << min_ << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

vector<ll> cards;

ll find(ll node) {
  if (node == cards[node]) return node;
  ll root = find(cards[node]);
  cards[node] = root;
  return root;
}

void uni(ll a, ll b) {
  cards[find(b)] = find(a);
}

int main() {
  ll input(n, m);
  cards = vector<ll>(n + 1);
  REP(i, n + 1) cards[i] = i;
  REP(i, m) {
    ll input(x, y, z);
    uni(x, y);
  }

  set<ll> roots;
  for (auto v: cards) {
    roots.insert(find(v));
  }

  cout << roots.size() - 1 << endl;
}


Measured memory_bytes: 8736
a, b, x = map(int, input().split())

import math

theta1 = math.atan((b - x/a**2)*2/a)
theta2 = math.atan((a*b**2/(2*x)))
if b < a*math.tan(theta2):
    theta = theta2
else:
    theta = theta1

print(math.degrees(theta))

Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  char s;
  cin >> s;
  if (isupper(s)) {
    cout << 'A' << endl;
  } else {
    cout << 'a' << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int n, c;
    cin >> n >> c;
    vi s(n), t(n), u(n);
    rep(i, n) cin >> s[i] >> t[i] >> u[i];
    vector<vector<pii>> v(c);
    rep(i, n) {
        v[u[i]-1].pb(make_pair(s[i], t[i]));
    }
    vector<vector<pii>> v2(c);
    rep(i, c) {
        if(v[i].empty()) continue;
        sort(all(v[i]));
        v2[i].pb(v[i].front());
        REP(j, 1, v[i].size()) {
            if(v2[i].back().se == v[i][j].fi) {
                v2[i].back().se = v[i][j].se;
            }
            else {
                v2[i].pb(v[i][j]);
            }
        }
    }
    priority_queue<int,vector<int>,greater<int> > q;
    q.push(-1);
    int ans = 0;
    vector<pii> v3;
    rep(i, c) rep(j, v2[i].size()) v3.pb(v2[i][j]);
    sort(all(v3));
    rep(i, v3.size()) {
        if(q.top() < v3[i].fi) {
            q.pop();
            q.push(v3[i].se);
        }
        else {
            q.push(v3[i].se);
        }
        ans = max(ans, (int)q.size());
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4600
#include <stdio.h>
#include <stdlib.h>
#define N 200000

unsigned int a[N];

int L[N/2 + 2], R[N/2 + 2];

long long merge_sort(int *a, int l, int r){
int m  = (l+r)/2, count, i, j;
int n1, n2;
long long v1, v2, cnt = 0;
  if(l == r)
   return 0;

  v1 = merge_sort(a, l, m);
  v2 = merge_sort(a, m + 1, r);
  n1 = m-l+1;
  n2 = r - m;
  L[n1]  = R[n2] = 2000000000;
  for(count = l; count <= m; count++){
     L[count - l] = a[count];
  }
  for(count = m + 1; count <= r; count++){
    R[count - m - 1] = a[count];
  }
  for(i = 0, j = 0, count = l; count <= r; count++){
    if(L[i] <= R[j]){
     a[count] = L[i++];
    }
    else{
     a[count] = R[j++];
     cnt += n1 - i;
    }

  }

   return cnt + v1 + v2;
}

int main(int argc, char** argv){
int n, i = 0;
   scanf("%d", &n);

   for(i; i < n; i++)
    scanf("%d", &a[i]);


 printf("%lld\n", merge_sort(a, 0, n-1));

  return 0;
}

Measured memory_bytes: 2156
function main(input) {
  const args = input.split('\n');
  const S = args[0];
  const N = args[1];
  let ary = S.split('');
  let ans = 'No';
  
  for (let i = 0; i < ary.length; i++) {
    char = ary.splice(0, 1);
    ary.push(char[0]);
    
    chars = ary.join('');
    if (chars === N) { ans = 'Yes'; }
  }
  
  console.log(ans);
  
  
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29572
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()

    println(abc127a(a, b))
}

fun abc127a(a: Int, b: Int): Int {
    if (a >= 13) { return b }
    if (6 <= a && a <= 12) { return b / 2 }
    return 0
}


Measured memory_bytes: 29732
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n, d; cin >> n >> d;
	double x, y;
	int ans=0;
	REP(i,n){
		cin >> x >> y;
		if(sqrt(pow(x,2)+pow(y,2))<=d)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    int a[n], b[n];
    pair<int, int> p[n];
    rep(i, n) {
        cin >> a[i] >> b[i];
        p[i] = make_pair(b[i], a[i]);
    }
    sort(p, p + n);
    bool flag = true;
    ll sum = 0;
    rep(i, n) {
        sum += p[i].second;
        if (sum > p[i].first) {
            flag = false;
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 3328
import java.util.*;
class Main {
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		Dice dice = new Dice(stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt());
		String a = stdIn.next();
		for(int i = 0; i < a.length(); i++) {
			if(a.charAt(i) == 'N') {
				dice.TurnN();
			}
			else if(a.charAt(i) == 'W') {
				dice.TurnW();
			}
			else if(a.charAt(i) == 'E') {
				dice.TurnE();
			}
			else {
				dice.TurnS();
			}
		}
		System.out.println(dice.Top);
	}
	
	
}

class Dice {
	int Top; 
	int Bottom; 
	int N; 
	int S; 
	int W;
	int E; 
	Dice(int a, int b, int c, int d, int e, int f) {
		Top = a;
		S = b;
		E = c;
		W = d;
		N = e;
		Bottom = f;
	}
	public void TurnN() {
		int tmp = Top;
		Top = S;
		S = Bottom;
		Bottom = N;
		N = tmp;
	}
	public void TurnW() {
		int tmp = Top;
		Top = E;
		E = Bottom;
		Bottom = W;
		W = tmp;
	}
	public void TurnE() {
		int tmp = Top;
		Top = W;
		W = Bottom;
		Bottom = E;
		E = tmp;
	}
	public void TurnS() {
		int tmp = Top;
		Top = N;
		N = Bottom;
		Bottom = S;
		S = tmp;
	}
	
}

Measured memory_bytes: 17312
use std::cmp;

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
       a: usize,
       b: usize
    }
    for i in 0..cmp::max(a, b) {
        print!("{}", cmp::min(a, b))
    }
    println!()
}


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

using namespace std;

typedef pair<int,int> pii;
#define N 300000
#define P(x,y) make_pair(x,y)

int n;
multiset<int> s[N];
map<int,int> mp[N];
queue<pii> q;

void ins(int x,int y){
	if (x==y) return;
	++mp[x][y]; ++mp[y][x];
	if (mp[x][y]==2) q.push(P(x,y));
	s[x].insert(y); s[y].insert(x);
}

int main(){
	scanf("%d",&n);
	for (int i=1;i<n*2-1;++i){
		int x,y; scanf("%d%d",&x,&y);
		ins(x,y);
	}
	for (int i=1;i<n;++i){
		while (1){
			if (q.empty()){puts("NO"); return 0;}
			int x=q.front().first,y=q.front().second; q.pop();
			if (!mp[x][y]) continue;
			if (s[x].size()<s[y].size()) swap(x,y);
			for (int i:s[y]){
				mp[y][i]=mp[i][y]=0;
				s[i].erase(s[i].find(y));
				ins(i,x);
			}
			break;
		}
	}
	puts("YES");
	
	return 0;
}
			

Measured memory_bytes: 76032
#include<stdio.h>
int main(void)
{
    int i,j,ans=0,k[300]={0},u[300]={0},p[300]={0},c[300]={0};
    char kb[305];
    scanf("%s",kb);
    for(i=0;;i++){
        if(kb[i]=='\0') break;
        if(kb[i]=='K'||kb[i]=='U'||kb[i]=='P'||kb[i]=='C')
        {
            for(j=0;;j++)
            {
                if(kb[i]=='K'&&k[j]==0)
                {
                    k[j]=1;
                    break;
                }
                else if(kb[i]=='U'&&u[j]==0)
                {
                    u[j]=1;
                    break;
                }
                else if(kb[i]=='P'&&p[j]==0)
                {
                    p[j]=1;
                    break;
                }
                else if(kb[i]=='C'&&c[j]==0)
                {
                    c[j]=1;
                    break;
                }
            }
        }
    }

    for(i=0;;i++)
    {
        if(k[i]==1&&u[i]==1&&p[i]==1&&c[i]==1)
        {
            ans++;
        }
        else break;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;

ll i,j,k;


ll mo(ll p){
    if(p>=0)return p%13;
    return ((p%13)+13)%13;
}


int main(){
   string N;
   cin>>N;
   ll L=N.length();

   ll dp[L][13];
   ll rui[L];
   rui[0]=1;
   rep(i,L){
       if(i>0)rui[i]=(rui[i-1]*10)%13;
       rep(j,13){
           if(i==0){
               if(N[L-1]=='?'){
                   if(j<10)dp[i][j]=1;
                   else dp[i][j]=0;
               }
               else{
                   int c=N[L-1]-'0';
                   if(j==c)dp[i][j]=1;
                   else dp[i][j]=0;
               }
           }
           else{
               
               if(N[L-i-1]=='?'){
                  ll a=0;
                  rep(k,10){
                      a=(a+dp[i-1][mo(j-rui[i]*k)]);
                      a%=mod;
                  }
                  dp[i][j]=a;
                  
               }
               else{
                   int c=N[L-i-1]-'0';
                   dp[i][j]=dp[i-1][mo(j-rui[i]*c)];
               }
           }
       }
   }
   if(dp[L-1][5]>=0)cout<<dp[L-1][5]%mod<<endl;
   else cout<<dp[L-1][5]%mod+mod<<endl;
}

Measured memory_bytes: 11392
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n, d; cin >> n >> d;
	int ans = (n + 2 * d) / (2 * d + 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
x = int(input())

if x <= 599:
  print(8,"\n")
elif x <= 799:
  print(7,"\n")
elif x <= 999:
  print(6,"\n")
elif x <= 1199:
  print(5,"\n")
elif x <= 1399:
  print(4,"\n")
elif x <= 1599:
  print(3,"\n")
elif x <= 1799:
  print(2,"\n")
elif x <= 1999:
  print(1,"\n")

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

int main() {
  int a, b;
  cin >> a >> b;
  
  int M = max(a,b);
  int m = min(a,b);
  
  for (int i = 0; i < M; i++){
    cout << m;
  }
  
  cout << endl;
}

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

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

  map<string,int> dict;
  
  int mx =0;
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    dict[S] ++;
    mx=max(mx,dict[S]);
  }
  
  for (auto itr: dict){
        if((itr.second) == mx){
          cout<<itr.first<<'\n';
        }
    }  
}

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

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

void call(int n) {
    for (int x = 1; x <= n ; x++) {
        if ( x % 3 == 0 || has3(x) == true ) {
            cout << " " << x ;
        }
    }
    cout << endl;
}

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

    call(n);

    return 0;
}

Measured memory_bytes: 3040
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        int count0 = 0;
        int count1 = 0;
        for(int i=0; i<s.length; i++) {
            if(s[i].equals("0")) count0++;
            else count1++;
        }
        if(count0 >= count1) System.out.println(count1*2);
        else System.out.println(count0*2);
    }
}


Measured memory_bytes: 33072
#include<bits/stdc++.h>
using namespace std;
int N,ans;
char S[100];
int main(){
    scanf("%d",&N);
    scanf(" %s",&S);

    for(int x=0;x<N-2;x++){
        if(S[x]=='A'&&S[x+1]=='B'&&S[x+2]=='C')
            ans++;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import           Control.Monad.Trans.State.Strict
import qualified Data.ByteString.Char8            as B
import           Data.Char
import           Data.Coerce
import qualified Data.List                        as L

main :: IO ()
main = do
    n <- readLn
    lrs <- L.unfoldr (runParser parseInt2) <$> B.getContents
    print $ solve n lrs

solve :: Int -> [(Int, Int)] -> Int
solve n lrs = goL 0 0 sortedR sortedL `max` goR 0 0 sortedR sortedL
  where
    (ls, rs) = unzip lrs
    sortedL = L.sortBy (flip compare) ls
    sortedR = L.sort rs
    goR !res !cur (l:ls) (r:rs)
        | cur <= r = goL (res + r - cur) r (l:ls) rs
    goR res cur _ _ = res + abs cur
    goL !res !cur (l:ls) (r:rs)
        | l <= cur = goR (res + cur - l) l ls (r:rs)
    goL res cur _ _ = res + abs cur

type Parser a = StateT B.ByteString Maybe a

runParser :: Parser a -> B.ByteString -> Maybe (a, B.ByteString)
runParser = runStateT

parseInt :: Parser Int
parseInt = coerce $ B.readInt . B.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = (,) <$> parseInt <*> parseInt

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = (,,) <$> parseInt <*> parseInt <*> parseInt


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

int main()
{
	string s;
	cin >> s;

	bool isBad = false;
	for (int i = 0; i < 3; ++i) {
		if (s[i] == s[i + 1]) {
			isBad = true;
			break;
		}
	}

	if (isBad) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}

	return 0;
}

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

#define MOD 1000000007

typedef long long ll;

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

ll dp[100010];

int main(){
	int n,m;
	cin>>n>>m;
	vector<int>a(m);
	vector<bool>ok(n+1,true);
	for(int i=0;i<m;i++){
		cin>>a[i];
		ok[a[i]]=false;
	}
	dp[0]=1;
	for(int i=0;i<=n;i++){
		if(ok[i]){
			dp[i+1]+=dp[i];
			dp[i+1]%=MOD;
			dp[i+2]+=dp[i];
			dp[i+2]%=MOD;
		}
	}
	cout<<dp[n]%MOD<<endl;
	return 0;
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main()
{
	int n,x[3];
	cin>>n;
	for(int i=0;i<3;i++)
	{
		x[i]=n%10;
		n/=10;
	}
	for(int i=2;i>=0;i--)
	cout<<10-x[i];
 } 

Measured memory_bytes: 256
import math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]


def distance(a, b):
  dist = 0.0
  for i in range(len(a)):
    dist += pow(a[i]-b[i], 2)
  return math.sqrt(dist)

ans = 0
for k in range(N-1):
  for l in range(k+1, N):
    if distance(X[k], X[l]).is_integer():
      ans += 1
print(ans)

Measured memory_bytes: 3064
import copy
n, m = map(int, input().split())
adjacent_list = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    adjacent_list[a].append(b)
    adjacent_list[b].append(a)
ans = 0
def dfs(node,f):
    f.add(node)
    global ans
    if len(f) == n:
        ans += 1
    else:
        for i in adjacent_list[node]:
            if i not in f:
                k = copy.deepcopy(f)
                dfs(i,k)
dfs(1,set())
print(ans)

Measured memory_bytes: 56408
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<limits.h>
#include<float.h>

#define NUM 100001

int main(){
	char c[NUM];
	int bw = 0, wb = 0;
	scanf("%s\n", c);
	for(int i=0; c[i]; i++){
		if(i%2){
			if(c[i]=='0') wb++;
			else bw++;
		} else {
			if(c[i]=='0') bw++;
			else wb++;
		}
	}
	if(bw < wb)
		printf("%d\n", bw);
	else
		printf("%d\n", wb);
	return 0;
}




Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int a[100001], y[100001],ballNum[100001];
bool can[100001];
signed main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int minu = min(a[i], a[i + 1]);
		if ((a[i] - minu) % 2 == 1 && minu !=0) {
			minu -= 1;
		}
		ans += minu;
		a[i] -= minu;
		a[i + 1] -= minu;
		ans += a[i] / 2;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
/*
 * https://atcoder.jp/contests/abc144/tasks/abc144_b
 */
#include <bits/stdc++.h>
 
using namespace std;

#define ll long long
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

const int MOD = 1e9 + 7;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    string a;
    REPS(i, 1, 10) {
        REPS(j, 1, 10) {
            if(i * j == n) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
ca = [0]*n
for i in range(n):
    ca[i] = list(map(int,input().split()))
ans = 10**10
for i in range(2**n):
    s = [0]*m
    c = 0
    for j in range(n):
        if (i>>j)&1:
            c += ca[j][0]
            for k in range(1,m+1):
                s[k-1] += ca[j][k]
    s = sorted(s)
    if s[0] >= x:
        ans = min(ans,c)
if ans == 10**10:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();
		//????????¶??\???
		if(0<=x-r && 0<=y-r && x+r<=W && y+r<=H){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int main(void){
  int k, x;
  cin >> k >> x;
  cout << (500*k>=x?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int s;
  vector<int> b;
for (int i = 0; i < n; i++) {
  cin >> a.at(i);
  if (a.at(i) == i + 1){s++;}
  else{b.push_back(s);
       s = 0;}
}
  b.push_back(s);
  int r;
  r = b.size();
  int m = 0;
  for (int i = 0; i < r; i++) {
    m += (b.at(i) + 1) / 2;
  }
  cout << m << endl;
}

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

int main(){
    std::string s;
    std::string p;
    std::string ans; 
    int check;
    
    std::cin>>s>>p;
    s +=s;
        check=s.find(p);
        
        if(check==std::string::npos){
            ans="No";
        }else{
            ans="Yes";
        }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <cstring>
using namespace std;
int main(){
  int n;
  double x,sum=0.0;
  char s[10];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x >> s;
    if(!strcmp(s,"BTC")) {
      sum+=380000.0*x;}
    else {
          sum+=x;}
  }
  cout << sum;
  return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var a = ReadInt();
            WriteLine(n * n - a);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    int N;
    cin >> N;
    int bestMin = INF;
    for (int i = 0; i <= 11; ++i) {
        if (N <= i*1000 and bestMin >= abs(N - i*1000)) {
            bestMin = abs(N - i*1000);
        }
    }
    cout << bestMin << endl;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
using namespace std;
typedef long long ll;
int main() 
{
    fast;
    ll t;
    cin>>t;
    ll flg=0;
    while(t)
    {
        ll rem = t%10;
        if(rem==7)
        {
            flg=1;
            cout<<"Yes";
            break;
        }
        t/=10;
    }
    if(flg==0)
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3656
h,w,k,*S=open(0).read().split()
h,w=int(h),int(w)
c,n=0,0
for s in S:
  l,r=-1,s.find('#')
  n+=1
  if r==-1:continue
  t=[]
  while r!=-1:
    c+=1
    t+=[c]*(r-l)
    l,r=r,s.find('#',r+1)
  t+=[c]*(w-l-1)
  for i in range(n):
    print(*t)
  n=0
for i in range(n):
  print(*t)

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

using namespace std;

int n, x[1005];

int main() {
	x[0] = 1;
	for (int i = 0; i <= 100; i++)
		if (x[i])
			x[i + 4] = x[i + 7] = 1;
	scanf("%d", &n);
	printf(x[n] ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char s[100002];
  int i,min=-1,max=-1;
  scanf("%s",s);
  int n=strlen(s);
  for(i=0;i<n-1;i++){
    if(s[i]==s[i+1]){
      min=i+1;
      max=i+2;
    }
    else if(s[i]==s[i+2]){
      min=i+1;
      max=i+3;
    }
  }
  printf("%d %d\n",min,max);
  return 0;
}


Measured memory_bytes: 1832
n = int(input())
d_list = input().split()
d_list = [int(x) for x in d_list]

m = int(input())
t_list = input().split()
t_list = [int(x) for x in t_list]

from collections import Counter

count_d = Counter(d_list)
count_t = Counter(t_list)

check = 0
for key, value in count_t.items():
    if count_d[key] < value:
        check = 1
        break

if check == 0:
    print("YES")
else:
    print("NO")
    

Measured memory_bytes: 56788
n = int(input())
a = list(map(int,input().split()))
q = int(input())
b = [0] * q
c = [0] * q
ans = sum(a)
number = [0] * 100001
for i in range(q):
    b[i],c[i] = map(int,input().split())

for i in range(n):
    number[a[i]] += 1

for i in range(q):
    if number[b[i]] > 0:
        ans += (c[i] - b[i]) * number[b[i]]
        number[c[i]] += number[b[i]]    
        number[b[i]] = 0
    print(ans)

Measured memory_bytes: 21948
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
#include<math.h>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int A,B,C; cin >> A >> B >> C;
    int d = A-B;
    int ans = max(C-d,0);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
 
int main() {
  int n, a, b, ans = 0;
  //string s;
  cin >> a;
  //vector<int> a(n);
  //if(1) {}
  //rep(i, n)
  cout << (a + 1) / 2 << endl;
}

Measured memory_bytes: 256
a,b,ab,x,y = gets.chomp.split(" ").map(&:to_i)
z = 0
if x > y
  z = x
else
  z = y
end

count = 10**10
for i in 0..z
  if x - i > 0 && y - i > 0
    if count > a*(x - i) + b*(y - i) + ab*i*2
      count =  a*(x - i) + b*(y - i) + ab*i*2
    end
  elsif x - i > 0
    if count > a*(x - i) + ab*i*2
      count = a*(x - i) + ab*i*2
    end
  elsif y - i > 0
    if count > b*(y - i) + ab*i*2
      count = b*(y - i) + ab*i*2
    end
  else
    if count > ab*i*2
      count = ab*i*2
    end
  end
end

print count


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
priority_queue<ll, vector<ll>, greater<ll>> que;
vector<P> vec;
ll n, k, t, d, sum, shu, a[100010], ans;
bool jud[100010];
int main(void){
    // Your code here!
    cin >> n >> k;
    for (ll i = 0; i < n; i++) {
        cin >> t >> d;
        vec.push_back(P(d, t));
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    for (ll i = 0; i < k; i++){
        if (jud[vec[i].second]){
            que.push(vec[i].first);
        } else {
            jud[vec[i].second] = true;
            shu++;
        }
        sum += vec[i].first;
    }
    a[shu] = sum;
    for (ll i = k; i < n; i++){
        if (jud[vec[i].second]) continue;
        if (que.size() == 0) continue;
        jud[vec[i].second] = true;
        shu++;
        a[shu] = a[shu - 1] + vec[i].first - que.top();
        que.pop();
    }
    for (ll i = 0; i <= n; i++) {
        if (a[i] == 0) continue;
        ans = max(ans, a[i] + i * i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] == s[i+1]) {
            cout << "Bad" << endl;
            return;
        }
    }
    cout << "Good" << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void start()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
}
signed main()
{
	start();
	int x,n;
	cin>>x>>n;
	if(n==0)
	{
		cout<<x<<"\n";
		return 0;
	}
	int f=0;
	unordered_map<int,int>m;
	int arr[n],i;
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
		m[arr[i]]++;
		if(arr[i]==x)
			f=1;
	}
	if(f==0)
	{
		cout<<x<<"\n";
		return 0;
	}
	i=x-1;int j=x+1;
	while(true)
	{
		if(m[i]==0 && m[j]==0)
		{
			cout<<i<<"\n";
			return 0;
		}
		else if(m[i]==0)
		{
			cout<<i<<"\n";return 0;
		}
		else if(m[j]==0)
		{
			cout<<j<<"\n";
			return 0;
		}
		i--;
		j++;
	}
	return 0;
}


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

int main(){
	long long int test=1;
	//cin>>test;
	while(test--){
	    int r;
	    cin>>r;
	    cout<<(long double)2.0*r*3.14159265358979<<endl;
	}
	return 0;
}

Measured memory_bytes: 3776
/// Solution to https://atcoder.jp/contests/abc144/tasks/abc144_c
/* ------
    Atcoder.jp @betuyash
    -------
    */
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" "<<x<<endl;
#define int long long
void Solve_Case()
{
     int n;
     cin >> n;
    int Answer = 1e18;
     for(int i=1LL;i<=sqrt(n);i++)
     {
         if(n % i == 0)
         {
              Answer = min(Answer , n/i - 1 + i - 1);
         }
     }
     cout << Answer;
}
signed main()
{
    int TestCases = 1;
    /// cin >> TestCases;
    while(TestCases--)
    {
        Solve_Case();
    }
}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    A = []
    A.append(int(input()))

    A.append(int(input()))

    A.append(int(input()))

    A.append(int(input()))

    A.append(int(input()))

    k = int(input())


    if A[4]-A[0] >k:
        print(":(")
    else:
        print("Yay!")

if __name__ == "__main__":
    main()


Measured memory_bytes: 61792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N,M;
  cin>>N>>M;
  vector<vector<int>> A(M);
  rep(i,M){
    int X;
    cin>>X;
    rep(j,X){
      int Y;
      cin>>Y;
      A[i].push_back(Y);
    }
  }
  vector<int> P(M);
  rep(i,M) cin>>P[i];
  int ans=0;
  vector<vector<int>> S(N);
  rep(i,M) rep(j,A[i].size()){
    S[A[i][j]-1].push_back(i);
  }
  rep(i,pow(2,N)){
    int PP[M]={};
    rep(j,N){
      int E=i;
      E&=(int)pow(2,j);
      if(E){
        rep(k,S[j].size()){
          PP[S[j][k]]^=1;
        }
      }
    }
    int a=1;
    rep(j,M) a*=(P[j]==PP[j]);
    if(a) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
program main
  implicit none

  integer(8), allocatable :: wv(:,:), dp(:,:)
  integer(8) :: n, wmax, i, j

  read(*,*) n, wmax

  allocate(wv(2,n))
  allocate(dp(n,wmax))

  read(*,*) wv

  do i = 1, n
     do j = 1, wmax
        dp(i,j) = -1
     end do
  end do

  do j = 1, wmax
     if(j - wv(1,1) >= 0) then
        dp(1,j) = wv(2,1)
     else
        dp(1,j) = 0
     end if
  end do
     
  
  do j = 1, wmax
     do i = 2, n
        if(j - wv(1,i) >= 0) then
           if(j - wv(1,i) == 0) then
              dp(i,j) = max(dp(i,j), 0 + wv(2,i))
           else
              dp(i,j) = max(dp(i,j), dp(i-1,j-wv(1,i)) + wv(2,i))
           end if
        end if
        
        dp(i,j) = max(dp(i,j), dp(i-1, j))
     end do
  end do

  write(*,*) dp(n,wmax)

end program main

           
  
  
  


Measured memory_bytes: 78336
#include <cstdio>

int apply(int &cur, int c, int d)
{
	if (c == 0) return 0;
	if (cur + d < 10)
		return apply(cur += d, c - 1, d) + 1;
	return apply(cur += d - 9, c - 1, d) + 2;
}

int main()
{
	int m; scanf("%d", &m);
	int cur = -1;
	long long res = 0;
	for (int i = 0; i < m; ++i)
	{
		int d; scanf("%d", &d);
		long long c; scanf("%lld", &c);
		if (cur == -1)
			cur = d, --c;
		res += apply(cur, c % 9, d) + (c / 9) * (9 + d);
	}
	printf("%lld\n", res);
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

void solve() {
    ll k;
    string s;
    cin >> k >> s;
    if(s.size() > k) s = s.substr(0, k) + "...";
    cout << s << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3580
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nx = readln.split.to!(int[]);
    auto N = nx[0];
    auto X = nx[1];
    int r = 1, d;
    foreach (l; readln.split.to!(int[])) {
        d += l;
        if (d > X) break;
        ++r;
    }
    writeln(r);
}

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

using namespace std;

int n, k;
long long a[100100];
long long f[100100];

int main () {
    cin >> n >> k;
    for ( int i = 1; i <= n; i++) {
        cin >> a[i]; f[i] = pow(10, 9);
    }
    f[1] = 0;
    for ( int i = 2; i <= n; i++) {
        for ( int j = 1; j <= k && i - j >= 1; j++) {
            f[i] =  min(f[i], f[i - j] + abs(a[i] - a[i - j]));
        }
        //cout <<"i = " << i << " f[i] = " << f[i] << endl;
    }
    cout << f[n];
}


Measured memory_bytes: 1792
// Problem: B - Substring
// Contest: AtCoder - AtCoder Beginner Contest 177
// URL: https://atcoder.jp/contests/abc177/tasks/abc177_b
// Parsed on: 2020-08-29 17:30:02
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

#define fastio  ios_base::sync_with_stdio(false); cin.tie(0);

using namespace std;

int main()
{
	string s,t;
	cin>>s>>t;
	int ans = t.size();
	for(int a=0;a<s.size() - t.size()+1;a++)
	{
		auto ster = s.substr(a, t.size());
		int subans = t.size();
		for(int aa=0;aa<t.size();aa++)
		{
			if(ster[aa] == t[aa]) subans--;
		}
		
		if(subans < ans) ans = subans;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> p(n); 
  rep(i, k) {
    int d;
    cin >> d;
    rep(j, d) {
      int x;
      cin >> x;
      p[x-1]++;
    }
  }
  int ans = 0;
  rep(i, n) {
    if (p[i] == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

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

  if (k == 1) {
    int ans = 0;
    for (int i = 1; i < n; i ++) {
      ans += abs(a[i] - a[i-1]);
    }
    cout << ans << endl;
    return 0;

  } else {
    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i ++) {
      dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]), dp[i-2] + abs(a[i]-a[i-2]));
      for (int j = 3; j <= k && j <= i; j ++) {
        dp[i] = min(dp[i], dp[i-j] + abs(a[i]-a[i-j]));
      }
    }
    cout << dp[n-1] << endl;
  }
}


Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;
int min = 1000000;

int main(){
	int a, b, c, d, l;
	cin >> a >> b >> c >> d;
	l = abs(c - a);
	if(l <= d){
		cout << "Yes" << endl;
	}else if(abs(a - b) <= d && abs(b - c) <= d){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
q = int(input())
M = list(map(int,input().split()))

S = set([])
for i in range(2<<n):
    num = 0
    for j in range(n):
        bit = (i>>j) & 1
        num += bit * A[j]
    S.add(num)

for m in M:
    if m in S:
        print('yes')
        continue
    print('no')



Measured memory_bytes: 5652
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

const int MAXN = 1e5 + 10;
int N, M;
vector<int> adj[MAXN], _1, _2;
bool vis[MAXN];

inline void Dfs(int x) {
	_1.push_back(x); vis[x] = 1;
	for(auto y: adj[x])
		if(!vis[y])
			return Dfs(y);
}

int main() {
	register int i; int x, y;
	scanf("%d%d", &N, &M);
	for(i = 1; i <= M; ++i)
		scanf("%d%d", &x, &y),
		adj[x].push_back(y), adj[y].push_back(x);
	Dfs(1); swap(_1, _2); Dfs(1);
	printf("%d\n", (int) (_1.size() + _2.size() - 1));
	reverse(_2.begin(), _2.end());
	for(auto x: _2) if(vis[x]) vis[x] = 0, printf("%d ", x);
	for(auto x: _1) if(vis[x]) vis[x] = 0, printf("%d ", x);
	return 0;
}

Measured memory_bytes: 7928