akhauriyash/Code-Regression huggingface dataset:
var n,i,max1,max2:longint;
    a:array[1..200000] of longint;
begin
	readln(n);
	max1:=0; max2:=0;
	for i:=1 to n do 
	  begin
	    read(a[i]);
	    if a[i] > max1 then max1:=a[i]
	    else if a[i] > max2 then max2:=a[i];
	  end;
	for i:=1 to n do
	  if a[i] = max1 then writeln(max2)
	  else writeln(max1);
end.

Measured memory_bytes: 2304
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int h[100005];
int n;
int dy[100005];
int main() {
	scanf("%d", &n);
	int i;
	for (i = 1; i <= n; i++) scanf("%d", &h[i]);
	dy[1] = 0; dy[2] = abs(h[1] - h[2]);
	for (i = 3; i <= n; i++) {
		dy[i] = min(dy[i - 1] + abs(h[i] - h[i - 1]), dy[i - 2] + abs(h[i] - h[i - 2]));
	}
	printf("%d", dy[n]);
	return 0;
}
/*
#include<cstdio>
int main() {
	freopen("input.txt", "r", stdin);
	freopen("output.txt","w",stdout);
	return 0;
}
*/

Measured memory_bytes: 896
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    // Your code here!
    double n,key=1,tmp;
    cin>>n;
    for(int i=1;i<=6;i++){
        tmp=1;
        for(int j=1;j<=i;j++){
            tmp*=2;
        }
        
        if(tmp<=n) key++;
    }
    
    
    
    if(key==1) cout<<1<<endl;
    else cout<<pow(2,key-1)<<endl;
    
}

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

typedef long long lint;
typedef unsigned long long ulint;

lint root(lint *uni, lint a){
    if(uni[a]<0) return a;
    return uni[a]=root(uni,uni[a]);
}
lint cnt(lint *uni, lint a){
    return -uni[root(uni,a)];
}
lint connect(lint *uni, lint ia, lint ib){
    lint a=root(uni, ia),b=root(uni, ib);
    if(a==b) return -a;
    if(uni[a]<uni[b]){
        uni[a]+=uni[b];
        uni[b]=a;
        return root(uni,a);
    }else{
        uni[b]+=uni[a];
        uni[a]=b;
        return root(uni,b);
    }
}

int main(){
    lint M,N;
    cin >> N >> M;
    ulint *A;
    A=new ulint[N];
    priority_queue<ulint> *cost;
    cost=new priority_queue<ulint>[N];

    for(lint i=0;i<N;i++) cin >> A[i];
    lint *uni;
    uni=new lint[N];
    for(int i=0;i<N;i++) uni[i]=-1;

    for(lint i=0;i<M;i++){
        ulint P,Q;
        cin >> P >> Q;
        lint con=connect(uni,P,Q);
    }

    for(int i=0;i<N;i++){
        cost[root(uni,i)].push(-A[i]);
    }

    lint c=0;
    ulint ans=0;
    priority_queue<ulint> rcost;
    for(int i=0;i<N;i++){
        if(c==2*(N-M-1)) break;
        if(!cost[i].empty()){
            ans-=cost[i].top();
            cost[i].pop();
            c++;
        }
        while(!cost[i].empty()){
            rcost.push(cost[i].top());
            cost[i].pop();
        }
    }

    while(!rcost.empty()){
        if(c==2*(N-M-1)) break;
        ans-=rcost.top();
        rcost.pop();
        c++;
    }

    if(c==2*(N-M-1)) cout << ans << endl;
    else cout << "Impossible" << endl;

    delete[] A,cost,uni;
    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
int main() {
	long long int a=0,b=0,c=0,d=0,n=0,ans=0,count=0,h,w ,end=0,idx,m;
	string s;
	vector<long long int> x,l,xc,lc;
	vector<long long int>::iterator position;
	bool q=false;
	cin >> n>>m;
	if (n == m)cout << "Yes"<<endl;
	else cout << "No" << endl;
	
}

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

int stat[100001];
int main() {
  int N, M;
  int AC = 0, PENALTY = 0;
  string feedback;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> N >> feedback;
    if (feedback == "AC" && stat[N] != -1) {
      PENALTY += stat[N];
      AC++;
      stat[N] = -1;		// mark AC
    }
    else if (feedback == "WA" && stat[N] != -1) {
      stat[N]++;		// count WA
    }
  }
  cout << AC << ' ' << PENALTY;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

ll INF = 1000000000000000000;

int main() {
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A.at(i);
    
    ll ans = 1;
    int i = 0;
  
  	rep(i, N){
      if(A.at(i)==0){
        cout << 0 << endl;
        return 0;
      }
    }
  
    while(i<N){
      	if(INF/A.at(i)<ans){
          cout << -1 << endl;
          return 0;
        }
        ans *= A.at(i);
        i++;
    }

    cout << ans << endl;
}

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

int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  int dp[n];
  for(int i=0;i<n;i++)
  {
    dp[i]=INT_MAX;
  }
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  dp[0]=0;
  for(int i=0;i<n;i++)
  {
     for(int j=1;j<=k;j++)
     {
         if(i+j<n)
         dp[i+j]=min(dp[i+j],dp[i]+abs(a[i+j]-a[i]));
     }
  }
  cout<<dp[n-1]<<"\n";
  return 0;
}

