akhauriyash/Code-Regression huggingface dataset:
// abc134_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int r;
    cin >> r;
    int ans = 3 * r * r;
    print(ans);

    return 0;
}


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

using namespace std;

int main()
{
        int n;
        long long l[ 104 ];
        string l_str;

        int ans = 0;

        cin >> n ;

        for ( int i = 1; i <= n; i++ )
        {
                cin >> l[ i ];
                //printf( "l-%d: %lld\n", i, l[ i ] );
        }

        for ( int i = 1; i <= n; i++ )
        {
                for ( int j = i+1; j <= n; j++ )
                {
                        for ( int k = j+1; k <= n; k++ )
                        {
                                if (( l[ i ] == l[ j ] ) ||
                                        ( l[ j ] == l[ k ] ) ||
                                        ( l[ k ] == l[ i ] ))
                                {
                                        continue;
                                }

                                long long ij = l[ i ] + l[ j ];
                                long long jk = l[ j ] + l[ k ];
                                long long ki = l[ k ] + l[ i ];
                                if (( l[ i ] < jk ) &&
                                        ( l[ j ] < ki ) &&
                                        ( l[ k ] < ij ))
                                {
                                        //printf( "%d[%d] %d[%d] %d[%d]\n", i, l[i], j,l[j],k,l[k]);
                                        ans++;
                                }
                        }
                }
        }

        cout << ans << '\n';


        return 0;
}


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

long long gcd(long long x, long long y){
    if(y > x) return gcd(y, x);
    if(x % y == 0) return y;
    return gcd(y, x % y);
}

int main(void){
    int N;
    long long X;
    std::cin >> N >> X;
    long long x;
    long long D;
    std::cin >> x;
    D = abs(x - X);
    for(int i = 1; i < N; i++){
        std::cin >> x;
        D = gcd(D, abs(x - X));
    }
    std::cout << D << std::endl;
    return 0;
}


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

