akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
 
using namespace std;
 
#define eb emplace_back
#define pb push_back
#define MP make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define rep(i,j,n) for (int i = j; i < n; ++i)
#define repn(i,j,n) for (int i = j; i <= n; ++i)
#define revn(i,j,n) for (int i = j; i >= n; --i)
#define sz(i) i.size()
#define mem(i,v) memset(i,v,sizeof(i))
#define all(v) v.begin(), v.end()
#define endl '\n'
#define int long long
#define INF 1e18
#define ss second
#define ff first

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int mod=1e9+7;
//const int mod=998244353;
const int up=1e5+10;
const int MAXN=1e5+10;
int par[up];

int find(int x)
{
    if(par[x]==x)
        return x;
    else
        return par[x]=par[find(par[x])];
}

// int merge(int u,int v)
// {
//     int x=find(u);
//     int y=find(v);
//     if(x!=y)
//     {
//         if(size[x]<=size[y])
//         {
//             par[x]=y;
//         }
//     }
// }
const int chk=1e18;
int n,k,a[up];
int s[up];

void solve()
{
    int n,ans=1;
    cin>>n; 
    int f=0;
    repn(i,1,n)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            f=1;
        }
    }
    //cout<<f<<endl;
    sort(a+1,a+n+1);
    if(f==1)
    {
        cout<<0<<endl;
        return;
    }
    repn(i,1,n)
    {
        if(ans*a[i]>chk || ans*a[i]<ans)
        {
            //cout<<ans*a<<endl;
            cout<<-1<<endl;
            return;
        }
        ans=ans*a[i];
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}

int32_t main()
{
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}



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

int main() {
  int N;
  cin >> N;
  int c=N%10;
  int t=N/10;
  // ここにプログラムを追記
  while(t>0){
      c+=t%10;
      t/=10;
      }
  if (N%c ==0){
  cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
y, m, d = map(int, input().split('/'))
a = 'TBD'
if y <= 2018:
  a = 'Heisei'
if y == 2019 and m <= 3:
  a = 'Heisei'
if y == 2019 and m == 4 and d <= 30:
  a = 'Heisei'
print(a)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

struct data_t {
	int ID;
	int correct;
	int time;

	bool operator<( const data_t& right ) const {
		if ( correct == right.correct) {
			if ( time == right.time ) {
				return ( ID > right.ID );
			}
			else {
				return ( time < right.time );
			}
		}
		else {
			return ( correct > right.correct );
		}
	}
};


int main(void) {
	int M,T,P,R;
	cin >> M;
	cin >> T;
	cin >> P;
	cin >> R;

	while (M!=0||T!=0||P!=0||R!=0) {
		std::vector<data_t> data(T);
		std::vector< std::vector<int> > wrong(T, std::vector<int>(P,0));

		for (int i = 0; i < T; i++) {
			data[i].ID = i+1;
			data[i].time = 0;
			data[i].correct = 0;
		}

		int m,t,p,r;
		for (int i = 0; i < R; i++) {
			cin >> m;
			cin >> t;
			cin >> p;
			cin >> r;
			
			if (r == 0) {
				data[t-1].correct++;
				data[t-1].time += m + (20 * wrong[t-1][p-1]);
			}
			else {
				wrong[t-1][p-1]++;
			}
		}

		std::sort(data.begin(), data.end());

		for (int i = 0; i < T; i++) {
			if (i == T-1) {
				cout << data[i].ID << endl;
			}
			else {
				if ( (data[i].correct == data[i+1].correct) && (data[i].time == data[i+1].time) ) {
					cout << data[i].ID << "=";
				}
				else {
					cout << data[i].ID << ",";
				}
			}
		}

		cin >> M;
		cin >> T;
		cin >> P;
		cin >> R;

	}

	return 0;
}

Measured memory_bytes: 3156
#!/usr/bin/env python3
#ABC123 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = I()
b = I()
c = I()
d = I()
e = I()
m = min(a,b,c,d,e)
ans = math.ceil(n/m) + 4
print(ans)


Measured memory_bytes: 38384
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 62;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
constexpr long long mod = 998244353LL;
const long double PI = acos(-1);

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int W, H;

int dfs(int cur, int h, int w, vector<vector<int>> &a) {
	int res = inf;
	if (cur > 10) return inf;
	if (h + 1 < H and a[h + 1][w] != 1) {
		for (int i = h; i < H - 1; i++) {
			if (a[i + 1][w] == 3) {
				return 1;
			}
			if (a[i + 1][w] == 1) {
				a[i + 1][w] = 0;
				chmin(res, 1 + dfs(cur + 1, i, w, a));
				a[i + 1][w] = 1;
				break;
			}
		}

	}
	if (h > 0 and a[h - 1][w] != 1) {
		for (int i = h; i > 0; i--) {
			if (a[i - 1][w] == 3) {
				return 1;
			}
			if (a[i - 1][w] == 1) {
				a[i - 1][w] = 0;
				chmin(res, 1 + dfs(cur + 1, i, w, a));
				a[i - 1][w] = 1;
				break;
			}
		}
	}
	if (w + 1 < W and a[h][w + 1] != 1) {
		for (int i = w; i < W - 1; i++) {
			if (a[h][i + 1] == 3) {
				return 1;
			}
			if (a[h][i + 1] == 1) {
				a[h][i + 1] = 0;
				chmin(res, 1 + dfs(cur + 1, h, i, a));
				a[h][i + 1] = 1;
				break;
			}
		}
	}
	if (w > 0 and a[h][w - 1] != 1) {
		for (int i = w; i > 0; i--) {
			if (a[h][i - 1] == 3) {
				return 1;
			}
			if (a[h][i - 1] == 1) {
				a[h][i - 1] = 0;
				chmin(res, 1 + dfs(cur + 1, h, i, a));
				a[h][i - 1] = 1;
				break;
			}
		}
	}
	return res;
}
void solve() {
	scanf("%d %d", &W, &H); if (W == 0 and H == 0) exit(0);
	vector<vector<int>> a(H, vector<int>(W)); for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) scanf("%d", &a[i][j]);
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
		if (a[i][j] == 2) {
			int res = dfs(0, i, j, a);
			if (res > 10) res = -1;
			printf("%d\n", res);
			return;
		}
	}

}
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3268
#include <stdio.h>

