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

using namespace std;

int main()
{
    int A, B, C, K, Sum = 0;
    vector<int> v;
    cin >> A >> B >> C >> K;

    v.push_back(A);
    v.push_back(B);
    v.push_back(C);

    for (int i = 0; i < K; i++)
    {
        sort(v.begin(), v.end(),greater<>());
        v[0] = v[0] * 2;
    }

    for (int i = 0; i < v.size(); i++)
    {
        Sum += v[i];
    }
  
  cout << Sum;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n,m,k;
  cin >> n >> m >> k;
  vector<ll>a(n+1),b(m+1);
  a[0]=0;
  b[0]=0;
  rep(i,n){
    ll x;
    cin >> x;
    a[i+1]=a[i]+x;
  }
  rep(i,m){
    ll x;
    cin >> x;
    b[i+1]=b[i]+x;
  }
  if(b[1]>k && a[1]>k){
    cout << 0 << endl;
    return 0;
  }
  if(a[1]>k){
    ll ans = 0;
    rep(i,m+1){
      if(b[i]<=k)ans=i;
    }
    cout << ans << endl;
    return 0;
  }
  if(b[1]>k){
    ll ans = 0;
    rep(i,n+1){
      if(a[i]<=k)ans=i;
    }
    cout << ans << endl;
    return 0;
  }
  ll ans=0;
  rep(i,n+1){
    ll t=a[i];
    if(t>k)break;
    ll l=0,r=m+1;
    while(abs(r-l)>1){
      ll mid = (l+r)/2;
      if(t+b[mid]>k)r=mid;
      else l=mid;
    }
    ans=max(ans,i+l);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6364
#include<bits/stdc++.h>
using namespace std;
#define bitCount(num)  __builtin_popcount(num)
#define pb push_back
#define ll long long
#define bye return 0;
#define f(i,a,b) for( long long i=a;i<b;i++)
#define testCases long long t;cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define newLine <<"\n"
#define all(x) (x).begin(), (x).end()
#define vll vector<long long>

void showDP(vector<vector<ll>> dp)
{
	f(i,0,dp.size())
	{
		f(j,0,dp[i].size())
		{
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}
}




ll knapSack(vector<pair<ll,ll>> p,vector<vector<ll>> &dp, ll w, ll currSum=0, ll n=0)
{
     // showDP(dp);

	if(n==p.size()) 
		return dp[n][currSum]=0;


if(dp[n][currSum]!=-1) return dp[n][currSum];
   // cout<<"value is: "<<p[n].first<<endl;


   // cout<<n<<" "<<currSum<<endl; 

  if(currSum + p[n].first <= w) 
  	{
  		ll ans1= p[n].second+knapSack(p,dp,w,currSum+p[n].first,n+1);
  		ll ans2=knapSack(p,dp,w,currSum,n+1);
  		return dp[n][currSum] =max(ans1,ans2);
  	}

  else return dp[n][currSum]=knapSack(p,dp,w,currSum,n+1);

}



int main()
{
    fast

    ll n,w;
    cin>>n>>w;
    vector<pair<ll,ll>> p;

    f(i,0,n)
    {
    	ll a,b;
    	cin>>a>>b;
    	p.pb(make_pair(a,b));
    }

    // sort(p.begin(),p.end());
// cout<<p.size()<<endl;
    // cout<<p.size()<<endl;
    vector<vector<ll>> dp(n+1, vector<ll>(w+1,-1));
    cout<<knapSack(p,dp,w);




   
    bye
}

Measured memory_bytes: 83072
#include<bits/stdc++.h>
using namespace std;
#define N 1000005
char s[N];
int n,a,b,c,d;
int main()
{
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	scanf("%s",s+1);
	if(s[c]=='#'||s[d]=='#')
	{
		printf("No");
		return 0;
	}
	s[0]='.';
	while(a<c)
	{
		if(a==c||(s[a-1]=='.'&&s[a+1]=='.'))
			break;
		if(s[a+1]=='.'&&a+1!=b)
			a++;
		else
		{
			if(s[a+2]=='.'&&a+2!=b)
				a+=2;
			else
			{
				break;
			}
		}
	}
	while(b<d)
	{
		if(b==d||(s[b-1]=='.'&&s[b+1]=='.'))
			break;
		if(s[b+1]=='.'&&b+1!=a)
			b++;
		else
		{
			if(s[b+2]=='.'&&b+2!=a)
				b+=2;
			else
			{
				break;
			}
		}
	}
	while(a<c)
	{
		if(a==c)
			break;
		if(s[a+1]=='.'&&a+1!=b)
			a++;
		else
		{
			if(s[a+2]=='.'&&a+2!=b)
				a+=2;
			else
			{
				printf("No");
				return 0;
			}
		}
	}
	while(b<d)
	{
		if(b==d)
			break;
		if(s[b+1]=='.'&&b+1!=a)
			b++;
		else
		{
			if(s[b+2]=='.'&&b+2!=a)
				b+=2;
			else
			{
				printf("No");
				return 0;
			}
		}
	}
	printf("Yes");
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			long N = scan.nextLong();
			long A = scan.nextLong();
			long B = scan.nextLong();


			if(A>B) {
				System.out.println(0);
				return;
			}

			if(N==1&& A!=B) {
				System.out.println(0);
				return;
			}

			if(N==1) {
				System.out.println(1);
				return;
			}

			long max = A+B+(N-2)*B;
			long min = A+B+(N-2)*A;

			System.out.println(max-min+1);



		}


	}


}


Measured memory_bytes: 35620
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };



