akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int MAX = 393;

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

	vector<int> S(n), L(n), P(n);//, SUB(n);
	for (int i=0; i<n; i++) {
		cin >> S[i] >> L[i] >> P[i];
		//SUB[i] = L[i]-S[i];
	}

	int m;
	cin >> m;

	vector<int> W(m);
	for (int i=0; i<m; i++)
		cin >> W[i];

	int **dp = new int*[MAX+10];
	for (int i=0; i<MAX+10; i++) {
		dp[i] = new int[3*MAX];
		for (int j=0; j<3*MAX; j++)
			dp[i][j] = 0;
	}

	dp[0][0] = 0;
	for (int j=S[0]; j<=L[0]; j++)
		dp[0][j] = P[0];
	
	for (int i=1; i<n; i++) {
		for (int j=0; j<=MAX; j++) {
			dp[i][j] = dp[i-1][j];
			if (j>=S[i])
				for (int k=S[i]; k<=L[i]; k++)
					if (j-k>=0) dp[i][j] = max(dp[i][j], dp[i][j-k]+P[i]);
		}
	}

	vector<int> point(m);
	bool flag = false;
	for (int i=0; i<m; i++) {
		point[i] = dp[n-1][W[i]];
		if (point[i]==0) {
			flag = true;
			break;
		}
	}
	
	if (flag) cout << -1 << endl;
	else {
		for (int i=0; i<m; i++)
			cout << point[i] << endl;
	}

	for (int i=0; i<MAX+10; i++)
		delete [] dp[i];
	delete [] dp;

	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
int n, g;
ll a[N];
ll dp[N][2] ;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    memset(dp, 0xcf, sizeof(dp)) ;
    dp[n - 1][0] = a[n] + a[n - 1];
    dp[n - 1][1] = -dp[n - 1][0] ;
    for(int i = n - 2; i > 0; i--) {
        dp[i][0] = max(dp[i + 1][0], dp[i + 1][1]) + a[i];
        dp[i][1] = max(dp[i + 1][1] + 2 * a[i + 1] - a[i], dp[i + 1][0] - 2 * a[i + 1] - a[i]);
        //cout << dp[i][0] << ' ' << dp[i][1] << '\n';
    }
    cout << max(dp[1][0], dp[1][1]) ;
    return 0;
}


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

#define f(x, y, z) for (int x = (y), __ = (z); x < __; ++x)
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int INF = 1 << 27;
const ll LLINF = (ll)1 << 60;
const ll MOD = 1e9 + 7;

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