main(){

  int i, N;

  scanf("%d", &N);

  int A[N+1], key, j, p;

  for(i = 0; i < N; i++){
    scanf("%d", &A[i]);
  }
  for(i = 1; i < N+1; i++){
    for(p = 0; p < N; p++){
      if(p > 0) printf(" ");
      printf("%d", A[p]);
    }
    printf("\n");
    key = A[i];
    j = i - 1;
    while( j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
      A[j+1] = key;
    }
  }
  return 0;
}

Measured memory_bytes: 604
# -*- coding:utf-8 -*-
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

x, y = map(int,input().split())

flag = 0
for i in range(len(a)):
    if a[i] == x:
        flag = 1

for i in range(len(b)):
    if b[i] == x:
        flag = 2

for i in range(len(c)):
    if c[i] == x:
        flag = c

result = 0        
if flag == 1:
    for i in range(len(a)):
        if a[i] == y:
            result = 1
elif flag == 2:
    for i in range(len(b)):
        if b[i] == y:
            result = 1
elif flag == 3:
    for i in range(len(c)):
        if c[i] == y:
            result = 1

if result == 1:
    print('Yes')
elif result == 0:
    print('No')
    

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000000
#define MAX 200001
#define MOD 1000000007

void dfs(int s, Graph &G, vector<int> &visited, vector<ll> &cnt){
    visited[s] = 1;
    cnt[(s - 1) / 100000] += 1;
    for(auto v: G[s]){
        if(visited[v]) continue;
        dfs(v, G, visited, cnt);
    }
}

int main(){
    int N;
    ll ans = 0;
    cin >> N;
    vector<vector<int>> G(200005);
    for(int i = 0; i < N; i++){
        int x, y;
        cin >> x >> y;
        y += 100000;
        G[x].push_back(y);
        G[y].push_back(x);
    }   
    vector<int> visited(200005, 0);
    for(int i = 0; i < 200001; i++){
        if(visited[i]) continue;
        vector<ll> cnt(2, 0);
        dfs(i, G, visited, cnt);
        ans += cnt[0] * cnt[1];
    }
    cout << ans - N << endl;
}

Measured memory_bytes: 14696
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long
#define pai 3.1415926535897932384626433832795028841971693
int compare(const void *a, const void *b){
  return (*(ll int *)a)- (*(ll int *)b);
}
 
 
int main(){
  ll int ans=0;
  ll int n,i;
  scanf("%lld",&n);
  ll int a[n];
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
    ans^=a[i];
  }
  for(i=0;i<n;i++){
    printf("%lld\n",ans^a[i]);
  }
  return 0;
}  

//XORは同じものを消し合わせて考えることができる

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


int main() {
    int h,w;
    cin >> h >> w;
    vector<int> cnt(26,0);
    rep(i,h)rep(j,w){
        char a;
        cin >> a;
        cnt[a -'a'] ++;
    }
    int four = 0,two = 0;
    rep(i,26){
        four += cnt[i]/4;
        cnt[i] %= 4;
        two += cnt[i]/2;
    }

    four -= (h/2) * (w/2);
    if(four < 0){
        cout << "No" << endl;
        return 0;
    }
    two += four * 2;

    if(h%2 ==1) two -= w/2;
    if(w%2 ==1) two -= h/2;

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

    
}

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

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

H, W = map(int, input().split())
edge = dict()

for i in range(10):
    edge[i] = list(map(int, input().split()))

for k in range(10):
    for i in range(10):
        for j in range(10):
            edge[i][j] = min(edge[i][j], edge[i][k] + edge[k][j])