int main(void){
  int n,m; cin >> n >> m;
  vector<int> l(m);
  vector<int> r(m);
  rep(i,m) cin >> l[i] >> r[i];
  sort(l.begin(),l.end());
  sort(r.begin(),r.end());
  if(r[0] - l[m-1] + 1 > 0) cout << r[0] - l[m-1] + 1 << endl;
  else cout << 0 << endl;
  return 0;
}


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

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < 100; i++) {
		if (a + (a - 1) * (i - 1) >= b) {
			cout << i;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
int main()
{    
	string a;
	cin>>a;
	if(a.size()%2!=0)
	{
		cout<<"No";
		return 0;
	}
	for(int i=1;i<=a.size()/2;i++)
	{
		if((a[i-1]=='p'&&a[a.size()-i]!='q')||(a[i-1]=='q'&&a[a.size()-i]!='p')||(a[i-1]=='q'&&a[a.size()-i]!='p')||(a[i-1]=='p'&&a[a.size()-i]!='q'))
		{
			cout<<"No"<<endl;
			return 0;
		}
		if((a[i-1]=='b'&&a[a.size()-i]!='d')||(a[i-1]=='d'&&a[a.size()-i]!='b')||(a[i-1]=='d'&&a[a.size()-i]!='b')||(a[i-1]=='b'&&a[a.size()-i]!='d'))
		{
			cout<<"No"<<endl;
			return 0;
		}
		//cout<<a[i-1]<<" "<<a[a.size()-i]<<endl;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 512
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int h, w, n;
	scanf("%d %d %d", &h, &w, &n);
	int x = std::max(h, w);
	printf("%d\n", (n+x-1)/x);
	return 0;
}



Measured memory_bytes: 3760
import java.util.*;

class Main{
	public static void main(String args []){
    Scanner scan = new Scanner(System.in);
      int n = scan.nextInt();
      int l = scan.nextInt();
      String [] ss = new String[n];
      int i=0;
      while(i<n)
      {
        ss[i]=scan.next();
        i++;
      }
      Arrays.sort(ss);
      String res = "";
      for(String s:ss){
      	res+=s;
      }
      
      System.out.println(res);
    }
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int s;
  cin >> s;
  int h = s/(60*60);
  s -= h * 3600;
  int m = s/60;
  s -= m * 60;
  cout << h << ':' << m << ':' << s << endl;
  return 0;
}



Measured memory_bytes: 3088
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<time.h>

#define MOD 1000000007

typedef struct node{int value;struct node* right;struct node* left;}node;

void swap(int* a, int* b){int c=*a;*a=*b;*b=c;}
int gcd(int a, int b){if(a<b){swap(&a,&b);}while(a%b!=0){int c=a%b;a=b;b=c;}return b;}
int permutations(int n, int r){int a=n;for(int i=1;i<=r;i++){a*=n-i;}return a;}
int combination(int n, int r){if(r==0||r==n){return 1;}if(r==1){return n;}return combination(n-1,r-1)+combination(n-1,r);}
int isPrime(int n){if(n==1){return 0;}if(n==2||n==3){return 1;}if(n%2==0||n%3==0){return 0;}for(int i=5;i*i<=n;i+=2){if(i%3==0){continue;}if(n%i==0){return 0;}}return 1;}
int compare_ascending(const void* a, const void* b){return *(int*)a-*(int*)b;}

int main(){
    long long int n;
    scanf("%lld", &n);
    long long int min = n;
    for(long long int i=1; i<=sqrt(n); i++){
        if(n % i == 0){
            if(min > i+(n/i)-2){
                min = i+(n/i)-2;
            }
        }
    }
    printf("%lld", min);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

// snukeさんのmodint
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

// mint N;
//cout << N.x << endl;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    mint ans = 0;
    mint k = K,two = 2;
    for(int i=0; i<N; i++){
        mint cnt = 0;
        mint cnt2 = 0;
        for(int j=0; j<N; j++){
            if(A[j] > A[i]) cnt+=1;
        }
        for(int j=0; j<i; j++){
            if(A[j] > A[i]) cnt2+=1;
        }
        ans += (k-1)*k/two * cnt;
        ans += k * cnt2;
    }
    cout << ans.x << enld;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>
#include <bits/stdc++.h>
#include <string.h>
#include <string>
#include <algorithm>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define N 100005
#define inf 1e18
#define mem(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << (#x) << " = " << x << endl;
#define debug2(i,j) cout << (#i) << "=" << i << " , " << (#j) << "=" << j << endl;

using namespace std;

ll binomialCoeff(ll n,ll k)
{
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll mod = 1e9+7;

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return (temp*temp)%mod;
    else
        return (((x*temp)%mod)*temp)%mod;
}


/* nCr % mod
ll fact[6*N];
ll inv[6*N],invfac[6*N];
ll mod = 998244353;

void factorial()
{
    fact[0] = invfac[0] = fact[1] = invfac[1] = 1;
    inv[1] = 1;
    for(int i=2;i<=5*N + 10;i++)
    {
        fact[i] = (fact[i-1]*i)%mod;
        inv[i] = (inv[mod%i]*(mod - mod/i))%mod;
        invfac[i] = (invfac[i-1]*inv[i])%mod;
    }
}*/

vector<ll> primes;

void Sieve(int n)
{
    vector<bool> prime(n+1,true);
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primes.push_back(p);
}

//******************************************************    CHECK CONSTRAINTS   ***************************************************************//

const int Nmax = 2e6 + 6;

int n;
ll arr[Nmax];
ll fen[Nmax];
ll last[Nmax];    
pair<int,pair<int,int>> t[Nmax];
ll ans[Nmax];

void update(int ind,int val)
{
    while(ind<=n)
    {
        fen[ind] += val;
        ind += ind&(-ind);
    }
}

ll get(int ind)
{
    ll ans = 0;
    while(ind>0)
    {
        ans += fen[ind];
        ind -= ind&-ind;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin >> n;
    int q;
    cin >> q;
    for(int i=0;i<Nmax;i++)
        last[i] = -1;
    for(int i=0;i<n;i++)
        cin >> arr[i];
    for(int i=0;i<q;i++)
    {
        int l,r;
        cin >> l >> r;
        l--,r--;
        t[i] = {r,{l,i}};
    }
    sort(t,t+q);
    int c = 0;
    for(int i=0;i<n;i++)
    {
        ll val = arr[i];
        if(last[val]!=-1)
        {
            update(last[val]+1,-1);
        }
        last[val] = i;
        update(i+1,1);
        while(c < q && t[c].first == i)
        {
            ans[t[c].second.second] = get(i+1) - get(t[c].second.first);
            c++;
        }
    }
    for(int i=0;i<q;i++)
    {
        cout << ans[i] << "\n";
    }
}


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

static const int MAX = 2e+5;
double E[MAX], sumE[MAX];

int main(){
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        int p;
        cin >> p;
        E[i] = (p+1) / (double)2;
    }
    sumE[0] = 0;
    for(int i = 1; i <= n; i++){
       sumE[i] = sumE[i-1] + E[i-1];
    }
    double ans = 0;
    for(int i = 0; i <= n-k; i++){
        ans = max(ans, sumE[i+k] - sumE[i]);
    }
    printf("%.7f\n", ans);
    return 0;
}

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

int main(void){
    int n,m;
    cin >> n >> m;
    int a[50],b[50],num[50];
    for(int i = 0;i < n;i++)num[i] = 0;
    for(int i = 0;i < m;i++){
        cin >> a[i] >> b[i];
        num[a[i]-1] += 1;
        num[b[i]-1] += 1;
    }
    for(int i = 0;i < n;i++)cout << num[i] << endl;
}

Measured memory_bytes: 256
N = gets.to_i
a = gets.split(' ').map(&:to_i)
dp = []
dp[0] = 0
dp[1] = (a[0] - a[1]).abs
(2..N-1).each do |n|
  dp[n] = [dp[n-1] + (a[n] - a[n-1]).abs, dp[n-2] + (a[n] - a[n-2]).abs].min
end
p dp[N-1]

Measured memory_bytes: 11396
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int f[110][11];
int p[110][11];

int main()
{
	int n;cin >> n;
	
	REP(i,n)
	{
		REP(j,10)
		{
			cin >> f[i][j];
		}
	}
	
	REP(i,n)
	{
		REP(j,11)
		{
			cin >> p[i][j];
		}
	}
	
	
	ll ans = -1000000000;
	for(int i = 1;i < (1<<10);i++)
	{
		ll hi = 0;
		REP(q,n)
		{
			int num = 0;
			REP(j,10)
			{
				if((i>>j)&1)num+=f[q][j];
			}
			//cout <<  p[q][num] << ' ' << num << ' ';
			hi += p[q][num];
		}
		//cout << i << ' ' << hi << endl;
		ans = max(ans,hi);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int i=0,n,x=0,max=0;
char ch[1000];
scanf("%d",&n);
scanf("%s",ch);
while(ch[i]!=NULL)
{
    if(ch[i]=='I')
    {
        x += 1;
    }
    else if(ch[i]=='D')
    {
        x -= 1;
    }
    
    if(x>max)
    {
        max=x;
    }
    i++;
}
printf("%d",max);

}


Measured memory_bytes: 128
function main(arg) {
	var num = parseInt(arg.replace(/\s/g,"").replace(/\r/g,""));
 
	var jougen = Math.sqrt(num)+10;
	var kyori = num - 1;
 
	for(i=2;i<jougen;i++){
		if(num%i===0){
			var hikaku = i + num/i - 2;
			if(hikaku<kyori){
				kyori = hikaku;
			}
		}
	}
	console.log(kyori);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21192
#include<stdio.h>
#include<stdlib.h>

#define WHITE 10000
#define BLACK 10001
#define GRAY 10002
#define TRUE 1
#define FALSE 0
#define NUL NULL

void dfs(void);
void visit(int);
void push(int);
void pop(void);
int isEmpty(void);

int v[101][101],s[101],time1,n;
int *d,*f,*color;
int top = 0;

int main(){
  int u,i,j,w,k;

  scanf("%d",&n);

  d = malloc(sizeof(int) * (n + 1));
  f = malloc(sizeof(int) * (n + 1));
  color = malloc(sizeof(int) * (n + 1));

  for(i = 1;i <= n;i++){
    scanf("%d %d",&u,&k);
    for(j = 1;j <= k;j++){
      scanf("%d",&w);
      v[i][w] = 1;
    }
  }

  dfs();

  for(i = 1;i <= n;i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }

  return 0;
}

void dfs(){
  int i = 1,j = 1;
  for(i = 1;i <= n;i++){
      color[i] = WHITE;
  }

  time1 = 0;

  for(i = 1;i <= n;i++){
    if(color[i] == WHITE){
      visit(i);
    }
  }    

}

void visit(int r){
  int u,vv=NUL,i;

  push(r);
  color[r] = GRAY;
  d[r] = ++time1;

  while(isEmpty() == FALSE){
    vv=NUL;
    u = s[top];
    for(i = 1;i <= n;i++){
	if(v[u][i] == 1 && color[i] == WHITE){
	  vv = i;
	  break;
	}
	
    }
    if(vv != NUL){
      if(color[vv] == WHITE){
	push(vv);
	color[vv] = GRAY;
	d[vv] = ++time1;
      }
    }
    else{
      pop();
      color[u] = BLACK;
      f[u] = ++time1;
    }
  }
}

void push(int x){
  top++;
  s[top] = x;
}

int isEmpty(){
  if(top == 0){
    return TRUE;
  }
  else{
    return FALSE;
  }
}

void pop(){
  top--;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)

vector<double> x, y;

double __pow(double a) {
    return a * a;
}

int main() {
    double px,py;
    while(~scanf("%lf,%lf",&px,&py)) {
        x.push_back(px); y.push_back(py);
    }

    int n = x.size();
    double s = 0;
    FOR(i,2,n) {
        double a = sqrt(__pow(x[0]-x[i-1]) + __pow(y[0]-y[i-1]));
        double b = sqrt(__pow(x[0]-x[i]) + __pow(y[0]-y[i]));
        double c = sqrt(__pow(x[i-1]-x[i]) + __pow(y[i-1]-y[i]));
        double z = (a+b+c) / 2.0;
        s += sqrt(z * (z-a) * (z-b) * (z-c));
    }

    printf("%.15lf\n", s);

    return 0;
}

Measured memory_bytes: 1256
import sys
sys.setrecursionlimit(10**8)
N = int(input())
graph = [[] for _ in range(N)]

for i in range(1, N):
    u, v, w = map(int, input().split())
    graph[u-1].append((v-1, w))
    graph[v-1].append((u-1, w))

color = [0 for _ in range(N)]
visited = [False for _ in range(N)]

def dfs(now):

    for adj in graph[now]:
        v, dist = adj
        if visited[v]:
            continue
        visited[v] = True
        color[v] = color[now] + dist
        dfs(v)

    return


for start in range(N):
    if not visited[start]:
        color[start] = 0
        visited[start] = True
        dfs(start)

for i in range(N):
    print(color[i] % 2)


Measured memory_bytes: 84512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num,init) vector<ll> name((num),(init));
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum,init); vector<vector<ll>> name((fnum),vector<ll>((snum),(init)));
#define debugP int debug_point; cin>>debug_point;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/

void dfs(ll d){

}


int main(){
    ll n,m;
    cin>>n>>m;
    if(n%3==0||m%3==0||(n+m)%3==0){
        opP;
    }else opI;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(ALL(A));
    int tmp = A[0];
    while (A[N - 2] != 0) {
        FOR(i, 1, N) {
            A[i] = A[i] % tmp;
            if (0 < A[i] && A[i] < tmp) tmp = A[i];
        }
        sort(ALL(A));
    }
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>


//using namespace std;

int main() {
	int i,j,n, a[100];
	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	int min = 5000000, temp = 0;
	for (j = -100; j <= 100; j++) {
		temp = 0;
		for (i = 0; i < n; i++) temp += (a[i] - j)*(a[i] - j);
		if (min > temp) min = temp;
	}
	printf("%d\n", min);
	return 0;
}

Measured memory_bytes: 128
h, w = gets.split.map(&:to_i)
ch, cw = gets.split.map(&:to_i)
dh, dw = gets.split.map(&:to_i)
s = h.times.map {gets.chomp + "##"} + ["#" * (w+4), "#" * (w+4)]

move = [[1,0], [0,1], [-1,0], [0,-1]]
warp_all = (-2..2).flat_map do |i|
    (-2..2).map {|j| i.abs + j.abs > 1 ? [i, j] : nil}
end.compact
warp = [[[2,-2], [2,-1], [2,0], [2,1], [2,2]], [[-2,2], [-1,2], [0,2], [1,2], [2,2]],
        [[-2,-2], [-2,-1], [-2,0], [-2,1], [-2,2]], [[-2,-2], [-1,-2], [0,-2], [1,-2], [2,-2]]]

v = ch <= dh ? (cw <= dw ? 0 : -1) : (cw <= dw ? 1 : 2)
move.rotate!(v)
warp.rotate!(v)
warp << warp_all

d = Array.new(h+2) {Array.new(w+2)}
que = [[ch-1, cw-1, 0, 4]]

while !d[dh-1][dw-1] && !que.empty?
    x,y,z,f = que.shift
    next if d[x][y]
    d[x][y] = z

    4.times do |k|
        i,j = move[k]
        next if d[x+i][y+j] || s[x+i][y+j] == ?#
        que.unshift([x+i, y+j, z, k])
    end

    warp[f].each do |i,j|
        que << [x+i, y+j, z+1, 4] if s[x+i][y+j] == ?. && !d[x+i][y+j]
    end
end

p d[dh-1][dw-1] ? d[dh-1][dw-1] : -1


Measured memory_bytes: 26696
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define endl '\n'
#define ll long long
#define inf 1000000007
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	ll dp[n];
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(ll i=2;i<n;i++)
	{
		ll m;
		m=i-k;
		if(m<0)
			m=0;
		dp[i]=(ll)pow(10,18);
		for(ll j=i-1;j>=m;j--)
		{
		dp[i]=min(abs(arr[i]-arr[j])+dp[j],dp[i]);
		}
	}
	cout<<dp[n-1]<<endl;

	return 0;
}


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

int input[1001];
int number,need;

	

int q_sort(int start, int end){ 
	if(end == start)
		return 0; 
	else{ 
		int p = start;
		for(int i = (start + 1); i < end + 1; i++){ 
			if(input[i] < input[p]){ 
				int temp = input[i]; 
				memmove(input + start + 1, input + start, (i - start)*sizeof(int));
				input[start] = temp;
				p++;
			}
		}
		
		if(start != p)
			q_sort(start,p-1);
			
		if(end != p)  
			q_sort(p+1,end); 
		
		return 0;
	}
}

int main(){
	scanf("%d %d",&number,&need);
	for(int i=0;i<number;i++)
	scanf("%d",&input[i]);
	q_sort(0,number-1);
	int ans=0;
	for(int i=0;i<need;i++)
	ans=ans+input[i];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N, A, B; 
	cin >> N >> A >> B; 
	long long int V[60] = {}; 
	for(int i = 0; i < N; i++){
		cin >> V[i]; 
	}
	sort(V, V+N, greater<long long int>()); 
	long long int sum = 0; 
	for(int i = 0; i < A; i++){
		sum += V[i];  
	}
  	cout.precision(20);
	cout << (double) sum / (double) A << endl; 
  
	long long int P[60][60] = {}; 
	P[0][0] = 1; 
	for(int i = 0; i <= 52; i++){
		P[i][0] = 1; 
		for(int j = 1; j <= i; j++){
			P[i][j] = P[i-1][j] + P[i-1][j-1]; 
		}
	}
	int X = 0, Y = 0; 
	for(int i = 0; i < N; i++){
		if(V[i] > V[A-1]){X ++;}
		else if(V[i] == V[A-1]){Y ++;}
    }
  if(V[0] != V[A-1]){
    cout << P[Y][A-X] << endl;  
  }
  else{
	long long int ans = 0; 
	for(int i = A-X; i <= min(B-X, Y); i++){
		ans += P[Y][i]; 
	}
  cout << ans << endl; 
  }
}

Measured memory_bytes: 256
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,x,y=nii()
x-=1
y-=1
ans=[0 for i in range(n)]

for i in range(n-1):
  for j in range(i+1,n):
    dist1=j-i
    dist2=abs(i-x)+1+abs(j-y)
    dist=min(dist1,dist2)
    ans[dist]+=1

for i in ans[1:]:
  print(i)

Measured memory_bytes: 9228
k,n  = map(int,input().split())
list_a = list(map(int,input().split()))
list_kankaku = []
x = 0
for i in range(n-1):
  list_kankaku.append(list_a[i+1]-list_a[i])
list_kankaku.append(k-list_a[-1]+list_a[0])
x = max(list_kankaku)
ans = k-x
print(ans)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
const int MOD = 1000000007;

int main() {
    int h, w, k;
    cin >> h >> w >> k;

    vector<vector<string>> c(h, vector<string>(w));
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            c.at(i).at(j) = s[j];
        }
    }

    // 白と黒の総数
    int black_sum = 0;
    int white_sum = 0;

    rep(i, h) {
        rep(j, w) {
            // 黒
            if (c.at(i).at(j) == "#")
                black_sum += 1;
        }
    }
    white_sum += h * w - black_sum;

    int ans = 0;

    // 行と列の選び方は2^6 * 2^6通りある
    for (int bit_i = 0; bit_i < (1 << h); bit_i++) {
        for (int bit_j = 0; bit_j < (1 << w); bit_j++) {
            // 黒の数
            int count = 0;

            // 全てのi行j列目の要素について考える
            rep(column, h) {
                rep(row, w) {
                    // 片方でもbitが立っているなら含めない
                    if (!(bit_i & (1 << column)) && !(bit_j & (1 << row))) {
                        // 黒なら追加
                        if (c.at(column).at(row) == "#") {
                            count++;
                        }
                    }
                }
            }

            // 黒の数がkと等しければok
            if (count == k) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3660
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i * 500 + j * 100 + k * 50 == X:
                cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;
int main(){
  int n;
  cin>>n;
  vector<int> ans(n+1);
   for(int x=1;x<=100;x++){
      for(int y=1;y<=100;y++){
        for(int z=1;z<=100;z++){
          int s = x*x+y*y+z*z+x*y+y*z+z*x;
          if(s>n)break;
          ans[s]++;
        }
      }
    }
  for(int i=1;i<=n;i++){
    cout<<ans[i]<<endl;
  }
  
  
  

}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N_MAX = 5010;
int N,K;
ll v[N_MAX];

//v[index]を使わずにk-v[index]<= Sum < kとなる挿話が作れるならfalse
bool isNoNeed(int index){
  //i枚目まで使った時にjにできるか
  //trueできる，falseできない
  bool dp[2][K];
  bool *prev, *next;
  prev = dp[0];
  next = dp[1];
  rep(j,K) prev[j] = false;
  prev[0] = true;
  rep(i,N){
    rep(j,K){
      next[j] = prev[j];
      if(i==index)continue;
      if(j-v[i]>=0 && prev[j-v[i]]){
        if(j>=K-v[index]) return false;
        next[j] = true;
      }
    }
    swap(prev,next);
  }
  return true;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int n;cin >> n >> K;
  N=0;
  rep(i,n){
    int x;cin >> x;
    if(x>=K)continue;
    else v[N++]=x;
  }
  sort(v,v+N);
  int l = 0, r=N;
  if(!isNoNeed(l)){
    cout << 0 << endl;
    return 0;
  }
  while(r-l>1){
    int m = (r+l)/2;
    bool isnoneed = isNoNeed(m);
    if(isnoneed) l = m;
    else r = m;
  }
  cout << r << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pii pair<int,int>
#define reset(x,n) memset((x),(n),sizeof(x))
#define all(n) (n).begin(),(n).end()
#define pb push_back
#define IOS ios::sync_with_stdio(0),cin.tie(0);
bitset<10010> ok[5005];
int stick[] = {0,2,5,5,4,5,6,3,7,6};
bool used[10];
int n,m;

int main(){
	ok[0][0] = 1;
	cin>>n>>m;
	for(int i=1,x;i<=m;i++){
		cin>>x;
		used[x] = 1;
	}
	for(int i=0;i<5000;i++){
		for(int j=2*i;j<=10000;j++){
			if(ok[i][j]){
				for(int k=1;k<=9;k++){
					if(used[k]){
						ok[i+1][j+stick[k]] = 1;
					}
				}
			}
		}
	}
	int now = n;
	string ans = "";
	int st = 5000;
	while(!ok[st][now]) st--;
	for(int i=st;i>=1;i--){
		for(int j=9;j>=1;j--){
			if(used[j] && now >= stick[j] && ok[i-1][now-stick[j]]){
				ans += j + '0';
				now -= stick[j];
				break;
			}
		}
	}
	cout<<ans<<'\n';	
}


Measured memory_bytes: 9732
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

ll sum(int n) {
  return 1LL * n * (n + 1) / 2;
}

int main() {
  string s;
  cin >> s;
  int lc = 0, rc = 0;
  ll ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '<') {
      if (rc > 0) {
        if (lc < rc) ans += sum(max(0,lc-1)) + sum(rc);
        else ans += sum(lc) + sum(rc-1);
        lc = rc = 0;
      }
      lc += 1;
    }
    else {
      rc += 1;
    }
  }
  if (lc < rc) ans += sum(max(0,lc-1)) + sum(rc);
  else ans += sum(lc) + sum(max(0,rc-1));
  cout << ans << endl;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
constexpr int MAXN = 1e5 + 5;

#define pii pair<int, int>
typedef long long LL;
typedef unsigned long long uLL;
constexpr LL M = 1e9 + 7;
using namespace std;
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while(isdigit(ch)) x = (x << 3) + (x << 1) + ch -48, ch = getchar();
    return x * f;
}
LL n, a, b, sum;
inline int qpow(LL a, LL b, LL res){ //a^b
    while(b){
        if(b & 1) res = res * a % M;
        a = a * a % M;
        b >>= 1;
    }
    return res;
}
inline int getC(LL x) {
	if (x > n) return 0;
	LL res1 = 1, res2 = 1;
	for (LL i = n; i >= n - x + 1; i--) res1 = res1 * i % M;
	for (LL i = x; i >= 1; i--) res2 = res2 * i % M;
	return res1 * qpow(res2, M - 2, 1) % M;
}
int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> a >> b;
	sum = qpow(2, n, 1) - 1;
	LL sum2 = (getC(a) + getC(b)) % M;
	cout << ((sum - sum2) % M + M) % M << endl;
	return 0;
}

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

int main()
{
  string s;
  cin >> s;
  int n = s.length();
  bool can = true;
  string temp1, temp2;
  temp1 = s;
  reverse(temp1.begin(), temp1.end());
  if(s != temp1)
	can = false;
  temp1 = s.substr(0, (n - 1)/2);
  temp2 = temp1;
  reverse(temp1.begin(), temp1.end());
  if(temp1 != temp2)
    can = false;
  temp1 = s.substr((n + 1) / 2, (n - 1) / 2);
  temp2 = temp1;
  reverse(temp1.begin(), temp1.end());
  if(temp1 != temp2)
    can = false;
  if(can)
    cout << "Yes\n";
  else
    cout << "No\n";
  
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
h = gets.split.map(&:to_i)
ans = true
h[0] -= 1
(1...n).each do |i|
    if h[i] > h[i-1]
        h[i] -= 1
    elsif h[i] < h[i-1]
        ans = false
        break
    end
end
puts (ans ? "Yes" : "No")

Measured memory_bytes: 10500
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<deque>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

const string base = "()[]";
set<char> st;

int solve(string s) {
	string a = "";
	for (char c : s) {
		if (st.count(c)) a.push_back(c);
	}

	stack<char> sta;

	for (char c : a) {
		if (c == '(' || c == '[') sta.push(c);
		else {
			if (sta.empty()) return 0;
			if (c == ')' && sta.top() != '(') return 0;
			if (c == ']' && sta.top() != '[') return 0;
			sta.pop();
		}
	}

	return sta.empty();
}


int main() {
	for (auto c : base) st.insert(c);
	string s;
	while (getline(cin,s), s != ".") {
		cout << (solve(s) ? "yes" : "no") << endl;
	}
}


Measured memory_bytes: 3144
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];

    ll mx_idx=0;
    rep(i,n){
        if(abs(a[i])>abs(a[mx_idx]))mx_idx=i;
    }

    cout<<2*(n-1)<<endl;
    rep(i,n){
        if(i==mx_idx)continue;
        cout<<mx_idx+1<<' '<<i+1<<endl;
    }

    if(a[mx_idx]>0){
        rep(i,n-1)cout<<i+1<<' '<<i+2<<endl;
    }else{
        rrep(i,n-1)cout<<i+2<<' '<<i+1<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	int a,b;
	string s;
	bool flag=true;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(flag&&s[i]=='A')
		{
			a=i;
			flag=false;
		}
		if(s[i]=='Z')b=i;
	}
	cout<<b-a+1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
	int n,m;
	cin >> n >> m;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >>  h.at(i);
	}

	vector<bool> c(n, 1);

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		if (h.at(a - 1) > h.at(b - 1)) {
			c.at(b - 1) = 0;
		}
		else if(h.at(a - 1) < h.at(b - 1)) {
			c.at(a - 1) = 0;
		}
		else {
			c.at(b - 1) = 0;
			c.at(a - 1) = 0;
		}

	}

	int d = 0;
	for (int i = 0;i < n; i++){
		if (c.at(i) == 1) d++;
	}

	cout << d << endl;

		
	

	


}

