akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
	
#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


string e;
//vector<int> sets[256];
map<char, vector<int> > sets;
vector<int> calculate(char ope, const vector<int>& left, const vector<int>& right)
{
	vector<int> res(left.size() + right.size());
	vector<int>::iterator end;
	if (ope == 'u')
		end = set_union(all(left), all(right), res.begin());
	else if (ope == 'i')
		end = set_intersection(all(left), all(right), res.begin());
	else if (ope == 'd')
		end = set_difference(all(left), all(right), res.begin());
	else if (ope == 's')
		end = set_symmetric_difference(all(left), all(right), res.begin());

	res.erase(end, res.end());
	return res;
}
vector<int> parse(int a, int b)
{
	int p = b;
	for (int par = 0; p >= a; --p)
	{
		if (e[p] == '(')
			++par;
		else if (e[p] == ')')
			--par;
		else if (par == 0 && strchr("uids", e[p]))
			break;
	}
	if (p < a)
	{
		if (e[a] == 'c')
			return calculate('s', sets['U'], parse(a + 1, b));
		else if (e[a] == '(')
			return parse(a + 1, b - 1);
		else
			return sets[e[a]];
	}

	return calculate(e[p], parse(a, p - 1), parse(p + 1, b));
}
int main()
{
	while (true)
	{
		//rep (i, 256)
		//	sets[i].clear();
		sets.clear();

		vector<int> universe;
		while (true)
		{
			char a;
			int n;
			if (!(cin >> a >> n))
				return 0;

			if (a == 'R')
				break;

			sets[a] = vector<int>();
			while (n--)
			{
				int t;
				cin >> t;
				sets[a].push_back(t);
				universe.push_back(t);
			}
			sort(all(sets[a]));
		}
		sort(all(universe));
		universe.erase(unique(all(universe)), universe.end());
		sets['U'] = universe;

		cin >> e;
		vector<int> res = parse(0, e.size() - 1);
		if (res.empty())
			cout << "NULL" << endl;
		else
		{
			for (int i = 0; i < res.size(); ++i)
			{
				cout << res[i];
				if (i + 1 < res.size())
					cout << ' ';
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int n, h[20], ans = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	int now = h[0];
	for(int i = 0; i < n; i++){
		if(now <= h[i]){
			ans++;
			now = h[i];
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int x,y,a,b,c,n,i;
	long long sum=0;
	int  arr[100005],brr[100005],crr[100005],drr[200005];
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	for(i=0;i<a;i++)
	{
		scanf("%lld",&arr[i]);
	}
	sort(arr,arr+a,greater<int>());
	for(int j=0;j<b;j++)
	{
		scanf("%lld",&brr[j]);
	}
	sort(brr,brr+b,greater<int>());
	for(int k=0;k<c;k++)
	{
		scanf("%lld",&crr[k]);
	}
	sort(crr,crr+c,greater<int>());
	for(i=0;i<x;i++)
	{
		drr[i]=arr[i];
	}
	for(i=x;i<x+y;i++)
	{
		drr[i]=brr[i-x];
	}
	n=x+y;
	sort(drr,drr+n);
    int	num=0;
	for(i=0;i<c;i++)
	{
			if(crr[i]>drr[num])
		{
			drr[num]=crr[i];
			num++;
		}
	}
	for(i=0;i<n;i++)
	{
		sum+=drr[i];
	}
	printf("%lld",sum);
 } 

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  int N,K;
  cin >> N >> K;
  int a[N];
  rep(i,N) cin >> a[i];
  sort(a,a+N);
  vector<pair<int, int> > m;
  int c=1;
  rep1(i,N-1){
    if(a[i]==a[i-1]){
      c++;
      if(i==N-1){
	m.pb(mp(c,a[i]));
      }
    }
    else{
      m.pb(mp(c,a[i-1]));	
      c=1;
      if(i==N-1){
	m.pb(mp(c,a[i]));
      }
    }        
  }
  sort(m.begin(),m.end());
  int kind=m.size();
  int ans=0;
  int i=0;
  while(kind>K){
    ans+=m[i].first;
    i++;
    kind--;
  }
  cout << ans << endl;
  
  return 0;

}


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

int N;
vector<int> d(55);

int main(){

    cin >> N;
    for (int i=0; i<N; i++){
        cin >> d.at(i);
    }

    int sum = 0;
    for (int i=0; i<N; i++){
        for (int j=i+1; j<N; j++){
            sum += d.at(i)*d.at(j);
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
using namespace std;
int main(){
  int n;
  cin >> n;
  double tmp = 0.0;
  string unit;
  double ans = 0.0;
  for(int i=1; i<=n; i++){
    cin >> tmp >> unit;
    if(unit == "JPY") ans += tmp;
    else {ans += tmp * 380000.0;}
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define f(a) (a)*(a)
using namespace std;

typedef struct{
  double l;
  double a;
  double b;
}Data;

vector<bool> vec;
vector<Data> v;
int n,m;

double diff(Data d1,Data d2){
  return (f(d1.l-d2.l)+f(d1.a-d2.a)+f(d1.b-d2.b));
}

double big(double a,double b){
  return ((a > b) ? (a) : (b));
}

double calc(int index){
  double ans=0.0;
  for(int i=index;i<n;i++){
    if(vec[i]){
      for(int j=i+1;j<n;j++){
	if(vec[j])
	  ans+=diff(v[i],v[j]);
      }
      ans+=calc(i+1);
      break;
    }
  }
  return ans;
}

double solve(int index,int cnt){
  if(cnt >= m) return calc(0);
  if(index >= n) return 0.0;
  double max=0.0;
  for(int i=index;i<n;i++){
    if(!vec[i]){
      vec[i]=true;
      max = big(solve(i+1,cnt+1),max);
      vec[i]=false;
    }
  }
  return max;
}

int main(){
  cin>>n>>m;
  vec.resize(n);
  v.resize(n);
  for(int i=0;i<n;i++){
    cin>>v[i].l>>v[i].a>>v[i].b;
    vec[i]=false;
  }
  cout.precision(20);
  cout<<solve(0,0)<<endl;

}

Measured memory_bytes: 1296
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int n;
    cin >> n;
    cout << (n+1)/2 << endl;
}

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

using namespace std;

int main(){
    int n; cin >> n;
    int a[n], m = 0;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        m += a[i];
    }
    int t = 0, mi = m;
    for(int i = 0;i < n;i++){
        t += a[i];
        int l = m - t;
        mi = min(abs(l - t), mi);
    }
    cout << mi;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

map<int,int> m;

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
while(n--)
{
	int x;
	cin>>x;
	m[x]++;
}
cin>>n;
while(n--)
{
	int x;
	cin>>x;
	m[x]--;
}
tr(m,it)
{
	if((it->ss)<0)
	{
		ol("NO");
		return 0;
	}
}
ol("YES");
return 0;
}



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

int main() {
int n;
cin>>n;
if (n==1)cout<<1<<endl;
else if(n<4)cout<<2<<endl;
else if(n<8)cout<<4<<endl;
else if(n<16)cout<<8<<endl;
else if(n<32)cout<<16<<endl;
else if(n<64)cout<<32<<endl;
else cout<<64<<endl; 
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int N;
int a;

multiset <int> q;

int main() {
  ios_base::sync_with_stdio(false);
  cin >> N;
  int ans = 0;
  for(int i = 0; i < N; i++) {
    cin >> a;
    if(q.size() == 0 || *q.begin() >= a) {
      ans++;
      q.insert(a);
    } else {
      q.erase(--q.lower_bound(a));
      q.insert(a);
    } 
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
import bisect
N,A,B=map(int,input().split())
C=A-B
H=[int(input()) for i in range(N)]
H.sort()
BIG=(H[-1]+B-1)//B
MAX=BIG
MIN=0
idx=(1,2)
def check(i):
    start=bisect.bisect_right(H,B*i)
    if start>=N:
        return True
    cnt=0
    for j in range(start,N):
        cnt+=(H[j]+C-1-B*i)//C
        if cnt>i:
            return False
    if cnt<=i:
        return True
    return False
while True:
    if MIN+1==MAX:
        break
    i=BIG*idx[0]//idx[1]
    if check(i):
        MAX=i
        idx=(idx[0]*2-1,idx[1]*2)
    else:
        MIN=i
        idx=(idx[0]*2+1,idx[1]*2)
print(MAX)

Measured memory_bytes: 7520
N,Q=map(int,input().split())
S=input()
L=[0]
T=0
for i in range(N-1):
  T+=S.count('AC',i,i+2)
  L.append(T)
for j in range(Q):
  l,r=map(int,input().split())
  print(L[r-1]-L[l-1])

Measured memory_bytes: 7688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		if (n % 2 == 1) {
			System.out.println("No");
			return;
		}

		String s = scanner.next();
		for (int i = 0; i < n / 2; i++) {
			if (s.charAt(i) != s.charAt(i + n / 2)) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}

}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{


    class Program
    {

        
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var dic_blue = new Dictionary<string, int>();
            for(int i = 0; i < N; i++)
            {
                string s = Console.ReadLine();
                if (dic_blue.ContainsKey(s)) dic_blue[s]++;
                else dic_blue[s] = 1;
            }
            int M = int.Parse(Console.ReadLine());
            var dic_red = new Dictionary<string, int>();
            for(int i = 0; i < M; i++)
            {
                string s = Console.ReadLine();
                if (dic_red.ContainsKey(s)) dic_red[s]++;
                else dic_red[s] = 1;
            }

            int point = 0;

            foreach(var s in dic_blue)
            {
                int p = s.Value;
                if (dic_red.ContainsKey(s.Key)) p -= dic_red[s.Key];
                if (point < p) point = p;
            }

            Console.WriteLine(point);

        }
    }
}

Measured memory_bytes: 13152
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <limits>

#define MAX_N 100000

using namespace std;

int N, K;

int dp[MAX_N];

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

	int input[N];

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

	int tmp_min = 0;

	dp[0] = 0;
	for(i = 1; i<N; i++) {
		j = i-K;
		if(j < 0) j = 0;
		
		tmp_min = numeric_limits<int>::max();
		for(; j<i; j++) {
			tmp_min = min(dp[j]+abs(input[j]-input[i]), tmp_min);
		}

		dp[i] = tmp_min;
	}

	printf(" %d", dp[N-1]);

	return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc083.contest.atcoder.jp/tasks/arc083_b>
問題文============================================================
 かつて存在した高橋王国には N 個の都市があり、いくつかの都市の組は道路で双方向に結ばれていました。
 道路の構造は以下のようであったことがわかっています。
 
 都市間の移動は道路を通ってのみ行われ、
 どの都市からどの都市へも必要なら他の都市を経由することで移動できるようになっていた。
 
 道路の長さは道路によって異なっていたかもしれないが、全て正整数であった。
 考古学者のすぬけ君は、高橋王国の遺跡で整数からなる N×N の表 A を発見しました。
 すぬけ君は、この表は高橋王国における都市間の道路に沿った最短距離を表した表ではないかと考えました。
 
 すべての u,v について、A の u 行目 v 列目の整数 Au,v が都市 u から都市 v への最短経路の長さとなるような
 道路の構造が存在するかどうか判定してください。
 さらに、存在する場合、
 そのような道路の構造のうち、存在する道路の長さの和が最小となるようなものについて、その和を求めてください。
 
=================================================================

解説=============================================================

 入力からワーシャルフロイドを行なって、各頂点間の距離が変化（厳密には小さくなる）ようであれば
 条件を満たす構造が存在しないため -1
 
 また、必要な最低限の辺に関していえば
 
 頂点 (j,k) において
 dist[j][k] == dist[j][i] + dist[i][k] となる点 i が存在するならば
 直接 j-kへの辺を引くよりも j-i-k へ辺を引くほうが都合がよく
 全ての辺について同様のことを調べて、最終的に 引いたほうが良い辺のコストの総和を出力すれば答え
 
================================================================
*/
ll solve(){
    ll ret = -1;
    ll N; cin >> N;
    vector<vector<ll>> G(N,vector<ll>(N,0));
    for(int i = 0; i < N;i++) for(int j = 0; j < N;j++) cin >> G[i][j];
    
    auto tG = G;
    for(int i = 0; i < N;i++) for(int j = 0; j < N;j++) for(int k = 0; k < N;k++){
        G[j][k] = min(G[j][k],G[j][i] + G[i][k]);
    }
    for(int i = 0; i < N;i++) for(int j = 0; j < N;j++) if(G[i][j] != tG[i][j]) return ret;

    ret = 0;
    vector<vector<int>> use(N,vector<int>(N,1));
    
    for(int i = 0; i < N;i++) for(int j = 0; j < N;j++) for(int k = 0; k < N;k++){
        if(i == j || i == k || j == k) continue;
        if(G[j][k] == G[j][i] + G[i][k]) use[j][k] = 0;
    }

    for(int i = 0; i < N;i++) for(int j = 0; j < N;j++)if(use[i][j]) ret += G[i][j];
    ret /= 2;
    return ret;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


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

int main(){
	string w,t;
	int time=0;
	
	cin >> w;
	while(1){
		cin >> t;
		if(t=="END_OF_TEXT"){
			break;
		}else{
			for(int i=0; i<t.size(); ++i){
				t[i] = tolower(t[i]);
			}
			
			if(t==w){
				++time;
			}
		}
	}
	printf("%d\n", time);	
}




Measured memory_bytes: 3236
def resolve():
    N, K, Q = list(map(int, input().split()))
    A = [int(input()) for _ in range(Q)]
    points = [0] * N
    for i in range(Q):
        points[A[i]-1] += 1

    for i in range(N):
        if K + points[i] - Q > 0:
            print('Yes')
        else:
            print('No')

    return

resolve()

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

#define int long long

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

int N;
vector<int> G[100000];
bool used[100000] = {};

int dfs(int x) {
    used[x] = true;
    if (G[x].size() == 1) {
        return 11;
    }
    if (G[x].size() == 2) {
        if (!used[G[x][0]]) {
            return dfs(G[x][0]);
        } else {
            return dfs(G[x][1]);
        }
    }
    int res = 0;
    bool exist_erasable = false;
    for (int i = 0; i < G[x].size(); i++) {
        if (!used[G[x][i]]) {
            int re = dfs(G[x][i]);
            if (re % 10 == 1) {
                exist_erasable = true;
            }
            res += re / 10;
        }
    }
    if (exist_erasable) {
        res--;
    }
    return res * 10;
}

signed main() {
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int ans = 10;
    for (int i = 0; i < N; i++) {
        if (G[i].size() > 2) {
            ans = dfs(i);
            break;
        }
    }
    cout << ans / 10 << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;


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

	string w;
	cin >> w;

	int n = w.size();

	vector<int> alp(26, 0);
	rep(i, n){
		alp[w[i] - 'a']++;
	}

	rep(i, 26){
		if(alp[i] % 2 != 0){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 2e5 + 5;
const int M = 1560 + 5;
const ll OO = 2e18;
const int mod = 1e9 + 7;

int n,p,pre[N];
string s;
ll ans;
map<int, int> m;

int mul(int a, int b) {

    return (a*b)%p;

}

int pw(int b, int k) {

    if(!k) return 1;

    int res = pw(b, k>>1);

    return mul(mul(res, res), (k&1 ? b : 1));

}

int modInv(int a) {

    return pw(a, p-2);

}

void init() {
}

int main() {

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


    cin >> n >> p >> s;

    if(p==2 || p==5) {

        for (int i = 0; i < n; ++i) {
            if((s[i]-'0')%p==0) {
                ans += i+1;
            }
        }

    } else {

        for (int i = 0; i < n; ++i) {
            pre[i] = ((i ? pre[i-1] : 0) * 10 + (s[i] - '0'))%p;
        }

        m[0] = 1;

        for (int i = 0; i < n; ++i) {
            ans += m[mul(pre[i],modInv(pw(10,i)))]++;
        }

    }

    cout << ans << '\n';

    return 0;
}

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

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

#define int long long
signed main(){
//int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int n=s.size();

    int idx = 0;
    int ans = 0;
    int cnt = 0;
    while(idx<n) {
        if(s[idx]=='A'){
            cnt++;
        }
        else if(s[idx]=='B' && s[idx+1]=='C'){
            ans+=cnt;
            idx++;
        }
        else cnt=0;
        idx++;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<cstdio>
using namespace std;
int a,b,c,d,e;
int len,ans;
int main(){
    cin>>a>>b>>c>>d>>e;
    len=c*60+d-a*60-b;
    if (len<0) cout<<"0";
    else cout<<len-e;
    return 0;
}

Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int l,r,d,ans=0; cin>>l>>r>>d;
    for(int i=l;i<=r;i++){
        if(i%d==0) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define nn 2036
#define lf double
#define mod 924844033
ll n;ll k;
ll dp[nn+23],cp[nn+23];
ll f[nn+23][nn+23][2][2];ll s[nn][nn];
void add(ll &x,ll y)
{
	x+=y,x%=mod;
}
ll cf[nn];
int main()
{
	cf[0]=1;
	for(int i=1;i<nn;i++) cf[i]=cf[i-1]*(i)%mod;
	scanf("%lld%lld",&n,&k);
	f[0][0][0][1]=1;//where, numberofchoice, nowover, lastover
 	for(ll i=0;i<nn;i++)
	{
		for(ll j=i;j>=0;j--)
		{
			ll now=f[i][j][0][0];
			add(f[i+1][j][0][0],now);//nothing
			add(f[i+1][j+1][1][0],now);//right
			add(f[i+1][j+1][0][0],now);//left
			
			now=f[i][j][0][1];
			add(f[i+1][j][0][0],now);//nothing
			add(f[i+1][j+1][1][0],now);//right
			
			now=f[i][j][1][0];
			add(f[i+1][j][0][1],now);//nothing
			add(f[i+1][j+1][1][1],now);//right
			add(f[i+1][j+1][0][1],now);//left
			
			now=f[i][j][1][1];
			add(f[i+1][j][0][1],now);//nothing
			add(f[i+1][j+1][1][1],now);//right
			
			for(int x1=0;x1<1;x1++) for(int y1=0;y1<2;y1++)
				s[i][j]+=f[i][j][x1][y1];//you can't choose self
			s[i][j]%=mod;
		}
	}
	dp[0]=1;
	for(ll i=0;i<n%k;i++)
	{
		ll ct=n/k+1;
		for(ll j=n;j>=0;j--)
		{
			for(ll l=1;l<=ct and j+l<=n;l++)
				add(dp[j+l],dp[j]*s[ct][l]%mod);
			add(dp[j],-dp[j]+dp[j]*s[ct][0]%mod);
		}
	}
	for(ll i=0;i<k-n%k;i++)
	{
		ll ct=n/k;
		for(ll j=n;j>=0;j--)
		{
			for(ll l=1;l<=ct and j+l<=n;l++)
				add(dp[j+l],dp[j]*s[ct][l]%mod);
			add(dp[j],-dp[j]+dp[j]*s[ct][0]%mod);//cout<<dp[1];
		}
		
//	cout<<dp[1]<<dp[0]<<"\n";
	}
	ll ans=cf[n];
	ll tag=-1;//ans=0;
	for(ll i=1;i<=n;i++)
	{
		ans+=tag*dp[i]*cf[n-i]%mod;
		tag*=-1;ans%=mod;
	}
	cout<<(ans+mod)%mod;
	return 0;
} 

Measured memory_bytes: 162688
#include <iostream>
using namespace std;
int main(void){
    int h1,h2,k1,k2,a,b,c,d;
    cin>>h1>>h2>>k1>>k2>>a>>b>>c>>d;
    int hiroshi=h1*a+h2*b+h1/10*c+h2/20*d;
    int kenjiro=k1*a+k2*b+k1/10*c+k2/20*d;
    if(hiroshi>kenjiro)
    {
        cout<<"hiroshi"<<endl;
        
    }
    else if(hiroshi<kenjiro)
    {
        cout<<"kenjiro"<<endl;
        
    }
    else
    {
        cout<<"even"<<endl;
        
    }
    return 0;
}



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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int HPinit, HPmax, R, C, T, S, P, p[22];
string grid[111];
unordered_map< char, int > trap;

string dirs = "LURD";
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};

typedef pair< int, int > pii;
vector< pii > step;

int max_hp[1L << 13][1010];

void maxUpdate(int& a, int b) { a = max(a, b); }

bool solve() {
	int SS = step.size();
	
	vector< int > damage(SS);
	
	for_(i,0,SS) {
		pii pos = step[i];
		int x = pos.first, y = pos.second;
		damage[i] = trap[grid[y][x]];
	}
	
	memset(max_hp, -1, sizeof(max_hp));
	
	max_hp[0][0] = HPinit;
	
	for_(U,0,1<<P) for_(i,0,SS) {
		if (max_hp[U][i] <= 0) continue;
		
		maxUpdate(max_hp[U][i + 1], max_hp[U][i] - damage[i]);
		
		for_(j,0,P) {
			if (U >> j & 1) continue;
			maxUpdate(max_hp[U | 1 << j][i], min(HPmax, max_hp[U][i] + p[j]));
		}
	}
	
	bool res = false;
	for_(U,0,1<<P) res |= (max_hp[U][SS] > 0);
	
	return res;
}

int main() {
	while (cin >> HPinit >> HPmax, HPinit) {
		cin >> R >> C;
		for_(r,0,R) cin >> grid[r];
		
		trap.clear();
		cin >> T;
		
		for_(i,0,T) {
			char alph; int d;
			cin >> alph >> d;
			trap[alph] = d;
		}
		
		step.clear();
		cin >> S;
		
		pii pos(0, 0);
		
		for_(i,0,S) {
			char d; int n;
			cin >> d >> n;
			
			int dr = dirs.find(d);
			
			for_(j,0,n) {
				pos = pii(pos.first + dx[dr], pos.second + dy[dr]);
				if (pos.first < 0) pos.first = 0;
				if (pos.second < 0) pos.second = 0;
				if (pos.first >= C) pos.first = C - 1;
				if (pos.second >= R) pos.second = R - 1;
				step.push_back(pos);
			}
		}
		
		cin >> P;
		for_(i,0,P) cin >> p[i];
		
		cout << (solve() ? "YES" : "NO") << endl;;
	}
}

Measured memory_bytes: 35528
let n = stdin.ReadLine() |> int
let hp = stdin.ReadLine().Split() |> Array.map int

// 最大公約数
let rec gcd x y = 
    let (x,y) = if y > x then (y,x) else (x,y)
    match x % y with
    | 0 -> y
    | z -> gcd y z

hp |> Seq.reduce (fun acc x -> gcd acc x) |> stdout.WriteLine

Measured memory_bytes: 28000
#include <stdio.h>
#include <string.h>

char prog1[201];
char prog2[201];


int chk_string(int *pos1, int *pos2)
{
    int res;
    
    (*pos1)++;
    (*pos2)++;
    
    res = 0;
    while (prog1[*pos1] != '\"'){
        if (res == 0){
            if (prog1[*pos1] != prog2[*pos2]){
                res = 1;
            }
            (*pos1)++;
            if (prog2[*pos2] != '\"'){
                (*pos2)++;
            }
            else {
                res = 1;
            }
        }
        else {
            (*pos1)++;
        }
    }
    if (prog2[*pos2] != '\"'){
        res = 1;
        while (prog2[*pos2] != '"'){
            (*pos2)++;
        }
    }
    return (res);
}


int main(void)
{
    int pos1, pos2;
    int result;
    
    while (1){
        scanf("%s", prog1);
        if (strcmp(prog1, ".") == 0){
            break;
        }
        scanf("%s", prog2);
        
        if (strcmp(prog1, prog2) == 0){
            printf("IDENTICAL\n");
            continue;
        }
        
        pos1 = pos2 = 0;
        result = 0;
        while (prog1[pos1] != '\0'){
            if (prog1[pos1] != prog2[pos2]){
                result = 2;
                break;
            }
            if (prog1[pos1] == '\"'){
                result += chk_string(&pos1, &pos2);
            }
            pos1++;
            pos2++;
        }
        if (prog2[pos2] != '\0'){
            result = 2;
        }
        
        if (result >= 2){
            printf("DIFFERENT\n");
        }
        else {
            printf("CLOSE\n");
        }
    }
    return (0);
}



Measured memory_bytes: 1988
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k, q;
    cin >> n >> k >> q;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    int cut=0;
    bool done=false;
    const ll INFTY=2e9;
    ll ans=INFTY;
    while(!done) {
        ll mi=INFTY;
        rep(i,0,n) if(a[i]>cut) mi=min(mi,a[i]);
        int l=0, r=0;
        vector<ll> c;
        while(l<n) {
            if(a[l]<=cut) ++l;
            else {
                r = l;
                while(r<n && a[r]>cut) ++r;
                if(r-l>=k) {
                    vector<ll> b(r-l);
                    rep(i,0,r-l) b[i]=a[l+i];
                    sort(all(b));
                    rep(i,0,r-l-k+1) c.push_back(b[i]);
                }
                l = r;
            }
        }
        sort(all(c));
        if(sz(c)<q) done=true;
        else {
            ll hi=c[q-1], lo=c[0];
            ans=min(ans,hi-lo);
        }
        cut = mi;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 384
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#include <string>
#include <sstream>
#include <stdio.h>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
ull gcd(ull a, ull b){return b? gcd(b, a%b):a;}
using namespace std;

int d[2001][2001] = {3000};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N, X, Y;
	cin >> N >> X >> Y;

	int counts[N] = {0};
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			int dist = min(min(abs(j-i), abs(X-1-i) + 1 + abs(j-Y+1)), abs(Y-1-i) + 1 + abs(j-X+1));
			counts[dist]++;
		}
	}

	for(int i = 1; i < N; i++){
		cout << counts[i] <<endl;
	}

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve(S):
    if S == "Sunny":
        print("Cloudy")
    elif S == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")


def main():
    S = input()
    solve(S)


if __name__ == '__main__':
    main()


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

using namespace std;
using i64 = int64_t;
#define int i64
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const i64 INFL = (1LL << 62);
const i64 MOD = 1000000007;

template <typename T>
T in() {
  T value;
  cin >> value;
  return value;
}

#undef int
int main() {
#define int i64
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a = in<int>();
  int b = in<int>();
  int c = in<int>();
  int x = in<int>();
  int y = in<int>();
  int ans = INF;
  ans = min(a * x + b * y, ans);
  ans = min(max(x, y) * c * 2, ans);
  if (x < y) {
    int tmp = (y - x) * b + x * c * 2;
    ans = min(tmp, ans);
  } else {
    int tmp = (x - y) * a + y * c * 2;
    ans = min(tmp, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch

#include<bits/stdc++.h>

using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}

char a[9][9];
int main()
{
    ios_base::sync_with_stdio(0);
    double H;
    cin>>H;
    double to_do= log(H)/log(2);
    ll loop= (ll)to_do+1;
    ll sum=1;
    for(int i=1;i<=loop;i++)
    {
        sum*=2;
    }
    cout<<sum-1<<endl;

}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        n:usize,
        an:[i64;n],
    }
    let mut cp = an.clone();
    cp.sort();
    let max = cp[n-1];
    let next = cp[n-2];
    
    for &a in &an{
        if next  == max  || max == a {
            println!("{}",next);
        } else {
            println!("{}",max);
        }
    }
}


fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}


Measured memory_bytes: 9724
n,m=map(int,input().split())
from math import factorial
mod=10**9+7
if abs(n-m)>=2:
  print(0)
elif abs(n-m)==1:
  n,m=min(n,m),max(n,m)
  #n<m
  print(((factorial(n)%mod)*(factorial(m)%mod))%mod)
else:
  print((2*(((factorial(n)%mod)**2)%mod))%mod)

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) (a).begin(),(a).end()

template<typename T1, typename T2> inline void chkmin(T1 & x, const T2 & y) {if (y < x) x = y;}
template<typename T1, typename T2> inline void chkmax(T1 & x, const T2 & y) {if (x < y) x = y;}

#define int ll

struct pt{
	int x, y;
	pt() {}
	pt(int _x, int _y) {
		x = _x, y = _y;
	}
};

bool operator<(const pt & a, const pt & b) {
	return tie(a.x, a.y) < tie(b.x, b.y);
}

const int N = 2e5 + 10;
const int INF = 1e9 + 228;
int n;
vector<pt> a[4];
int ans = INF;
vector<int> fx[N][4];
vector<int> fy[N][4];
map<int, vector<int>> have[2];

int get(char x) {
	if (x == 'U') return 0;
	if (x == 'R') return 1;
	if (x == 'D') return 2;
	if (x == 'L') return 3;
	assert(false);
	return -1;
}

void read() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x, y;
		char t;
		cin >> x >> y >> t;
		a[get(t)].push_back({x, y});
	}
}

void solveOneDir(vector<int> & a, vector<int> & b, int add) {
	sort(all(a));
	sort(all(b));
	for (auto i : a) {
		int pos = lower_bound(all(b), i) - b.begin();
		if (pos == (int)b.size()) continue;
		chkmin(ans, add * (b[pos] - i));
	}
}

void solvePerpDir(vector<pt> & u, vector<pt> & r) {
	have[0].clear();
	have[1].clear();
	for (auto [x, y] : u) {
		have[0][x + y].push_back(x);
	}
	for (auto [x, y] : r) {
		have[1][x + y].push_back(x);
	}
	for (auto i : have[1]) {
		if (!have[0].count(i.first)) continue;
		solveOneDir(i.second, have[0][i.first], 10);
	}
}

void make(vector<pt> & a, int t) {
	for (auto &[x, y] : a) {
		if (t == 0) x = -x;
		else if (t == 1) y = -y;
	}
}

void run() {
	for (int i = 0; i < 4; i++) {
		for (auto [x, y] : a[i]) {
			fx[x][i].push_back(y);
			fy[y][i].push_back(x);
		}
	}
	for (int i = 0; i < N; i++) {
		solveOneDir(fx[i][0], fx[i][2], 5);
		solveOneDir(fy[i][1], fy[i][3], 5);
	}
	solvePerpDir(a[0], a[1]);
	make(a[1], 1);
	make(a[2], 1);
	solvePerpDir(a[2], a[1]);
	make(a[0], 0);
	make(a[3], 0);
	solvePerpDir(a[0], a[3]);
	make(a[3], 1);
	make(a[2], 0);
	solvePerpDir(a[2], a[3]);
}

void write() {
	if (ans == INF) {
		cout << "SAFE" << endl;
	} else {
		cout << ans << endl;
	}
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 72956
#include <iostream>
using namespace std;
int main(void){
    long long n = 50, k, a[50];
    cin >> k;
    for(int i=0;i<n;i++){
        a[i] = n-1 + k/n;
    }
    
    k %= n;
    for(int i=0;i<k%n;i++){
        a[i] += n - k + 1;
    }
    
    for(int i=k%n;i<n;i++){
        a[i] -= k;
    }
    
    cout << n << endl;
    for(int i=0;i<n;i++){
        cout << a[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z) cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
#define ld long double
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vec<int> a(N);
  REP(i, N) cin >> a[i];
  int ans = 0;
  REP(i, N - 1) {
    ans += a[i] / 2;
    a[i] = a[i] % 2;
    int mina = min(a[i], a[i + 1]);
    a[i] -= mina;
    a[i + 1] -= mina;
    ans += mina;
  }
  ans += a[N - 1] / 2;

  print(ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <climits>
using namespace std;
// rep macro
#define rep(i, n)        for (int i = 0; i < (int)(n); i++)
#define rev(i, n)        for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i, s, n)    for (int i = (s); i < (int)(n); i++)
#define rev2(i, s, n)    for (int i = (int)(n) - 1; i >= (int)(s); i--)
#define bitrep(i, n)     for (int i = 0; i < (1 << (int)(n)); i++)
#define bitrep2(i, s, n) for (int i = (s); i < (1 << (int)(n)); i++)
// vector macro
#define all(v) v.begin(), v.end()
using vi  = vector<int>;
using vvi = vector<vector<int>>;
using vl  = vector<long>;
using vvl = vector<vector<long>>;
using vb  = vector<bool>;
using vvb = vector<vector<bool>>;
// math macro
#define lcm(a, b) a / __gcd(a, b) * b
// print macro
#define println(x) cout << x << endl
#define Yes println("Yes")
#define No println("No")
#define YES println("YES")
#define NO println("NO")
// pair macro
#define x first
#define y second
using pii = pair<int, int>;
using pdd = pair<double, double>;
// memo
// desc sort: sort(vec.begin(), vec.end(), greater<int>());

int main()
{
    int n, k; cin >> n >> k;
    vi a(n); rep(i, n) cin >> a[i];
    long long min_cost = LLONG_MAX;
    bitrep(b, n)
    {
        bitset<14> bs(b);
        vi ta = a;
        long long cost = 0;
        int w = 0;
        rep2(i, 1, n)
        {
            if (ta[i] > ta[w]) w = i;
            else if (bs[i-1] == 1)
            {
                cost += ta[w] - ta[i] + 1;
                ta[i] = ta[w] + 1;
                w = i;
            }
        }
        int cnt = 1; int v = 0;
        rep2(i, 1, n)
        {
            if (ta[i] > ta[v])
            {
                cnt++;
                v = i;
            }
        }
        if (cnt >= k)
        {
            min_cost = min(cost, min_cost);
        }
    }
    cout << min_cost << endl;
}

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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  if ((B / K) < 1) {
    cout << "NG" << endl;
    return 0;

  }
  int amari = B % K;
  if ((B - amari) < A) {
    cout << "NG" << endl;
    return 0;

  }
  cout << "OK" << endl;
}

Measured memory_bytes: 3568
#include <cstdio>
long long le[32];
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		for (int j = 30; j >= 0; j--) {
			int xh = x >> j;
			int kh = k >> j;
			if ((xh & kh) != xh) {
				continue;
			}
			if (j == 0) {
				le[j] += y;
				continue;
			}
			if ((x >> (j - 1) & 1) < (k >> (j - 1) & 1)) {
				le[j] += y;
			}
		}
	}
	long long ans = 0;
	for (int j = 30; j >= 0; j--) {
		if (ans < le[j]) {
			ans = le[j];
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
'use strict'

main()

function main (input) {
  readInput()
  .then(parseInput)
  .then(calc)
}

function calc (input) {
  let n = input[0][0]
  let k = input[0][1]
  let operations = new Array(n).fill(0).map(
    (_, i) => ({ a: input[i + 1][0], b: input[i + 1][1] })
  )
  operations.sort((one, another) => one.a - another.a)
  for (let op of operations) {
    let a = op.a
    let b = op.b
    if (k > b) {
      k -= b
    } else {
      console.log(a)
      return
    }
  }
}

function parseInput (inputRaw) {
  let input = inputRaw.split('\n').map(row => row.split(' ').map(Number))
  return input
}

function readInput () {
  return new Promise((resolve) => {
    let inputArr = []
    process.stdin.resume()
    process.stdin.setEncoding('utf8')
    process.stdin.on('data', (chunk) => {
      inputArr.push(chunk)
    })
    process.stdin.on('end', () => {
      let input = inputArr.join('').trim()
      resolve(input)
    })
  })
}


Measured memory_bytes: 54396
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
#include<fstream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;




int main(){
    ll n,m;
    cin>>n>>m;
    vector<deque<ll>> a(n);
    vector<ll> C(m,0);
    ll mx=0;
    ll w=-1;
    for(int i=0;i<n;i++){
        for(int t=0;t<m;t++){
            ll b;
            cin>>b;
            b--;
            a[i].push_back(b);
            if(t==0){
                C[b]++;
                if(mx<C[b]){mx=C[b]; w=b;}
            }
        }
    }
    vector<bool> done(m,false);
    ll er=m;
    ll ans=mx;
    while(er>1){
        if(done[w]){continue;}
        done[w]=true;
        er--;
        C[w]=0;
        for(int i=0;i<n;i++){
            while(done[a[i][0]]){
                a[i].pop_front();
                if(!done[a[i][0]]){
                    C[a[i][0]]++;
                }
            }
        }
        //cout<<w;
        mx=0; w=-1;
        for(int i=0;i<m;i++){
            //cout<<" "<<C[i];
            if(mx<C[i]){mx=C[i]; w=i;}
        }
        //cout<<endl;
        ans=min(ans,mx);
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 1024
from itertools import groupby

s = input()
gr = groupby(s)

ans = 0
n_prev = 0
k_prev = '0'
for k, g in gr:
    n = len(list(g))
    n_sum = n * (n + 1) // 2 
    ans += n_sum
    if k_prev == '<' and n_prev < n:
        ans -= n_prev
    elif k_prev == '<' and n_prev >= n:
        ans -= n
    n_prev = n
    k_prev = k

print(ans)

Measured memory_bytes: 8328
// Created by sz
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int h,w,ink;
    cin >> h >>w >> ink;
    vector<string> s(h);
    for (int i = 0; i < h; i++){
        cin >> s[i];
    }
    
//    vector<vector<int>> cntw(h, vector<int>(w,0));
//    int total = 0;
//    for (int i = 0; i < h; i++){
//        for (int j = 0; j < w; j++){
//            total += s[i][j] == '1';
//            if(j == 0) cntw[i][j] = s[i][j] == '1';
//            else cntw[i][j] = cntw[i][j-1] + (cntw[i][j] == '1');
//
//            if(i != 0){
//                cntw[i][j] += cntw[i-1][j];
//            }
//        }
//    }
//
    int ans = h-1  + w-1;
    
    for (int i = 0; i <= (1<<(h-1))-1; i++){
        int last = 0;
        vector<int> pos;
        pos.push_back(0);
        for (int j = 0; j <= h-1; j++){
            if(i &(1 << j))pos.push_back(j+1);
        }
        pos.push_back(h);
        int curans = pos.size() - 2;
        vector<int> ssum(pos.size()-1, 0);
        int valid = 1;
        for (int j = 0; j < w; j++){
            int ok = 1;
            vector<int> tmp(pos.size()-1, 0);
            for (int k = 0; k < pos.size()-1; k++){
                for(int l = pos[k]; l < pos[k+1]; l++){
                    tmp[k] += (s[l][j] == '1');
                }
                if(tmp[k] > ink)valid = 0;
                if(ssum[k]+ tmp[k] > ink ) ok = 0;
            }
            
            if(!valid)break;
            if(ok){
                for (int l = 0; l< ssum.size(); l++) {
                    ssum[l] += tmp[l];
                }
            }
            else{
                curans++;
                for (int l = 0; l< ssum.size(); l++) {
                        ssum[l] = tmp[l];
                }
                
            }
        }
        if(valid)ans = min(ans, curans);
    }
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val str:String = StdIn.readLine()

    val A:Int = str.split(" ")(0).toInt
    val B:Int = str.split(" ")(1).toInt

    val sum:Int = A + B
    val sub:Int = A - B
    val mul:Int = A * B

    println(List(sum, sub, mul).max)
  }
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string s;
    cin>>s;
    
    for(int i = 0; i < 3; i++)
    {
        if(s[i] =='1')
        {
            cout << '9';
        }
        else
        {
            cout << '1';
        }
    }
    cout<<endl;
    

    return 0;
}

Measured memory_bytes: 256
// 
// WIP
// 

#include<stdio.h>
int main(void){
	long n;
	long x = 0;
	long y = 10;
	scanf("%ld", &n);
	if(n%2 != 0){
	}
	else{
		while(n >= y){
			x += n/y;
			y *= 5;
		}
	}
	printf("%ld\n", x);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main()
{
    while (1)
    {

        int i, j, h, w;

        scanf("%d %d", &h, &w);

        if (h == 0 && w == 0)
        {

            break;
        }

        for (i = 1; i <= h; i++)
        {

            for (j = 1; j <= w; j++)
            {

                if (i != 1 && i != h && j != 1 && j != w)
                {
                    printf(".");
                }

                else
                {

                    printf("#");
                }
            }

            printf("\n");
        }

        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2032