res = 0
for h in range(H):
    A = list(map(int, input().split()))
    for a in A:
        if a != -1:
            res += edge[a][1]

print(res)


Measured memory_bytes: 9160
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
  int i;
  int n;
  while(cin>>n&&n){
    long long a=0;
    for(i=0;i<n;++i){
      int p;
      cin>>p;
      a+=p;
    }
    int b[65000];
    for(i=0;i<n-1;++i)
      cin>>b[i];
    sort(b,b+n-1,greater<int>());
    long long mx=0;
    for(i=0;i<n;++i){
      mx=max(mx,(long long)(n-i)*a);
      a+=b[i];
    }
    cout<<mx<<endl;
  }
  return 0;
}

Measured memory_bytes: 1424
# frozen_string_literal: true

suit_map = { 'S' => 0, 'H' => 1, 'C' => 2, 'D' => 3 }
suits = %w[S H C D]
cards = Array.new(4).map { Array.new(13, false) }
n = gets.to_i
n.times do
  card = readline.split(' ')
  cards[suit_map[card[0]]][card[1].to_i - 1] = true
end
cards.each_with_index do |row, i|
  suit = suits[i]
  row.each_with_index do |b, j|
    puts "#{suit} #{j + 1}" unless b
  end
end



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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int pre = -1;
    rep(i, n) {
        if (pre <= h[i] - 1) {
            pre = h[i] - 1;
        } else if (pre <= h[i]) {
            pre = h[i];
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main()
{
    string s; cin>>s;
    int n=s.size();
    long res=0;
    for(int i=0; i<(1<<(n-1)); ++i) {
        long x=s[0]-'0', sum=0;
        for(int j=0; j<n-1; ++j) {
            if ((i>>j)&1) {
                sum+=x;
                x=0;
            }
            x=10*x+s[j+1]-'0';
        }
        sum+=x;
        res+=sum;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vecctor<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N, K;
    cin >> N >> K;
    VL A(N);
    rep(i, 0, N) cin >> A[i];

    VVL dp(100, VL(2, -1));
    dp[0][0] = 0;

    rep(d, 0, 50){
        ll mask = 1LL<<(50-d-1);

        ll c = 0;
        rep(i, 0, N) if(A[i] & mask) c++;

        ll c0 = c * mask;
        ll c1 = (N - c) * mask;

        if(dp[d][1] != -1){
            dp[d+1][1] = max(dp[d+1][1], dp[d][1] + max(c0, c1));
        } 

        if(dp[d][0] != -1){
            if(K & mask){
                dp[d+1][1] = max(dp[d+1][1], dp[d][0] + c0);
            }
        }

        if(dp[d][0] != -1){
            if(K & mask) dp[d+1][0] = max(dp[d+1][0], dp[d][0] + c1);
            else dp[d+1][0] = max(dp[d+1][0], dp[d][0] + c0);
        }
    }

    cout << max(dp[50][0], dp[50][1]) << endl;
    return 0;
}

Measured memory_bytes: 1024
/*****************************************************

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 2e5+7;
const ll inf = 1e17;

int pwr(int x, int y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return r % MOD;
}

int inv(int x)
{
    return pow(x, MOD-2);
}

void solve()
{
    double w, h, x, y; cin>>w>>h>>x>>y;
    double a = w*h/2;
    cout<<fixed<<setprecision(10)<<a;
    cout<<" ";
    if(x==w/2 and y==h/2)
        cout<<"1";
    else
        cout<<'0';
}

signed main()
{

    int t=1;
    // cin >>t;
    while(t--){
        solve();
    }
    return 0;
}

/*****************************


****************************/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int s,w;
  std::cin >> s >> w;

  if(w >= s)
    std::cout << "unsafe" << '\n';

  else
    std::cout << "safe" << '\n';
  return 0;
}


Measured memory_bytes: 3624
sx, sy, tx, ty = tuple(map(int, input().split()))
dx = tx - sx
dy = ty - sy
ans = ""
ans += "U" * dy
ans += "R" * dx
ans += "D" * dy
ans += "L" * dx
ans += ("L" + "U" * (dy + 1) + "R" * (dx + 1) + "D")
ans += ("R" + "D" * (dy + 1) + "L" * (dx + 1) + "U")
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n,a[N];

int main(){
    readi(n);
    lp(i,1,n) readi(a[i]);

    int ans = 0;
    lp(i,1,n-1) if(a[i] == i) swap(a[i], a[i+1]), ++ans;
    if(a[n] == n) ++ans;
    cout <<ans;
}

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
ios::sync_with_stdio(0);cin.tie(0);
*/


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

long gcd(long a, long b){
  if(b == 0)
    return a;

  return gcd(b, a%b);
}

int main(){
  long p, q;
  cin >> p >> q;

  long tmp = gcd(q, p);
  p /= tmp;
  q /= tmp;

  long ans = 1;
  long root = sqrt(q) + 1;
  vector<bool> hurui(root, true);
  for(int i=2; i<=root; i++){
    if(hurui[i] == true){
      if(i <= root){
	for(int j=2*i; j<=root; j+=i){
	  hurui[j] = false;
	}
      }
      if(q%i == 0){
	ans *= i;
	while(q%i == 0)
	  q /= i;
	if(q == 1)
	  break;
      }
    }
  }
  ans *= q;

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

Measured memory_bytes: 3100
def factorization(n):
    if n > 1:
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp % i == 0:
                count = 0
                while temp % i == 0:
                    count += 1
                    temp //= i
                arr.append([i, count])

        if temp != 1:
            arr.append([temp, 1])

        if arr == []:
            arr.append([n, 1])

    elif n == 1:
        arr = []

    return arr


A,B = map(int,input().split())
a = factorization(A)
b = factorization(B)
check = 1
for i in range(0,len(a)):
    for j in range(0,len(b)):
        if a[i][0] == b[j][0]:
            check += 1
print(check)

Measured memory_bytes: 3188
using System;
using System.Linq;

namespace AtCoderBeginnercontest161
{
	class Program
	{
		static void Main(string[] args)
		{
			var inputs = ReadIntArray();
			var array = ReadIntArray();

			var sum = array.Sum();
			var line = sum % (4 * inputs[1]) == 0 ? sum / (4 * inputs[1]) - 1 : sum / (4 * inputs[1]);

			Console.WriteLine(array.Count(x => x > line) >= inputs[1] ? "Yes" : "No");
		}

		public static int ReadInt()
			=> int.Parse(Console.ReadLine());

		public static int[] ReadIntArray()
			=> Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

		public static long ReadLong()
			=> long.Parse(Console.ReadLine());

		public static long[] ReadLongArray()
			=> Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

		public static string ReadString()
			=> Console.ReadLine();

		public static string[] ReadStringArray()
			=> Console.ReadLine().Split();
	}
}


Measured memory_bytes: 13396
#include <stdio.h>

int main(void)
{
	int x,y,z,a,b,n;
	char d[6] = {"aeiou"},c;
	scanf("%c",&c);
	for(x=0;x<5;x++) if (c == d[x]) break;
	if (x == 5) printf("consonant");
	else printf("vowel");
	return 0;
}

Measured memory_bytes: 128
/*
   AtCoder Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;
    int cost = 700;
    for(char c : s){
        if(c == 'o'){
            cost += 100;
            
        }
    }

    cout << cost << endl;
    return 0;
}


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

int main()
{
	long long int a, b;
	cin >> a >> b;
	if (abs(a-b) % 2){
		cout << "IMPOSSIBLE" << endl;
	}
	else cout << (a > b ? b + (a-b)/2 : a + (b-a)/2) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



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

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k,s;cin>>n>>k>>s;
  if(s==1e9){
    rep(i,n-k){
      cout<<1<<" ";
    }
    rep(i,k){
      cout<<s<<" ";
    }
    cout<<endl;return 0;
  }
  rep(i,k){
    cout<<s<<" ";
  }
  rep(i,n-k){
    cout<<s+1<<" ";
  }
  cout<<endl;

  return 0;

}


Measured memory_bytes: 1280
N,K = [int(i) for i in input().split()]
mod = 998244353
LR = []
S = []
dp = [0]*(N+1)
dps = [0]*(N+1)
dps[1] = 1
dp[1] = 1
for i in range(K):
  LR.append([int(i) for i in input().split()])

for i in range(1,N+1):
  for l,r in LR:
    l,r = i - r,i - l
    #print(l,r)
    if r < 1:
      continue
    l = max(1,l)
    dp[i] += dps[r] - dps[l-1]
    dp[i] %= mod
    #print(dp[i])
    
  dps[i] = dps[i-1] + dp[i]
  #print(dp, dps)
print(dp[-1])

Measured memory_bytes: 27848
#include<iostream>
using namespace std;
int main()
{
  int n;
  for(;cin>>n,n;)
    {
      string data[n];
      for(int i=0;i<n;i++)
	{
	  cin>>data[i];
	  int j=0;
	  for(;data[i][j]=='.';j++)
	    data[i][j]=' ';
	  j--;
	  if(j>=0)
	    {
	      int ii=i-1;
	      data[i][j]='+';
	      while(ii>=0 && data[ii][j]==' ')
		{
		  data[ii][j]='|';
		  ii--;
		}
	    }
	}
      for(int i=0;i<n;i++)
	cout<<data[i]<<endl;
    }


}

Measured memory_bytes: 1984
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		boolean[] to1 = new boolean[n];
		boolean[] ton = new boolean[n];

		for(int i=0;i<m;i++) {
			int a=sc.nextInt();
			int b=sc.nextInt();
			if(a==1) {
				to1[b-1]=true;
			} else if (a==n) {
				ton[b-1]=true;
			} else if(b==1) {
				to1[a-1]=true;
			} else if(b==n) {
				ton[a-1]=true;
			}
		}
		boolean result = false;
		for(int j=0;j<n;j++) {
			if(to1[j] && ton [j]) {
				result=true;
			}
		}
		System.out.println(result ? "POSSIBLE" : "IMPOSSIBLE");

	}

}


Measured memory_bytes: 93700
from collections import Counter

def get_prime_factors(x):
    out = []
    if x < 1:
        return out
    while not x%2:
        out.append(2)
        x //= 2
    i = 3
    while i*i <= x:
        if not x%i:
            out.append(i)
            x //= i
        else:
            i += 2
    if x != 1:
        out.append(x)
    return out
    
def main():
    n = int(input())
    ans = 0
    primes = Counter(get_prime_factors(n))
    for k, v in primes.items():
        num = 1
        while v >= num:
            v -= num
            num += 1
            ans += 1
    print(ans)
    

if __name__ == "__main__":
    main()

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

int main() {
	int N;
	int R;
	int sum = 0;
	cin >> N >> R;

	sum = (100 * (10 - N)) + R;

	if (N >= 10) {
		cout << R << endl;
	}
	else {
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
	static int max;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] ar = new int[100003];
		ar[0] = 1;
		ar[100002] = -1;
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			ar[a]++;
			ar[b+1]--;
		}
		int max = 0;
		for(int i = 1; i < ar.length; i++) {
			ar[i] += ar[i-1];
			if(ar[i] >= i) max = Math.max(max, i);
		}
		
		
		System.out.println(max-1);
		
		
		
		
		
		
		
	}
}

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

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(void){
    nil = (Node *)malloc(sizeof(Node));
    nil->prev = nil;
    nil->next = nil;
}

void printList(void){
    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(void){
    deleteNode(nil->next);
}

void deleteLast(void){
    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;
    x->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 (int i=0; i<n; i++){
        //scanf("%s%d", com, &key);
        scanf("%s", com);
        if (com[0] == 'i') {scanf("%d", &key); 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{
                scanf("%d", &key);
                deleteKey(key); nd++;
            }
        }
    }
    printList();
    return 0;
}


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

//爆弾の範囲,強さの予約をqueueで行う

int main(){
    int n;
    ll d,a;
    cin >>n>>d>>a;
    
    vector<P> xh(n);
    rep(i,n){
        cin >>xh[i].first>>xh[i].second;
        xh[i].second = (xh[i].second+a-1)/a;
    }
    sort(xh.begin(),xh.end());
    
    v x,h;
    rep(i,n){
        x.push_back(xh[i].first);
        h.push_back(xh[i].second);
    }
    
    ll tot = 0;
    ll ans = 0;
    queue<pair<ll,ll>> q;
    
    rep(i,n){
        while(q.size() && q.front().first<x[i]){
            tot -= q.front().second;
            q.pop();
        }
        h[i] -= tot;
        if(h[i]>0){
            ans += h[i];
            tot += h[i];
            q.emplace(x[i]+2*d, h[i]);
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

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

#define f(i, q) for(int i = 0; i < q; i++)  

typedef long long ll;

int main() {
    string s;
    ll lSum, rSum, tmp;

    cin >> s;

    lSum = rSum = 0;
    tmp = s.at(0) - '0';
    for(ll i = 1; i < s.length(); i++) {
        if(s.at(i) - '0' == tmp) lSum++;

        if(tmp == 1) tmp = 0;
        else tmp = 1;
    }

    tmp = s.at(s.length() - 1) - '0';
    for(ll i = s.length() - 2; i >=0; i--) {
        if(s.at(i) - '0' == tmp) rSum++;

        if(tmp == 1) tmp = 0;
        else tmp = 1;
    }

    ll ans = min(rSum, lSum);

    cout << ans << endl;

    return 0;
}


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

int main(){
  string day;
  cin >> day;
  vector<string> days(7);
  days.at(0) = "SUN";
  days.at(1) = "MON";
  days.at(2) = "TUE";
  days.at(3) = "WED";
  days.at(4) = "THU";
  days.at(5) = "FRI";
  days.at(6) = "SAT";
  int ans = 0;
  
  for(int i = 0; i < 7; i++){
    if(day == days.at(i)){
      ans = 7 - i;
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;

int main()
{
    ll i,j;
    ll n,a,b;
    cin >> n >> a >> b;
    ll d = n%(a + b);
    ll c = (n-d)/(a + b);
    if(d > a){
        d = a;
    }
    cout << c*a + d << endl;
    return 0;
}

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

using namespace std;

int main(){
	int l, ans = 0;
	cin >> l;
	int  n = 1, m = 0;
	while((1 << n) <= l) n++;
	vector<int> a(n);
	vector<string> s;
	for(int i = 1; i < n; i++){
		int x = 1 << (i - 1);
		s.push_back(to_string(i) + " " + to_string(i + 1) + " 0");
		s.push_back(to_string(i) + " " + to_string(i + 1) + " " + to_string(x));
		a[i] = a[i - 1] + x;
	}
	int t = a[n - 1] + 1;
	for(int i = n - 1; i >= 0; i--){
		if(a[i] + t <= l - 1){
			s.push_back(to_string(i + 1) + " " + to_string(n) + " " + to_string(t));
			t = a[i] + t + 1;
		}
	}
	m = s.size();
	cout << n << " " << m << endl;
	for(auto&& i : s){
		cout << i << endl;
	}
	return 0;
}

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

int main() {
  int H, A;
  cin >> H >> A;
  
  int ans=0;
  if(H%A==0) cout << H/A << endl;
  else cout << H/A + 1 << endl;

}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a = sorted(a,reverse=True)

flag = True
for i in range(n-1):
  if flag :
    if a[i]==a[i+1]:
      hen1 =a[i]
      a[i+1]=-1
      flag =False
  elif not flag:
    if a[i]==a[i+1]:
      hen2 = a[i]
      print(hen1*hen2)
      exit()
print(0)

Measured memory_bytes: 14252
import math
def kumi(s, n):
    count = 1
    for x in range(s, s - n, -1):
        count *= x
    ret = count // math.factorial(n)
    return ret

def main():
    N = int(input().strip())
    S = []
    D = {}
    for _ in range(N):
        in_s = (input().strip())[0]
        if in_s in ['M','A','R','C','H']:
            S.append(in_s)
            D[in_s] = D.get(in_s, 0) + 1

    if not S or len(D.keys()) < 3:
        return 0

    
    # 組み合わせ数
    count = kumi(len(S), 3)
    # 重複削除
    for v in D.values():
        if v < 2:
            continue
        elif v == 2:
            count -= len(S) - v
        else:
            count -= kumi(v, 2) * (len(S) - v)
            count -= kumi(v, 3)
    return count

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

Measured memory_bytes: 4012
S = input()
flag = True
for i in range(len(S)):
  if i%2 == 1:
    if S[i] == 'R':
      flag = False
  if i%2 == 0:
    if S[i] == 'L':
      flag = False
if flag:
  print('Yes')
else:
  print('No')
    

Measured memory_bytes: 2940
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split(' ');
	var xys = toIntArr(input);
	var p1 = [xys[0],xys[1]];
	var p2 = [xys[2],xys[3]];

	var v = [p2[0]-p1[0],p2[1]-p1[1]];
	var p3 = [p2[0]-v[1],p2[1]+v[0]];
	var p4 = [p1[0]-v[1],p1[1]+v[0]];
	console.log(p3[0],p3[1],p4[0],p4[1]);
}

Measured memory_bytes: 21064
#include <stdio.h>
int main(void){
    // Here your code !
    int n,i,a;
    int max=0;
    int min=1000;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(a>max){
            max = a;
        }
        if(a<min){
            min = a;
        }
    }
    printf("%d\n",max-min);
    
    return 0;
    
}


Measured memory_bytes: 128
a, b, m =  map(int, input().split())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
x = [list(map(int, input().split())) for _ in range(m)]
ln = []
for i in range(m):
    ln.append(aa[x[i][0] - 1] + bb[x[i][1] - 1] - x[i][2])
ln.append(min(aa) + min(bb))
print(min(ln))

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

long long compME(long long b, long long e, long long m)
{
    long long ans = 1;

    while (e > 0) {
       if ((e & 1) == 1) ans = (ans * b) % m;
       e >>= 1;
       b = (b * b) % m;
    }

    return ans;
}

int main(){
  int n;
  cin >> n;
  if (n < 2){
    cout << 0;
    return 0;
  }
  //if (n == 2){
   // cout << 2;
  //  return 0;
  //}
  long long mod = 10e8+7;
  long long me;
  //me = compME((long)10, (long)n-2, mod)*((n*(n-1)/2)%mod)*2;
  me = compME((long long)10, (long long )n, mod)+mod*2 - compME((long long)9, (long long)n, mod)*2 + compME((long long)8, (long long)n, mod);
  cout << me%mod;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstring>
#include <algorithm>


const int MAX_N = 100;
int used[MAX_N];

int main(){
	int N,K;	scanf("%d%d",&N,&K);
	for (int i = 0; i < K; ++i){
		int d; scanf("%d",&d);
		for (int j = 0; j < d; ++j){
			int x;	scanf("%d",&x);
			used[x-1] = true;
		}
	}

	int cnt = 0;
	for (int i = 0; i < N; ++i)
		if(used[i] == false)
			++cnt;
	printf("%d\n",cnt);

}


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

int main(void) {
  ll n;
  cin >> n;
  ll ans = 1e18;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i != 0) continue;
    ll j = n / i;
    ans = min(ans, i + j - 2);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3596
#include<iostream>	// 入出力
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか


using namespace std;


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

	while (S.length() != 0) {
		S.pop_back();

		int b = S.length() % 2;
		int a = S.length() / 2;

		if (b == 0) {
			if (S.substr(0, a) == S.substr(a, a)) {
				cout << S.length() << endl;
				return 0;
			}
		}
	}
	cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

signed main() {
	int a;
	cin >> a;
	while (!prime(a)) {
		a++;
	}
	cout << a << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, M;
  cin >> N >> M;
  vl H(N + 1);
  rep2(i, 1, N + 1) cin >> H[i];
  ll A, B;
  vl good(N + 1, 1);
  rep(i, M){
    cin >> A >> B;

    if(H[A] <= H[B]){
      good[A] = 0;
    }
    if(H[B] <= H[A]){
      good[B] = 0;
    }
  }

  ll cnt = 0;
  rep2(i, 1, N + 1){
    cnt += (good[i] == 1) ? 1 : 0;
  }

  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 4844
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
  string s;
  cin >> s;
  vector<pair<int, int>> v;

  vector<int> result(s.size());
  int index = 0;
  bool is_counting_r = true;
  int rcnt = 0;
  int lcnt = 0;
  for (int cur = 0; cur < (int)s.size(); cur++) {
    if (is_counting_r) {
      if (s.at(cur) == 'R') {
        rcnt++;
      } else {
        is_counting_r = false;
        lcnt++;
        index = cur-1;
      }
    } else {
      if (s.at(cur) == 'L') {
        lcnt++;
      } else {
        is_counting_r = true;
        result.at(index) += rcnt / 2 + rcnt % 2;
        result.at(index+1) += rcnt / 2;
        result.at(index) += lcnt / 2;
        result.at(index+1) += lcnt / 2 + lcnt % 2;
        rcnt = 1;
        lcnt = 0;
      }
    }
  }
  result.at(index) += rcnt / 2 + rcnt % 2;
  result.at(index+1) += rcnt / 2;
  result.at(index) += lcnt / 2;
  result.at(index+1) += lcnt / 2 + lcnt % 2;

  cout << result.at(0);
  for (int i = 1; i < (int)result.size(); i++) {
    cout << ' ' << result.at(i);
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 1024
// Example program
#include <iostream>
#include <string>
using namespace std;

int main()
{
  int a = 0;
  int b = 0;
  for (int i = 0; i < 4; i++) {
      int s;
      cin >> s;
      a += s;
  }
  
  for (int i = 0; i < 4; i++) {
      int s;
      cin >> s;
      b+= s;
  }
  
  if (a > b) {
      cout << a << endl;
  }else {
      cout << b << endl;
  }
}

Measured memory_bytes: 1160
s = input()
k = int(input())

if s[0] != '1':
    print(s[0])
else:
    len_1 = 0
    while True:
        if s == '1':
            len_1 = 1
            ans = 1
            break
        if s[0] == '1':
            s = s[1:]
            len_1 += 1
        elif s[0] != '1':
            ans = s[0]
            break
    if k > len_1:
        print(ans)
    else:
        print('1')


Measured memory_bytes: 38256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll K;
  ll NUM[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
              1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> K;
  cout << NUM[K - 1] << endl;
  return 0;
}

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

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

    vector<long long> dp(n);
    dp[1] = abs(h[0]-h[1]);
    for(int i=2; i<n; i++){
        long long small = pow(10,18);
        for(int j=max(0,i-k); j<i; j++){
            if(small > dp[j]+abs(h[j]-h[i])) small = dp[j]+abs(h[j]-h[i]);
        }
        dp[i] = small;
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1408
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	x, _ := strconv.Atoi(s[0:2])
	y, _ := strconv.Atoi(s[2:4])
	if x >= 1 && x <= 12 && y >= 1 && y <= 12 {
		fmt.Println("AMBIGUOUS")
		return
	}
	if x >= 1 && x <= 12 && (y > 12 || y == 0) {
		fmt.Println("MMYY")
		return
	}
	if (x > 12 || x == 0) && y >= 1 && y <= 12 {
		fmt.Println("YYMM")
		return
	}
	fmt.Println("NA")
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include<iomanip>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int N,H;

int main(int argc, const char * argv[]) {
    cin >> N >> H;
    int i;
    int a,b;
    int maxa = 0;
    int bl[100001];
    vector<int> bb;
    for (i = 0; i < N; i++) {
        cin >> a >> b;
        bl[i] = b;
        bb.push_back(b);
        maxa = max(maxa, a);
    }
    
    sort(bb.begin(), bb.end(), std::greater<int>());
    

    
    int sum = 0;
    int num = 0;
    for (i = 0; i < N; i++) {
        if (bl[i] > maxa) {
            sum += bl[i];
            num++;
        }
    }
    
    if (sum >= H) {
        int s = 0;
        int k = 0;
        for (auto it = bb.begin(); it != bb.end(); it++) {
            k++;
            s += *it;
            if (s >= H) {
                cout << k << endl;
                return 0;
            }
        }
    }
    
    num += (H - sum)/maxa;
    if ((H - sum) % maxa != 0)
        num += 1;
    cout << num << endl;
    
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i=0; i<N; i++){
        cin >> p[i];
    }
    
    for (int i=1; i<=N; i++){
       if (i != p[i-1]){
           int k = p[i-1];
           if(p[k-1] == i){
               p[i-1] = i;
               p[k-1] = k;
               break;
           }
       }
    }
    for (int i=1; i<=N; i++){
       if (i != p[i-1]){
           cout << "NO";
           return 0;
       }
    }
    cout << "YES";
    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n;
  scanf("%d", &n);
  int choise = n/1.08;
  if((int)(choise*1.08) == n){
	  printf("%d",choise);
  }else if((int)((choise+1)*1.08) == n){
	  printf("%d",choise+1);
  }else
	  puts(":(");
}


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

int main(){
    ll n,m,l, sum=0;
    cin>>n>>m>>l;
    vector<vector<int>> a1(n, vector<int> (m) );
    vector<vector<int>> a2(m, vector<int> (l) );
    rep(i,n){
        
        rep(j,m){
            cin>>a1[i][j];
            //cout<<a1[i][j]<<" ";
        }
        //cout<<endl;
    }
    rep(i,m){
        
        rep(j,l){
            cin>>a2[i][j];
           // cout<<a2[i][j]<<" ";
        }
     // cout<<endl;
    }
  
      
      
      
      
      
    rep(i,n){
        
        rep(j, l){
            sum=0;
            rep(k, m){
                sum+=a1[i][k]*a2[k][j];
                
            }
            if(j==l-1) cout<<sum;
            else cout<<sum<<" ";
        }
        cout<<endl;
    }
    
    
}


Measured memory_bytes: 3232
N, M = map(int, input().split())
W, V = [], []
for n in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)
f = [[0 for m in range(M + 1)] for n in range(N + 1)]
for n in range(N):
    for m in range(M + 1):
        if m < W[n]:
            f[n + 1][m] = f[n][m]
        else:
            f[n + 1][m] = max(f[n][m], f[n][m - W[n]] + V[n])
print(f[N][M])


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

int main(){
    ll n,m;
    cin>>n>>m;

    int ar[n+2];

    for(int i=1;i<=n;i++)cin>>ar[i];
    int br[m+2];
    for(int j=1;j<=m;j++)cin>>br[j];
    int dp[n+2][m+2];
    memset(dp,0,sizeof dp);
    dp[0][0] = 1;
    for(int i=1;i<=n;i++)dp[i][0] = 1;
    for(int j=1;j<=m;j++)dp[0][j] = 1;


    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
                if(ar[i]!=br[j])
            dp[i][j] =  dp[i][j-1] + dp[i-1][j] -dp[i-1][j-1];
            else if(ar[i]==br[j]){
                dp[i][j]=(dp[i][j-1] + dp[i-1][j] -dp[i-1][j-1]+dp[i-1][j-1]);
               // cout<<i<<"ded"<<j<<" "<<(dp[i][j-1]+dp[i-1][j])<<endl;
            }
            dp[i][j] =(dp[i][j]%1000000007+1000000007)%1000000007;

           // cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
        }
    }
    cout<<dp[n][m]<<endl;



    return 0;
}


Measured memory_bytes: 15872
#include"iostream"
#include<algorithm>
#include<set>
typedef long long ll;
using namespace std;

string s;
ll x, n, t;


int main()
{  
	int a;
	cin >> n >> x >> t;
	if (n % x != 0)
		a = n / x + 1;
	else
		a = n / x;
	cout << a * t;
	
	return 0;
}

Measured memory_bytes: 3636
// E - Knapsack 2
#include <bits/stdc++.h>
using namespace std;

// void dpprn(vector<int> &v, int inf){
// 	for(int i=0;i<v.size();i++){
// 		if(v[i]==inf) cout<<"∞"; else cout<<v[i];
// 		cout<<((i+1)%10?",\t":"\n");
// 	}
// 	cout<<"--\n";
// }

#define VMAX 100000
#define WMAX 1000000000
vector<int> dp(VMAX+1, WMAX+1);

int main(){
	int N,W; cin>>N>>W;
	dp[0] = 0;
	for(int i=1; i<=N; i++){
		int w,v; cin>>w>>v;
		for(int j=VMAX; j>=v; j--) dp[j] = min(dp[j], dp[j-v] + w);
	}
	// dpprn(dp,WMAX+1);

	int ans = 0;
	for(int i=1; i<=VMAX; i++) if(dp[i]<=W) ans = max(ans, i);
	cout<< ans <<endl;
}

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

using namespace std;

int main() {
  int N;
  vector<long> list;
  
  cin >> N;
  
  for (int i = 1; i <= N; i++) {
    long in;
    
    cin >> in;
    
    list.push_back(in - (i + 1));
  }
  
  sort(list.begin(), list.end());
  
  long median_of_list = N % 2 == 0 ? (list.at(N / 2) + list.at(N / 2 - 1)) / 2 : list.at(N / 2); 
  long minimum_sum = 0;
  
  for (int i = 0; i < N; i++) {
    minimum_sum += abs(list.at(i) - median_of_list);
  }
  
  cout << minimum_sum << endl;
  
  return 0;
}

Measured memory_bytes: 2420