Measured memory_bytes: 3788
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>

using namespace std;

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

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const long double PI = 3.14159265358979323846;

// ****************************************CODE***************************************//


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

    cout << max(max(a+b, a-b), a*b) << endl;

    return 0;
}

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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var MOD = 1000000007L;

            var sum = A.Sum();
            sum %= MOD;
            var result = 0L;
            for (int i = 0; i < N - 1; i++)
            {
                sum -= A[i];
                if (sum < 0) sum += MOD;
                result += A[i] * sum;
                result %= MOD;
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 47100
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000



int main(){
	
	int N,K;
	cin>>N>>K;
	
	vector<long long> H(N+1,0);
	for(int i=1;i<=N;i++)cin>>H[i];
	
	vector<vector<vector<long long>>> dp(N+1,vector<vector<long long>> (K+1,vector<long long>(N+1,Inf)));
	
	dp[0][0][0] = 0;
	
	for(int i=1;i<=N;i++){
		for(int j=0;j<=K;j++){
			for(int k=0;k<i;k++){
				long long h = max(0LL,H[i]-H[k]);
				dp[i][j][i] = min(dp[i][j][i],dp[i-1][j][k] + h);
				if(j==0)continue;
				dp[i][j][k] = min(dp[i][j][k],dp[i-1][j-1][k]);
			}			
		}
	}
	
	long long ans = Inf;
	for(int i=0;i<=K;i++){
		for(int j=0;j<=N;j++){
			ans = min(ans,dp.back()[i][j]);
		}
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 216832
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int total = 0;
    int[] num = new int[9];
    for (int i = 0 ; i < 9 ; i++){
      num[i] = sc.nextInt();
      total += num[i];
    }
    int nextTotal1 = num[0] + num[1] + num[3] + num[4];
    int nextTotal2 = num[4] + num[5] + num[7] + num[8];
    int nextTotal3 = num[1] + num[2] + num[4] + num[5];
    int nextTotal4 = num[3] + num[4] + num[6] + num[7];
     int nextTotal5 = num[0] + num[2] + num[6] + num[8];
    if (total % 3 == 0 && nextTotal1 % 2 == 0 && nextTotal1 % 2 == 0 && nextTotal3 % 2 == 0 && nextTotal4 % 2 == 0 && nextTotal5 % 2 == 0) System.out.println("Yes");
    else System.out.println("No");
    sc.close();
  }
}


Measured memory_bytes: 22996
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    std::string S;
    std::cin >> S;

    std::string T;
    std::cin >> T;

    std::set<std::string> SS;

    for (size_t i = 0; i < S.size() - T.size() + 1; ++i) {
        bool cand = true;
        for (size_t j = i; j < i + T.size(); ++j) {
            auto si = j;
            auto ti = j - i;
            if (S[si] == '?' || (S[si] == T[ti])) {
                // ok
            }
            else {
                cand = false;
                break;
            }
        }
        if (cand) {
            std::string tmp = S;
            tmp.replace(i, T.size(), T);
            boost::algorithm::replace_all(tmp, "?", "a");
            SS.insert(tmp);
        }
    }

    if (SS.size() == 0) {
        std::cout << "UNRESTORABLE" << std::endl;
    }
    else {
        std::cout << *SS.begin() << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define MAX 2000

using namespace std;


long f(long k){
    return (k*(k+1))/2;
}


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

    long cnt = 0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            if(a[i] > a[j]){
                cnt += f(k);
            }
            if(a[i] < a[j]){
                cnt += f(k-1);
            }
            cnt%=(long)(pow(10,9)+7);
        }
    }
    cout << cnt << endl;
    return 0;
}

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

    typedef long long ll;
    typedef long double ld;
    ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
    ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
    #define endl '\n'
    #define max3(a,b,c) max(a,max(b,c))

    const int q = 1e9+9;




    int main()
    {
        int r,d,n;
        cin>>r>>d>>n;
        int prev=n;
        for(int i=0;i<10;i++){
            prev = r*prev-d;
            cout<<prev<<endl;
        }



        return 0;
    }
        // gotcha;


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n;
	if(scanf("%d",&n)==EOF){return 0;}
	int ftemp = n/3;
	double f =(double) ftemp;
	int btemp = n/5;
	double b =(double) btemp;
	int fbtemp = n/15;
	double fb =(double) fbtemp;
	
	double nd = (double)n;
	//printf("%lf %lf %lf", f,b,fb);
	
	double sum =(double) (1+nd)*nd/2;
	double fizz = f*(f+1)/2;
	double buzz = (b)*(b+1)/2;
	double fizzbuzz = (fb)*(fb+1)/2;
	sum = sum - 3*fizz - 5*buzz+15*fizzbuzz;


	printf("%.0lf\n",sum);
	return 0;
	
}


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

