akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T & a, const T & b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N, K;
	cin >> N >> K;
	cout << N - K + 1 << endl;
	return 0;
}


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

int main(void)
{
    int m,f,r;
    while(true)
    {
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1)break;
        if(m == -1 || f == -1)
        {
            cout << 'F' << endl;
            continue;
        }
        if(m + f >= 80)
        {
            cout << 'A' << endl;
            continue;
        }
        else if(m + f >= 65)
        {
            cout << 'B' << endl;
            continue;
        }
        else if(m + f >= 50)
        {
            cout << 'C' << endl;
            continue;
        }
        else if(m + f >= 30)
        {
            if(r >= 50)
            {
                cout << 'C' << endl;
                continue;
            }
            cout << 'D' << endl;
            continue;
        }
        else cout << 'F' << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
    
int n,m,b[510][510];
int pc[1<<24],dp[2][1<<24],bits[510];
    
void compute() {
  int maxi = 0;
  if( n <= m ) {
    for(int i=0;i<(1<<n);i++){
        bool ok=1;
        for(int j=0;j<m;j++){
          int cont=0;
          for(int k=0;k<n;k++){
            if((i>>k)&1 && b[k][j])++cont;
          }
          if(cont&1){
            ok=0;
            break;
          }
        }
        if(ok)maxi=max(maxi,__builtin_popcount(i));
      }
  } else { // n > m
   int list[501];
      fill(list,list+n,0);
      for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
          if(b[i][j]){
            list[i]=list[i]|(1<<j);
          }
        }
      }
      for(int i=0;i<2;i++)for(int j=0;j<(1<<m);j++)dp[i][j]=-1;
      dp[0][0]=0;
      for(int i=0;i<n;i++){
        for(int j=0;j<(1<<m);j++)dp[(i+1)&1][j]=-1;
        for(int j=0;j<(1<<m);j++){
          if(dp[i&1][j]==-1)continue;
          dp[(i+1)&1][j^list[i]]=max(dp[(i+1)&1][j^list[i]],dp[i&1][j]+1);
          dp[(i+1)&1][j]=max(dp[(i+1)&1][j],dp[i&1][j]);
        }
      }
      if(dp[n&1][0]!=-1)maxi=dp[n&1][0];
  }
  cout << maxi << endl;
}
    
int main() {
  for(int i=0;i<(1<<23);i++) pc[i] = __builtin_popcount(i);
  while( cin >> n >> m, n|m ) {
    for(int i=0;i<n;i++) {
      string s;
      cin >> s;
      for(int j=0;j<m;j++) b[i][j] = ( s[j] == '1' );
    }
    compute();
  }
  return 0;
}


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

int bit[16];

int memo[366][9][7][7][7][7];
constexpr int idx[9] = {0, 1, 2, 4, 5, 6, 8, 9, 10};

array<array<int, 5>, 9> to = {{{0, 1, 2, 3, 6},
    {0, 1, 2, 4, 7},
    {0, 1, 2, 5, 8},
    {0, 3, 4, 5, 6},
    {1, 3, 4, 5, 7},
    {2, 3, 4, 5, 8},
    {0, 3, 6, 7, 8},
    {1, 4, 6, 7, 8},
    {2, 5, 6, 7, 8}}};
tuple<int, int, int, int> calc(int d, int d1, int d2, int d3, int d4) {
    if(d == 0) {
        d1 = 0;
        d2++; d3++; d4++;
    } else if(d == 2) {
        d2 = 0;
        d1++; d3++; d4++;
    } else if(d == 6) {
        d3 = 0;
        d1++; d2++; d4++;
    } else if(d == 8) {
        d4 = 0;
        d1++; d2++; d3++;
    } else {
        d1++; d2++; d3++; d4++;
    }
    return make_tuple(d1, d2, d3, d4);
}

bool solve(int d, int now, int d1, int d2, int d3, int d4, vector<int> const& v) {
    int& r = memo[d][now][d1][d2][d3][d4];
    if(r != -1) {
        return r;
    }
    if(v[d] & bit[idx[now]]) {
        return r = false;
    }
    if(d == v.size()-1) {
        return r = true;
    }
    bool f = false;
    for(int i=0; i<5; ++i) {
        int to2 = to[now][i];
        auto t = calc(to2, d1, d2, d3, d4);
        if(get<0>(t) == 7 || get<1>(t) == 7 || get<2>(t) == 7 || get<3>(t) == 7) {
            continue;
        }
        f |= solve(d+1, to2, get<0>(t), get<1>(t), get<2>(t), get<3>(t), v);
    }
    
    return r = f;
}

int main() {
    int init = 0b1100110000000000;
    for(int i=0; i<16; ++i) {
        bit[i] = init;
        init >>= 1;
    }
    int D;
    while(cin >> D, D) {
        vector<int> v(D);
        for(int i=0; i<D; ++i) {
            int bit = 0;
            for(int j=0; j<16; ++j) {
                bit <<= 1;
                int b;
                cin >> b;
                bit += b;
            }
            v[i] = bit;
        }
        for(int i=0; i<366; ++i) {
            for(int j=0; j<9; ++j) {
                for(int k=0; k<7; ++k) {
                    for(int l=0; l<7; ++l) {
                        for(int m=0; m<7; ++m) {
                            for(int n=0; n<7; ++n) {
                                memo[i][j][k][l][m][n] = -1;
                            }
                        }
                    }
                }
            }
        }
        //fill(memo[0][0][0][0][0], memo[366][9][7][7][7], -1);
        cout << solve(0, 4, 1, 1, 1, 1, v) << endl;
    }
}