int main() {
	int N,M;
	scanf("%d%d", &N,&M);
	int K[40];
	int A[40][40];

	int love[40] = {0};
	int count = 0;

	for (int i = 0; i < N; i++) {
		scanf("%d", &K[i]);
		for (int j = 0; j < K[i]; j++) {
			scanf("%d", &A[i][j]);
			love[A[i][j]-1]++;
		}
	}
	for (int i = 0; i < M; i++)
		if (love[i] == N)count++;

	printf("%d", count);

}





/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
・文字列の＜＜スペル＞＞は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

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

long long N, Q;
string S;

set<long long> pos[30];

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

	for(long long i = 0; i < N; i++) {
		pos[S[i] - 'a'].insert(i);
	}

	for(long long i = 0; i < Q; i++) {
		long long q;
		cin >> q;

		if(q == 1) {
			long long idx;
			char c;
			cin >> idx >> c;
			idx--;

			for(long long al = 0; al < 30; al++) {
				pos[al].erase(idx);
			}
			pos[c - 'a'].insert(idx);
		} else {

			long long left, right;
			cin >> left >> right;
			left--;right--;


			long long ans = 0;
			for(long long al = 0; al < 30; al++) {
				set<long long>::iterator it = pos[al].lower_bound(left);
				if(it == pos[al].end()) continue;
				if((*it) >= left && (*it) <= right) {
					ans++;
				}
			}
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 27200
#include <stdio.h>

int main()
{
	int input = 0;
	int hour = 0;
	int minute = 0;
	int second = 0;

	scanf("%d", &input);

	hour = input / 3600;
	input -= hour * 3600;
	minute = input / 60;
	input -= minute * 60;
	second = input;

	printf("%d:%d:%d\n", hour, minute, second);
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;

int main(){
	int N, E = 0, W = 0, min, count;
	string S;
	cin >> N;
	min = N;
	S.reserve(N);

	cin >> S;

	for (int i = 0; i < N; ++i){
		if (S[i] == 'E')
			++E;
		else
			++W;
	}
	int e = 0, w = 0;

	if (S[0] == 'E'){
		min = E - 1;
		++e;
	}
	else{
		min = E;
		++w;
	}
	for (int i = 1; i < N - 1; ++i){
		if (S[i] == 'E'){
			if (E + 1 - e + w < min)
				min = E + 1 - e + w;
			++e;
		}
		else{
			if (E - e + w < min)
				min = E - e + w;
			++w;
		}
	}

	if (S[N - 1] == 'W'){
		if (W - 1 < min)
		min = W - 1;
	}
	else{
		if (W < min)
			min = W;
	}
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 512
// 基本テンプレート
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[10][2][2][2][2][2];
signed main() {
    string s; cin >> s;
    int d = s.length();
    // int d = 0, M = N;
    // while(M > 0) d++, M /= 10;

    vector<int> cand = {7, 5, 3, 0};
    dp[0][0][0][0][0][0] = 1;
    for(int i=0; i<d; i++) {
        for(int e7=0; e7<2; e7++) {
            for(int e5=0; e5<2; e5++) {
                for(int e3=0; e3<2; e3++) {
                    for(int f=0; f<2; f++) {
                        for(int z=0; z<2; z++) {
                            int lim = f ? 9 : s[i] - '0';
                            for(auto x : cand) {
                                if(x > lim) continue;
                                if(z == 1 and x == 0) continue;
                                int n7 = e7 || (x == 7);
                                int n5 = e5 || (x == 5);
                                int n3 = e3 || (x == 3);
                                int nf = f || (x < lim);
                                int nz = z || (x != 0);
                                dp[i+1][n7][n5][n3][nf][nz] += dp[i][e7][e5][e3][f][z];
                            }
                        }
                    }
                }
            }
        }
    }

    int ans = dp[d][1][1][1][0][1] + dp[d][1][1][1][1][1];
    // ans += dp[d][1][1][1][0][0] + dp[d][1][1][1][1][0];

    fprintf(stderr, "ans[d][1][1][1][0][0] = %lld\n", dp[d][1][1][1][0][0]);
    fprintf(stderr, "ans[d][1][1][1][0][1] = %lld\n", dp[d][1][1][1][0][1]);
    fprintf(stderr, "ans[d][1][1][1][1][0] = %lld\n", dp[d][1][1][1][1][0]);
    fprintf(stderr, "ans[d][1][1][1][1][1] = %lld\n", dp[d][1][1][1][1][1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int N, M;
int Sum[100005], Leaf[100005];
vector <int> G[100005];
queue <int> Q, Q2;
bool Use[100005];
int Grade[100005];
void Read()
{
    cin >> N;
    for(int i = 1; i <= N - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        ++Grade[a];
        ++Grade[b];
        G[a].push_back(b);
        G[b].push_back(a);
    }
    //int cnt = 0;
    for(int i = 1; i <= N; i++)
        if(G[i].size() == 1)
        {
            Q.push(i);
        }
    int cnt = 0;
        while(!Q.empty())
        {
        int node = Q.front();


        Q.pop();
        if(Use[node] == 1)
            continue;
        ++cnt;
        if(Grade[node] == 0)
        {
            cout << "First\n";
            return;
        }
        Use[node] = 1;
        while(G[node].size() > 0 && Use[G[node].back()] == 1)
            G[node].pop_back();
        int neighb = G[node].back();
        --Grade[neighb];
        Use[neighb] = 1;
        for(int i = 0; i < G[neighb].size(); i++)
        {
            int n = G[neighb][i];
            if(Use[n] == 0)
            {
                --Grade[n];
                if(Grade[n] == 1)
                    Q.push(n);
            }
        }
        }

    cout << "Second\n";
}
int main()
{
    Read();
    return 0;
}


Measured memory_bytes: 6528
#include<stdio.h>
int main()
{
    int a[3][3];
	int i,j,i1,n,n0,n1,n2,tmp;
	j=0;

	scanf("%d %d %d",&n0,&n1,&n2);
	a[0][0]=n0;
	a[0][1]=n1;
	a[0][2]=n2;

	scanf("%d %d %d",&n0,&n1,&n2);
	a[1][0]=n0;
	a[1][1]=n1;
	a[1][2]=n2;

	scanf("%d %d %d",&n0,&n1,&n2);
	a[2][0]=n0;
	a[2][1]=n1;
	a[2][2]=n2;

    scanf("%d", &n);
	for (i1=0;i1<n;i1++){
		scanf("%d",&tmp);
		for (i=0;i<3;i++){
			for (j=0;j<3;j++){
				if (a[i][j]==tmp)
					a[i][j]=-1;
			}
		}
	}


	if ((a[0][0]==-1) && (a[0][1]==-1) && (a[0][2]==-1)){
		printf("Yes\n");
		return 0;
	}
	else if ((a[1][0]==-1) && (a[1][1]==-1) && (a[1][2]==-1)){
		printf("Yes\n");
		return 0;
	}
	else if ((a[2][0]==-1) && (a[2][1]==-1) && (a[2][2]==-1)){
		printf("Yes\n");
		return 0;
	}
	else if ((a[0][0]==-1) && (a[1][0]==-1) && (a[2][0]==-1)){
		printf("Yes\n");
		return 0;
	}
	else if ((a[0][1]==-1) && (a[1][1]==-1) && (a[2][1]==-1)){
		printf("Yes\n");
		return 0;
	}
	else if ((a[0][2]==-1) && (a[1][2]==-1) && (a[2][2]==-1)){
		printf("Yes\n");
		return 0;
	}
	else if ((a[0][0]==-1) && (a[1][1]==-1) && (a[2][2]==-1)){
		printf("Yes\n");
		return 0;
	}
	else if ((a[0][2]==-1) && (a[1][1]==-1) && (a[2][0]==-1)){
		printf("Yes\n");
		return 0;
	}
	else {
		printf("No\n");
    	return 0;
	}
}


Measured memory_bytes: 128
class Binary_Indexed_Tree():
    def __init__(self, n):
        self.bit = [0]*n
        self.n = n
    def add(self, ind, num):
        while(ind <= self.n):
            self.bit[ind - 1] += num
            ind += ind & -ind
    def sum(self, ind):
        ret = 0
        while(ind > 0):
            ret += self.bit[ind-1]
            ind -= ind & -ind
        return ret

class Binary_Indexed_Tree_RAQ_RSQ():
    def __init__(self,n):
        self.p = Binary_Indexed_Tree(n+1)
        self.q = Binary_Indexed_Tree(n+1)

    def add(self, s,t,x):
        t += 1
        self.p.add(s,-x*s)
        self.p.add(t, x*t)
        self.q.add(s,x)
        self.q.add(t,-x)

    def sum(self, s, t):
        t += 1
        return self.p.sum(t) + self.q.sum(t)*t - self.p.sum(s) - self.q.sum(s)*s

n,m = map(int, input().split())
a = list(map(lambda x: int(x)-1, input().split()))
score = Binary_Indexed_Tree_RAQ_RSQ(2*m+10)


for i in range(n-1):
    cur, nxt = a[i], a[i+1]
    if cur > nxt:
        nxt += m
    if cur + 2 <= nxt:
        score.add(cur+3, nxt+1, 1)
        k = nxt-cur-1
        score.add(nxt+2, nxt+2, -k)

scores = [score.sum(0, i+1)+score.sum(0, i+m+1) for i in range(m)]

x = tmp = 0
for i in range(m):
    if scores[i] > tmp:
        x = i
        tmp = scores[i]
ans = 0

def cnt(cur, nxt):
    if cur > nxt:
        nxt += m
    return nxt-cur

for i in range(n-1):
    cur, nxt = a[i], a[i+1]
    ans += min(cnt(cur, nxt), cnt(x, nxt)+1)

print(ans)



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

ans = 0
if x == 1:
    ans = 1
else:
    for i in range(2, int(x**0.5)+1):
        j = 2
        while True:
            if i**j > x:
                break
            else:
                ans = max(i**j, ans)
                j += 1

print(ans)


Measured memory_bytes: 9316
//confilm 0LL and 1LL
//confilm cornercases such as 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n;
	cin >> n;
	ll m = 0;
	repn(i, n){
		if(i*(i+1)/2 == n){
			m = i;
			puts("Yes");
			co(m+1);
			break;
		}else if(i*(i+1)/2 > n){
			puts("No");
			return 0;
		}
	}

	VecVec s(m+1);
	ll l = 0, r = 1;
	repn(i, m*(m+1)/2){
		s[l].pb(i);
		s[r].pb(i);
		if(++r == m+1){
			l++; r = l+1;
		}
	}

	rep(i, m+1){
		cosp(m);
		rep(j, m) cosp(s[i][j]);
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

int main() {
    int h,w;cin>>h>>w;
    vector<string> C(h+1);
    for(auto i = 1; i<=h;i++) cin>>C[i];
    
    for(auto i =1; i<=2*h;i++){
        cout<<C[(i+1)/2]<<endl;
    }
    return 0;
}







Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
a.sort()
b.sort()
if n % 2 == 0:
    ans = 0
    ans += b[n // 2 - 1] + b[n // 2]
    ans -= a[n // 2 - 1] + a[n // 2]
    print(ans + 1)
else:
    print(b[n // 2] - a[n // 2] + 1)


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

int main(){
    
    // 1. 入力情報.
    char c[11];
    scanf("%s", c);
    
    // 2. 母音か判定.
    bool ans = false;
    if(c[0] == 'a') ans = true;
    if(c[0] == 'e') ans = true;
    if(c[0] == 'i') ans = true;
    if(c[0] == 'o') ans = true;
    if(c[0] == 'u') ans = true;
    
    // 3. 出力.
    printf("%s\n", ans ? "vowel" : "consonant");
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << "a > b" << endl;
	}
	else if (a < b) {
		cout <<"a < b"<< endl;
	}
	else
	{
		cout << "a == b" << endl;
	}
	return 0;
}



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

int main(){
	int n;cin>>n;
	int d[n];
	rep(i,n) cin>>d[i];
	sort(d,d+n);

	cout<<d[n/2]-d[n/2-1]<<"\n";
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
    int v;
    cin >> v;
    int a, b, c, d;
    d = v % 10;
    c = (v / 10) % 10;
    b = (v / 100) % 10;
    a = (v / 1000) % 10;
    uint8_t n = 3;
    uint8_t result = 0;
    int array[3] = {b, c, d};
    for (uint8_t bit = 0; bit < (1 << n); ++bit) {
        int sum = a;
        for (uint8_t i = 0; i < n; ++i) {
            if (bit & (1 << i)) {
                sum += array[i];
            }
            else {
                sum -= array[i];
            }
        }
        if (sum == 7) {
            result = bit;
            break;
        }
    }
    cout << a << ((result & (1 << 0)) ? "+" : "-") << b << ((result & (1 << 1)) ? "+" : "-") << c << ((result & (1 << 2)) ? "+" : "-") << d << "=7" << endl;
    return EXIT_SUCCESS; 
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf ((ll)1e18+1)
#include<chrono>
using namespace chrono;
mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define debr(x,y) {cout<<"-->  "<<#x<<" to "<<#y<<" :  "; auto itr=x; while(itr!=y) cout<<(*itr++)<<' '; cout<<endl; }
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s);istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"  ,  ";
    err(++it, args...);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll t=n/1000;
    if(n%1000){
        t++;
    }
    ll ans=t*1000-n;
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 3652
import itertools
K=int(input())
 
result=[]
count=0
cnt=0
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
 
 
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans1=gcd(j,k)
      count=gcd(i,ans1)
      cnt+=count
      
print(cnt)

Measured memory_bytes: 74056
#include <stdio.h>

  int main()
  {
    int a,b;
    scanf("%d %d",&a,&b);
    if(a < b){
      printf("a < b\n");
    }else if(a > b){
      printf("a > b\n",a,b);
    }else{
      printf("a == b\n",a,b);
    }
    return 0;
  }


Measured memory_bytes: 2088
import sys

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

s=SI()
ans=0
for b in range(1<<(len(s)-1)):
    f=""
    for i,c in enumerate(s):
        f+=c
        if b>>i&1:f+="+"
    ans+=eval(f)
print(ans)


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

int main(){
  int t,m1 = 1 << 25,m2 = 1 << 25;
  for(int i=0;i<3;i++){
    cin >> t; m1 = min(m1,t);
  }
  for(int i=0;i<2;i++){
    cin >> t; m2 = min(m2,t);
  }
  cout << m1 + m2 - 50 << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <string>
#include <cmath>
using namespace std;

typedef long long ll;

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 (b < a) {a = b; return 1;} return 0;}

int main() {
    int n;
    cin >> n;
    int a[n];
    vector<int> ans[n+1];

    a[0] = 0;

    for (int i = 1; i < n+1; i++) cin >> a[i];

    int cont = a[1];
    for (int i = 2; i < n+1; i++) {
        if (a[i-2] > a[i-1]) {
            if (a[i-1] < a[i]) {
                cont = cont + (a[i] - a[i-1]);
                continue;
            }
        }
        if (a[i-1] < a[i])
            cont = cont + (a[i] - a[i-1]);
    }
    cout << cont << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))

int main() {
	char c[100];
	scanf("%s", c);
	if (c[1] == 'R')printf("ABC");
	else printf("ARC");
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define rep(i,a,b) for(int i=a; i<b; i++)
#define dep(i,a,b) for(int i=a; i>=b; i--)
#define ALL(x)	(x).begin(), (x).end()
using namespace std;
const long long INF = 1e18 , MAXN =1e5, MOD = 1e9 + 7,N=1000010;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
	vector<int>stone;
	rep(i,0,n){
		int x;cin>>x;stone.pb(x);
	}
	vector<int>ans;
	ans.pb(0);
	ans.pb(abs(stone[0]-stone[1]));
	rep(i,2,n){
		ans.pb(min(ans[i-1]+abs(stone[i]-stone[i-1]),ans[i-2]+abs(stone[i]-stone[i-2])));
	}
	cout<<ans.back()<<"\n";
return 0;
}


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

int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double sum = 0.0;
    vector<int> v(N);
    for(int i = 0; i < N; i++) v[i] = i + 1;
    do {
        for(int i = 0; i < N - 1; i++) sum += dist(v[i], v[i+1]);
    } while(next_permutation(v.begin(), v.end()));
    int Factorial = 1;
    for(int i = 2; i <= N; i++) Factorial *= i;
    cout << fixed << setprecision(10) << sum / Factorial << endl;
    return;
}

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


Measured memory_bytes: 4244
#include <iostream>

void solve() {
    int a, b, c, k;
    std::cin >> a >> b >> c >> k;

    while (b <= a) {
        b *= 2;
        --k;
    }
    while (c <= b) {
        c *= 2;
        --k;
    }

    std::cout << (k >= 0 ? "Yes" : "No") << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3648
// C - Sentou
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,T; cin>>N>>T;
	int pre_start; cin>>pre_start;
	long long ans = 0;
	int end = T;
	while(--N){
		int cur_start; cin>>cur_start;
		ans += end>=cur_start? cur_start - pre_start: T;
		end = cur_start + T;
		pre_start = cur_start;
	}
	cout<< ans + T <<endl;
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
  {
    cin >> a.at(i);
  }
  vector<int> b(N);
  copy(a.begin(), a.end(), back_inserter(b));
  sort(b.begin(), b.end(), greater<int>());
  int max = b.at(0);
  int second = b.at(1);
  int max_cnt = 1;
  int max_index = -1;
  for (int i = 1; i < N; i++)
  {
    if (b.at(i) == max)
    {
      max_cnt++;
    }
  }
  for (int i = 0; i < N; i++)
  {
    if (a.at(i) == max)
    {
      max_index = i + 1;
    }
  }
  if (max_cnt > 1)
  {
    for (int i = 0; i < N; i++)
    {
      cout << max << endl;
    }
  }
  else
  {
    for (int i = 1; i < N + 1; i++)
    {
      if (i == max_index)
        cout << second << endl;
      else
        cout << max << endl;
    }
  }
}


Measured memory_bytes: 3952
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    h, w = LI()
    a = LIR(h)
    b = LIR(h)
    mab = [[abs(a[y][x]-b[y][x]) for x in range(w)] for y in range(h)]
    ab = abs(a[0][0] - b[0][0])
    hw = h + w
    dp = [[0] * w for i in range(h)]
    dp[0][0] |= (1 << (6400 + ab) | 1 << (6400 - ab))
    for i in range(1, h + w - 1):
        for x in range(w):
            y = i - x - 1
            if 0 <= x < w and 0 <= y < h:
                value = dp[y][x]
            else:
                continue
            for mx, my in [[0, 1], [1, 0]]:
                mx += x
                my += y
                if 0 <= mx < w and 0 <= my < h:
                    mxy = mab[my][mx]
                    dp[my][mx] |= ((value << mxy) | (value >> mxy))
    ans = dp[-1][-1]
    for i in range(ans.bit_length()):
        if ans & (1 << (6400-i)):
            print(i)
            return
    return


#main
if __name__ == '__main__':
    solve()


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

int main(){

	int num[200][2];
	int count=0;

	while(cin >> num[count][0] >> num[count][1]){
		count++;
		if(count>199){
			break;
		}
	}

	int sum;

	for(int i=0;i<count;i++){
		sum=num[i][0]+num[i][1];
		int ans=0;

		while(sum!=0){
			sum = sum/10;
			ans++;
		}
		cout << ans << endl;
	}

    return 0;
}


Measured memory_bytes: 3008
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <thread>///////////////////

#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<int> w;
vector<long long int> vll;
vector<long long int> wll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;

//int N, Y;
int mode = 0;

//tuple<int, int, int> calc(int A, int B, int C) {}



int main() {
	int N, M;
	cin >> N >> M;
	cout << (N*(N - 1) + M * (M - 1)) / 2 << '\n';

	return 0;
}

Measured memory_bytes: 256
s=input()
ans=0
if len(s)%2==0:
  for i in range(len(s)//2):
    if s[i]!=s[-1-i]:
      ans+=1
else:
  for i in range((len(s)-1)//2):
    if s[i]!=s[-1-i]:
      ans+=1
print(ans)

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

int act[100100][3];
int dp[100100][3];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> act[i][j];
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + act[i][k]);
            }
        }
    }

    int ans = max(dp[N][0], max(dp[N][1], dp[N][2]));

    cout << ans << endl;
}

Measured memory_bytes: 5944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 100000000;
const int MOD = 1000000007;

int main(){
  string s;
  int counter=0;
  std::cin >> s;
  rep(i,s.size())if(s[i]=='x')counter++;
  if(counter>=8)std::cout << "NO" << std::endl;
  else std::cout << "YES" << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
using namespace std;

int main() {
	while(true){
		int a, b;
		char x;
		cin >> a >> x >> b;
		if(x == '?') break;
		if(x == '+') cout << a+b << endl;
		if(x == '-') cout << a-b << endl;
		if(x == '*') cout << a*b << endl;
		if(x == '/') cout << a/b << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007

using namespace std;

int main()
{

   //// freopen("input.txt", "r", stdin);
   /// freopen("output.txt", "w", stdout);
    int x, y;
    cin >> x >> y;
    if (y % 2 == 0 && y >= 2 * x && y <= 4 * x)
    {
        cout << "Yes\n";
    }
    else
        cout << "No"
             << "\n";
    return 0;
}

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

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

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}





void _main() {
        double a, b, x; cin >> a >> b >> x;
        if (a * a * b < 2 * x){
                double y = 2 * (b - x / (a * a));
                cout << fixed << setprecision(10) << atan(y / a) * 180 / M_PI << '\n';
        }
        else {
                double y = (2 * x) / (a * b);
                cout << fixed << setprecision(10) << atan(b / y) * 180 / M_PI;
        }
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 4112
#include <iostream>
#include <cmath>

using namespace std;

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

    for(int i = 0; i <= n; i++)
    {
        int cnt = 0;
        int tmp = i;
        while(tmp > 0)
        {
            cnt += tmp % 6;
            tmp /= 6;
        }

        tmp = n - i;
        while(tmp > 0)
        {
            cnt += tmp % 9;
            tmp /= 9;
        }

        if(res > cnt)
        {
            res = cnt;
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define llint long long
#define inf 2000000000000000005

using namespace std;

llint N, M;
llint Min[100005], Max[100005];

llint parent[100005];
llint val[100005];

void init(){
	for(llint i = 1; i <= N; i++){
		parent[i] = i;
		val[i] = 0;
	}
}

llint root(llint i)
{
	if(parent[i] == i) return i;
	int prev = parent[i];
	parent[i] = root(parent[i]);
	val[i] = val[prev] + val[i];
	return parent[i];
}

void unite(llint i, llint j, llint v)
{
	llint root_i = root(i), root_j = root(j);
	if(root_i == root_j) return;
	parent[root_i] = root_j;
}

bool same(llint i, llint j)
{
	return root(i) == root(j);
}

int main(void)
{
	cin >> N >> M;
	init();
	
	llint l, r, d;
	for(int m = 0; m < M; m++){
		cin >> l >> r >> d;
		
		llint root_l = root(l), root_r = root(r);
		if(root_l == root_r){
			if(val[l] +  d != val[r]){
				cout << "No" << endl;
				return 0;
			}
		}
		parent[root_r] = root_l;
		val[root_r] = val[l] - val[r] + d;
	}
	
	for(llint i = 1; i <= N; i++) root(i);
	for(llint i = 1; i <= N; i++) if(val[i] > 1000000000){
		cout << "No" << endl;
		return 0;
	}
	
	cout << "Yes" << endl;
	return 0;
}

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

int main() {
    int n, q, k;

    cin >> n >> k >> q;
    vector< int > a(n + 1, 0);

    for(int i = 0; i < q; i++) {
        int c; cin >> c;
        a[c]++;
    }

    for(int i = 1; i <= n; i++) {
        if(k - q + a[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 1024
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():
    s = input()
    t = input()
    cnt = 0
    for i in range(3):
        if s[i] == t[i]:
            cnt+=1

    print(cnt)

main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }



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

	int n; cin >> n;
	char fi[n][n];

	for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) cin >> fi[i][j];
	int ans = 0;

	for(int b=0; b<n; ++b){
		bool flg = true;
		for(int i=0; i<n; ++i){
			for(int j=0; j<n; ++j){
				if(fi[i][(j+b)%n] != fi[j][(i+b)%n]) flg = false;
				// if(b == 1){
				// 	printf("(i, j) = %c\n", fi[i][(j+b)%n]);
				// 	printf("(j, i) = %c\n", fi[j][(i+b)%n]);
				// }
			}
		}
		if(flg) ans += n;
	}

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

Measured memory_bytes: 384
"""
https://abc086.contest.atcoder.jp/tasks/abc086_b
"""
[a,b]=[i for i in input().split()]
s=int(a+b)
i=1
while (i**2)<=s:
    i=i+1

if (i-1)**2==s:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
h,w = map(int,input().split())
s = [list(input()) for i in range(h)]
for i in range(h):
    s[i].insert(w,0)
    s[i].insert(0,0)
s.insert(h,[0]*(w+2))
s.insert(0,[0]*(w+2))
x = '#'
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] == x:
            if s[i-1][j] == x or s[i][j-1] == x or s[i][j+1] == x or s[i+1][j] == x:
                pass
            else:
                print('No')
                exit(0)

print('Yes')

Measured memory_bytes: 9152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);
            int iC = int.Parse(sS[2]);
            int iD = int.Parse(sS[3]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = iC * iD;
            int iAB = iA * iB;
            if (iOut < iAB) { iOut = iAB; }

            //出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

ll n;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  rep(i, 1, n) {
    rep(j, i+1, n+1) {
      ll k=0;
      while (!(((j>>k)&1)^((i>>k)&1))) k++;
      cout << k+1;
      if (j != n) cout << ' ';
    }
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define inp(a) int a; cin>>a;
#define inpa(a,n) vector<int>a(n+2); FOR(i,1,n) cin>>a[i];
#define PI 3.141592653589793238
#define vec(x) vector<x>
#define pii pair<int,int>
#define mem(a,b) memset(a, b, sizeof a)
#define FOR(i,j,n) for(int i= j; i<=n; i++)
#define CASE int t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define print(x) for(auto c : x) cout << c << " ";
#define dbg(x) cerr << #x << " :: "<< x << endl;
#define dbg2(x,y) cerr << #x << " :: "<<x <<"\t" << #y << " :: "<<y <<endl;
const int INF = 1e9 + 7;
const int maxn = 1e6 + 3;
const int MOD = 1e9 + 7; 
//////////// template ends here //////////////////////////

vec(int)dp(maxn, -1);
vec(int)h(maxn, 0);

int topdown(int n, int k) {
	if(n == 1)
		return 0;
	if(dp[n] != -1)
		return dp[n];
	int sub = INF;

	FOR(i,1,k){
		if(n-i > 0)
			sub = min(sub, topdown(n-i, k) + abs(h[n]-h[n-i]));
	}

	return dp[n] = sub;

}


void solve(){
	inp(n); inp(k);
	FOR(i,1,n)
		cin>>h[i];

	cout << topdown(n, k) << endl;


}



int32_t main(){
	#ifndef ONLINE_JUDGE 
		freopen ("input.txt","r",stdin);
		freopen ("output.txt","w",stdout);
	#endif	
	 ios::sync_with_stdio(0); 
	 cin.tie(0); cout.tie(0);
	//CASE{
		solve();
	//}

	cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
}

Measured memory_bytes: 23516
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<int> h(n); rep(i, n)cin >> h[i];
	int res = 0;
	while (1)
	{
		if (*max_element(all(h)) == 0)break;

		int i = 0;
		while (i < n)
		{
			if (h[i] == 0)++i;
			else
			{
				++res;
				while (i < n && h[i]>0)
				{
					--h[i];
					++i;
				}
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		Scanner sc =new Scanner(System.in);
		int a[] =new int[5];
		int b[] =new int[5];
		int sum=0;
		int min=0;
		for(int i=0;i<5;i++) {
			a[i]=sc.nextInt();
			b[i]=a[i]+9;
			b[i]=b[i]-b[i]%10;
			sum+=b[i];
			min = Math.max(min, b[i]-a[i]);

		}
		
		System.out.println(sum-min);

}
}





Measured memory_bytes: 22740
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
#include<numeric>
//AtCoderC++.cpp

using namespace std;

int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a == b + c || b == a + c || c == a + b) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

  int main(){
    ll n,k;
    string s;
    cin >> n >> k;
    ll ans= 1LL << 62;
    ll atemp;
    atemp = (n/k)-1;
    rep(i,4){
      ans=min(abs(n-atemp*k),ans);
      atemp++;
    }
    
    cout << ans << endl;

    return 0;
  }

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b)
	{
		if(b<c)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int a=in.nextInt();
		int b=in.nextInt();
		int c=in.nextInt();
		int ans;
		ans=((a+b)*c)/2;
		System.out.println(ans);
		}
}

Measured memory_bytes: 23252
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int max_a = 1000001;

// aとbの最大公約数を求める関数
template <class T>
T gcd(T a, T b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> c(max_a);
    rep(i, n) {
        cin >> a[i];
        c[a[i]]++;
    }

    int all_gcd = 0;
    rep(i, n) all_gcd = gcd(all_gcd, a[i]);
    if (all_gcd > 1) {
        cout << "not coprime" << endl;
        return 0;
    }

    for (int i = 2; i < max_a; i++) {
        int cnt = 0;
        for (int j = i; j < max_a; j += i) {
            cnt += c[j];
        }
        if (cnt > 1) {
            cout << "setwise coprime" << endl;
            return 0;
        }
    }

    cout << "pairwise coprime" << endl;
    return 0;
}


Measured memory_bytes: 11032
#include <iostream>
#include <algorithm>
#include <string.h>
#include <unordered_map>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int k,s;
unordered_map<int,int> cnt;

int main() {
	scanf("%d%d",&k,&s);
	for (int i=0;i<=k;i++) {
		for (int j=0;j<=k;j++) {
			cnt[i+j]++;
		}
	}
	ll ans=0;
	for (int i=0;i<=k;i++) {
		ans+=(ll)cnt[s-i];
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := make([]string, N)
	pre := 0

	P1 := 0
	P2 := 0
	used := false
	other := false
	nc := 0
	for i := 0; i < N; i++ {
		A[i] = sc.NextLine()
		pre += strings.Count(A[i], "AB")

		k := true
		if A[i][0] == 'B' && A[i][len(A[i])-1] == 'A' {
			if !used {
				k = false
			}
			used = true
		}
		if A[i][0] == 'B' {
			if k {
				P1++
			} else {
				nc++
			}
		}

		if A[i][len(A[i])-1] == 'A' {
			P2++
			if A[i][0] != 'B' {
				other = true
			}
		}
	}
	if other && used {
		P1 += nc
	}
	//fmt.Println(P1, P2, pre, nc)
	ans := min(P1, P2)

	fmt.Println(pre + ans)
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

using namespace std;

int main()
{
    int n,m,min=INT_MAX,max=INT_MIN,l,r;

    cin>>n>>m;
    while(m--){
        cin>>l>>r;
        if(l>max) max=l;
        if(r<min) min=r;
    }
    if(max>min) cout <<0<<endl;
    else cout << abs(max-min)+1<<endl;

    return 0;
}


Measured memory_bytes: 256