int main(void){
  int N,i;
  int count=0,yes=0;
  int D[101][2];

  scanf("%d", &N);

  for(i=0;i<N;i++){
    scanf("%d %d", &D[i][0],&D[i][1]);

    if(D[i][0]==D[i][1]){
      count++;
      if(count==3) yes++;
    }
    else count=0;

  }

  if(yes>=1) printf("Yes\n");
  else printf("No\n");

  return 0;

}


Measured memory_bytes: 1660
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    int n,x[100],y[100];
    double p1=0.0;
    double p2=0.0;
    double p3=0.0;
    double p4=0.0;
    cin >>n;
    
    for(int i = 0; i<n; i++) cin >>x[i];
    for(int i = 0; i<n; i++) cin >>y[i];
    p4 = fabs(x[0]-y[0]);
    
    for(int i = 0; i<n; i++){
        p1 += fabs(x[i]-y[i]);
        p2 += pow(fabs(x[i]-y[i]),2);
        p3 += pow(fabs(x[i]-y[i]),3);
        if(p4 < fabs(x[i]-y[i])){
            p4 = fabs(x[i]-y[i]);
        }
    }
    p2 = pow(p2,1.0/2);
    p3 = pow(p3,1.0/3);
    printf("%lf\n", p1);
    printf("%lf\n", p2);
    printf("%lf\n", p3);
    printf("%lf\n", p4);
    
    return 0;
}