Measured memory_bytes: 33948
program kadai
    implicit none
    integer  ::  n
    integer(8),allocatable  ::  a(:)
    integer(8),allocatable  ::  b(:)
    integer,allocatable  ::  m(:,:)
integer(8)  ::  sum,sum2
    integer  ::  i,j,test

    read(*,*) n
    allocate(a(n))
    allocate(b(n))

    read(*,*) b
    sum=0
    sum2=0
    do i=1,n
        sum=sum+b(i)
    end do
    do i=2,n-1,2
        sum2=sum2+b(i)
    end do
    a(1)=sum-2*sum2

    do i=1,n-1
        a(i+1)=2*b(i)-a(i)
    end do

    write(*,*) a

stop
contains

end program kadai

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

using namespace std;


const int N = 100100;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vipb(v) int x;cin>>x;v.pb(x);
#define vllpb(v) ll x;cin>>x;v.pb(x);
#define in(x) cin>>x;
#define in2(x,y) cin >> x >> y;
#define in3(x,y,z) cin>>x>>y>>z;
#define in4(a,x,y,z) cin>>a>>x>>y>>z;
#define in5(a,b,x,y,z) cin>>a>>b>>x>>y>>z;


typedef vector<int> VI;
typedef vector<ll> VL;


string s;
ll n, m, k;

int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		if (i + k -1<= n)
			m++;
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using std::cout;
using std::cin;
using std::min;
using std::max;

int main(){
    int p,q,r;
    cin >> p >> q >> r;
    cout << min(p,q) + min(r,max(p,q)) << '\n';
    return 0; 
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>

using namespace std;

#define cn cout << '\n'
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

int main() {
    cio;
    int n,i; cin >> n;
    bool b = false;
    for (i = 9; i > 0; --i)
    {
        if (n % i == 0 && n / i <= 9)
        { b = !b; break; }
    }

    if (!b)
        cout << "No\n";
    else
        cout << "Yes\n";
    cn;
    return 0;
}


Measured memory_bytes: 3132
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 100005

int a[N],b[N];
void bal(int n){
  int i;
  for(i=0;i<=n-1;i++)
    a[i]=i,b[i]=1;
}
int vep(int i){
  while(i!=a[i])
    a[i]=a[a[i]],i=a[i];
    return i;
}
int kanagu(int x,int y){
  return vep(x)==vep(y);
}
void helps(int x,int y){
  int i = vep(x),j = vep(y);
  if(i==j)
    return;
  if(b[i]<b[j]){
    a[i]=j;
  b[j]+=b[i];
  }
  else{
    a[j]=i;
  b[i]+=b[j];
  }
}

#if 1
#define gun() getchar_unlocked()
#else
#define gun() getchar()
#endif

int bb(){
  int n = 0,c = gun();
  do n = 10*n+(c & 0xf),c=gun();
  while(c>='0');
  return n;
}

int main(){
  int n,m,p,f,g;

  n=bb();
  m=bb();
  
  bal(n);
  while(m--){
    f=bb();
    g=bb();
    helps(f, g);
  }

  p=bb();
  while(p--){
    f=bb();
    g=bb();
    puts(kanagu(f, g)? "yes":"no");
  }
  return 0;
}



Measured memory_bytes: 2320
#include "cstdio"
#include "algorithm"
#define int unsigned long long 
using namespace std;
int n,m;
struct  can
{
	int a,b;
}arr[1000001];
bool cmp(can a,can b)
{return a.a<b.a;}
signed main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld %lld",&arr[i].a,&arr[i].b);
	}
	sort(arr+1,arr+n+1,cmp);
	int need=0,tmp=0,ans=0;
	for(int i=1;i<=n;i++)
	{
		need=min(arr[i].b,m);
		ans+=need*arr[i].a;
		m-=need;
		if(m==0)
		{
			printf("%lld",ans);
			return 0;
		}
	}
	return 0;
}

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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9 + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 n;
  cin >> n;
  i64 a;
  vector<i64> cum(n + 1);
  cum[0] = 0;
  reps(i, 1, n) {
    cin >> a;
    cum[i] = cum[i-1] + a;
  }

  map<i64, i64> cnt;
  reps(i, 0, n) {
    ++cnt[cum[i]];
  }

  map<i64, bool> exist;
  i64 ans = 0;
  reps(i, 0, n) {
    if (exist[cum[i]]) continue;
    exist[cum[i]] = true;
    ans += (((cnt[cum[i]] - 1) * cnt[cum[i]]) / 2);
  }

  cout << ans << "\n";

  return 0;
}

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

using namespace std;

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

int n;
int l[2005];
bool used[2005];