int main() {
  int N;
  scanf("%d", &N);
  vector<vector<int>> a(N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      int v;
      scanf("%d", &v);
      if (v == 1) a[i].push_back(j);
    }
  }

  int size = 1 << N;
  vector<int> dp(size);
  dp[size - 1] = 1;
  for (int i = size - 2; i >= 0; i--) {
    int x = 0;
    int tmp = i;
    while (tmp) {
      x++;
      tmp &= (tmp - 1);
    }

    int state = i;
    int ans = 0;
    for (int j : a[x]) {
      if ((state & (1 << j)) == 0) {
        ans = (ans + dp[state | (1 << j)]) % MOD;
      }
    }
    dp[state] = ans;
  }

  printf("%d\n", dp[0]);
}


Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;
long long INF = 1LL << 60;
int main() {
	long long N;
	cin >> N;
	int root_N = sqrt(N);
	long long ans = INF;
	for (long long i = 1; i <= root_N; i++) {
		long long j = N / i;
		if (N % i == 0) ans = min(ans, i + j - 2);
	}
	if (ans == INF) ans = N - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

S, W = mi()

if W >= S:
    print('unsafe')
else:
    print('safe')

Measured memory_bytes: 9184
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
int main(){
  double a,b,x;
  cin>>a>>b>>x;
  if(x<(a*a*b)/2){
    double t=a*b*b/(2*x);
    double ans=atan(t);
//    cout<<"I"<<endl;
    printf("%.10f\n",ans*180/M_PI);
  }
  else{
    double t=(b-(x/(a*a)))*2;
    //cout<<t<<endl;
    double ans=atan(t/a);
    //cout<<"J"<<endl;
    printf("%.10f\n",ans*180/M_PI);
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
     
    while(true){
        int n,m,a;
        int h,p,q;
        int amida[101][1001]={{0}};

        cin >> n >> m >> a;
        if(n==0&&m==0&&a==0){
                break;
        }
         
        for(int i=0;i<m;i++){
            cin >> h >> p >> q;
            amida[p][h]=1;
        }
         
        for(int j=1000;j>0;j--){
            if(amida[a][j]==1) a++; //????????????
            else if(amida[a-1][j]==1) a--; //???
        }
         
        cout << a << endl;
    }
     
    return 0;
}

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

int main()
{
 int n, i, j, a;
  cin>>n;
  vector<int> v(n+1);
  for(i=0; i<n; i++){
    cin>>a;
    v[a] = i+1;
  }
  for(i=1; i<=n; i++) cout<<v[i]<<" "; cout<<endl;
}

Measured memory_bytes: 1152
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# pragma GCC target("avx2")
# pragma GCC optimize("O3")
# pragma GCC optimize("unroll-loops")
# define int long long

using namespace std;

const int N = 2e3 + 7;
const int mod = 1e9 + 7;

int used[N][N], n, m;
int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };
string s[N];

bool can( int x, int y ) {
    return x > 0 && x <= n && y > 0 && y <= m && s[x][y] == '.';
}

int32_t main() {
    speed;
    cin >> n >> m;
    int sx, sy;
    int ex, ey;
    cin >> sx >> sy;
    cin >> ex >> ey;
    for ( int i = 1; i <= n; i++ ) {
        cin >> s[i];
        s[i] = '#' + s[i];
    }
    deque < pair < pair < int, int >, int > > q;
    q.push_back( { { sx, sy }, 0 } );
    while ( !q.empty() ) {
        int x = q.front().first.first, y = q.front().first.second;
        int cnt = q.front().second;
        q.pop_front();
        if ( used[x][y] ) {
            continue;
        }
        if ( x == ex && y == ey ) {
            cout << cnt;
            return 0;
        }
        used[x][y] = 1;
        for ( int i = 0; i < 4; i++ ) {
            int xx = dx[i] + x, yy = dy[i] + y;
            if ( can( xx, yy ) ) {
                q.push_front( { { xx, yy }, cnt } );
            }
        }
        for ( int k1 = -2; k1 <= 2; k1++ ) {
            for ( int k = -2; k <= 2; k++ ) {
                if ( can( x + k1, y + k ) ) {
                    q.push_back( {{ x + k1, y + k }, cnt + 1} );
                }
            }
        }
    }
    cout << -1;
}


Measured memory_bytes: 18460
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int n,k,x,y;
  cin >> n >> k >> x >> y;

  if (n > k) {
    pr(k*x + (n-k)*y);
  } else {
    pr(n*x);
  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 long long  n,d;
 cin>>n>>d;
 int res=0;
 while(n--)
 {
     long long  x,y;
     cin>>x>>y;
     if(x*x + y*y <= d*d) res++;
 }
 cout<<res<<endl;
 return 0;   
}


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

using namespace std;
int main(){
	int n;
	cin >> n;
	long long int ans = 0;
	long frontHeight = 0;
	while(n--)
	{
		long height;
		cin>>height;
		ans+= max(0L,frontHeight-height);
		frontHeight = max(frontHeight,height);
	}
	cout << ans;
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  int N,x;
  cin>>N>>x;
  int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  long long sum=0;
  if(a[0]+a[1]>x){
    if(x>=a[0]){
      sum+=a[1]-(x-a[0]);
      a[1]-=a[1]-x+a[0];
    }else{
      sum+=a[1]+a[0]-x;
      a[1]=0;

    }

      
    }
  for(int i=1;i<N-1;i++){
    if(a[i]+a[i+1]>x){
    if(x>=a[i]){
      sum+=a[i+1]-(x-a[i]);
      a[i+1]-=a[i+1]-x+a[i];
    }else{
      sum+=a[i+1]+a[i]-x;
      a[i+1]=0;

    }}

  }
  cout<<sum<<endl;
  
  



}



Measured memory_bytes: 640
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Predicate;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		String a = scan.next();
		String b = scan.next();
		String c = scan.next();

		System.out.println("A" + b.charAt(0) + "C");

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 26956
#include<stdio.h>
int main()
{
    int k,a[5],i;
    for(i=0;i<5;i++)
        scanf("%d",&a[i]);
    scanf("%d",&k);
    if(a[4]-a[0]<=k)
        printf("Yay!\n");
    else
        printf(":(\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, k; cin >> n >> k;
    int ans = k;
    FOR(i, 0, n - 1)ans *= k - 1;
    cout << ans << "\n";
}

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

int main() {
  string s;
  cin>>s;
  bool test=true;
  if(s[0]!='A'){
    test=false;
  }
  int count=0;
  for(int i=1;i<s.size();i++){
    if(isupper(s[i])){
      count++;
      if(i==1||i==s.size()-1||s[i]!='C'){
        test=false;
      }
    }
  }
  if(count!=1){
    test=false;
  }
  if(test){
    cout<<"AC"<< endl;
  }
  else{
    cout<<"WA"<< endl;
  }
}
    


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

int main() {
    std::vector<std::string> data, result;
    int h, w, counter;

    std::cin >> h >> w;
    data.resize(h);
    result.resize(h);

    for (int i{0}; i < h; i++)
        std::cin >> data.at(i);
    
/*
    std::cout << "H: " << h << "\n";
    std::cout << "W: " << w << "\n";

    for (const auto &d : data)
        std::cout << "data : " << d << "\n";
*/

    for (int i{0}; i < h; i++) {
        for (int j{0}; j < w; j++) {
            if (data.at(i).at(j) == '#') {
                result.at(i) += '#';
            } else {
                int counter{0};
                if (j > 0) {
                    if (data.at(i).at(j - 1) == '#')
                        counter++;
                }
                if (j < w - 1) {
                    if (data.at(i).at(j + 1) == '#')
                        counter++;
                }

                if (i > 0) {
                    if (data.at(i - 1).at(j) == '#')
                        counter++;

                    if (j > 0) {
                        if (data.at(i - 1).at(j - 1) == '#')
                            counter++;
                    }
                    if (j < w - 1) {
                        if (data.at(i - 1).at(j + 1) == '#')
                            counter++;
                    }
                }
                if (i < h - 1){
                    if (data.at(i + 1).at(j) == '#')
                        counter++;

                    if (j > 0) {
                        if (data.at(i + 1).at(j - 1) == '#')
                            counter++;
                    }
                    if (j < w - 1) {
                        if (data.at(i + 1).at(j + 1) == '#')
                            counter++;
                    }
                }
                result.at(i) += std::to_string(counter);
            }
        }
        std::cout << result.at(i) << "\n";
    }
}


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

signed main(){
	int a,b;
	string op;
	cin>> a >> op >> b;
	if(op == "+")
		cout << a + b << endl;
	else
		cout << a - b << endl;
}


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

int main() {
    int n;
    cin >> n;
    if (n == 1) cout << "Hello World" << endl;
    else {
        int a, b;
        cin >> a >> b;
        cout <<  a + b << endl;
    }
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    string S;
    cin >> S;
    if (S[1] == 'A') {
        if (S[0] == 'B' or S[2] == 'B') {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        if (S[0] == 'A' or S[2] == 'A') {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
long long gcd(long long a, long long b) { return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b) { return a/gcd(a,b)*b;}

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

const int INF = 1001001001;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v;
  int tmp;
  int dp[n + k + 5];

  rep (i, n) {
    cin >> tmp;
    v.push_back(tmp);
  }

  rep (i, n + k + 5) {
    dp[i] = INF;
  }

  dp[0] = 0;
  rep (i, n) {
    for (int j = 1; j <= k; j++) {
      int ni = i + j;
      dp[ni] = min(dp[ni], dp[i] + abs(v[i] - v[ni]));
    }
  }

  // rep (i, n) {
  //   cout << dp[i] << endl;
  // }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 1144
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll collatz(ll x)
{
  if (x % 2 == 0)
  {
    return x / 2;
  }
  else
  {
    return 3 * x + 1;
  }
}

int main()
{
  char s[200001];
  scanf("%s", s);
  ll ans = 0;
  int j = 0, flag = 0;
  for (int i = 0; i < strlen(s) + 1; i++)
  {
    if (s[i] == 'W')
    {
      for (; j < i; j++)
      {
        if (s[j] == 'B')
        {
          flag++;
        }
      }
      ans += flag;
      j = i + 1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 384
N = gets.to_i
SS = readlines.map(&:to_i)

total = SS.inject(:+)
if total % 10 == 0
  ss = SS.reject { |s| s % 10 == 0 }
  if ss.empty?
    p 0
  else
    p(total - ss.min.to_i)
  end
else
  p total
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>K;
    vec x(N);
    rep(i,N) cin>>x[i];
    ll cen = lower_bound(x.begin(),x.end(),0LL) - x.begin();
    if(cen == N){
        cout<<-x[N - K]<<endl;
        return 0;
    }
    ll ans = 1e+9;
    rep(i,K+1){ //つける負の座標のろうそくの本数
        if(cen - i < 0 || cen + K - i - 1 >= N) continue;
        ll left = x.at(cen - i), right = x.at(cen + K - i - 1);
        ll temp;
        if(i == 0 || i == K){
            temp = max(abs(left),right);
        }else{
            temp = right - left + min(abs(left),right);
        }
        ans = min(ans,temp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
// In the name of ALLAH


#include <bits/stdc++.h>

using namespace std;

template<typename T>
ostream &operator<<(ostream &stream, vector<T> &x) {
    for (auto &curr : x)
        stream << curr << ' ';
    return stream;
}
template<typename T>
istream &operator>>(istream &stream, vector<T> &x) {
    for (auto &curr : x) {
        stream >> curr;
    }
    return stream;
}

template<typename T>
ostream &operator<<(ostream &stream, set<T> &x) {
    for (auto &curr : x)
        stream << curr << ' ';
    return stream;
}

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

    int n;cin >> n;
    string s;cin >> s;
    int cnt = 0;
    for(int i=0,j;i < n; i = j) {
        j = i + 1;
        while (j < n && s[i] == s[j]) ++j;
        ++cnt;
    }
    cout << cnt;
    return 0;
}


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

ll fastpower (ll b , ll p){
    ll k= p%2 ? b : 1 ;
    return p==0 ? 1 : k*(fastpower(b*b,p/2));
}

//int v1[105],v2[105];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
	//cin>>t;
	while(t--){
		ll n,d,ans=0;
		cin>>n>>d;
		double x,y;
		for(int i=0;i<n;i++){
			cin>>x>>y;
			double d1=sqrt((x*x)+(y*y));
			if(d1<=(double)d){
				ans++;
				//cout<<d1<<"\n";
			}
		}
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
ll exgcd(ll a, ll b, ll & x, ll & y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;	
	}
	ll d = exgcd(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
ll pow(ll a, ll b, ll MOD) {
	ll ans = 1;
	a%=MOD;
	while(b){
		if(b&1) ans=(ll)ans*a%MOD;
		a=(ll)a*a%MOD;
		b>>=1;
	}
	return ans;
}
ll inv(ll a,ll MOD)
{
ll x,y;
exgcd(a,MOD,x,y);
x=(x%MOD+MOD)%MOD;
return x;
}
ll inv2(ll a,ll MOD)
{
ll x=pow(a,MOD-2,MOD);
return x;
}
ll C(ll n,ll m,ll p)
{
if(m>n) return 0;
ll a=1,b=1;
//组合数 C(n,m)=[n*(n-1)*...*(n-m+1)]/[m*(m-1)*...*1]
while(m){
a=a*n%p;
b=b*m%p;
n--;
m--;
}
return (ll)a*inv(b,p)%p;
}
ll lucas(ll n,ll m,ll p)
{
//递归结束条件 n>=m
if(m==0) return 1;
return (ll)C(n%p,m%p,p)*lucas(n/p,m/p,p)%p;
}
ll fac[200010];
void init(ll p) {
	fac[0] = 1;
	for (int i = 1; i <= p; i++) fac[i] = fac[i - 1] * i % mod;
}
ll lucas2(ll n, ll m) {
	ll ret = 1, a, b;
	while (n && m) {
		a = n % mod, b = m % mod;
		if (a < b) return 0;
		ret = ret * fac[a] % mod * inv(fac[b] * fac[a - b] % mod, mod) % mod;
		n /= mod, m /= mod;
	}
	return ret;
}
int main()
{
	ll x, y, n, m;
	
	scanf("%lld%lld%lld%lld", &n, &m, &x, &y);
	ll ans = 0;
	init(200005);
	ll z = y, p = n + m - 2;
	for (ll i = 0; i <= n - x - 1; i++) {
		ans = ans + lucas2(z + i - 1, i) * lucas2(p - z - i, n - 1 - i) % mod;
		ans %= mod;
		//printf("1  %lld  %lld\n", i, ans);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1792
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define forsaken
#ifdef forsaken
  #define dbg(args...) do {cout << #args << " : "; err(args);} while (0)
#else
  #define dbg(...)
#endif
void err() {std::cout << std::endl;}
template<typename T, typename...Args>
void err(T a, Args...args){std::cout << a << ' '; err(args...);}
#define IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const int max_n=100005;
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
	inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
char s[max_n];
int n;
int cnt[30];
int main()
{
    scanf("%d",&n);
    scanf(" %s",s+1);
    for(int i=1;i<=n;i++)cnt[s[i]-'a']++;
    int res=1;
    for(int i=0;i<26;i++)res=Mul(res,cnt[i]+1);
    res=Sub(res,1);
    printf("%d\n",res);
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
typedef unsigned long long int uli;
using namespace std;
int main() {
	int i,j;
	int n,nam=0;
	cin >> n;
	for(i = 0; i < n; ++i) {
		int a;
		cin >> a;
		if(a != i + 1)
			++nam;
	}
	if(nam < 3)
		cout << "YES" << endl;
	else 
        cout << "NO" << endl;
}

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

const int maxn = 2e5+5;
const int inf = 0x3f3f3f3f;
typedef long long ll;
int a[maxn],b[maxn];
int n,m;
int dp[maxn][2];
string str;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>str;
	int len = str.length();
	// 假设只有分成长度为1和长度为2的
	dp[0][0] = dp[0][1] = 1;
	if(str[1] == str[0]){
		dp[1][0] = -inf;
	}
	else{
		dp[1][0] = 2;
	}
	dp[1][1] = 2;
	for(int i=2; i<len; i++){
		if(str[i] != str[i-1]){
			dp[i][0] = max(dp[i-1][0],dp[i-2][1]) +1;
		}
		else{
			dp[i][0] = dp[i-2][1]+1;
		}
		if(str[i]==str[i-2] && str[i+1]==str[i-1]){
			dp[i][1] = dp[i-1][0]+1;
		}
		else{
			dp[i][1] = max(dp[i-1][0], dp[i-2][1])+1;
		}
	}
	cout<<max(dp[len-1][0], dp[len-2][1])<<endl;
}

Measured memory_bytes: 2196
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	char s[25];
	while(~scanf("%s",s + 1)){
		s[6] = s[14] = ' ';
		puts(s + 1);
	}
    return 0;
}

Measured memory_bytes: 128
import bisect
from collections import defaultdict

def main():

    q = int(input())
    d = defaultdict(list)

    inserted_flag = False
    sorted_keys = None

    for _ in range(q):
        para = input().split()

        if para[0] == "0":
            d[para[1]].append(int(para[2])) 
            inserted_flag = True

        elif para[0] == "1":
            if para[1] in d.keys():
                for i in range(len(d[para[1]])):
                        print(d[para[1]][i])
                        
        elif para[0] == "2":
            if para[1] in d.keys():
                del d[para[1]]
                inserted_flag = True
            
        elif para[0] == "3":
            if sorted_keys is None:
                sorted_keys = sorted(d.keys())

            if inserted_flag:
                sorted_keys = sorted(d.keys())
                inserted_flag = False

            l = bisect.bisect_left(sorted_keys, para[1])
            r = bisect.bisect_right(sorted_keys, para[2])

            for i in range(l, r):
                for j in range(len(d[sorted_keys[i]])):
                    print("{} {}".format(sorted_keys[i], d[sorted_keys[i]][j]))

main()


Measured memory_bytes: 40072
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto o = readln.chomp;
  auto e = readln.chomp;
  foreach (i; 0..(o.length + e.length)) {
    if (i % 2) {
      write(e[i/2]);
    } else {
      write(o[i/2]);
    }
  }
  writeln("");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
  public static void main(String[] args)
   {
     Scanner sc = new Scanner(System.in);
     int a = sc.nextInt();
     int b = sc.nextInt();
     int area = a*b;
     int length = (a+b)*2;
     System.out.println(area+" "+length);
     sc.close();
   }
}


Measured memory_bytes: 26396
#include <bits/stdc++.h>
using namespace std;
#define int       long long int
#define vi        vector<int>
#define vii       vector<pii>
#define pii       pair<int, int>
#define mii       map<int, int>
#define pb        push_back
#define rev(v)    reverse(v.begin(), v.end())
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define endl      '\n'
#define F         first
#define S         second
#define PI        3.14159265359
#define MAXN      100007

const int mod = 1e9 + 7;

int dp[100001][2], arr[101];
int n;

int solve(int k, int turn)
{
	if (k < 0)
		return 1;
	if (dp[k][turn] != -1)
		return dp[k][turn];

	dp[k][turn] = 0;
	for (int i = 0; i < n; ++i)
	{
		dp[k][turn] = dp[k][turn] | !solve(k - arr[i], !turn);
	}
	return dp[k][turn];
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	memset(dp, -1, sizeof dp);
	int k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
	}

	if (solve(k, 0))
		cout << "First\n";
	else
		cout << "Second\n";
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    ll X;
    cin >> X;

    ll N = 100;
    int ans = 0;
    while (N < X) N *= 1.01, ans++;

    cout << ans << endl;
}

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

using namespace std;
int main(){
	int A,B,T;
	cin>>A>>B>>T;
	int ans=0;
	for(int i=A;i<=T+0.5;i+=A){
		ans+=B;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() 
{
	int a, b, h, m;
	scanf("%d%d%d%d", &a, &b, &h, &m);
	long double ang_h = (h + (long double)m / 60) / 12;
	long double ang_m = (long double)m / 60;
	long double ang = abs(ang_h - ang_m) * 2 * acos((long double)-1);
	long double ans = sqrt(a * a + b * b - 2 * a * b * cos(ang));
	printf("%.20f\n", (double)ans);
	return 0;
}


Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

i64 N;
void rec(i64 i, string& s, char c) {
  if(i == N) {
    cout << s << endl;
    return;
  }
  for(char ne = 'a'; ne <= c; ne++) {
    s.push_back(ne);
    if(c == ne) {
      rec(i + 1, s, c + 1);
    }
    else {
      rec(i + 1, s, c);
    }
    s.pop_back();
  }
}

int main() {
  cin >> N;
  string s = "";
  rec(0, s, 'a');
}


Measured memory_bytes: 1536
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: i32 = sc.read();
    let ans = match n % 10 {
        2 | 4 | 5 | 7 | 9 => "hon",
        0 | 1 | 6 | 8 => "pon",
        3 => "bon",
        _ => "none",
    };
    println!("{}", ans);
}

Measured memory_bytes: 2132
from collections import deque 
num, K = map(int, input().split())
monster = list(map(int, input().split()))
monster.sort(reverse=True)
ans = deque(monster)
for i in range(K):
  if len(ans)==0:
    print(0)
    exit()
  ans.popleft()
  
print(sum(ans))


Measured memory_bytes: 27660
#include<bits/stdc++.h>
#define inf 0x3fffffff
#define LL long long  

using namespace std;
  
inline char nc(){
    /* 
  static char buf[100000],*p1=buf,*p2=buf;
  if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
  return *p1++;
    */return getchar();
}
  
inline void read(int &x){
  char c=nc();int b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
  
inline void read(LL &x){
  char c=nc();LL b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
 
inline void read(char &x){
  for (x=nc();!(x=='('||x==')');x=nc());
}

inline int read(char *s)
{
    char c=nc();int len=1;
    for(;!(c>='a'&&c<='z');c=nc()) if (c==EOF) return 0;
    for(;(c>='a'&&c<='z');s[len++]=c,c=nc());
    s[len++]='\0';
    return len-2;
}
int wt,ss[19];
inline void print(int x){
    if (x<0) x=-x,putchar('-'); 
    if (!x) putchar(48); else {
    for (wt=0;x;ss[++wt]=x%10,x/=10);
    for (;wt;putchar(ss[wt]+48),wt--);}
}
inline void print(LL x){
    if (x<0) x=-x,putchar('-');
    if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}
}

int n,a[200010],b[200010];
struct data
{
    int x,id;
    data(int a=0,int b=0):x(a),id(b){}
};
struct cmp
{
    bool operator()(data x,data y)
    {
        return x.x<y.x;
    }
};

int calc(int x)
{
    if (x==0) return n;
    if (x==n+1) return 1;
    return x;
}

int main()
{
    read(n);
    priority_queue<data,vector<data>,cmp> q;
    for (int i=1;i<=n;i++)
        read(a[i]);
    for (int i=1;i<=n;i++)
        read(b[i]),q.push(data(b[i]-a[i],i));
    LL ans=0;int flag=0;
    while(!q.empty())
    {
        data x=q.top();q.pop();
        if (x.x<0) {flag=1;break;}
        if (x.x==0) continue;
        int y=(b[x.id]-a[x.id])/(b[calc(x.id-1)]+b[calc(x.id+1)]);
        if (y==0)  {flag=1;break;}
        ans+=(LL)y;
        b[x.id]-=(b[calc(x.id-1)]+b[calc(x.id+1)])*y;
        q.push(data(b[x.id]-a[x.id],x.id));
    }
    if (flag) puts("-1");
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3700
#include <iostream>

using namespace std;

int main()
{
    char c ;
    cin>>c;
    if( c=='A')
    {
        cout<<'T';
    }
    if(c=='T')
    {
        cout<<'A';
    }
    if(c=='G')
       {
           cout<<'C';
       }
       if (c=='C')
        cout<<'G';

    return 0;

}


Measured memory_bytes: 3588
#![allow(non_snake_case, unused)]
use std::collections::*;

////////// missing functions in 1.15.1 //////////
macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}
/////////////////////////////////////////////////
pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

#[macro_export]
macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

fn run() {
	let N = read!(usize);
	let a = read!([i64]);
	let mut dp = mat![0; N + 1; N + 1];
	for j in 1..N+1 {
		for i in (0..j).rev() {
			dp[i][j] = std::cmp::max(a[i] - dp[i + 1][j], a[j - 1] - dp[i][j - 1]);
		}
	}
	println!("{}", dp[0][N]);
}


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

#define int long long
typedef pair<int, int> P;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*
ifstream ifs("in.txt");
ofstream ofs("out.txt");
#define cin ifs
#define cout ofs
//*/

string S;
signed main() {
    cin >> S;
    int ans = 700;
    for (int i = 0; i < 3; i++) {
        if (S[i] == 'o') ans += 100;
    }
    cout << ans << endl;
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int a[N];
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    double res =(double)a[0];
    for(int i=1;i<n;i++){
        res=((double)res+(double)a[i])/2.0;
    }
    printf("%.5lf",res);
    
    return 0;
}

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

int main(){
  int r, g, b;
  cin >> r >> g >> b;
  if((r * 100 + g * 10 + b) % 4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<cctype>
using namespace std;
#define fr first
#define sc second
typedef pair<int,int> Pt;
typedef pair<Pt ,int> P;
Pt ST,GL;
int h,w,c,used[20][20][1 << 10],d[]={0,1,0,-1};
char mas[20][20];
int bfs();
int main(){
  while(cin >> w >> h && w){
    c = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> mas[i][j];
        if(mas[i][j] == 'o') ST = Pt(i,j);
        else if(mas[i][j] == '*') mas[i][j] = c++;
      }
    }
    cout << bfs() << endl;
  }
}
int bfs(){
  memset(used,-1,sizeof(used));
  queue<P> que;
  que.push(P(ST,0));
  used[ST.fr][ST.sc][0] = 0;
  while(!que.empty()){
    P p = que.front();
    que.pop();
    if(p.sc==(1<<c)-1) return used[p.fr.fr][p.fr.sc][p.sc];
    int log = used[p.fr.fr][p.fr.sc][p.sc];
    for(int i=0;i<4;i++){
      int nx = d[i] + p.fr.fr,ny = d[3-i] + p.fr.sc;
      int bits = p.sc;
      if(nx>=0&&nx<h&&ny>=0&&ny<w){
        if(mas[nx][ny] == 'x') continue;
        if(mas[nx][ny] >= 0 && mas[nx][ny] < 10){
          bits |= 1<<mas[nx][ny] ;
        }
        if(used[nx][ny][bits] != -1) continue;
        que.push(P(Pt(nx,ny),bits));
        used[nx][ny][bits] = log + 1;
      }
    }
  }
  return -1;
}

Measured memory_bytes: 2916
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n,k; cin >> n >> k;
    mcf_graph<int,ll> g(2*n+2);
    int S = 2*n, T = 2*n+1;
    rep(i,n) g.add_edge(S, i, k, 0);
    rep(i,n) g.add_edge(i+n, T, k, 0);
    g.add_edge(S, T, inf, inf);
    rep(i,n) rep(j,n){
        ll a; cin >> a;
        g.add_edge(i, j+n, 1, inf-a);
    }
    auto res = g.flow(S,T,n*k);
    ll ans = n * k * inf - res.second;
    cout << ans << "\n";
    auto edge = g.edges();
    vs t(n,string(n,'.'));
    for(auto e : edge){
        if(e.from == S || e.to == T || e.flow == 0) continue;
        t[e.from][e.to-n] = 'X';
    }
    rep(i,n) cout << t[i] << "\n";
}

Measured memory_bytes: 3928
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>

#define INF 10e10
#define REP(i,n) for(int i=0; i<n; i++)
#define REP_R(i,n,m) for(int i=m; i<n; i++)
#define MAX 100

using namespace std;

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

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]) {

  bool all_visited = true;

  for (int i = 0; i < N; i++) {
    if (visited[i] == false) all_visited = false;
  }

  if (all_visited) {
    return 1;
  }

  int ret = 0;

  for (int i = 0; i < N; ++i) {
    if (graph[v][i] == false) continue;
    if (visited[i]) continue;

    visited[i] = true;
    ret += dfs(i, N, visited);
    visited[i] = false;
  }

  return ret;
}

int main() {
  int N,M;
  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    int A,B;
    cin >> A >> B;
    graph[A-1][B-1] = graph[B-1][A-1] = true;
  }

  bool visited[nmax];
  for (int i = 0; i < N; i++) {
    visited[i] = false;
  }

  visited[0] = true;
  cout << dfs(0, N, visited) << endl;
  return 0;
}


Measured memory_bytes: 256