Measured memory_bytes: 3340
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	const int n = 100, m = 25;
	int a, b;
	cin >> a >> b;
	bool swap_flag = (a < b);
	if(swap_flag){ swap(a, b); }
	vector<string> grid(n, string(n, '.'));
	for(int i = 0; i < n; i += 4){
		for(int j = 0; j < n; ++j){ grid[i][j] = '#'; }
		for(int j = 0; j < n; ++j){ grid[j][i] = '#'; }
	}
	--b;
	for(int i = a; i < m * m; ++i){
		const int r = (i / m) * 4, c = (i % m) * 4;
		for(int y = 1; y < 4; ++y){
			for(int x = 1; x < 4; ++x){ grid[r + y][c + x] = '#'; }
		}
	}
	for(int i = 0; i < b; ++i){
		const int r = (i / m) * 4, c = (i % m) * 4;
		grid[r + 2][c + 2] = '#';
	}
	if(swap_flag){
		for(auto& s : grid){
			for(auto& c : s){
				if(c == '.'){
					c = '#';
				}else{
					c = '.';
				}
			}
		}
	}
	cout << n << " " << n << endl;
	for(const auto& s : grid){
		cout << s << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

void swap(int *a, int *b) {
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int n, sum = 0;
	int l[200];

	scanf("%d", &n);
	for (int i = 0; i < 2 * n; i++) {
		scanf("%d", &l[i]);
	}

	for (int i = 0; i < 2 * n; i++) {
		for (int j = 2 * n - 1; j > i; j--) {
			if (l[i] > l[j]) swap(&l[i], &l[j]);
		}
	}

	for (int i = 0; i < 2 * n; i += 2) {
		sum += l[i];
	}

	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 128
head, leg = [int(idx) for idx in input().split()]
crane = 2
turtle = 4
for idx in range(0,head+1):
  ans1 = 0
  ans2 = 0
  ans1 = crane*idx
  ans2 = turtle*(head-idx)
  if ans1 + ans2 == leg:
    print('Yes')
    break
  elif idx == head:
    print('No')

Measured memory_bytes: 9180
import bisect as bi
a, b, q = map(int, input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
u = [int(input()) for i in range(q)]

for x in u:
    c = []
    d = []
    tmp = bi.bisect_left(s, x)
    if tmp != a : c.append(s[tmp])
    if tmp != 0 : c.append(s[tmp-1])
    tmp = bi.bisect_left(t, x)
    if tmp != b : d.append(t[tmp])
    if tmp != 0 : d.append(t[tmp-1])
    ans = 2**64
    for e in c:
        for f in d:
            g = abs(x-e)
            h = abs(x-f)
            if (x-e)*(x-f) > 0:
                ans = min(ans, max(g, h))
            else:
                if g > h : g,h = h,g
                ans = min(ans, 2*g+h)
    print(ans)


Measured memory_bytes: 16244
def main():
    N, Y = map(int, input().split())

    for i in range(0, N+1):
        for j in range(0, N+1):
            if N-i-j < 0:
                continue
            if i * 10000 + j * 5000 + (N-i-j) * 1000 == Y:
                print(i, j, (N-i-j))
                return 
    print(-1, -1, -1)

main()

Measured memory_bytes: 3060
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N, M = map(int, input().split())
ans = 0
if N >= 2:
    ans += comb(N, 2)
if M >= 2:
    ans += comb(M, 2)
print(ans)

Measured memory_bytes: 3060