int main(){
	cin >> n;
	rep(i, n) cin >> l[i];
	
	sort(l, l+n);
	int ans = 0;
	rep(i, n) REP(j, i + 1, n) {
		ans += lower_bound(l+j, l+n, l[i]+l[j]) - (l+j) - 1;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int n,k;
    scanf("%d %d",&n,&k);
    vi v ;
    v.resize(n);
    lp(i,n)scanf("%d",&v[i]);
    ll sum =0;
    sort(all(v));
    lp(i,k)sum+=(ll)v[i];
    printf("%lld",sum);
    return 0;
}

Measured memory_bytes: 3788
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
char ss[100010];
int main()
{
    //freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read(),m=read(),ans=0,top=0;
	scanf("%s",ss+1);
	for(int i=1;i<=n;i++)if(ss[i]!=ss[i-1])top++;
	int ul=top/2;
	if(m>=ul)top=1;
	else top=top-m*2;
	pr2(n-top);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  ll mx=0;
  ll mn=inf; 
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    mx=max(mx,a[i]);
    mn=min(mn,a[i]);
  }
  if(mx-mn>1) {
    cout << "No" << endl;
  }
  else if(mx==mn) {
    if(mx+1==n||mx*2<=n) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    ll x=0;
    ll y=0;
    for(ll i=0;i<n;i++) {
      if(a[i]==mx) x++;
      if(a[i]==mn) y++;
    }
    if(y<mx&&(mx-y)*2<=x) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
int n,m,mapp[105][105],num[105][105],i,j;
char s[105];
int main()
{
    cin>>n>>m;
    for(i=1;i<=n;i++)
    {
        scanf("%s",s+1);
        for(j=1;j<=m;j++)
        {
            if(s[j]=='#')
            mapp[i][j]=1;
            else mapp[i][j]=0;
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(mapp[i][j]==1)
            cout<<"#";
            else cout<<mapp[i-1][j]+mapp[i][j-1]+mapp[i-1][j-1]+mapp[i+1][j]+mapp[i+1][j+1]+mapp[i][j+1]+mapp[i+1][j-1]+mapp[i-1][j+1];
            if(j==m)cout<<endl;
        }
    }
    return 0;
}

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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
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; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}


int m,n;

string s;
int main()
{
    cin>>s;
    bool a,b;
    a=(s[2]==s[3]);
    b=(s[4]==s[5]);
    if(a && b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;

}




Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
b = [0]*(n+1)
cnt = 0
for i in range(n,0,-1):
    #print(i)
    for j in range(1,n+1):
        #print(j)
        if(i*j>n):
            break
        else:
            cnt += b[i*j]
    if((cnt%2==0 and a[i]==0) or (cnt%2==1 and a[i]==1)):
        b[i] = 0
    elif((cnt%2==0 and a[i]==1) or (cnt%2==1 and a[i]==0)):
        b[i] = 1
    else:
        b[i]=a[i]
    cnt = 0

m = sum(b)
print(m)
for k in range(1,n+1):
    if(b[k]==1):
        print(k,end=' ')
#print('')
# print(a)
#print(b)


Measured memory_bytes: 8660
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner kbd = new Scanner(System.in);
        int sx = kbd.nextInt();
        int sy = kbd.nextInt();
        int tx = kbd.nextInt();
        int ty = kbd.nextInt();
        int[] s = { sx, sy };
        int[] t = { tx, ty };

        // いちどめ
        move(s, t);
        move(t, s);

        // にどめ
        int[] s1 = { sx, sy - 1 };
        int[] t1 = { tx + 1, ty };
        move(s, s1);
        move(s1, t1);
        move(t1, t);
        int[] s2 = { sx - 1, sy };
        int[] t2 = { tx, ty + 1 };
        move(t, t2);
        move(t2, s2);
        move(s2, s);
        System.out.println();
    }

    static void move(int[] s, int[] t) {
        moveX(s[0], t[0]);
        moveY(s[1], t[1]);
    }

    static void moveX(int s, int t) {
        if (s < t) {
            for (int i = 0; i < t - s; i++) {
                System.out.print("R");
            }
        } else if (s == t) {
            return;
        } else {
            for (int j = s; j > t; j--) {
                System.out.print("L");
            }
        }
        return;
    }

    static void moveY(int s, int t) {
        if (s < t) {
            for (int i = 0; i < t - s; i++) {
                System.out.print("U");
            }
        } else if (s == t) {
            return;
        } else {
            for (int j = s; j > t; j--) {
                System.out.print("D");
            }
        }
        return;
    }
}


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

int n,x;
set<int> s;

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>x;
		s.insert(x);
	}
	if (s.size()==n)  cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
vector<vector<int>> A;
vector<int> B;
//=============================