Measured memory_bytes: 1024
import numpy as np


def main():
    x = int(input())
    A = np.arange(-120, 120)
    a = A ** 5
    for i, a_1 in enumerate(a):
        for j, a_2 in enumerate(a):
            if a_1 - a_2 == x:
                print(A[i], A[j])
                return


if __name__ == "__main__":
    main()


Measured memory_bytes: 27132
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <cstdlib>
#include <stack>
#include <queue>
#include <list>
#include <set>

#define llong long long int

using namespace std;

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    if(n == 25) cout << "Christmas" << endl;
    else if(n == 24) cout << "Christmas Eve" << endl;
    else if(n == 23) cout << "Christmas Eve Eve" << endl;
    else cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}

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

#include <cmath>

long long parallelogram_len(long long A, long long B);

long long parallelogram_len(long long A, long long B) {
  long long a, b, y;
  if(A < B) {
    a = A;
    b = B;
  } else {
    a = B;
    b = A;
  }
  
  if(b%a == 0) {
    y = 2 * std::floor(b / a) * a - a;
  } else {
    y = 2 * std::floor(b / a) * a + parallelogram_len(a, b % a);    
  }
  return y;
}

int main(void) {
  long long N, X;
  std::cin >> N >> X;
   
  std::cout << N + parallelogram_len(X, N - X) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
long long a[10000000];
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}

void bfs(){
  queue<long long>QUE;
  for(int i=1;i<=9;i++)
  QUE.push(i);
  int k=9;
  int f=1;
  while(!QUE.empty()){
  	  long long x=QUE.front();
  	    a[f]=x;
//		cout<<f<<" "<<x<<endl;
  	  f++;
  	  if(f==100001)
  	   break;
  	  QUE.pop();
  	  long long y=x%10;
  	  if(y>=1&&y<=8)
  	  {
  	     for(int i=-1;i<=1;i++)
		   {
		   	QUE.push(x*10+(y+i));
		   }	
	  }
	  else if(y==0){
	  	QUE.push(x*10+0);
	  	QUE.push(x*10+1);
	  }else if(y==9){
	  	QUE.push(x*10+8);
	  	QUE.push(x*10+9);
	  }
  }
} 
int main(){
    bfs();
    int n=read();
    cout<<a[n]<<endl;
 	return 0;
} 

Measured memory_bytes: 2560
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli x,n;
    cin>>x>>n;
    set<lli> p;
    rep(i,n){
        lli pi;
        cin>>pi;
        p.insert(pi);
    }
    rep(i,101){
        lli u,l;
        u=x+i;
        l=x-i;
        if(!p.count(l)){
            out(l);
            break;
        }
        else{
            if(!p.count(u)){
                out(u);
                break;
            }
        }
    }
}

Measured memory_bytes: 3640
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

pair<int, int> ecnt[100005];
pair<int, int> ocnt[100005]; 
int a[100005];

