akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#define int long long int
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int x;
	cin>>x;
	if(x>=30)
	   cout<<"Yes"<<endl;
	else
	   cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
#include <utility>
#include <cmath>

struct XY
{
  long long x;
  long long y;
};

int main()
{
  int n, m;
  XY a[50];
  XY c[50];
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i)
  {
    long long x, y;
    scanf("%lld%lld", &a[i].x, &a[i].y);
  }
  for (int i = 0; i < m; ++i)
  {
    long long x, y;
    scanf("%lld%lld", &c[i].x, &c[i].y);
  }
  for (int i = 0; i < n; ++i)
  {
    int ans = 0;
    long long d = 1e12;
    for (int j = 0; j < m; ++j)
    {
      long long dd = std::abs(a[i].x - c[j].x) + std::abs(a[i].y - c[j].y);
      if (d > dd)
      {
        d = dd;
        ans = j;
      }
    }
    printf("%d\n", ans + 1);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

int N, M;

int main() {
    cin >> N >> M;
    cout << (N == M ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,w = map(int,input().split())

#d[i][j]:i→jへの距離
d = [[float("inf")]*n for i in range(n)]
for i in range(w):
   x,y,z = map(int,input().split())
   d[x][y] = z 


dp = [[-1] * n for i in range(1<<n)]


#訪れた集合がs、今いる点がvの時０に戻る最短経路
def rec(s,v):
    if dp[s][v] != -1:
        return dp[s][v]
        
    if s == (1<<n)-1 and v == 0:
        #全ての頂点を訪れた(s = 11...11 and v = 0)
        dp[s][v] = 0
        return 0
    
    res = float("inf")
    for u in range(n):
        if (s>>u&1) == 0:
            #uに訪れていない時(uの箇所が0の時),次はuとすると
            res = min(res,rec(s|(1<<u),u)+d[v][u])
            
    dp[s][v] = res
    return res
ans = rec(0,0)
if ans == float("inf"):
    print(-1)
else:
    print(ans)



Measured memory_bytes: 19260
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <queue>

using namespace std;

queue<int> q;
vector<int> lista[2010];
long long n,k,x,y,Rdist[2010],usa[2010],dist[2010];

void bfs(int x){
    usa[x]=x;
    dist[x]=0;
    for (int i=0;i<lista[x].size();i++){
        q.push(lista[x][i]);
        usa[lista[x][i]]=x;
        dist[lista[x][i]]=1;
    }
    while (!q.empty()){
        y = q.front(), q.pop();
        Rdist[dist[y]]++;
        for (int i=0;i<lista[y].size();i++){
            if (usa[lista[y][i]]!=x){
                usa[lista[y][i]]=x;
                dist[lista[y][i]]=dist[y]+1;
                q.push(lista[y][i]);
            }
        }
    }
}

int main()
{
    cin>>n>>x>>y;
    for (int i=1;i<n;i++){
        lista[i].push_back(i+1);
        lista[i+1].push_back(i);
    }
    lista[x].push_back(y);
    lista[y].push_back(x);
    for (int i=1;i<=n;i++) bfs(i);
    for (int i=1;i<n;i++) cout<<Rdist[i]/2<<endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#define MAX_LENGTH 10000
#define NIL -2
int main() {
    int num;
    int arr[MAX_LENGTH];
    for(int i=0;i!=MAX_LENGTH;i++){arr[i]=NIL;}
    scanf("%d", &num);
    for(int i = 1;i<num+1;i++)
    {
        scanf("%d", &arr[i]);
    }
    for(int j=1;j<num+1;j++)
    {
        printf("node %d: ", j);
        printf("key = %d, ", arr[j]);
        if(j!=1){printf("parent key = %d, ", arr[j/2]);}
        if(arr[2*j]!=NIL){printf("left key = %d, ", arr[2*j]);}
        if(arr[2*j+1]!=NIL){printf("right key = %d, ", arr[2*j+1]);}
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2056
n = int(input())
s = input()

w = [0]
cnt = 0
for i in range(n):
  if s[i] == '#':
    cnt += 1
  w.append(cnt)

ans = len(s)
for i in range(n+1):
  ans = min(ans, w[i]+(n-i-(w[-1]-w[i])))
print(ans)

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

public class Digits
{
    public static void Main(string[] args)
    {
        var vals = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
        var num = vals[0];
        var cnt = 0;
        while (num != 0)
        {
            var result = Math.Floor((double)(num / vals[1]));
            cnt++;
            num = (int)result;
        }
        Console.WriteLine(cnt);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 2e5 + 10;
int n, tot;
int c[maxn];
ll f[maxn], sumf[maxn];
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		int val;
		scanf("%d", &val); 
		if(tot && c[tot] == val)
			--tot;
		c[++tot] = val;
	}
	f[0] = 1;
	for(int i = 1; i <= tot; ++i)
	{
		f[i] = (sumf[c[i]] + f[i - 1]) % mod;
		sumf[c[i]] += f[i - 1];
	}
	printf("%lld\n", f[tot]);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int K,i,a;
const int MOD=1e9+7;
long x=1,ans=0;
vector<long> fact_inv,inv,Com;
void init_nCk(int n,int k){
  fact_inv.resize(k+1);
  inv.resize(k+1);
  fact_inv[0]=fact_inv[1]=inv[1]=1;
  for(int i=2;i<=k;i++){
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    fact_inv[i]=fact_inv[i-1]*inv[i]%MOD;
  }
  Com.resize(k+1);
  Com[0]=1;
  for(int i=1;i<=k;i++){
    Com[i]=Com[i-1]*((n-i+1)*inv[i]%MOD)%MOD;
  }
}
int nCk(int k){
  return Com[k];
}
int main(){
  string S;
  cin>>K>>S;
  a=K+S.size();
  init_nCk(a,K);
  for(i=0;i<=K;++i){
    ans+=x*nCk(i);
    ans%=MOD;
    x=x*25%MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 27640
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let v: Vec<u32> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();
    let mut i = 0;
    for x in 0..v[0]+1 {
        for y in 0..v[0]+1{
            if 0 <= v[1] - x - y && v[1] - x - y <= v[0] {i += 1;}
        }
    }
    println!("{}", i);
}



Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#define N 1000000
int count=0, n, l, A[N], *S;

void insertionSort(int A[], int n, int m){
int i, j, k;
  for(i=m; i<n; i++){
    k = A[i];
    j = i-m;
    while(j >= 0 && A[j] > k){
      A[j+m] = A[j];
      j -= m;
      count++;
    }
    A[j+m] = k;
  }
}

void Sort(int A[],int n){
  int i = 0, s;

S=(int *)malloc(n * sizeof(int));

for(s = 1; ; ){
if(s > n) break;
S[i] = s;
i++;
  s = 3 * s + 1;
}
l = i;
  for(i=l-1; i>=0; i--){
    insertionSort(A,n,S[i]);
  }
}

int main(){
int i;
scanf("%d",&n);
for(i=0; i<n; i++) scanf("%d",&A[i]);
count=0;

Sort(A,n);

printf("%d\n",l);
for(i = l-1; i>=0; i--){
printf("%d", S[i]);
if(i) printf(" ");
}
printf("\n");
printf("%d\n", count);
for(i=0; i<n; i++)   printf("%d\n", A[i]);
 free(S);
  return 0;
}



Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;
constexpr size_t invalid = ~0ull;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  char c; cin >> c; cout << static_cast <char> (c + 1) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> K;
	int C;
	cin >> C;
	string S;
	cin >> S;
	vector< int > L(K), R(K);
	int j = 0;
	rep(i, K) {
		while (S[j] == 'x')
			j++;
		L[i] = j;
		j += C + 1;
	}
	j = N - 1;
	rep(i2, K) {
		int i = K - 1 - i2;
		while (S[j] == 'x')
			j--;
		R[i] = j;
		j -= C + 1;
	}
	//cout << L << R;
	vector< int > ans;
	rep(i, K) if (L[i] == R[i]) ans.push_back(L[i] + 1);
	sort(ans.begin(), ans.end());
	rep(i, ans.size()) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 6516
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
const int MX = 1e5+3;
ll a[MX];
int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    ll n, m; cin >> n >> m;
    unordered_map<ll, ll> mp;
    FOR(i,0,n-1) {
        cin >> a[i];
    }
    ll cur = 0;
    FOR(i,0,n-1) {
        cur += a[i];
        mp[(cur)%m]++;
    }
    ll ans = 0;
    for(auto &[k,v]: mp) {
        ans += v*(v-1)/2;
    }
    ans += mp[0];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7296
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
#include <numeric>
#include <ext/pb_ds/assoc_container.hpp>
#define MOD 1000000007
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){

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

	long long int s;
	cin>>s;
	vector<int> dp(max(3LL,s+1),0);
	dp[1]=dp[2]=0;
	dp[0]=1;
	for(int i=3;i<=s;++i){
		for(int j=3;j<=i;++j){
			dp[i]+=dp[i-j];
			dp[i]%=MOD;
		}
	}
	cout<<dp[s]<<endl;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <math.h>

int main()
{
  int x,y,r;

  scanf("%d %d",&x,&y);

  if(x < y){
    r = y;
    y = x;
    x = r;
  }

  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }

  printf("%d\n",x);
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
        #include <cstdio>
        #include <vector>
        #include <algorithm>
        #include <cstring>
        #include <queue>
        using namespace std;
        const int N=1e5+50;
        const long long INF=1e18;
        int n;
        int k,p;
        long long dis[N];
        int vis[N];
        struct Edge
        {
            int y;
            int w;
        };
        vector<Edge> v[N];
        void Init()
        {
            for(int i=0; i<=n; i++)
                v[i].clear();
        }
        void spfa(int s)
        {
            queue<int> p;
            p.push(s);
            for(int i=0; i<=n; i++) dis[i]=INF;
            dis[s]=0;
            memset(vis,0,sizeof(vis));
            vis[s]=1;
            while(!p.empty())
            {
                int u=p.front();
                p.pop();
                vis[u]=0;
                for(int i=0; i<v[u].size(); i++)
                {
                    int w=v[u][i].w;
                    int y=v[u][i].y;
                    if(dis[y]>dis[u]+w)
                    {
                        dis[y]=dis[u]+w;
                       if(!vis[y])
                       {
                           p.push(y);
                           vis[y]=1;
                       }

                    }
                }
            }
        }
        int main()
        {
            scanf("%d",&n);
            Init();
            for(int i=0; i<n-1; i++)
            {
                int x,y,w;
                scanf("%d%d%d",&x,&y,&w);
                Edge now;
                now.y=y;
                now.w=w;
                v[x].push_back(now);
                now.y=x;
                v[y].push_back(now);
            }
            scanf("%d%d",&p,&k);
            spfa(k);
            for(int i=0; i<p; i++)
            {
                int x,y;
                scanf("%d%d",&x,&y);
                cout<<dis[x]+dis[y]<<endl;
            }
            return 0;
        }


Measured memory_bytes: 9204
def main():
    N = int(input())
    P = list(map(int, input().split()))
    
    count = 0
    k = 0
    for i in range(N):
        flag = True
        for j in range(k, i):
            if P[i] > P[j]: 
                flag = False
                break

        if flag:
            count += 1
            k = i
            
    print(count)
if __name__ == "__main__":
    main()


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

int main() {
  int N;
  cin >> N;
  map<int, int> M;
  rep(i, N){
    int a;
    cin >> a;
    M[a]++;
  }

  if(M.size() == 1 && M.find(0) != M.end()){
    cout << "Yes" << endl;
    return 0;
  }

  if(N % 3 != 0){
    cout << "No" << endl;
    return 0;
  }

  if(M.size() == 2){
    for(auto mp : M){
      if(0 == mp.first && N / 3 == mp.second){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  if(M.size() == 3){
    int tmp = 0;
    for(auto mp : M){
      if(N / 3 == mp.second){
        tmp ^= mp.first;
      }
      else{
        cout << "No" << endl;
        return 0;
      }
    }
    if(0 == tmp){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
    
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        var uf = new UnionFind(n+1);
        for(int i = 0; i < m; i++){
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            uf.unite(a, b);
        }
        int ans = 0;
        for(int i = 1; i <= n; i++){
            ans = Math.max(uf.size[i], ans);
        }
        System.out.println(ans);
    }
    
    static class UnionFind {
        int[] parent, size;
        
        public UnionFind(int n) {
            parent = new int[n];
            size = new int[n];
            for(int i = 0; i < n; i++){
                parent[i] = i;
                size[i] = 1;
            }
        }
        int root(int x){
            if(parent[x] == x){
                return x;
            }else{
                return parent[x] = root(parent[x]);
            }
        }
        void unite(int x, int y){
            x = root(x);
            y = root(y);
            if(x == y) return;
            
            if(size[x] < size[y]){
                parent[x] = y;
                size[y] += size[x];
            }else{
                parent[y] = x;
                size[x] += size[y];
            }
        }
        boolean same(int x, int y){
            return root(x) == root(y);
        }
    }
}

Measured memory_bytes: 61168
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int N, D, X[10][10];
	cin >> N >> D;
	int i, j, k, hantei, ans = 0;
	for(i = 0; i < N; i++) for(j = 0; j < D; j++) cin >> X[i][j];
	
	for(i = 0; i < N; i++){
		for(j = N-1; i < j; j--){
			hantei = 0;
			for(k = 0; k < D; k++) hantei += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
			if(sqrt(double(hantei)) == double(int(sqrt(double(hantei))))) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cmath>
using namespace std;

int n,d,a[105][105],ans=0;

int read(){
	int t=1,s=0;
	char c=getchar();
	while((c>'9'||c<'0')&&c!='-')c=getchar();
	if(c=='-')t=-1,c=getchar();
	while(c>='0'&&c<='9')
	s=s*10+c-'0',c=getchar();
	return s*t;
}

int main(void){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d %d",&n,&d);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=d;j++)
		scanf("%d",&a[i][j]);
	} 
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			int s=0;
			for(int k=1;k<=d;k++)
			s+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			int jvli;
			jvli=sqrt(s);
			if(jvli*jvli==s)ans++;
		}
	}
	printf("%d",ans);
}


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


int main()
{
	long long A, B, C, K,X;
	cin >> A >> B >> C;
	cin >> K;
	X = max(max(A, B), C);
	for (int i = 0; i < K; ++i) {
		X = X * 2;
	}
	cout << X + A + B + C - max(max(A, B), C) << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int w,h;
int graph[51][51];

void dfs(int x,int y,int x1,int y1){
    graph[x][y]=0;
    vi move={-1,0,1};
    for (int i:move){
        for (int j:move){
            if (i==0 && j==0)continue;
            else if (x+i<=0 || x+i>h || y+j<=0 || y+j>w)continue;
            else if (x+i==x1 && y+j==y1)continue;
            else if (graph[x+i][y+j]==0)continue;
            else dfs(x+i,y+j,x,y);
        }
    }
}

int main() {
    while (1){
        cin>>w>>h;
        if (w==0 && h==0)return 0;
        memset(graph,0,sizeof(graph));
        rep(i,h){
            rep(j,w){
                cin>>graph[i+1][j+1];
            }
        }
        int ans=0;
        for (int i=1;i<h+1;i++){
            for (int j=1;j<w+1;j++){
                if (graph[i][j]){
                    ans+=1;
                    dfs(i,j,0,0);
                }
            }
        }
        cout<<ans<<endl;
    }
    

    return 0;
}


Measured memory_bytes: 3412
#include<bits/stdc++.h>
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define ll long long int
using namespace std;
int main()
{
    ll a,b,c,x,y,z,cnt=0,sum=0;
    string str;
    cin>>str;
    if(str=="ABC")
    {
        cout<<"ARC"<<endl;
    }
    else cout<<"ABC"<<endl;

}



Measured memory_bytes: 3592
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main(){
	double p = acos(-1);
	int r;
	cin >> r;
	cout << 2* p * r << endl;
} 

Measured memory_bytes: 3260
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(l,r)     ((l)+((r)-(l))/2) 

#define fo(i,a,b)    for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***

int n,k;
const ll maxn = 2e5+5;
ld a[maxn+5];

bool apxeq(double a, double b, double absEpsilon = 1e-12,
           double relEpsilon = 1e-8) {
  // Check if the numbers are really close -- needed when comparing numbers near
  // zero.
  double diff = abs(a - b);
  if (diff <= absEpsilon)
    return true;
    re false;
}

bool pos(ld len){
    ll req = 0;
    fo(i,0,n-1){
        if(apxeq(a[i],len) or a[i]<=len)continue;
        ld q = a[i]/len;
        req += q-1;
        if(!apxeq(q,(ll)q))req++;
        if(req>k)re 0;
    }
    re 1;
}

void solve()
{
    rd(n,k);
    read(a,n);
    ld l=1;
    ld r = 0;
    for(int i=0;i<n;i++)r = max(r,(ld)a[i]);
    ld m = l+(r-l)/2;
    ld ans = r;
    
    while(l<=r and r-l>0.1 and m>=1){
        m = mid(l,r);
        if(pos(m)){
            ans = m;
            r = m - 0.5;
        }
        else{
            l = m + 0.5;
        }
        m = mid(l,r);
    }
    ll realans = round(ans);
    cout<<realans<<endl;
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 6856
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cstring>
using namespace std;

int main(){
    int N, len, numb = 0, numa = 0, numd = 0;
    long long ans = 0;
    cin >> N;
    static const int max = 11;
    char s[N][max];
    for(int i = 0; i < N; i++){
        scanf("%s", s[i]);
        len = strlen(s[i]);
        if(s[i][0] == 'B') numb++;
        if(s[i][len-1] == 'A') numa++;
        if(s[i][0] == 'B' && s[i][len-1] == 'A') numd++;
        for(int j = 0; j < len - 1; j++){
            if((s[i][j] == 'A' )&& (s[i][j+1] == 'B')) ans++;
        }
    }
    if(numd == numa && numd == numb){
        if( numd != 0) ans += numd - 1;
    }
    else{
        ans += min(numa , numb);
    }
    cout  << ans << endl;
    return 0;
}

Measured memory_bytes: 384
n = int(input())
# a = list(map(int, input()split()))
for i in range(1<<n):
    ans = []
    _i = i
    cnt = 0
    while i:
        if i&1:
            ans.append(cnt)
        cnt += 1
        i=i>>1
    print(f'{_i}:',end = '')
    if _i == 0:
        print()
    else:print("",*ans)


Measured memory_bytes: 6256
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <stdio.h>
#include <math.h>
#include <utility>
#include <algorithm>

using namespace std;

void solve() {

}

int main() {
	int a[5],k;
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
	for (int i = 0; i < 5; i++) {
		for (int j = i+1; j < 5; j++) {
			int d=a[j] - a[i];
			if (d > k) {
				cout << ":(";
				return 0;
			}
		}
	}
	cout << "Yay!";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,bell,hess[7]={0};
  while(1){
    cin >> n;
    if(n==0){
      break;
    }
    for(int i=0;i<n;i++){
      cin >> bell;
      if(bell<10){
	hess[0]++;
      }
      else if(bell<20){
	hess[1]++;
      }
      else if(bell<30){
	hess[2]++;
      }
      else if(bell<40){
	hess[3]++;
      }
      else if(bell<50){
	hess[4]++;
      }
      else if(bell<60){
	hess[5]++;
      }
      else{
	hess[6]++;
      }
    }
    for(int i=0;i<7;i++){
      cout << hess[i] << endl;
    }
    for(int i=0;i<7;i++){
      hess[i]=0;
    }
  }
}

Measured memory_bytes: 1160
book = int(input())
if book % 10 == 0 or book % 10 == 1 or book % 10 == 6 or book % 10 == 8 :
	print('pon')
elif book % 10 == 2 or book % 10 == 4 or book % 10 == 5 or book % 10 == 7 or book % 10 == 9:
	print('hon')
elif book % 10 == 3 :
	print('bon')


Measured memory_bytes: 9132
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-02-21 10:55:21
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;

    if (s == u) {
        a--;
    } else {
        b--;
    }

    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(time(NULL));

const int maxN = 2e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int n, arr[maxN], brr[maxN];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	priority_queue<ii> pq;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> arr[i];
	for(int i = 0; i < n; i++) {
		cin >> brr[i];
		if(brr[i] < arr[i]) {
			cout << "-1\n"; return 0;
		}
		if(brr[i] > arr[i])
			pq.push(ii(brr[i], i));
	}

	ll ans = 0;
	while(pq.size()) {
		auto cr = pq.top().se;
		pq.pop();
		int prv = (cr + n - 1) % n, nex = (cr + 1) % n;
		if(arr[prv] == brr[prv] && arr[nex] == brr[nex]) {
			int dff = brr[cr] - arr[cr];
			if(dff % (brr[prv] + brr[nex])) {
				cout << "-1\n"; return 0;
			}
			ans += dff / (brr[prv] + brr[nex]);
			brr[cr] = arr[cr];
			continue;
		}
		if(brr[cr] < brr[prv] + brr[nex]) {
			cout << "-1\n"; return 0;
		}
		ans += brr[cr] / (brr[prv] + brr[nex]);
		brr[cr] %= (brr[prv] + brr[nex]);
		if(brr[cr] < arr[cr]) {
			cout << "-1\n"; return 0;
		}
		if(brr[cr] > arr[cr])
			pq.push(ii(brr[cr], cr));
	}

	cout << ans << '\n';
}


Measured memory_bytes: 7792
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<iomanip>
using namespace std;
int t(string x)
{
	int s=0;
	for(int i=0;i<x.size();i++)
	
	s=s*10+(x[i]-'0');	
	
	return s;
}
int main()
{
	ios::sync_with_stdio(false);
	string a,b;
	cin>>a>>b;
	int t(string x);
	int s;
	a+=b;
	s=t(a);
	if(int(sqrt(s))==sqrt(s))
	cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#define DEBUG 0

/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 5/22/2019, 4:32:20 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, K;
string S;

int main()
{
  cin >> N >> S >> K;
  K--;
  char x = S[K];
  for (auto i = 0; i < N; i++)
  {
    if (S[i] != x)
    {
      S[i] = '*';
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}
 
template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}
 
#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int main() {
	long long a, b, c;
	cin >> a >> b >> c;

	if(c - a - b < 0) {
		cout << "No\n" << endl;
		return 0;
	}

	if(4 * (a*b) < (c - a - b) * (c - a - b))
		cout << "Yes\n";
	else
		cout << "No\n";
  
}

Measured memory_bytes: 256
def main():
    n = int(input())
    flg = False

    while not flg:
        if is_prime(n):
            print(n)
            exit()
        else:
            n += 1

def is_prime(num):
    if num == 2:
        return True
    if num % 2 == 0:
        return False
    for i in range(3, num // 2 + 1, 2):
        if num % i == 0:
            return False

    return True

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
def solve(R, G, B, N):
    ans = 0
    mr = N // R
    for i in range(mr + 1):
        mg = (N - i * R) // G
        for j in range(mg + 1):
            b = N - i * R - j * G
            if b % B == 0:
                ans += 1
    return ans


if __name__ == "__main__":
    R, G, B, N = map(int, input().split(" "))
    print(solve(R, G, B, N))


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    int x, y, n;
    while(1)
    {
    cin >> x >> y;
    if(x == 0 && y == 0) break;
    else if(x > y) cout << y << " " << x << "\n";
    else if(x < y) cout << x << " " << y << "\n";
    else if(x == y) cout << x << " " << y << "\n";
    }
    return 0;
}




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

int gcd(int a, int b){
   int M = max(a,b);
   int m = min(a,b);
   if(M%m == 0){
       return m;
   } 
   else{
       return gcd(M%m, m);
   }
}


int main(){
    int k;
    cin >> k;
    int ans=0;
    for(int i=1; i<=k; i++){
        for(int j=1; j<=k; j++){
            for(int l=1; l<=k; l++){
                ans += gcd(gcd(i,j), l);
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int n;
string a, b, c;

bool read() {
    if (!(cin >> n >> a >> b >> c))
        return false;

    return true;
}

void solve() {
    int ans = 0;

    forn (i, n) {
        if (a[i] == b[i] && b[i] == c[i])
            continue;

        if (a[i] == b[i] || a[i] == c[i] || b[i] == c[i])
            ++ans;
        else
            ++++ans;
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;

    for(int i=A-1;i<C-1;i++){
        if(S[i] == '#' && S[i+1] == '#'){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i=B-1;i<D-1;i++){
        if(S[i] == '#' && S[i+1] == '#'){
            cout << "No" << endl;
            return 0;
        }
    }
    if(C<D){
        cout << "Yes" << endl;
    }else{
        for(int i=B-2;i<D-1;i++){
            if(S[i] == '.' && S[i+1] == '.' && S[i+2] == '.'){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main(){
    
  int N,H[100010]={},d,border;
  cin >>N;

  for(int j=1;j<=N;j++){
    cin >>H[j];
  }

  border=H[1]-1;

  for(int i=1;i<=N-1;i++){
    d=H[i+1]-H[i];
    if(d<=-2){
      cout << "No"<<endl;
      return 0;
    }else if(d==-1){
      if((H[i]-1)>=border){
        H[i]-=1;
        border=H[i];
      }else{
        cout << "No"<<endl;
        return 0;
      }
    }
  }

  cout<<"Yes"<<endl;

  return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1e9+7;
const int maxn=2e5+10;
const LL inf=-1e18;
LL a[maxn];
int n;
LL dp[maxn][5];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<=4;j++){
            dp[i][j]=inf;
        }
    }
    for(int i=1;i<=3;i++){
        dp[i][i-1]=a[i];
    }
    dp[3][0]=a[1]+a[3];
    for(int i=4;i<=n;i++){
        dp[i][0]=max(dp[i-2][0]+a[i],dp[i][0]);
        dp[i][1]=max(dp[i-2][1]+a[i],dp[i-3][0]+a[i]);
        dp[i][2]=max(dp[i-2][2],dp[i-3][1])+a[i];
        if(i>4){
            dp[i][2]=max(dp[i][2],dp[i-4][0]+a[i]);
        }
    }
    LL res=0;
    if(n&1){
        res=max(dp[n][2],max(dp[n-1][1],dp[n-2][0]));
    }
    else{
        res=max(dp[n][1],dp[n-1][0]);
    }
    printf("%lld\n",res);
    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()  
#define sz(x) int(x.size()) 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=63;
const int mxn=2e5+5;
bool DEBUG=0;

int a[mxn],n,k;

bool works(int val){
	ll cnt=0;
	for(int i=0; i<n; i++){
		cnt+=(a[i]-1)/val;
	}
	//cerr<<val<<" --- "<<cnt<<"\n";
	return cnt<=k;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    cin>>n>>k;
    for(int i=0; i<n; i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int lo=1, hi=a[n-1],ans=1;
	while(lo<=hi){
		int mid=(lo+hi)/2;
		//cerr<<lo<<" "<<hi<<" "<<mid<<"\n";
		if(works(mid)){
			hi=mid-1;
		}else{
			lo=mid+1;
			ans=mid+1;
		}
	}
	cout<<ans<<"\n";
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 4392
from math import sqrt
Q=int(input())
for i in range(Q):
    A,B=map(int,input().split())
    if A==B:
        print(2*(A-1))
        continue
    t=A*B
    s=int(sqrt(t))+5
    for j in range(s,s-10,-1):
        if j**2<t:
            s=j
            break
    if s*(s+1)<t:
        print(s*2-1)
    else:
        print(s*2-2)


Measured memory_bytes: 9068
'''     ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█  
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     '''


# [temp1.py] => [29-07-2020 @ 10:25:10] 
# Author & Template by : Udit "luctivud" Gupta
# https://www.linkedin.com/in/udit-gupta-1b7863135/


import math;   from collections import *
import sys;    from functools import reduce
import time;   from itertools import groupby

# sys.setrecursionlimit(10**6)

def input()         : return sys.stdin.readline()
def get_ints()      : return map(int, input().strip().split())
def get_list()      : return list(get_ints())
def get_string()    : return list(input().strip().split())
def printxsp(*args) : return print(*args, end="")
def printsp(*args)  : return print(*args, end=" ")


DIRECTIONS = [(+0, +1), (+0, -1), (+1, +0), (+1, -1)] 
NEIGHBOURS = [(-1, -1), (-1, +0), (-1, +1), (+0, -1),\
              (+1, +1), (+1, +0), (+1, -1), (+0, +1)]


CAPS_ALPHABETS = {chr(i+ord('A')) : i for i in range(26)}
SMOL_ALPHABETS = {chr(i+ord('a')) : i for i in range(26)}
INF = float('inf')


# Custom input output is now piped through terminal commands.
# for _test_ in range(int(input())): 
x = int(input())
print("Yes" if x >= 30 else "No")



# print("Time Elapsed: {}".format(float(S34p-S34t)))


Measured memory_bytes: 9520
#include <bits/stdc++.h>
using namespace std;
typedef long long int lo;
lo dp[500005],n,arr[500005],k;
lo f(lo i){
	if(i>n)return 1e10;
	if(i==n) return 0;
	if(dp[i]!=-1)return dp[i];
	dp[i]=1e10;
	for(lo j=1;j<=k;j++){
		dp[i]=min(f(i+j)+abs(arr[i]-arr[i+j]),dp[i]);
	}
	return dp[i];
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);
 //    freopen("out.txt","w",stdout);
    memset(dp,-1,sizeof dp);
    cin >> n >> k;
    for(lo i=1;i<=n;i++){
    	cin >> arr[i];
    }
    cout << f(1) << endl;
}

Measured memory_bytes: 9984
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

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

int main(){
	int a,b;
	cin>>a>>b;
	cout<<a*b<<" "<<(a*2+b*2)<<endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
int32_t main()
{
	int n,k;
	cin>>n>>k;

	int r,s,p,sum=0;

	cin>>r>>s>>p;

	string str;
	cin>>str;

	for(int i=0;i<n;i++)
	{
		if(i>=k and str[i]==str[i-k])
		{
			str[i]=' ';
		}
		else if(str[i]=='r')
			sum+=p;
		else if(str[i]=='s')
			sum+=r;
		else if(str[i]=='p')
			sum+=s;
	}
	cout<<sum<<endl;

	return 0;
}

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

namespace AtTest.ABC_154
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            string[] st = Read().Split();
            int[] ab = ReadInts();
            string u = Read();
            if (st[0] == u)
            {
                WriteLine((ab[0]-1) + " " + ab[1]);
            }
            else
            {
                WriteLine(ab[0] + " " + (ab[1]-1));
            }
        }

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


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
class BIT{
  //0-indexed
public:
  static const ll MAX_N=220000;
  ll bit[MAX_N+10]={},n;
  BIT(ll num){
    n=num+10;
  }
  void add(ll i,ll value){
    i++;
    while(i<=n){
      bit[i]+=value;
      i += i&-i;
    }
  }
  ll sum(ll i){
    ll ret=0;
    i++;
    while(i>0){
      ret += bit[i];
      i -= i & -i;
    }
    return ret;
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,d,a;cin>>n>>d>>a;
  BIT bit(n+10);
  set<ll>se;
  vi A;
  map<ll,ll>hp;
  //vector<pair<ll,ll>>pll(n);
  for(int i=0;i<n;i++){
    ll x,h;
    cin>>x>>h;
    se.insert(x);
    hp[x] = h;
   
  }
  ll cnt=0;
  map<ll,ll>zip;
  for(auto aa:se){
    zip[aa] = cnt;
    cnt++;
    A.pb(aa);
  }
  A.pb(llINF);
  ll ans=0;
  for(int i=n-1;i>=0;i--){
    ll num = A[i]-2*d;
    auto lb = lower_bound(ALL(A),num);
    ll hoge = (lb-A.begin());
    ll HP = hp[A[i]]-a*bit.sum(zip[A[i]]);
    if(HP>0){
      ans+=ceil((double)HP/a);
      bit.add(hoge,ceil((double)HP/a));
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 37872
def main():
    S = list(input())

    print(min(S.count('0'),S.count('1'))*2)

    # 当たり前だけど全探索はTLEでアウト
    # ans = 0
    # while True:
    #    cnt = 0
    #    for i in range(1,len(S)):
    #        if S[i] != S[i-1]:
    #            S.pop(i)
    #            S.pop(i-1)
    #            cnt += 2
    #            break
    #    if cnt == 0:
    #        break
    #    ans += cnt

    #print(ans)



main()

Measured memory_bytes: 46064
N, M = map(int, input().split())
xyz = []
ans = 0
for _ in range(N):
    xyz += [list(map(int, input().split()))]
for b in range(2 ** 3):
    pm = [1] * 3
    for j in range(3):
        if (b >> j) & 1:
            pm[j] *= -1
    r = []
    for i in range(N):
        r += [pm[0] * xyz[i][0] + pm[1] * xyz[i][1] + pm[2] * xyz[i][2]]
    r.sort(reverse=True)
    ans = max(ans, sum(r[:M]))
print(ans)


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

int main(){

  int cheeze[3], n, r, hole;
  double d;

  while(cin >> cheeze[0] >> cheeze[1] >> cheeze[2]){
    if(cheeze[0] == 0) break;
    cin >> n;

    sort(cheeze, cheeze+3);
    r = cheeze[0] * cheeze[0] + cheeze[1] * cheeze[1];
    d = (double)cheeze[0] * cheeze[1];
    d = d * d / r;

    for(int i=0; i<n; i++){
      cin >> hole;
      if(4 * hole * hole > r && (double)hole * hole > d) cout << "OK" << endl;
      else cout << "NA" << endl;
    }
  }

  return 0;

}

Measured memory_bytes: 1172
def mips():
    return map(int,input().split())
def chmax(DP,b,weight,number):
    if DP[number+1][weight] < b : 
        DP[number+1][weight] = b
        return True
    return False    
N,W = mips()
Poids = []
Valeur = []
for i in range(N):
    weight,value = mips()
    Poids.append(weight)
    Valeur.append(value)
DP = [[0] * (2*W) for i in range(N+1)]
for i in range(N):
    for sum_p in range(0,W+1):
        if sum_p - Poids[i] >= 0:
            chmax(DP,DP[i][sum_p-Poids[i]] + Valeur[i],sum_p,i)
        chmax(DP,DP[i][sum_p],sum_p,i)
print(DP[N][W])

Measured memory_bytes: 192408
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <stdio.h>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
  string S;
  IN(S);
  int cnt_1 = 0;
  int cnt_2 = 0;
  
  REP(i, S.size()){
    if(i%2==0){
      if(S[i] == '0') ++cnt_1;
    }
    else if(S[i] == '1') ++cnt_1;
  }
  OUT(MIN(cnt_1, S.size()-cnt_1));
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, A, B; cin >> N >> A >> B;
	vector<int> t(N, 0);
	rep (i, N) cin >> t[i];

	int res = 0;
	rep (i, N){
		if (A <= t[i] && t[i] < B) ++res;
	} // end rep

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int a,b,ans;
  cin >> a >> b;

  if(13 <= a){
    ans= b;
  }else if(6 <= a && a <= 12){
    ans=b/2;
  }else{
    ans=0;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()] 
H = [int(_) for _ in stdin.readline().rstrip().split()] 
dp = [10**9] * N
dp[0] = 0
for i in range(N-1):
  for j in range(1, min(K+1, N-i)):
    dp[i+j] = min(dp[i] + abs(H[i]-H[i+j]), dp[i+j])
print(dp[N-1])

Measured memory_bytes: 52320