void input()
{
    cin>>N;
    A.resize(2, vector<int>(N));
    rep(i,0,N-1){
        cin>>A[0][i];
    }
    rep(i,0,N-1){
        cin>>A[1][i];
    }

}
//=============================
void func(){}
void dfs(int now_i, int now_j, int cnt, int &ans){
    if (now_i >= 2 || now_j >= N) return;
    int cnt_new = cnt;
    cnt_new += A[now_i][now_j];
    if (now_i==1 && now_j == N-1) {
        ans = max(ans, cnt_new);
        return;
    }
    else {
        dfs(now_i+1, now_j, cnt_new, ans);
        dfs(now_i, now_j+1, cnt_new, ans);
    }
}
//=============================
void solve()
{
    int ans = -INF;
    dfs(0,0,0,ans);
    cout<<ans<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

class CommonDivisor{
private:
    unsigned int x;
    unsigned int y;
public:
    CommonDivisor(int x,int y);
    int getMaxCommonDivisor();
};

CommonDivisor::CommonDivisor(int x,int y){
    this->x = x;
    this->y = y;
}

int CommonDivisor::getMaxCommonDivisor(){
    
    if(x < y){
        unsigned int tmp = x;
        x = y;
        y = tmp;
    }

    unsigned int tmp = 0;

    while(true){
        tmp = (x % y);
        x = y;
        y = tmp;
        if(tmp == 0){
            break;
        }
    }
    
    return x;
    
}

int main(){

    int a, b;

    std::cin >> a >> b ;

    CommonDivisor cd = CommonDivisor(a, b);
    
    std::cout << cd.getMaxCommonDivisor() << std::endl;

    return 0;
}

Measured memory_bytes: 3092
function main(input){
    input = input.split(' ');
    var K = parseInt(input[0], 10);
    var S = parseInt(input[1], 10);

    var ans = 0;
    for(var x = 0;x <= K; x++)
	for (var y = 0;y <= K; y++){
	    z = S - (x + y)
	    if ( z >= 0 && z <= K ) ans++
	}
    console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
import math
n = int(input())
x = list(map(int,input().split(" ")))
a=math.ceil(sum(x)/n)
s = sum((xx - a)**2 for xx in x)
tmp = s
a = a-1
s = sum((xx - a)**2 for xx in x)
if s > tmp:
    print(tmp)
else:
    print(s)

Measured memory_bytes: 9072
// https://atcoder.jp/contests/abc133/tasks/abc133_e

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

typedef int64_t ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define FORR(i,b,e) for(int i=(b); i>=(int)(e); i--)
#define DUMP(a, n) REP(_i, n) cout << a[_i] << (_i + 1 == n ? endl : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) cout << a[_i][_j] << (_j + 1 == m ? endl : ' '); cout << endl

//------------------------------------------------------------------------------
int extgcd(int a, int b, int &x, int &y) {
  int ret = a;
  if (b == 0) {
    x = 1;
    y = 0;
  } else {
    ret = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  }
  return ret;
}

int mod_inverse(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}

//------------------------------------------------------------------------------
const int F_MAX = 1e5;

ll fact[F_MAX + 1];
ll fact_inv[F_MAX + 1];

void init_fact(int m) {
  fact[0] = 1;
  FOR(i, 1, F_MAX) fact[i] = fact[i - 1] * i % m;
  fact_inv[F_MAX] = mod_inverse(fact[F_MAX], m);
  FORR(i, F_MAX - 1, 0) fact_inv[i] = fact_inv[i + 1] * (i + 1) % m;
}

ll mod_permutation(ll n, ll m, ll mod) {
  if (m > n) return 0LL;
  return fact[n] * fact_inv[n - m] % mod;
}

//------------------------------------------------------------------------------
const int N_MAX = 1e5;
const int K_MAX = 1e5;
const int MOD = 1'000'000'007;

int N, K;
vector<vector<int>> G;

void add_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}

void dfs(int p, int v, ll &x) {
  int n = p < 0 ? K - 1 : K - 2;
  int m = p < 0 ? G[v].size() : G[v].size() - 1;
  // cout << n << ' ' << m << ' ' << mod_permutation(n, m, MOD) << endl;
  x = x * mod_permutation(n, m, MOD) % MOD;
  for (int u : G[v]) {
    if (u == p) continue;
    dfs(v, u, x);
  }
}

int main() {
  cin >> N >> K;
  G = vector<vector<int>>(N);
  REP(i, N - 1) {
    int a, b;
    cin >> a >> b;
    add_edge(a - 1, b - 1);
  }

  init_fact(MOD);

  ll ans = K;
  dfs(-1, 0, ans);
  cout << ans << endl;
}


Measured memory_bytes: 65408
#include <bits/stdc++.h>
using namespace std;
 
int getdigit(long long N) {
  int digit = 0;
  while(N>0) {
    digit++;
    N /= 10;
  }
  return digit;
}
  
int main() {
  long long N; cin >> N;
  int mindigit = 11;
  for (int i = 1; i <= sqrt(N); i++) {
    if(N % i == 0) mindigit = min(mindigit, max(getdigit(i), getdigit(N / i)));
  }
  cout << mindigit;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
ll bogo[1002][1002];
ll arr[1002][1002];
ll dp(ll n,ll m ,ll x,ll y)
{
    if(x==n&&y==m)return 1;
    else{
        if(bogo[x][y]==-1){
        ll cal=0;
        if(arr[x+1][y]==21){
            cal+= dp(n,m,x+1,y);
        }
        if(arr[x][y+1]==21){
            cal+= dp(n,m,x,y+1);
        }
        bogo[x][y]=cal;
        return cal;
    }
        return bogo[x][y]%1000000007;
    }
}
int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    memset(bogo,-1,1002*1002*sizeof(bogo[0][0]));
    ll n,m;
    cin>>n>>m;

    for (int i = 1; i <= n; ++i)
    {
        for (int j= 1; j <= m; ++j)
        {
           char temp;
           cin>>temp;
           if(temp=='.'){
            arr[i][j]=21;
           }
           if(temp=='#'){
            arr[i][j]=1;
           }
        }
    }
   cout<< dp(n,m,1,1)%1000000007;
}

Measured memory_bytes: 19428
#include <iostream>
using namespace std;
int main(void){
	int a,b,c,count = 0;
  	cin >> a >> b >> c;
  	if(a == b && a == 5||a == c && a == 5||b == c && b == 5){
      count++;
    }
  	if(a == 7 || b == 7||c == 7){
      count++;
    }
  	if(count == 2){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
}

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

#ifdef LOCAL
  #include <contest/local.hpp>
#else
  #define LOG(...) do {} while (false)
#endif

#define REP(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)

using namespace std;

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

  unsigned n;
  cin >> n;
  vector <int> p;

  REP (i, n)
  {
    int x;
    cin >> x;
    p.push_back (move (x));
  }

  auto ans = is_sorted (p.begin (), p.end ());

  if (ans) goto finish;

  REP (i, n) REP (j, i)
  {
    swap (p [i], p [j]);
    if (is_sorted (p.begin (), p.end ()))
    {
      ans = true;
      goto finish;
    }
    swap (p [i], p [j]);
  }
finish:
  cout << (ans ? "YES" : "NO") << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define fgx cerr<<" ---------------------------------------------- "<<endl
#define uint unsigned int 
#define ULL unsigned long long
#define DB double
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
inline LL read(){
	LL nm=0; bool fh=true; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) fh^=(cw=='-');
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return fh?nm:-nm;
}
#define M 400020
#define mod 998244353
namespace  CALC{
	inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
	inline int mns(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
	inline int mul(int x,int y){return (LL)x*(LL)y%mod;}
	inline void upd(int &x,int y){x+=y;(x>=mod)?(x-=mod):0;}
	inline void dec(int &x,int y){x-=y;(x<0)?(x+=mod):0;}
	inline int qpow(int x,int sq){int res=1;for(;sq;sq>>=1,x=mul(x,x))if(sq&1)res=mul(res,x);return res;}
}using namespace CALC;
LL n,a,b,ans,aa,bb;
int main(){
	n=read(),a=read(),b=read(),ans=n+n+n;
	if(!((a^b)&1)){printf("%lld\n",(b-a)>>1);return 0;}
	aa=2-a,bb=n+n-b;
	printf("%lld\n",(min(b-aa,bb-a)+1)>>1);
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

print(ri()//3)















Measured memory_bytes: 27192
import java.util.*;
class Main {
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
      if(A==0&&B==0){System.out.println("IMPOSSIBLE");}else{
      	if((A+B)%2==0){
		int K = (A+B)/2;
		if((A-K>=0&&B-K<=0)||(B-K>=0&&A-K<=0)) {
			System.out.println(K);}else{
				System.out.println("IMPOSSIBLE");
			}
        }else{
          System.out.println("IMPOSSIBLE");
        }
        }
	}
}

Measured memory_bytes: 21716
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));
  $b=$a;

  sort($a);

  $m1=$a[$n/2-1];
  $m2=$a[$n/2];

  for($i=0;$i<$n;$i++){
    if($b[$i] <= $m1){
      echo $m2.PHP_EOL;
    }else{
      echo $m1.PHP_EOL;
    }
  }

Measured memory_bytes: 38068
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long long LL;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

long long N;
vector<long long> A;
vector<bool> check;
long long D1, D2;
vector<long long> stair, inv, sinv;

long long solvefor(long long K) {
	long long all = (stair[N + 1] * sinv[K]) % MOD;
	all = (all * sinv[N - K + 1]) % MOD;
	long long doub = (stair[N + D1 - D2] * sinv[K - 1]) % MOD;
	if (N + D1 - D2 - K + 1 < 0)doub = 0;
	else doub = (doub * sinv[N + D1 - D2 - K + 1]) % MOD;
	return (all - doub + MOD) % MOD;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> N;
	A.resize(N + 1);
	check.resize(N + 1, false);
	for (int n = 0; n <= N; n++) {
		cin >> A[n];
		if (check[A[n]]) {
			D2 = n;
		}
		check[A[n]] = true;
	}
	for (int n = 0; n <= N; n++) {
		if (A[n] == A[D2]) {
			D1 = n;
			break;
		}
	}
	stair.resize(1e5 + 2);
	inv.resize(1e5 + 2);
	sinv.resize(1e5 + 2);
	inv[1] = 1;
	sinv[0] = 1;
	sinv[1] = 1;
	stair[1] = 1;
	stair[0] = 1;
	for (int n = 2; n <= 1e5 + 1; n++) {
		inv[n] = MOD - (inv[MOD % n] * (MOD / n)) % MOD;
		sinv[n] = (sinv[n - 1] * inv[n]) % MOD;
		stair[n] = (n * stair[n - 1]) % MOD;
	}
	cout << N << endl;
	for (int k = 2; k <= N; k++) {
		cout << solvefor(k) << endl;
	}
	cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 4352
import itertools
n,m,x=map(int,input().split())
book = [list(map(int,input().split()))for _ in range(n)]
ans = float("inf")


for i in range(1,n+1):
    for k in itertools.combinations(range(n),i):
        tmp = 0
        exp = [0]*m
        for j in k:
            gold = False
            for i,a in enumerate(book[j]):
                if i==0:
                    tmp += a
                else:
                    exp[i-1] += a
        if min(exp) >= x:
            ans = min(ans,tmp)

if ans == float("inf"):
    print(-1)
    exit()
print(ans)

Measured memory_bytes: 9224
//====== begin of bisma c++ template===========
#include<bits/stdc++.h>
#include <assert.h>
using namespace std;
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define repn(a,b,c) for(int a=b;a>=c;a--)
#define ll long long 
#define sum(a,b) a=a+b
#define mem(a, b) memset(a, (b), sizeof(a))


//=======binarysearch===========
int bs(vector<long long>&a,int que){
 auto it=lower_bound(a.begin(),a.end(),que);
 if(*it==que){
    return it-a.begin();
 }
 return -1;
}
//========binarysearch=========



//=======SUBSET WITH BRUTEFORCE=============
void subsets(string S, int n) {
     int nSub = 1<<n; 
     for(int i=0; i<nSub; i++){
     	  cout<<"{ ";//optional
          for(int k=0; k<n; k++){
               //if the k-th bit is set
               if( (1<<k) & i){
                    cout<<S[k]<<" ";
               } 
          }
          cout<<"}\n"; //optional
     }
}
//======SUBSET WITH BRUTE FORCE================


//======permuatate all ==================
void permutate(){
int n,x;
cin>>n;

vector<int> permutation;
for (int i = 0; i < n; i++) {
	cin>>x;
permutation.push_back(x);
}
do {
 rep(i,0,n-1) cout<<permutation[i];
 cout<<endl;
} while (next_permutation(permutation.begin(),permutation.end()));

}
//====permuatate all======================


//====check prime =========================

bool prime(ll x){
	ll ans=0;

	if(x==1){
		return false;
	}

	for(ll i=2;i<=sqrt(x);i++){
		if(x % i == 0){
			return false;
		}
	}

	return true;
}
//===check prime ========================


//======= the end of bisma c++ template ============


int a[100001];

int main(){

	int n,k;
	cin>>n>>k;
    int mins=100001;
	rep(i,1,n) {
		cin>>a[i];
		mins=min(a[i],mins);
	}
   int pos;
	rep(i,1,n){
		if(i==mins){
			pos=i;
			break;
		}
	}
if(n==k){
	cout<<1;
	return 0;
}

if(k==0||n==0){
	cout<<0;
	return 0;
}

if(k==2){
	cout<<n-1;
	return 0;
}

int cnt=1;
int ans=0;
rep(i,1,n-k){
  if(i%(k-1)==0){
  	ans++;
  }
}

if( (n-k)%(k-1)==0 ){
	ans=ans+cnt;
}else{
	ans=ans+cnt+1;
}

cout<<ans<<endl;

	
return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(v,n) find(v.begin(),v.end(),n)
#define sort1(v) sort(v.begin(),v.end())
#define lb(v,n) lower_bound(v.begin(),v.end(),n)-v.begin()
#define ub(v,n) upper_bound(v.begin(),v.end(),n)-v.begin()
#define mod 1000000007
#define reverse(s) reverse(s.begin(),s.end())
//#define pi pair<l,l> 
const double pi=3.141592653589793;
bool isprime(l n)
{
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
/*bool fact(l n)
{
	vector<l> v;
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			if(i%2==1||(n/i)%2==1)
			{
				return true;
			}
		}
	}
	return false;
}*/
l power(l a,l b)
{
	l ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=(ans*a);
		}
		b>>=1;
		a=(a*a);
	}
	return ans;
}//prefixsums
void frooty()
{
	l n;
	cin>>n;
	l dp[n+1];
	mem(dp,0);
	for(l x=1;x<=100;x++)
	{
		for(l y=1;y<=100;y++)
		{
			for(l z=1;z<=100;z++)
			{
				l val=(((x+y)*(x+y))+((y+z)*(y+z))+((z+x)*(z+x)))/2;
				if(val<=n)
					dp[val]++;
			}
		}
	}
	for(l i=1;i<=n;i++)
		cout<<dp[i]<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q=1;
	//cin>>q;
	while(q--)
	{
		frooty();
	}
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;
typedef long long ll;

ll n, b, s, a[N], d[N];
int main() {
	int i, j, k;
	cin >> n;
	for(i=0; i<n; i++) scanf("%lld", &a[i]);
	for(i=0; i<n; i++) scanf("%lld", &b), d[i] = a[i] - b;
	sort(d, d+n);
	for(i=0; i<n && d[i]<0; i++) s += d[i];
	for(j=n-1, k=0; j>=0 && s<0; j--, k++) s += d[j];
	cout << (s<0 ? -1 : i + k);
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
	int main(){
	int a,h,m,s;
	scanf("%d",&a);
	h = a/3600;
	m = (a-h*3600)/60;
	s = a-h*3600-m*60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <string>
#include <vector>
#include <cctype>

using namespace std;

struct Task {
	int x, y, mem, dir;
};

const int dx[] = { 1, 0, -1, 0 };
const int dy[] = { 0, -1, 0, 1 };
bool passed[20][20][16][4] = { { { { false } } } };

int main(){
	int R, C;
	cin >> R >> C;
	vector<string> program(R);
	for(int i = 0; i < R; ++i){ cin >> program[i]; }
	int x = 0, y = 0, mem = 0, dir = 0;
	bool answer = false;
	vector<Task> tasks;
	Task initial = { 0, 0, 0, 0 };
	tasks.push_back(initial);
	while(!answer && !tasks.empty()){
		Task &task = tasks.back();
		passed[task.y][task.x][task.mem][task.dir] = true;
		if(program[task.y][task.x] == '?'){
			Task t = task;
			tasks.pop_back();
			for(int i = 0; i < 4; ++i){
				Task next = t;
				next.dir = i;
				next.x = (next.x + C + dx[next.dir]) % C;
				next.y = (next.y + R + dy[next.dir]) % R;
				if(!passed[next.y][next.x][next.mem][next.dir]){
					tasks.push_back(next);
				}
			}
		}else{
			if(isdigit(program[task.y][task.x])){
				task.mem = program[task.y][task.x] - '0';
			}else{
				switch(program[task.y][task.x]){
				case '<': task.dir = 2; break;
				case '>': task.dir = 0; break;
				case '^': task.dir = 1; break;
				case 'v': task.dir = 3; break;
				case '_': task.dir = (task.mem == 0 ? 0 : 2); break;
				case '|': task.dir = (task.mem == 0 ? 3 : 1); break;
				case '+': task.mem = (task.mem + 1) & 0x0f; break;
				case '-': task.mem = (task.mem - 1) & 0x0f; break;
				case '@': answer = true; break;
				}
			}
			task.x = (task.x + C + dx[task.dir]) % C;
			task.y = (task.y + R + dy[task.dir]) % R;
			if(passed[task.y][task.x][task.mem][task.dir]){ tasks.pop_back(); }
		}
	}
	cout << (answer ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
auto in = [](auto &&... args) { (cin >> ... >> args); };


signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  
  int N , K;
  cin >> N >> K;
  vector<int> a(N+1);
  vector<int> dp(N+1,inf);

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

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

  for(int i = 3; i <= N; i++) {
    for(int j = 1; j <= K; j++){
      if(i - j < 1) break;
      dp[i] = min(dp[i] , abs(a[i] - a[i - j]) + dp[i - j]);
    }
  }
  cout << dp[N] << '\n';
}

Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e3+50;
int a[maxn],n;
int main()
{
    cin>>n;
    for(int i=0;i<n;++i) cin>>a[i];
    sort(a,a+n);
    //for(int i=0;i<n;++i) cout<<a[i]<<" ";
    //cout<<endl; 
    int ans=0;
    for(int i=0;i<n;++i)
    {
        for(int j=i+1;j<n;++j)
        {
            for(int k=j+1;k<n;++k)
            {
                if(a[i]==a[j]) continue;
                else if(a[j]==a[k]) continue;
                else if(a[i]+a[j]>a[k]) 
                {
                    ans++;
                   //cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<endl;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
import math
import numpy as np
import itertools
N = int(input())
x = []; y= []
for _ in range(N):
    x_,y_ = map(int,input().split())
    x.append(x_)
    y.append(y_)
lis = np.zeros((8,8))
for i in range(N):
    for j in range(N):
        lis[i,j] = math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)
num = 0
su = 0
ite = itertools.permutations([i for i in range(N)])
for it in ite:
    for i in range(len(it)-1):
        su += lis[it[i],it[i+1]]
    num += 1
print(su/num)


Measured memory_bytes: 12396
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int m = sc.nextInt();
    
    int[] arr = new int[n];
    int cntAC = 0;
    int cntWA = 0;
    int[] cntWAs = new int[n];
    
    for(int i = 0; i < m; i++){
      int num = sc.nextInt();
      String res = sc.nextLine();
      //System.out.println(res);
      
      if(arr[num - 1] == 0){
        if(res.equals(" AC")){
          cntAC++;
          cntWA += cntWAs[num - 1];
          arr[num - 1] = 1;
        }else{
          cntWAs[num - 1]++;
        }
      }
    }
    
    System.out.println(cntAC + " " + cntWA);
  }
}

Measured memory_bytes: 60836
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    string s; cin >> s;
    for (int i=0; s[i]; ++i) {
        if ((i%2==0&&s[i]=='L') || (i%2==1 && s[i]=='R')) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

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

int main() {
    while(true) {
        cin>>n>>p;
        if(!n) return 0;
        int now=0;
        int cnt[51]={};
        while(true) {
            if(p) {
                cnt[now]++;
                p--;
                if(!p) {
                    bool end=true;
                    for(int i=0; i<n; ++i) {
                        if(i!=now && cnt[i]) end=false;
                    }
                    if(end) {
                        cout<<now<<endl;
                        break;
                    }
                }
                ++now%=n;
            } else {
                p=cnt[now];
                cnt[now++]=0;
                if(now==n) now-=n;
            }
        }
    }
}


Measured memory_bytes: 3072
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int x;
    cin >> x;
    int sum = 0;
    int ans;
    rep(i, x) {
        sum += i + 1;
        if (sum >= x) {
            ans = i + 1;
            break;
        }
    }

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

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int strlen(char a[])
{
	int b;
	for(b=1;;b++)
	{
		if(a[b]=='\0')
		break;
	}
	return b;
}
int main()
{
	int i;
	char s[11],r[11];
	cin>>s;
	cin>>r;
	for(i=0;i<strlen(s);i++)
	{
		if(s[i]!=r[i])
		break;
	}
	if(i==strlen(s)&&strlen(s)+1==strlen(r))
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			string origin = Console.ReadLine();
			int q = int.Parse(Console.ReadLine());

			List<string> answer = new List<string>();
			string str = origin;
			for (var i = 0; i < q; ++i) {
				string command = Console.ReadLine();
				string[] commands = command.Split(' ');
				int a = int.Parse(commands[1]);
				int b = int.Parse(commands[2]);
				string[] tempStr = new string[3];
				switch (commands[0]) {
					case "print":
						answer.Add(str.Substring(a, b - a + 1));
						break;
					case "reverse": {
							tempStr[0] = str.Substring(0, a);
							tempStr[1] = new string(str.Substring(a, b - a + 1).Reverse().ToArray());
							tempStr[2] = str.Substring(b + 1, str.Length - b - 1);
							str = tempStr[0] + tempStr[1] + tempStr[2];
						}
						break;
					case "replace": {
							tempStr[0] = str.Substring(0, a);
							tempStr[1] = commands[3];
							tempStr[2] = str.Substring(b + 1, str.Length - b - 1);
							str = tempStr[0] + tempStr[1] + tempStr[2];
						}
						break;
				}
			}

			foreach (var item in answer) {
				Console.WriteLine($"{item}");
			}

			Console.ReadKey();
		}
	}
}


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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  rep(i, N) {
    cin >> H.at(i);
  }

  int ans = 0;
  vector<char> cnt(N-1);
  rep (i, (N -1)) {
    if (H.at(i) >= H.at((i + 1))) {
      cnt.at(i) = 'A';
    }
    else cnt.at(i) = 'B';
  }

  vector<int> baka;
  int c = 0;
  int k = 0;
  rep (i, cnt.size()) {
    if ('A' == cnt.at(i)) {
      c++;
    }
    else if ('B' == cnt.at(i)) {
      baka.push_back(c);
      c = 0;
      k++;
    }
  }
  baka.push_back(c);
  
  sort (baka.begin(), baka.end());
  reverse (baka.begin(), baka.end());
  
  cout << baka.at(0) << endl;



}

Measured memory_bytes: 1404
#coding:utf-8
n=int(input())
n1=[]
for i in range(3,-1,-1):
  n1.append(int(n/10**i))
  n%=10**i
if(n1[0]==n1[1]==n1[2] or n1[1]==n1[2]==n1[3]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	int m, f, r, z;
	while (1){
		cin >> m >> f >> r;
		z = m + f;
		if (m == -1 && f == -1 && -1)break;
		
		if (z >= 80){
			cout << 'A' << endl;
		}
		else if (z >= 65){
			cout << 'B' << endl;

		}
		else if (z >= 50 || r >= 50){
			cout << 'C' << endl; 
		} else if (z>=30&&m!=-1&&f!=-1){
			cout << 'D' << endl;
		}
		else cout << 'F' << endl;
	}




















	return 0;
}

Measured memory_bytes: 3068
import 'dart:io';

void main() {
  String s = stdin.readLineSync();
  int count;
  count = 0;
  int sum;
  sum = 1;
  if (s[0] == 'R') {
    count = 1;
    sum = 1;
  } else if (s[0] == 'S') {
    count = 0;
    sum = 0;
  }
  for (int i = 1; i < 3; i++) {
    if (count == 0 && s[i] == "R") sum = 1;
    if (s[i - 1] == "R" && s[i] == "R") {
      sum++;
    }
  }
  print(sum);
}

Measured memory_bytes: 13168
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define div 998244353
#define rep(i,n) for(int i=0;i<n;i++)
int n,cnt=1,ans=1,maxl=0;
int d[200000];
map<int,int>mp;
int my_pow(int a,int b){
    if(b==1)return a;
    if(b%2)return (my_pow(a,b/2)*my_pow(a,(b/2)+1))%div;
    return (my_pow(a,b/2)*my_pow(a,b/2))%div;
}
signed main(){
    cin>>n;
    rep(i,n){
        cin>>d[i];
        mp[d[i]]++;
        maxl=max(maxl,d[i]);
    }
    if(d[0]!=0||mp[0]>1){
        cout<<0<<endl;
        return 0;
    }
    for(int i=1;i<=maxl;i++){
        if(mp[i]==0){
            cout<<0<<endl;
        return 0;
        }
        ans*=my_pow(mp[i-1],mp[i]);
        ans%=div;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7296