int main(){
    cin.tie(0);
    
    int N;
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> a[i];
        if (i%2){
            ocnt[a[i]].first++;
            ocnt[a[i]].second = a[i];
        }else{
            ecnt[a[i]].first++;
            ecnt[a[i]].second = a[i];
        }
    }
    sort(ecnt, ecnt+100005, greater<pair<int, int>>());
    sort(ocnt, ocnt+100005, greater<pair<int, int>>());
    int ans = 0;
    if (ecnt[0].second == ocnt[0].second){
        ans += (ecnt[1].first > ocnt[1].first ? (N/2-ecnt[1].first)+(N/2-ocnt[0].first) : (N/2-ocnt[1].first)+(N/2-ecnt[0].first));
    }else{
        ans += N/2-ocnt[0].first;
        ans += N/2-ecnt[0].first;
    }
    cout << ans << endl;

    return 0;
} 


Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    void solve() throws IOException {
        int n = ni();
        int[] a = nia(n);
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 1) cnt++;
        }

        if (cnt % 2 == 1) {
            out.println("NO");
        } else {
            out.println("YES");
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 24100
#include<stdio.h>
#include<string.h>
int main(void)
{
	char a[10],b[10],c[10];
	scanf("%s %s %s", a, b, c);
	if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0])
	printf("YES\n");
	else
	printf("NO\n");
	
	return 0;
}

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

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >    VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define SI(n) scanf("%d",&n)
#define PI(n) printf("%d\n",n)
#define SLL(n) scanf("%lld",&n)
#define PLL(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
int cnt[26];
int main()
{
	int h, w;
	cin >> h >> w;
	char c;
	for (int i = 0 ; i < h*w ; i++)
		cin >> c, cnt[c-'a']++;
	multiset<int> ss;
	for (int i = 0 ; i < 26 ; i++)
		if (cnt[i])
			ss.insert(cnt[i]);
	VI v;
	for (int i = 0 ; i <= (h-1)/2 ; i++) {
		for (int j = 0 ; j <= (w-1)/2 ; j++) {
			int a = 1;
			if (h - i - 1 > (h-1)/2) {
				a++;
				if (w - 1 - j > (w-1)/2)
					a+=2;
			}
			else if (w - 1 - j > (w-1)/2)
				a++;
			v.PB(a);
		}
	}
	sort(ALL(v), greater<int>());
	string ans = "Yes\n";
	for (auto it : v) {
		if (ss.empty()) {
			ans = "No\n";
			break;
		}
		auto best = *ss.rbegin();
		if (best < it)
			ans = "No\n";
		else {
			ss.erase(ss.find(best));
			best -= it;
			if (best)
				ss.insert(best);
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
N, M, XX = (int(i) for i in input().split())  

C = []
X = []
for _ in range(N):
    tmp = [int(i) for i in input().split()] 
    c = tmp[0]
    x = tmp[1:]
    C.append(c)
    X.append(x)

totalC = 10000000000000000
for ho in range((2 ** N)):
    tmp_c = 0
    tmp_x = [0] * (M)

    tmp = format(ho, '013b')[13-N:]
    for i in range(len(tmp)):
        if tmp[i] == "1":
            tmp_c += C[i]
            for ii in range(M):
                tmp_x[ii] += X[i][ii]


    flag = True
    for fu in tmp_x:
        if fu < XX:
            flag = False
    
    if flag & (tmp_c < totalC):
        totalC = tmp_c

if totalC == 10000000000000000:
    print("-1")
else:
    print(totalC)





Measured memory_bytes: 68620
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

string solve(ll x, ll y) {

}

// true is alice
// false is brown
bool simulate(ll x, ll y) {
  // x<=y
  if(x<=1&&y<=1) {
    return false;
  }
  for(ll i=1; 2*i<=x; i++) {
    if(!simulate(x-2*i,y+i)) {
      return true;
    }
  }
  for(ll i=1; 2*i<=y; i++) {
    if(!simulate(x+i,y-2*i))
      return true;
  }
  return false;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  // rep(x,10) {
  //   rep(y,10) {
  //     cout << "x="<<x<<",y="<<y;
  //     if(simulate(x,y)) {
  //       cout << ",winner=Alice" << endl;
  //     } else {
  //       cout << ",winner=Brown"<<endl;
  //     }
  //   }
  // }
  ll x,y;
  cin>>x>>y;
  if(abs(x-y)<=1) {
    cout << "Brown" << endl;
  } else {
    cout << "Alice" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(c-a<=d&&c-a>=(-d)){
        cout<<"Yes"<<endl;
    }else if(b-a<=d&&b-a>=(-d)&&c-b<=d&&c-b>=(-d)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

// 2018-10-24T11:15:44+0800
// 2018-10-24T11:30:54+0800
// 2018-10-24T11:40:16+0800
func main() {
	var N, K int
	fmt.Scanf("%d%d", &N, &K)
	// n*K <= N
	O := cal(N / K)
	if K%2 == 0 {
		O += cal((N + K/2) / K)
	}
	fmt.Println(O)
}

func cal(M int) int {
	if M < 1 {
		return 0
	}
	if M == 1 {
		return 1
	}
	O := 3*M*(M-1) + M
	if M >= 3 {
		// Add A(M, 3): Choose 3 from M in order.
		O += M * (M - 1) * (M - 2)
	}
	return O
}

Measured memory_bytes: 512
N=int(input())

clear_flag=0
for i in range(N):
  txy=list(map(int,input().split()))
  if txy[0]>=(txy[1]+txy[2]) and (txy[0]+txy[1]+txy[2])%2==0:
    clear_flag+=1
  else:
    break
    
if clear_flag==N:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
n,x,y = map(int,input().split())

d = [[0 for _ in range(n)] for _ in range(n)]
x-=1
y-=1
ans = [0 for _ in range(n)]

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

Measured memory_bytes: 80476
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<cctype>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll A[N];
    ll i;
    ll sum=0;
    for(i=0;i<N;i++){
        cin >> A[i];
        sum+=A[i];
    }
    ll tmp=0,ans=sum;
    for(i=0;i<N;i++){
        tmp+=A[i];
        ans=min(ans,abs(sum-2*tmp));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

int main() {
	int A, B;
	int ans = 0;
	cin >> A >> B;
	for (int i = 0; i < 2; i++) {
		if (A > B) {
			ans += A;
			A -= 1;
		}
		else {
			ans += B;
			B -= 1;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
dats=[0,[".",",","!","?"," "],["a","b","c"],["d","e","f"],["g","h","i"],["j","k","l"],["m","n","o"],["p","q","r","s"],["t","u","v"],['w','x','y','z']]
for p in range(input()):
    a=raw_input().split('0')
    b=""
    for i in range(len(a)):
        if a[i]!="":
            c=a[i]
            b=b+dats[int(c[0])][len(c)%len(dats[int(c[0])])-1]
    print(b)

Measured memory_bytes: 6332
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
	int w, h;	cin >> w >> h;
	vector<pair<ll, int> > a;
	for (int i = 0; i < w; i++) {
		ll p;	cin >> p;
		a.push_back(make_pair(p, 0));
	}
	for (int i = 0; i < h; i++) {
		ll q;	cin >> q;
		a.push_back(make_pair(q, 1));
	}
	sort(a.begin(), a.end());
	ll leftw = w + 1, lefth = h + 1;
	ll ret = 0;
	for (int i = 0; i < a.size(); i++) {
		if (a[i].second == 0) {
			ret += a[i].first * lefth;
			leftw--;
		}
		else {
			ret += a[i].first*leftw;
			lefth--;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 4464
(defun fact (n)
  (labels ((rec (n a)
                (if (= n 0)
                    a
                    (rec (1- n) (mod (* n a) 1000000007)))))
          (rec n 1)))

(defun solver ()
  (let ((n (read)) (m (read))
        (big nil) (small nil) (smallfact nil))
    (if (> n m)
        (setf big n small m)
        (setf big m small n))
    (cond ((> (abs (- big small)) 1)
           (format t "0~%"))
          ((= big small)
           (setf smallfact (fact small))
           (format t "~A~%" (mod (* smallfact smallfact 2) 1000000007)))
          ((setf smallfact (fact small))
           (format t "~A~%" (mod (* smallfact (* smallfact (1+ small))) 1000000007))))))

(solver)

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

typedef long long int ll;

int main(void){
    // Here your code !
    int n,k;
    cin >> n >> k;
    
    vector<ll> a(n+10);
    vector<ll> rui(n+10);
    vector<ll> rui2(n+10);
    
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        rui[i] = rui[i-1] + a[i];
        if(a[i] > 0)
        rui2[i] = rui2[i-1] + a[i];
        else
        rui2[i] = rui2[i-1];
    }
    
    
    ll res = 0;
    
    for(int i = k; i <= n; i++){
        ll tmp = rui[i] - rui[i-k];
        
        if(tmp < 0) tmp = 0;
        
        tmp += rui2[i-k] + rui2[n] - rui2[i];
        
        res = max(tmp,res);
        
    }
    
    cout << res << endl;
    
    
}


Measured memory_bytes: 2560
import java.util.Scanner;
import java.lang.Math;
class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
double r=scan.nextDouble();
double area=r*r*Math.PI;
double cir=2*r*Math.PI;
System.out.printf("%.6f %.6f",area,cir);
}
}

Measured memory_bytes: 28364
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0055
{
	class Program
	{
		static void Main(string[] args)
		{
			while( true ) {
				var	s	= Console.ReadLine();
				if( s == null ) {
					break;
				}
				var	a	= double.Parse( s );
				
				var	sum	= a;
				for( int i = 2; i <= 10; i++ ) {
					if( (i % 2) == 0 ) {
						a	*= 2.0;
					} else {
						a	/= 3.0;
					}
					sum	+= a;
				}
				Console.WriteLine( "{0:f8}", sum );
			}
		}
	}
}

Measured memory_bytes: 5728
#include <bits/stdc++.h>
#define ll long long int
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N=(int)1e5+5;
int main()
{
#ifdef ONLINE_JUDGE
    FAST;
#endif
    ll K,A,B,sum;
    cin>>K>>A>>B;
    if ((A>=K)||(B-A<=2))
        return cout<<(K+1)<<"\n",0;
    K-=(A-1);
    sum=A;
    while(K>=2)
    {
        ll mn=min((sum/A),(K/2));
        if (!mn)
            break;
        sum-=(mn*A);
        sum+=(mn*B);
        K-=(mn*2);
    }
    sum+=K;
    cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  vi a(5);
  scan(a);
  int k; scan(k);
  if (a[4] - a[0] > k) {
    print(":(");
  } else {
    print("Yay!");
  }
  return 0;
}


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

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

    int tmp = n;
    bool is_div = false;
    int div = 100000;
    rep(i, 5) {
        if (tmp % div == 0) {
            is_div = true;
            break;
        }
        div /= 10;
    }
    if (is_div) {
        cout << "10" << endl;
        return 0;
    }
    int sum = 0;

    while (tmp != 0) {
        sum += tmp % 10;
        tmp = tmp / 10;
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll int n;
    cin>>n;
    ll int ans=0;
    ll int a=n%500;
    n=n/500;
    ans+=n*1000;
    a=a/5;
    ans+=a*5;
    cout<<ans;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    ll n, a, b;
    cin >> n >> a >> b;
    ll x, y;
    x = n / (a + b);
    y = n % (a + b);
    x *= a;
    y = min(a, y);
    cout << (x + y) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s, t, u string
	var a, b int
	fmt.Scan(&s, &t, &a, &b, &u)

	if u == s {
		fmt.Println(a-1, b)
	} else if u == t {
		fmt.Println(a, b-1)
	}

}


Measured memory_bytes: 512
import collections
X, N = map(int, input().split())
list = list(map(int, input().split()))
c = collections.Counter(list)
res1=-1000
res2=-1000
for i in range (0, 100):
  if(c[X+i]==0):
    res1=X+i
    if(c[X-i]==0):
      res2=X-i
    break
  if(c[X-i]==0):
    res2=X-i
    break
if(res1==-1000 and res2!=-1000):
  print(res2)
elif(res2==-1000 and res1!=-1000):
  print(res1)
elif(abs(X-res1)<abs(X-res2)):
  print(res1)
elif(abs(X-res2)<=abs(X-res1)):
  print(res2)


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

namespace AtCoderSolve
{
    class Solve
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            int N = int.Parse(Console.ReadLine());
            long []a = new long[N];
            for(var i = 0; i < N; i++)
            {
                a[i] = long.Parse(Console.ReadLine());

            }
            Array.Sort(a);
            int ans = 0;
            int c = 1;
            for(var i = 0; i < N; i++)
            {
                if (i == 0)
                {
                    ans += c;
                    c *= -1;
                    continue;
                }
                if (a[i] == a[i - 1])
                {
                    ans += c;
                    c *= -1;
                }
                else
                {
                    ans++;
                    c = -1;
                }
                
            }

            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }



    public class Calculation
    {
        
    }
}


Measured memory_bytes: 15964
//
// Created by yamunaku on 2019/08/10.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
        sort(all(s[i]));
    }
    sort(all(s));
    ll ans=0;
    ll c=1;
    for(int i=1;i<n;i++){
        if(s[i-1]==s[i]){
            c++;
        }else{
            ans+=c*(c-1)/2;
            c=1;
        }
    }
    ans+=c*(c-1)/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    for(int i= 0; i < s.size(); i++){
        s[i] += n;
        if(s[i] > 90){
            s[i] -= 26;
        }
        cout << s[i];
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    //cout << N << endl;
    
    int x[N + 1], y[N + 1], t[N + 1];
    int xsub, ysub, tsub, xysub;
    
    x[0] = 0;
    y[0] = 0;
    t[0] = 0;
    
    for(int i = 1;i < N + 1;i++) {
        cin >> t[i];
        cin >> x[i];
        cin >> y[i];
        //cout << t[i] << " " << x[i] << " " << y[i] << endl;
        tsub = t[i] - t[i - 1];
        xsub = abs(x[i] - x[i - 1]);
        ysub = abs(y[i] - y[i - 1]);
        xysub = xsub + ysub;
        //cout << tsub << " " << xysub << endl;
        if(xysub > tsub) {cout << "No"; exit(0);}
        else if(tsub % 2 == 0 && xysub % 2 == 1) {cout << "No"; exit(0);}
        else if(tsub % 2 == 1 && xysub % 2 == 0) {cout << "No"; exit(0);}
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';

int main() {
    string n;
    ll zibun=0,aite=0,kuriage=0;
    cin>>n;
    n="0"+n;
    for(ll i=n.length()-1;i>=0;i--){
        ll d = n[i]-48;
        if(kuriage>0){
            d++;
            if(d==10)d=0;
            else{
                kuriage=0;
            }
        }
        if(d<5){
            zibun+=d;
        }
        else if(d>5){
            aite+=10-d;
            kuriage=1;
        }else{
            int nxtmp = n[i-1] - 48;
            if(nxtmp+1 > 5) {
                aite += (10-d);
                kuriage = 1;
            } else {
                zibun += d;
                kuriage = 0;
            }
        }
    }
    cout<<zibun+aite+kuriage<<endl;
}


Measured memory_bytes: 2308
def dfs(i, s, l):
    if i == len(s):
        return ''
    for j in l:
        if j == int(s[i]):
            ans = dfs(i + 1, s, l)
            if ans is not None:
                ans += str(j)
                return ans
        elif j > int(s[i]):
            ans = str(l[0]) * (len(s) - i - 1) + str(j)
            return ans
    return None

n, k = map(int, input().split())
ns = str(n)
d = list(map(int, input().split()))
l = [i for i in range(10) if i not in d]
ans = dfs(0, ns, l)
if ans is None:
    if l[0] == 0:
        ans = str(l[1]) + str(l[0]) * len(ns)
    else:
        ans = str(l[0]) * (len(ns) + 1)
else:
    ans = ans[::-1]
print(ans)


Measured memory_bytes: 3064
import copy
import sys
import math

def main():
	n,m = map(int,input().split())
	ab = [list(map(int,input().split())) for _ in range(m)]
	b = {}
	for i in ab:
		try:
			b[i[0]].append(i[1])
		except:
			b[i[0]] = [i[1]]
		try:
			b[i[1]].append(i[0])
		except:
			b[i[1]] = [i[0]]
	ab = copy.deepcopy(b)
	for i in ab[1]:
		if(n in ab[i]):
			print('POSSIBLE')
			sys.exit()
	print('IMPOSSIBLE')


def listtodict(a):
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			b[i] = 1
	return b

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()



Measured memory_bytes: 207748
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
 
const int MAX = 50;
 
int main(){
    int N;
    int p[MAX];
 
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> p[i];
    }
 
    int cnt = 0;
    int a = 0,b = 0,c = 0,d = 0;
 
    for(int i = 1;i < N;i++){
        if(p[i-1] > p[i]){
            if(cnt == 0){
                a = p[i - 1];
                b = p[i];
            }
            if(cnt == 1){
                c = p[i - 1];
                d = p[i];
            }
            cnt++;
        }
    }
 

    if(cnt == 0 || (cnt == 2 && a >= c && b >= d))cout << "YES" << endl;
    else cout << "NO" << endl;
 
    return 0;
}

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

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var h = l[0]; var w = l[1];
        var pxl = new List<List<Char>>();
        var fpx = new List<Char>();
        for (var j = 0; w + 2 > j; j++)
        {
            fpx.Add('#');
        }
        pxl.Add(fpx);

        for (var i = 0; h > i; i++)
        {
            var px = Console.ReadLine().ToCharArray().ToList();
            px.Add('#');
            px.Insert(0, '#');
            pxl.Add(px);
        }
        pxl.Add(fpx);

        for (var i = 0; h + 2 > i; i++)
        {
            Console.WriteLine(new String(pxl[i].ToArray()));
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

int main(void){
  fast_io
  int n;cin>>n;
  string s,t;
  cin>>s>>t;
  rep(i,n){
    cout<<s[i];
    cout<<t[i];
  }
  cout<<endl;
  
  return 0;
}

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

using namespace std;

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

    vector<int> x(n), y(n);
    vector<string> c(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> c[i];
    }

    vector<vector<int>> s(4 * k + 1, vector<int>(4 * k + 1, 0));
    for (int i = 0; i < n; i++) {
        int xi = x[i] % (2 * k) + k;
        int yi = (c[i] == "B" ? y[i] % (2 * k) : (y[i] + k) % (2 * k)) + k;

        for (int j = 0; j < 5; j++) {
            for (int l = 0; l < 5; l++) {
                int xl = xi + (j - 2) * k + 1, xr = xi + (j - 1) * k + 1;
                int yl = yi + (l - 2) * k + 1, yr = yi + (l - 1) * k + 1;

                if (j % 2 == l % 2 && 0 <= xl && xr <= 4 * k && 0 <= yl && yr <= 4 * k) {
                    s[xl][yl]++;
                    s[xl][yr]--;
                    s[xr][yl]--;
                    s[xr][yr]++;
                }
            }
        }
    }

    for (int i = 0; i < 4 * k; i++) {
        for (int j = 0; j < 4 * k; j++) {
            s[i][j + 1] += s[i][j];
        }
    }
    for (int i = 0; i < 4 * k; i++) {
        for (int j = 0; j < 4 * k; j++) {
            s[i + 1][j] += s[i][j];
        }
    }

    int res = 0;
    for (int i = k; i < 3 * k; i++) {
        for (int j = k; j < 3 * k; j++) {
            res = max(res, s[i][j]);
        }
    }

    cout << res << endl;
}


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

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

int main(){
    ll n;cin >>n;
    vector<ll>a(5,0);
    for (int i = 0; i < n; ++i) {
        string s;cin >>s;
        if(s[0]=='M')a[0]++;
        if(s[0]=='A')a[1]++;
        if(s[0]=='R')a[2]++;
        if(s[0]=='C')a[3]++;
        if(s[0]=='H')a[4]++;
    }
    ll ans=0;
    for (int j = 0; j < 3; ++j) {
        for (int i = j+1; i < 4; ++i) {
            for (int k = i+1; k < 5; ++k) {
                ans+=a[j]*a[i]*a[k];
            }
        }
    }
    cout <<ans <<endl;
    return 0;
}

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

int main(){
  while(true){
    int n;
    cin>>n;
    if(n==0){
      break;
    }
    char c[100];
    for(int i=0;i<n;i++){
      cin>>c[i];
    }
    int cnt[26]={0};
    for(int i=0;i<n;i++){
      cnt[(int)(c[i]-'A')]++;
      int max1 = -1;
      int max2 = -1;
      for(int j=0;j<26;j++){
        if(cnt[j]>max1){
          max2=max1;
          max1=cnt[j];
        }else if(cnt[j]>max2){
          max2=cnt[j];
        }
      }
      if(max1-max2>n-(i+1)){
        for(int j=0;j<26;j++){
          if(cnt[j]==max1){
            cout<<(char)(j+'A')<<' ';
            break;
          }
        }
        cout<<(i+1)<<endl;
        break;
      }
      if(i==n-1){
        cout<<"TIE"<<endl;
        break;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3084
import math

N = int(input())
h = list(map(int, input().split()))
dp = [float('INF')] * (10**5 + 10)

def chmin(a, b):
    if a >= b:
        return b
    else:
        return a

dp[0] = 0 #初期値 = 0
for i in range(N-1):
    dp[i+1] = chmin(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
    if i < N-2:
        dp[i+2] = chmin(dp[i+2], dp[i] + abs(h[i+2] - h[i]))
print(dp[N-1])

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

int main() {
	int n;
	cin >> n;
	int p[n], max, min, cnt=0;
	for (int i = 0; i < n;i++) {
		cin >> p[i];
	}
	for (int i = 1; i < n-1; i++) {
		max = p[i - 1];
		min = p[i - 1];
		if (max<p[i+1]) {
			max = p[i + 1];
		}
		if (min>p[i + 1]) {
			min = p[i + 1];
		}
		if(p[i]<=max&&p[i]>=min){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

int main(){
  int n;
  cin>>n;
  for(int i = 0;i<=25;i++){
    for(int j = 0;j<13;j++){
      if(4*i+7*j == n){
	cout<<"Yes"<<endl;
	return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 888
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

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

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k) {
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= MOD;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= MOD;
    }
    return x * modinv(y, MOD) % MOD;
}

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

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

    return 0;
}


Measured memory_bytes: 3672
n = gets.to_i
c = gets.split(" ").map(&:to_i)

d = 0
0.upto(n-1) do |i|
  (n-1).downto(i+1) do |j|
    if c[j] < c[j-1]
      c[j],c[j-1] = c[j-1],c[j]
      d += 1
    end
  end
end

puts c.join(" ")
puts "#{d}"



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

int a[1000];
int n;

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

int j;
for(j=n-1;j>-1;j=j-1){
cout<<a[j];
if(j>0) {cout<<" ";}
if(j==0){cout<<endl;}
}
}





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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll A[3][3];
    for (int i = 0;i < 3;i++){
        for (int j = 0;j < 3;j++){
            cin >> A[i][j];
        }
    }

    ll N; cin >> N;
    for (int k = 0;k < N;k++){
        ll b; cin >> b;
        for (int i = 0;i < 3;i++){
            for (int j = 0;j < 3;j++){
                if(A[i][j] == b) A[i][j] = -1;
            }
        }
    }

    ll ans = false;

    for (int i = 0;i < 3;i++){
        if(A[i][0] == -1 && A[i][1] == -1 && A[i][2] == -1) ans = true;
        if(A[0][i] == -1 && A[1][i] == -1 && A[2][i] == -1) ans = true;
    }

    if(A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1) ans = true;
    if(A[0][2] == -1 && A[1][1] == -1 && A[2][0] == -1) ans = true;

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

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

using namespace std;

typedef pair<int, string> P;

string solve(int n, int q, vector<P> vec)
{
  for(int i = 0; i <= n; ++i) {
    if(q < vec[i].first) {
      return vec[i-1].second;
    }
  }

  return vec.back().second;
}

int main()
{
  int n, q;
  vector<P> vec;

  while(cin>>n>>q) {
    vec = vector<P>(n+1);
    vec[0] = P(0, "kogakubu10gokan");

    for(int i = 1; i <= n; ++i){
      cin >> vec[i].first >> vec[i].second;
    }
    
    cout << solve(n, q, vec) << endl;
    vec.clear();
  }

  return 0;
}

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

long long int dp[100005];

void get_res(int *weight, int *value, int N, int W )
{
    for( int i = 0; i < N; i++ ){
        for( int j = W; j >= weight[i]; j-- ){
		dp[j] = max(dp[j], dp[j-weight[i]]+value[i]);
	}
    }
}

int main()
{
    int N, W;

    cin >> N >> W;

    int weight[N];
    int value[N];

    for( int i = 0; i < N; i++ )
        cin >> weight[i] >> value[i];

    for( int j = 0; j <=W; j++ ){
        dp[j] = 0;
	}

    get_res( weight, value, N, W );
    cout << dp[W] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

struct Combination
{
	vector<ll> fact, inv, invFact;
	int MAX_FACT;
	ll MOD;
	Combination(int n, ll mod) : fact(n + 1), inv(n + 1), invFact(n + 1)
	{
		MAX_FACT = n + 1;
		MOD = mod;
		fact[0] = 1;
		fact[1] = 1;
		invFact[0] = 1;
		invFact[1] = 1;
		inv[1] = 1;
		for (auto i = 2; i < MAX_FACT; ++i)
		{
			fact[i] = fact[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
			invFact[i] = invFact[i - 1] * inv[i] % MOD;
		}
	}

	unsigned long long calcCombination(int n, int k)
	{
		if (n < k)
		{
			return 0;
		}
		if ((n < 0) || (k < 0))
		{
			return 0;
		}

		return fact[n] * (invFact[k] * invFact[n - k] % MOD) % MOD;
	}
};


int main()
{
	int H, W, A, B;
	cin >> H >> W >> A >> B;

	auto mod = (ll)1e9 + 7;
	auto ans = 0ll;
	Combination c(H + W, mod);
	auto h = H - A;
	for (auto i = B + 1; i <= W; ++i)
	{
		auto temp = c.calcCombination(h + i - 2, h - 1)
			* c.calcCombination(A + W - i - 1, A - 1) % mod;
		ans = (ans + temp) % mod;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<int>vec(12);
    for(int i=0;i<12;i++)cin>>vec[i];
    sort(vec.begin(),vec.end());
    if(vec[0]==vec[1]&&vec[1]==vec[2]&&vec[2]==vec[3]&&vec[4]==vec[5]&&vec[5]==vec[6]&&vec[6]==vec[7]&&vec[8]==vec[9]&&vec[9]==vec[10]&&vec[10]==vec[11])cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}


Measured memory_bytes: 3144