akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    int k,s;
    cin>>k>>s;
    ll res=0;
    rep(i,k+1){
        rep(j,k+1){
            int rest=s-(i+j);
            if(rest>=0&&rest<=k)res++;
        }
    }
    cout<<res<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);
#define int long long
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++)cin>>h[i];
	int res = 0;
	for(int i=0;i<n;i++)
	{
		bool v = 1;
		for(int j=0;j<i;j++)
			if(h[j]>h[i])
				v=0;
		res+=(v&1);
	}	
	cout<<res<<endl;
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define MAX 5000

int n, k;
ll a[MAX];

bool need(int p){
	vector<ll> v;
	v.push_back(0);
	for(int i=0; i<n; i++){
		if(i!=p) v.push_back(a[i]);
	}

	bool b[n][k+1];
	for(int i=0; i<n; i++){
		for(int j=0; j<=k; j++){
			if(j==0) b[i][j]=true;
			else b[i][j]=false;
		}
	}
	for(int i=1; i<n; i++){
		for(int j=0; j<=k; j++){
			b[i][j]=b[i-1][j];
		}
		for(int j=0; j<=k; j++){
			if(j+v[i]<=k){
				b[i][j+v[i]]|=b[i-1][j];
			}
		}
	}

	for(int j=max(k-a[p], 0ll); j<k; j++){
		if(b[n-1][j]) return true;
	}
	return false;
}

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

	int l=-1, r=n;
	while(r-l>1){
		int m=(l+r)/2;
		if(need(m)) r=m;
		else l=m;
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

const int maxN = 214514;
int UF[maxN];
int UFrank[maxN];
void UFinit(int n){
    for(int i=0;i<=n;i++){
        UF[i]=i;
        UFrank[i]=0;
    }
}
int UFroot(int k){
    if(UF[k]==k){
        return k;
    }else{
        UF[k]=UFroot(UF[k]);
        return UF[k];
    }
}
int UFsame(int P,int Q){
    return UFroot(P)==UFroot(Q);
}
void UFunite(int P,int Q){
    int p=UFroot(P);
    int q=UFroot(Q);
    if(p==q)return;
    if(UFrank[p]<UFrank[q])swap(p,q);
    UF[q]=p;
    if(UFrank[p]==UFrank[q])UFrank[p]++;
}


signed main(void){
    int N;
    int M=100000;
    int x[114514],y[114514];
    int p[214514]={},q[214514]={};
    cin >> N;
    REP(i,N){
        cin >> x[i] >> y[i];
        x[i]--;y[i]--;
    }
    UFinit(2*M);
    REP(i,N){
        UFunite(x[i],M+y[i]);
    }
    REP(i,M){
        p[UFroot(i)]++;
        q[UFroot(M+i)]++;
    }
    int Ans=0;
    //REP(i,10){cout << p[i]<<" ";}REP(i,10){cout << p[M+i]<<" ";}cout << endl;
    //REP(i,10){cout << q[i]<<" ";}REP(i,10){cout << q[M+i]<<" ";}cout << endl;
    REP(i,2*M){
        Ans+=p[i]*q[i];
    }
    cout << Ans-N << endl;
    
  return 0;
}



Measured memory_bytes: 8448
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
//int cnt = 0;

void depth_search(int ,int,vector< vector<int> > &);
void show(vector<vector <int> > &umi){
  return ;
  cout << "---------------------------" << endl;
  for(int i = 0;i < umi[0].size();i++){
    for(int j = 0;j < umi.size();j++){
      cout << umi[j][i];
    }
    cout << endl;
  }
    cout << "---------------------------" << endl;
  
}
int main(){
  int w,h;
  while(true){
    cin >> w;
    cin >> h;
    if(w == 0 && h == 0)return 0;
    vector< vector<int> > umi(w,vector<int>(h));
    //    cout << "aaaaaaaaaa" << endl;
    for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
	cin >> umi[j][i];

      }
    } 

    int cnt = 0;
    for(int i = 0;i < w;i++){
      for(int j = 0;j < h;j++){
	if( umi[i][j] == 1){
	  cnt++;
	  umi[i][j] = 3;
	  depth_search(i,j,umi);
	  show(umi);

	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
void depth_search(int x,int y,vector< vector<int> > &umi){
  int dx[3] = {0,1,-1};
  int dy[3] = {0,1,-1};
  for(int i = 0;i < 3;i++){
    for(int j = 0;j < 3;j++){
      if(!(x+dx[i] == -1
	 ||x+dx[i] == umi.size()
	 ||y+dy[j] == -1
	 ||y+dy[j] == umi[0].size())
	 && (umi[x+dx[i]][y+dy[j]] == 1)
	 && !(dx[i] == 0 && dy[j] == 0)){
	umi[x+dx[i]][y+dy[j]] = 3;
	depth_search(x+dx[i],y+dy[j],umi);
	
      }
    }
  }
}

Measured memory_bytes: 1484
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
B=nl()
ans=[0]*N
ans[0]=B[0]
for i in range(1,N-1):
    ans[i]=min(B[i-1],B[i])

ans[N-1]=B[N-2]
print(sum(ans))

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

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using pli=pair<ll,int>;

#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define testcase int _;cin>>_;while(_--)


/*A-Kyu in Atcoder*/
void Solve(){
	int x;
	cin>>x;
	cout<<10-(x/200);
}

int main(){
	fast
	//testcase
		Solve();
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define ss second
#define ff first 
#define ub upper_bound
#define lb lower_bound
// #define mp make_pair
const ll M=1000000007;
ll power(ll x,ll n){if(n==0)return 1;else if(n%2==0)return (power((x*x)%M,n/2))%M;else return ((x%M)*power(x,n-1)%M);}
ll ncr(int n,int r){if(r>n)return 0;if(r > n - r) r = n - r;ll ans = 1;
int i;for(i = 1; i <= r; i++){ans *= n - r + i;ans /= i;}return ans;}
ll nCrModpDP(ll n, ll r, ll p){ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
    C[0] = 1;
    for (ll i = 1; i <= n; i++){ 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
ll ncrmod(ll n, ll r, ll p){ 
   if (r==0) 
      return 1; 
   ll ni = n%p, ri = r%p; 
   return (ncrmod(n/p, r/p, p) * 
           nCrModpDP(ni, ri, p)) % p;  
} 
ll modInverse(ll a,ll m) 
{ 
   ll m0 = m; 
   ll y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
       ll q = a / m; 
       ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 
ll fun(ll num[],ll sum,ll n){
map<ll,ll>mp;
for(int i=0; i<n; i++){
mp[num[i]]++;
}
ll ans=0;
for(int i=0; i<n; i++){
if(mp[sum-num[i]]>0&&(sum-num[i]!=num[i])&&(mp[num[i]]>0)){
ans+=1,mp[sum-num[i]]--,mp[num[i]]--;
}
else if(mp[sum-num[i]]>=2&&(sum-num[i]==num[i])){
ans+=1,mp[sum-num[i]]-=2;
}
}
return ans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll a,b,c;
map<ll,ll>mp;
cin>>a>>b>>c;
mp[a]++,mp[b]++,mp[c]++;
cout<<mp.size();
return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

const double EPS = 0.00000001;
int n;
double arr[3001], dp[3001][3001];

double solve(int i = 0, int heads = 0) {
    if (i == n) {
        return heads > n - heads;
    }
    double& ret = dp[i][heads];
    if (ret >= 0) {
        return ret;
    }
    
    return ret = arr[i] * solve(i+1, heads+1) + (1-arr[i]) * solve(i+1, heads);
}
int main()
{
    IOS
    //bfreopen("balalance.in", "r", stdin);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    memset(dp, -1, sizeof dp);
    cout.precision(10);
    cout << fixed << solve() << endl;
    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
100000
)");
#define cin input
#endif

int main()
{
	int a, b, n;
	cin >> n;
	a=1;
	b=n-a;

	int ax, ay, bx, by, sum, suma, sumb;
	ax = ay = bx = by = suma = sumb = 0;
	sum = 1000000000;

	for (int i=0; i<n-1; i++)
	{
		ay = a;
		while (ay!=0)
		{
			ax = ay%10;
			suma += ax;
			ay = ay/10;
		}

		by = b;
		while (by!=0)
		{
			bx = by%10;
			sumb += bx;
			by = by/10;
		}

		
		if (sum > suma + sumb)
			sum = suma + sumb;

		a++;
		b--;
		suma = sumb = 0;
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    double a, b, c, d, e, f, x, y;
    while(scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f)!=EOF){
        if(a*e-b*d!=0)x=(c*e-b*f)/(a*e-b*d), y=(a*f-c*d)/(a*e-b*d);
        if(x==0)x=0;
        else if(y==0)y=0;
        printf("%.3lf %.3lf\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 652
#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>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { 
    return mint(-x);
  }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { 
    (x *= a.x) %= mod; 
    return *this;
  }
  mint operator+(const mint a) const { 
    return mint(*this) += a;
  }
  mint operator-(const mint a) const { 
    return mint(*this) -= a;
  }
  mint operator*(const mint a) const { 
    return mint(*this) *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return *this *= a.inv();
  }
  mint operator/(const mint a) const {
    return mint(*this) /= a;
  }
};
istream& operator>>(istream& is, mint& a) { 
  return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) { 
  return os << a.x;
}
mint f(int n){
  if(n==0) return 1;
  mint x = f(n/2);
  x *= x;
  if(n % 2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

int main(){
  int n;
  cin >> n;
  vector<mint> a(n);
  vector<mint> sum(n);
  rep(i,n) {
    cin >> a[i];
  }
  sum[0] = a[0];
  for(int i=1; i<n; i++){
    sum[i] = a[i] + sum[i-1];
  }
  mint ans = 0;
  // int cnt = 0;
  rep(i,n) {
    ans += a[i] * (sum[n-1] - sum[i]);
  }
  // if (ans < 0) ans += mod;
  // cout << cnt << endl;
  cout << ans << endl;
  return 0;
}

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

int main(){
  int a,b,k;
  
  cin >> a >> b >> k;
  
  for(int i=0; i<k; i++){
    if( i & 1 ){
      b /= 2;
      a += b;
    }
    else{
      a /= 2;
      b += a;
    }
  }
  
  cout << a << " " << b << endl;
  return 0;
}

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

using namespace std;
struct Project
{
	char name[10];
	int time;
};

int main()
{
	int n,t;
	int sum;
	queue<Project> myQueue;
	cin>>n>>t;
	for(int i=1;i<=n;i++)
	{
		Project p;
		cin>>p.name>>p.time;
		myQueue.push(p);
	}
	while(!myQueue.empty())
	{
		Project temp=myQueue.front();
		if(temp.time<=t){
			sum+=temp.time;
			cout<<temp.name<<" "<<sum<<endl;
			myQueue.pop();
		}
		else {
			sum+=t;
			Project newp=temp;
			newp.time=newp.time-t;
			myQueue.pop();
			myQueue.push(newp);
		}
	}
	return 0;
}


Measured memory_bytes: 3732
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#include <ext/pb_ds/detail/standard_policies.hpp>
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>



#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
//#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31


using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;


const int N = 102;
map<string, int> gain;
int n,m;
int main(){
    scanf("%d",&n);
    lp(i, 1, n) {
        string str;
        cin>>str;
        ++gain[str];
    }
    scanf("%d",&m);
    lp(i, 1, m){
        string str;
        cin>>str;
        if(gain.count(str)) --gain[str];
    }
    
    int ans = 0;
    for(auto it: gain) ans = max(ans, it.s);
    printf("%d\n",ans);
    return 0;
}



/*

 5 3
 1 3
 1 5
 3 6
 4 4
 2 6
 1 5 3
 1 5 4
 1 1 1

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

Measured memory_bytes: 256
import scala.collection.mutable.HashMap
import scala.collection.immutable.List

object Main {
  def main(args: Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val list = List.fill(n)(sc.nextInt)
    var hist = new HashMap[Int, Int]

    for (x <- list)
      hist(x) = hist.getOrElse(x, 0) + 1

    var ans = 0
    for (x <- hist.keys) {
      if (x < hist(x))
        ans += hist(x) - x
      else if (x > hist(x))
        ans += hist(x)
    }

    println(ans)
  }
}


Measured memory_bytes: 62752
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>
#include <stack>
#include <iomanip>
#include <sstream>

using namespace std;

template <typename T>
inline bool sign(T A) {
    return (A>0)-(A<0);
}
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SREP(i,s,n) for(int i=s; (n-i)*sign(n-s)>0; i+=sign(n-s))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool _less(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

template <template<class,class,class...> class C, typename K, typename V, typename... Args>
V map_get(const C<K,V,Args...>& m, K const& key, const V & defval)
{
    typename C<K,V,Args...>::const_iterator it = m.find( key );
    if (it == m.end())
        return defval;
    return it->second;
}

#define MOD (1'000'000'000+7)

ll dp[51][2501];
int main(void) {
    int N;
    string s;
    cin >> N >> s;

    s += s;
    REP(i, 4) {
        string t;
        if (i & 1)
            t += 'W';
        else
            t += 'S';
        
        if (i & 2)
            t += 'W';
        else
            t += 'S';

        SREP(j, 1, N+1) {
            if ((s[j] == 'o' && t[j] == 'S') || (s[j] == 'x' && t[j] == 'W'))
                t += t[j - 1];
            else
                t += (t[j - 1] == 'S')?'W':'S';
        }

        if (t[0] == t[N] && t[1] == t[N+1]) {
            cout << t.substr(0, N) << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}


Measured memory_bytes: 824
import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    static long[] fact = new long[100];
        public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("ABC")){
            System.out.println("ARC");
        }else{
            System.out.println("ABC");
        }
        
        
    }
    
}


Measured memory_bytes: 35688
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;

    for(int i=0; i<n; i++) {
        double ra,rb,xa,ya,xb,yb;
        cin>>xa>>ya>>ra>>xb>>yb>>rb;
        double d = sqrt(pow(xa - xb, 2) + pow(ya - yb, 2));

        if(d > ra + rb) {
            cout << 0 << endl;
        } else if(d < ra - rb) {
            cout << 2 << endl;
        } else if(d < rb - ra) {
            cout << -2 << endl;
        } else {
            cout << 1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
const int oo = 1e9;
const int mod = 1e9+9;
/*ll gcd(ll x, ll y){return (y ? gcd(y, x%y) : x); }
*ll lcm(ll x, ll y){return x*(y/gcd(x,y));}
*void exEuclid(int a, int b){
	if(b==0){x = 1; y=0; d=a; return ;}
	exEuclid(b, a%b);
	int x1=y;
	int y1=x-(a/b)*y;
	x=x1;
	y=y1;
} 
* */
//===========================================================//
const int nax = 1e5+103;
int n, k;
int dp[nax];
int a[nax];
int f(int i){
	if (i==n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	int ans = abs(a[i]-a[i+1])+f(i+1);
	for(int j=2; j<=k; j++){
		if(i+j<n) ans = min(ans, abs(a[i]-a[i+j])+f(i+j));
	}
	return dp[i]=ans;
}
int main(){
	cin>>n>>k;
	for(int i=0; i<n; i++) cin>>a[i];
	memset(dp, -1, sizeof dp);
	cout<<f(0)<<endl;
	return 0;
}

Measured memory_bytes: 5760
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#define INF 1000000000
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int A, B, C, D;
  ci(A, B, C, D);
  wh(true){
    C -= B;
    if(C <= 0){
      cout << "Yes" << endl;
      rt;
    }
    A -= D;
    if(A <= 0){
      cout << "No" << endl;
      rt;
    }
  }
}


Measured memory_bytes: 3596
x,n = map(int,input().split())
p_lst = list(map(int,input().split()))

check = float("inf")
ans = float("inf")
for p in range(1000,-1001,-1):
    if p in p_lst:
        continue
    else:
        #print(p)
        if check >= abs(p-x):
            check = abs(p-x)
            ans = p
            
print(ans)

Measured memory_bytes: 9216
#include <iostream>
using namespace std;
int main () {

  int N,A[100],a,c;

  cin >>N;
  
  for( int i=0 ; i < N ; i++ ){
    cin >>A[i];
  }
  
  for( int l=0 ; l < N ; l++ ){
    if( l == N-1){
      cout <<A[l]<<endl;
    }else{
      cout <<A[l]<<" ";
    }
  }
  
for( int j=0 ; j < N-1 ; j++ ){
    c=j;
    while( c >= 0 ){
      if( A[c] > A[c+1] ){
	a=A[c+1];
	A[c+1]=A[c];
	A[c]=a;
      }
      c--;
    }
    for( int k=0 ; k < N ; k++){
      if( k == N-1 ){
	cout <<A[k]<<endl;
      }else{
	cout <<A[k]<<" ";
      }
    }
  }

  return 0;

}

Measured memory_bytes: 1164
#include<iostream>

using namespace std;

int main() {
	int L, R;
	cin >> L >> R;
	int R2;
	int L2;
	int min = 1000000;
	int ans = 0;
	if (R - L >= 2018) {
		cout << 0 << endl;
	}
	else {
		/*cout << "&" << endl;*/
		for (int i = L;i <R;i++) {
			for (int q = i + 1;q < R +1;q++) {
				L2 = i % 2019;
				R2 = q % 2019;
				ans = L2 * R2;
				ans = ans % 2019;
				/*cout << "#" << endl;*/
				/*cout << ans << endl;*/
				if (min >= ans) {
					min = ans;
				}
			}
		}
		cout << min << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int SX, SY, TX, TY;
  cin >> SX >> SY >> TX >> TY;

  for (int i = 0; i < TX - SX; i++) printf("R");
  for (int i = 0; i < TY - SY; i++) printf("U");
  for (int i = 0; i < TX - SX; i++) printf("L");
  for (int i = 0; i < TY - SY; i++) printf("D");

  printf("D");
  for (int i = 0; i < TX - SX + 1; i++) printf("R");
  for (int i = 0; i < TY - SY + 1; i++) printf("U");  
  printf("LU");
  for (int i = 0; i < TX - SX + 1; i++) printf("L");
  for (int i = 0; i < TY - SY + 1; i++) printf("D");
  printf("R");

  cout << endl;


  return 0;
}


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

int main() {
  int a,b,c;
  string mess;
  cin >> a >> b >> c;
  if(b-a==c-b) {
    mess="YES";
  }else{
    mess="NO";
  }
  cout << mess << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int S = sc.nextInt(), h, m;
    h = S / 3600;
    S %= 3600;
    m = S / 60;
    S %= 60;
    System.out.println(h + ":" + m + ":" + S);
  }
}

Measured memory_bytes: 26324
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	x := nextInt()

	for a := 0; a <= 10000; a++ {
		apow5 := a * a * a * a * a
		bpow5 := apow5 - x
		for b := -10000; b <= 10000; b++ {
			if bpow5 == b*b*b*b*b {
				puts(a, b)
				return
			}
		}
	}
}


Measured memory_bytes: 1768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;
 
namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            
 
            if (N[0] == N[1] && N[0] == N[2] ||
                N[1] == N[2] && N[1] == N[3])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13140
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll dp[MAXn];
vector<ll> v[MAXn];

ll dfs(ll now)
{
    if(dp[now] != -1)return dp[now];
    dp[now] = 0;
    for(ll k:v[now])dp[now] = max(dp[now], dfs(k) + 1);
    return dp[now];
}

int main()
{
    IOS();
    ll n, m;
    cin>>n>>m;
    REP(i,m)
    {
        ll a,b;
        cin>>a>>b;
        v[a].pb(b);
    }
    FILL(dp, -1);
    REP1(i,n)if(dp[i] == -1)dfs(i);
    ll mx = 0;
    REP1(i,n)mx = max(mx, dp[i]);
    cout<<mx<<endl;  
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
int main(){
    int m,d;
    cin >> m >> d;
    int cnt = 0;
    for(int i = 4; i <= m; i++){
        for(int j = 22; j <= d; j++){
            int jd = j / 10;
            int ji = j % 10;
            if(jd >= 2 && ji >= 2 && jd * ji == i)
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

int main() {
    string S;
    cin >> S;
    if (S[0] == 'R' and S[1] == 'R' and S[2] == 'R') {
        cout << 3 << endl;
    }
    else if (S[0] == 'R' and S[1] == 'R') {
        cout << 2 << endl;
    }
    else if (S[1] == 'R' and S[2] == 'R') {
        cout << 2 << endl;
    }
    else if (S[0] == 'S' and S[1] == 'S' and S[2] == 'S') {
        cout << 0 << endl;
    }
    else {
        cout << 1 << endl;
    }
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll a,p;cin >>a>>p;
    p+=3*a;
    cout <<p/2<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=(1e+9) + 7;
int main(){
  int n;
  int lim = 'z'-'a' + 1;
  ll a[lim]={};
  string s;
  ll ans = 1;
  cin >> n >> s;
  for(int i=0;i<n;i++){
    a[s[i] - 'a']++;
  }
  for(int i=0;i<lim;i++){
    ans = (ans * (a[i] + 1)) % MOD;
  }
  cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <utility>
#include <queue>
#include <stdio.h>
#include <string>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000007
using namespace std;
typedef long long int ll;

int main(){
    int n,q;
    cin >> n >> q;
    vector<int> c(n);
    for(int i=0;i<n;i++) cin >> c[i];
    sort(c.begin(), c.end());
    for (int i = 0; i<q ; i++){
        int query;
        cin >> query;
        int flag = 1;
        int ans = c[n-1]%query;
        while (flag * query <= c[n-1]) {
            int lb=0,ub=n;
                while (abs(lb-ub)>1) {
                int mean = (lb+ub)/2;
                if (c[mean]<flag*query-1) {
                    lb = mean;
                }
                if (c[mean]>flag * query-1) {
                    ub = mean;
                }
                if (c[mean]==flag * query-1) {
                    ub = mean;
                    lb = mean;
                }
            }
            ans = max(ans,c[lb]%query);
            flag++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2324
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;

int main()
{
    int n;
    cin>>n;
    
    vector<int>odd,even,a(n);
    vector<bool>done(n,false);
    map<int,int>inip;
    rep(i,n){
        cin>>a[i];
        inip[a[i]]=i;
    }
    sort(all(a));
    int cost=0;
    rep(i,n){
        if(inip[a[i]]%2==i%2){

        }else{
            cost++;
        }
    }
    cout<<cost/2<<endl;

}


Measured memory_bytes: 5376
#include<stdio.h>
int main(void){
    int h, w, i;
    scanf("%d %d", &h, &w);
    
    char pic[h][w];
    for (i=0; i<h; i++){
        scanf("%s", pic[i]);
        printf("%s\n", pic[i]);
        printf("%s\n", pic[i]);
    }
    
    return 0;
}

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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 100000

int main(){

    ll n;
    cin >> n;

    ll a1,i;

    vector<ll> a;

    for(i=0;i<n;i++){
        cin >> a1;
        a.push_back(a1);
    }

    ll dp[2][n];

    dp[0][0] = 0;
    dp[1][0] = 0;
    dp[0][1] = abs(a[1]-a[0]);
    dp[1][1] = MAX;

    for(i=2;i<n;i++){
        dp[0][i] = abs(a[i]-a[i-1]) + min(dp[0][i-1],dp[1][i-1]);
        dp[1][i] = abs(a[i]-a[i-2]) + min(dp[0][i-2],dp[1][i-2]);
    }

    cout << min(dp[0][n-1],dp[1][n-1]) << endl;

}


Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,string> P;
#define INF (1<<20)

typedef struct {
  string name; // ??????
  string R; // ???
  string G; // ???
  string B; // ???
} color; // ???????§???????

color data[8]=
  {{"black","00","00","00"},
   {"blue","00","00","ff"},
   {"lime","00","ff","00"},
   {"aqua","00","ff","ff"},
   {"red","ff","00","00"},
   {"fuchsia","ff","00","ff"},
   {"yellow","ff","ff","00"},
   {"white","ff","ff","ff"}
  };

int trans(string num){
  int sum = 0;
  if(num[0] >= 'a' && num[0] <= 'f') sum = (num[0] - 'a' + 10)*16;
  else sum = (num[0] - '0')*16;
  if(num[1] >= 'a' && num[1] <= 'f') sum += (num[1] - 'a' + 10);
  else sum += (num[1] - '0');
  return sum;
}

int main(){
  string str;
  int RGB[8][3];
  for(int i=0;i<8;i++){
    RGB[i][0] = trans(data[i].R);
    RGB[i][1] = trans(data[i].G);
    RGB[i][2] = trans(data[i].B);
  }
  while(cin >> str , str!="0"){
    string red = str.substr(1,2);
    string green = str.substr(3,2);
    string blue = str.substr(5,2);
    int r = trans(red);
    int g = trans(green);
    int b = trans(blue);
    double ans = INF;
    int pos = 0;
    for(int i=0;i<8;i++){
      double tr = (r-RGB[i][0])*(r-RGB[i][0]);
      double tg = (g-RGB[i][1])*(g-RGB[i][1]);
      double tb = (b-RGB[i][2])*(b-RGB[i][2]);
      double tmp = sqrt(tr+tg+tb);
      if(ans > tmp){
	ans = tmp;
	pos = i;
      }
    }
    cout << data[pos].name << endl;
  }
}

Measured memory_bytes: 1188
n,m=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(m)]
c=[list(map(int,input().split())) for _ in range(n)]
ans0=[0]
ans1=[0]
ans2=[0]
for k in range(1,m+1):
    a0=0
    a1=0
    a2=0
    for i in range(n):
        for j in range(n):
            if (i+j+2)%3==0:
                a0+=d[c[i][j]-1][k-1]
            elif (i+j+2)%3==1:
                a1+=d[c[i][j]-1][k-1]
            else:
                a2+=d[c[i][j]-1][k-1]
    ans0.append(a0)
    ans1.append(a1)
    ans2.append(a2)
ans=float("inf")
import itertools
for x,y,z in itertools.permutations(range(1,m+1),3):
    ans=min(ans,ans0[x]+ans1[y]+ans2[z])

print(ans)


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    int n;
    cin >> n;
    map<string, int> m;
    rep(i, n) {
        string s;
        cin >> s;
        m[s]++;
    }
    for(string s : {"AC", "WA", "TLE", "RE"}) {
        cout << s << " x " << m[s] << endl;
    }
    

    return 0;
}


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

template<class t> void vin(vector<t>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
    return 0;
}


Measured memory_bytes: 256
n,q = [int(i) for i in input().split()]
s = input()
l = []
r = []
for i in range(q):
  l_tmp, r_tmp = [int(j) for j in input().split()]
  l.append(l_tmp-1)
  r.append(r_tmp-1)
  
r_cnt = [0]
for i in range(1,n):
  if s[i-1:i+1] == 'AC':
    r_cnt.append(r_cnt[i-1]+1)
  else:
    r_cnt.append(r_cnt[i-1])
    
for i in range(q):
  ans = r_cnt[r[i]] - r_cnt[l[i]]
  print(ans)

Measured memory_bytes: 14268
from math import ceil

N, H = map(int, input().split())

As = []
Bs = []
for i in range(N):
    A, B = map(int, input().split())
    As.append(A)
    Bs.append(B)

maxA = max(As)

ans = 0
for B in reversed(sorted(Bs)):
    if B <= maxA:
        break

    H -= B
    ans += 1
    if H <= 0:
        print(ans)
        exit()

ans += ceil(H / maxA)
print(ans)


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

int main() {
	int n,x;
	long int a,max,min,sum;
	sum=0;
	cin>>n;
	cin>>a;
	max=a;
	min=a;
	sum=sum+a;
	for(x=1;x<n;x++){
		cin>>a;
		if(max<a){
			max=a;
		}
		if(min>a){
			min =a;
		}
		sum=sum+a;
	}
	cout<<min<<" "<<max<<" "<<sum<<"\n";
	return 0;
}


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

int N;
int A[210];         // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    int res = 0;

    // 操作が行える限り操作を繰り返す
    while (true) {
        bool exist_odd = false;  // A[i] がすべて偶数かどうかを判定するフラグ
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;  // 奇数があったらフラグを立てる
        }

        if (exist_odd) break;  // 奇数があったら break

        // 操作を行えるなら操作を実際に行う
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;  // 操作回数をインクリメント
    }

    cout << res << endl;
}

Measured memory_bytes: 888
void main() {
    int x = readln.chomp.to!int;
    bool[] ok = new bool[x+1];
    ok[1] = true;
    for (int i = 2; i * i <= x; ++i) {
        for (int j = 2; i ^^ j <= x; ++j) {
            ok[i^^j] = true;
        }
    }
    foreach_reverse (i, y; ok) {
        if (y) {
            i.writeln;
            break;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.uni;

Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        int n = nextInt();
        int a = n%10;
        if(a==2||a==4||a==5||a==7||a==9){
            print("hon");
        }
        else if(a==0||a==1||a==6||a==8){
            print("pon");
        }
        else if(a==3){
            print("bon");
        }
    }

    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
    public static void print(Object a){
        System.out.println(a);
    }
}

Measured memory_bytes: 35644
import java.util.Scanner;

/**
 * https://abc062.contest.atcoder.jp/tasks/abc062_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] f = new String[H];
		for(int i=0; i<H; i++) f[i] = sc.next();
		sc.close();
		
		StringBuilder tb = new StringBuilder(); 
		for(int i=0; i<W+2; i++) tb.append("#");
		
		System.out.println(tb);
		for(int i=0; i<H; i++) System.out.println("#"+f[i]+"#");
		System.out.println(tb);

	}

}


Measured memory_bytes: 21844
import java.io.*;

class Main{
	public static void main(String[] args) throws IOException{
	
	BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	

	String[] line = reader.readLine().split(" ");

	int a = Integer.parseInt(line[0]);
	int b = Integer.parseInt(line[1]);

	int c = a * b;
	int d = a + a + b + b;

	System.out.println(c +" "+ d);
	}
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

int geta=2525;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<ll>dp(geta*2,0);
  int n,a;
  cin>>n>>a;
  dp[geta]=1;
  rep(i,n)
  {
    int x;
    cin>>x;
    x-=a;
    if(x<0)
    {
      repi(j,-x,geta*2)
      {
        if(dp[j]==0)continue;
        dp[j+x]+=dp[j];
      }
    }
    else
    {
      
      for(int j=geta*2-x-1;j>=0;j--)
      {
        if(dp[j]==0)continue;
        dp[j+x]+=dp[j];
      }
    }
  }
  cout<<dp[geta]-1<<endl;



  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
using namespace std;
int n;
vector <pair<int,int> > e;
signed main()
{
	scanf("%d",&n);
	if (n&1)
	{
		for (int i=1;i<=n;i++)
		{
			for (int j=i+1;j<=n;j++)
			{
				if (i+j==n) continue;
				e.push_back(m_k(i,j));
			}
		}
	}
	else
	{
		for (int i=1;i<=n;i++)
		{
			for (int j=i+1;j<=n;j++)
			{
				if (i+j==n+1) continue;
				e.push_back(m_k(i,j));
			}
		}
	}
	printf("%d\n",(int)e.size());
	for (int i=0;i<(int)e.size();i++) printf("%d %d\n",e[i].first,e[i].second);
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int dic[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
    int k;
    cin >> k;
    cout << dic[k-1] << endl;
    
}

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

#define DRACARYS ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, -1, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define PI 3.14159265
const long long int MAXN = 1e5+10;
const long long int MINN = 1e5+10;
const long long int inf = 1e9+7;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi; 
typedef stack<int> st;
vi a[MAXN],aux[MAXN],t;
int n,m,dp[MAXN],vis[MAXN];
stack <int> s;

void topo(int x){
    vis[x]=true;
    trav(el,a[x]) if(!vis[el]) topo(el);
    s.push(x);
}
int main(){ 
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    DRACARYS
    cin>>n>>m;
    rep(i,m){
        int x,y;
        cin>>x>>y;
        a[x].pb(y);
        aux[y].pb(x);
    }    
    repA(i,1,n) if(!vis[i]) topo(i);
    while(!s.empty()){
        t.pb(s.top());
        s.pop();
    }
    //rep(i,t.size()) cout<<t[i]<<" ";
    //cout<<endl;
    repA(i,1,t.size()-1){
        int val=-1;
        trav(el,aux[t[i]]) val=max(val,dp[el]);
        dp[t[i]]=val+1;
    }
    int ans=-1;
    rep(i,t.size()) ans=max(ans,dp[t[i]]); 
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 14900
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EQ(a,b) (abs((a)-(b))<EPS)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;
const D PI = acos(-1);

int n,r,q;
P p[30];
int cur;

inline D dot(const P &x, const P &y){return real(conj(x)*y);}

inline P rotate(const P &v, const D &s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline D arg(const P &a,const P &b,const P &c){return acos(dot(b-a,c-a)/(abs(b-a)*abs(c-a)));}

inline D rot_seta(const int &end){
  D dis = abs(p[end]-p[cur]);
  D seta = acos( (2*r*r - dis*dis)/(2*r*r) );
  P nxt = rotate(p[cur],-seta);
  return arg(p[cur],p[end],nxt);
}

int main(){
  
  while(cin >> n >> r >> q, n){
    rep(i,n){
      D x,y;
      cin >> x >> y;
      p[i] = P(x,y);
      if(EQ(abs(p[i]),r))cur = i;
    }
    
    vector<int> nxt(n,-1);
    
    rep(i,q){
      int id = -1;
      D min_s = PI;
      if(nxt[cur]>=0)id = nxt[cur];
      else{
	rep(j,n){
	  if(cur==j)continue;
	  D s = rot_seta(j);
	  if(id<0 || s+EPS < min_s)id = j, min_s = s;
	}
	nxt[cur] = id;
      }

      D seta = rot_seta(id);
      rep(i,n){
	if(i==cur)continue;
	p[i] = rotate(p[i]-p[cur],seta) + p[cur];
      }
      cout << fixed << setprecision(10) << p[id].real() << " " << p[id].imag() << endl;
      cur = id;
    }
  }
}

Measured memory_bytes: 1380
#include <stdio.h>
#include<stdlib.h>
 
int main()
{
	int x,a,b;
	scanf("%d %d %d",&x,&a,&b);
	if(x<=1000&&a<=1000&&b<=1000){
		if (abs(x-a)<abs(x-b)){
			printf("A");}
		else{
			printf("B");}}
	else{printf("Enter Valid Numbers");}
	return 0;
}
 

Measured memory_bytes: 128
#include <stdio.h>
 
int main(int argc,const char * argv[]){
int a,b;
scanf("%d %d",&a,&b);
if(a<b){
printf("a < b\n");
}else if(a>b){
printf("a > b\n");
}else{
printf("a == b\n");
}
return 0;
}

Measured memory_bytes: 580
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100005];
	scanf("%s",s);
	int i,j;
	int x;
	for(i=0;i<26;i++)
	{
		x=0;
		for(j=0;j<strlen(s);j++)
		{
			if(s[j]=='a'+i)
			{
				x++;
				break;
			}
		}
		if(x==0)
		{
			printf("%c\n",'a'+i);
			return 0;
		}
	}
	printf("None\n");
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    ll k, a, b;
    cin >> k >> a >> b;

    if(b - a <= 2){
        cout << k + 1 << endl;
    }else{
        ll ans = max(1ll * 0, (k - (a - 1)) / 2) * (b - a) + a;
        if((k - (a - 1)) % 2 == 1){
            ans++;
        }
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 256