akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int main() {
	LL n, k;
	cin >> n >> k;
	LL ans = 0;
	if (k == 0) {
		cout << n * n << endl;
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		ans += max(0LL, i - k) * (n / i) + max(0LL, n % i - k + 1);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll bc(ll i)
{
    if(i==0)
    return 1;
    ll st=1;
    for(ll j=1;j<=i;j++)
    st*=2;
    return st;
}
void solve()
{
   
       ll n,k;
       cin>>n>>k;
       ll ans=INT_MAX;
       for(ll i=0;i<=n;i++)
       {
           ll bc1=bc(i);
           ll sm=k*(n-i);
           ans=min(ans,bc1+sm);
            
       }
      
       cout<<ans<<endl;
}

int main()
{
  ll t;
  //cin>>t;
  t=1;
  while(t--)
  {
      solve();
  }
   
   
   
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
int main() {
	int a, b, c, d ,e;
	std::cin >> a >> b >> c >> d >> e;
	std::cout << std::min(a, std::min(b, c)) + std::min(d, e) - 50 << std::endl;
	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i,n) for (int i=0; i < int(n); i++)
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	cout << '\n';
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool integer(double num) {
	return floor(num) == num;
}

Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	IOS;
	string str; cin >> str;
	string temp;
	int cnt1 = 0;
	int pos = 0;
	string t="";
	for (int i = 0; i < str.size(); i++) {
		for (int k = 1; k < 200001; k++) {
			if (k+pos<=str.size())t = str.substr(pos, k);
			else {
				break;
			}
			if (t != temp) {
				cnt1++;
				temp = t;
				pos = pos+k;
				break;
			}
		}
	}
	cout << cnt1;

	cout << endl;
	return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 848
import java.util.*;
import java.lang.Math;

public class Main {
public static void main(String[] args) {
  
  Scanner sc = new Scanner(System.in);
	
  int a,b,loop;
  
  a = sc.nextInt();
  b = sc.nextInt();
  loop = 0;
  
  if (a > b) {
    loop = a;
    
     for(int i = 0; i < loop; i++) {
     	System.out.print(b); 
    }
    
  } else {
    loop = b; 
    
      for(int i = 0; i < loop; i++) {
     	System.out.print(a); 
    }
    
  }
  
	}
}

Measured memory_bytes: 21844
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k,l;
  int a[30][6],b[6],n;
  string s[]={"Cyan","Yellow","Red","Magenta","Green","Blue"},t;
  while(cin>>n&&n){
    l=0;
    for(i=0;i<n-l;i++){
      cin>>t;
      for(j=0;s[j]!=t;j++);
      a[i][0]=j;
      cin>>t;
      for(j=0;s[j]!=t;j++);
      a[i][1]=j;
      cin>>t;
      for(j=0;s[j]!=t;j++);
      a[i][2]=j;
      cin>>t;
      for(j=0;s[j]!=t;j++);
      a[i][4]=j;
      cin>>t;
      for(j=0;s[j]!=t;j++);
      a[i][3]=j;
      cin>>t;
      for(j=0;s[j]!=t;j++);
      a[i][5]=j;
      for(j=0;j<i;j++){
	memcpy(b,&a[i][0],6*sizeof(int));
	for(k=0;b[k]!=a[j][0];k++);
	if(0){
	}else if(k==0){
	}else if(k==1){
	  swap(b[3],b[0]);
	  swap(b[0],b[1]);
	  swap(b[1],b[5]);	  
	}else if(k==2){
	  swap(b[4],b[0]);
	  swap(b[0],b[2]);
	  swap(b[2],b[5]);
	}else if(k==3){
	  swap(b[1],b[0]);
	  swap(b[0],b[3]);
	  swap(b[3],b[5]);
	}else if(k==4){
	  swap(b[2],b[0]);
	  swap(b[0],b[4]);
	  swap(b[4],b[5]);
	}else if(k==5){
	  swap(b[3],b[0]);
	  swap(b[0],b[1]);
	  swap(b[1],b[5]);
	  swap(b[3],b[0]);
	  swap(b[0],b[1]);
	  swap(b[1],b[5]);
	}
	for(k=0;k<4;k++){
	  if(b[0]==a[j][0]&&b[1]==a[j][1]&&b[2]==a[j][2]&&b[3]==a[j][3]&&b[4]==a[j][4]&&b[5]==a[j][5])
	    break;
	  swap(b[4],b[1]);
	  swap(b[1],b[2]);
	  swap(b[2],b[3]);
	}
	if(k!=4){
	  i--;
	  l++;
	  break;
	}
      }
    }
    cout<<l<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();

        System.out.println((H - h) * (W - w));
    }

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  vii A(N,vi(N,INF));
  rep(i,0,M){
    int X,Y,Z; cin>>X>>Y>>Z;
    A[X-1][Y-1]=Z;
    A[Y-1][X-1]=Z;
  }
  vector<vector<bool>> F(N,vector<bool>(N));
  rep(i,0,N){
    vi memo(N);
    memo[i]=-1;
    priority_queue<pii,vector<pii>,greater<pii>> Q;
    Q.push(mp(0,i));
    vi B(N,MOD);
    B[i]=0;
    while(Q.size()>0){
      int X=Q.top().second,Y=Q.top().first;
      Q.pop();
      rep(j,0,N){
        if(B[j]>Y+A[X][j]){
          B[j]=Y+A[X][j];
          Q.push(mp(Y+A[X][j],j));
          memo[j]=X;
        }
      }
    }
    rep(i,0,N){
      int P=i;
      while(memo[P]!=-1){
        F[P][memo[P]]=1;
        P=memo[P];
      }
    }
  }
  int ans=0;
  rep(i,0,N){
    rep(j,0,N){
      if(F[i][j])
        ans++;
    }
  }
  cout<<M-ans/2<<endl;
  }


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int in[5];
  for (int i = 0; i < 5; i++) {
    cin >> in[i];
  }
  int k;
  cin >> k;
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      if (abs(in[j] - in[i]) > k) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;
}

Measured memory_bytes: 256
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int grid[4][4];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	set<int> tog; forl(i, 0, 3) forl(j, 0, 3) cin >> grid[i][j];
	int n; cin >> n;
	forl(i, 0, n) { int a; cin >> a; tog.insert(a); }
	forl(i, 0, 3) {
		if(tog.count(grid[i][0]) and tog.count(grid[i][1]) and tog.count(grid[i][2])) { println("Yes"); return 0; }
		if(tog.count(grid[0][i]) and tog.count(grid[1][i]) and tog.count(grid[2][i])) { println("Yes"); return 0; }
	}
	if(tog.count(grid[0][0]) and tog.count(grid[1][1]) and tog.count(grid[2][2])) { println("Yes"); return 0; }
	if(tog.count(grid[0][2]) and tog.count(grid[1][1]) and tog.count(grid[2][0])) { println("Yes"); return 0; }
	println("No");
}


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

using namespace std;

int dat[12][12];

int main() {
  int n, d;
  scanf("%d %d", &n, &d);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= d; ++j) {
      cin >> dat[i][j];
    }
  }

  int res = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      int sum = 0;
      for (int k = 1; k <= d; ++k) {
        sum += (dat[i][k] - dat[j][k]) * (dat[i][k] - dat[j][k]);
      }
      int s = sqrt(sum);
      if (s * s < sum) s ++;
      if (s * s > sum) s --;

      if (s * s == sum) res ++;
    }
  }
  cout << res << endl;
}


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

int n, nowx = 0, nowy = 0, nowt = 0;
bool ok = true;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int t, x, y, g;
        cin >> t >> x >> y;
        g = abs(x - nowx) + abs(y - nowy);
        if (t - nowt < g || (t - nowt - g) % 2) ok = false;
        
        nowx = x; nowy = y; nowt = t;
    }
    
    cout << (ok ? "Yes" : "No") << '\n';
    return 0;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;


int main() {

    int n;
    cin >> n;
    vector<vector<vector<int> > > building(4, vector<vector<int> >(3, vector<int>(10, 0)));

    rep(i, n) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        b--;
        f--;
        r--;
        building[b][f][r] += v;
    }

    rep(b, 4) {
        rep(f, 3) {
            rep(r, 10) {
                cout << ' '  << building[b][f][r];
            }
            cout << endl;
        }
        if (b != 3) cout << "####################" << endl;
    }

}


Measured memory_bytes: 3152
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

void solve() {

	int n;
	cin >> n;

	vector<int> L(n), R(n);
	priority_queue<pair<int, int>> LK;
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> RK;
	lint ans = 0;
	for (int i = 0; i < n; i++) {
		int k, l, r;
		cin >> k >> l >> r;
		k--;
		L[i] = l;
		R[i] = r;
		if (l > r) LK.emplace(k, i);
		else if (k != n - 1) RK.emplace(k, i);
		else ans += l;
	}

	int cnt = 0;
	priority_queue<int> subLR;
	for (int j = n; j >= 0; j--) {

		while (!LK.empty()) {
			const auto& [k, i] = LK.top();
			if (j > k) break;

			ans += L[i];
			subLR.emplace(L[i] - R[i]);
			LK.pop();
		}

		if (!subLR.empty()) {
			subLR.pop();
		}

	}

	while (!subLR.empty()) {
		ans -= subLR.top();
		subLR.pop();
	}

	priority_queue<lint> subRL;
	for (int j = 0; j < n; j++) {

		while (!RK.empty()) {
			const auto& [k, i] = RK.top();
			if (j <= k) break;

			ans += R[i];
			subRL.emplace(R[i] - L[i]);
			RK.pop();
		}

		if (!subRL.empty()) {
			subRL.pop();
		}

	}

	while (!subRL.empty()) {
		ans -= subRL.top();
		subRL.pop();
	}

	cout << ans << "\n";

};

int main() {

	int T;
	cin >> T;

	for (int i = 0; i < T; i++) {
		solve();
	}

	return 0;
}



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

#define pb push_back
const int N = 2e5L + 11;
using ll = long long;
const ll inf = 1e18L;

int x[N], y[N];
vector <int> vx[N], vy[N];
int atx[N], aty[N];
ll dis[N][2];
struct node {
	ll dis; int k1, k2;
	bool operator <(node r) const {
		return tie(dis, k1, k2) < tie(r.dis, r.k1, r.k2);
	}
};

int main() {
	ios :: sync_with_stdio(0);
	int w, h, n; cin >> w >> h >> n;
	for(int i = 1; i <= n; i ++)
		cin >> x[i] >> y[i];
	x[0] = y[0] = 1;
	x[n + 1] = w; y[n + 1] = h;

	for(int i = 0; i <= n + 1; i ++) {
		vx[x[i]].pb(i);
		vy[y[i]].pb(i);
	}
	for(int i = 0; i < N; i ++) {
		sort(vx[i].begin(), vx[i].end(), [&](int i, int j){ return y[i] < y[j]; });
		sort(vy[i].begin(), vy[i].end(), [&](int i, int j){ return x[i] < x[j]; });
		for(int j = 0; j < vx[i].size(); j ++) atx[vx[i][j]] = j;
		for(int j = 0; j < vy[i].size(); j ++) aty[vy[i][j]] = j;
	}

	for(int i = 0; i <= n + 1; i ++)
		for(int j : {0, 1}) dis[i][j] = inf;
	dis[0][0] = 0;
	set <node> st;
	for(int i = 0; i <= n + 1; i ++)
		for(int j : {0, 1}) st.insert({dis[i][j], i, j});

	auto upd = [&](int k1, int k2, ll w) {
		if(dis[k1][k2] > w) {
			st.erase({dis[k1][k2], k1, k2});
			dis[k1][k2] = w;
			st.insert({dis[k1][k2], k1, k2});
		}
	};
	auto f = [&](int i, int j) {
		return abs(x[i] - x[j]) + abs(y[i] - y[j]);
	};
	auto solve = [&](vector <int> &v, int k1, int k2) {
		int i = (k2 == 0) ? atx[k1] : aty[k1];
		if(i > 0) upd(v[i - 1], k2, f(v[i], v[i - 1]) + dis[k1][k2]);
		if(i + 1 < v.size()) upd(v[i + 1], k2, f(v[i], v[i + 1]) + dis[k1][k2]);
	};
	while(!st.empty()) {
		node i = *st.begin(); st.erase(st.begin());
		//cout << i.dis << ' ' << i.k1 << ' ' << i.k2 << '\n';
		if(i.k1 >= 1 && i.k1 <= n) upd(i.k1, i.k2 ^ 1, i.dis + 1);
		if(i.k2 == 0) solve(vx[x[i.k1]], i.k1, i.k2);
		if(i.k2 == 1) solve(vy[y[i.k1]], i.k1, i.k2);
	}
	ll ans = min(dis[n + 1][0], dis[n + 1][1]);
	cout << ((ans == inf) ? -1 : ans) << '\n';
}

Measured memory_bytes: 50016
#include<stdio.h>

int Euclid(int a,int b){
    int r;
    while(1){
        r = a % b;
        if(r == 0){
            break;
        }
        a  = b;
        b = r;
        
    }
    return b;
}
int main(){
    int n;
    scanf("%d",&n);
    int sum = 0;
    int d;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            for(int k = 1;k <= n;k++){
                d = Euclid(i,j);
                if(j == k || i == k){
                    sum += d;
                    
                    continue;
                }
                d = Euclid(d,k);
                sum += d;
               
            }
        }
    }
    printf("%d\n",sum);
}

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

int main(int argc, char const *argv[]){
	int n;
	priority_queue<int> que;

	while(1){
		int total = 0;
		int i;
		cin>>n;
		if (n==0) break;
		for (int i = 0; i < n; i++){
			int tmp;
			cin>>tmp;
			que.push(tmp);
		}
		que.pop();
		int m = que.size()-1;
		for (i = 0; i < m; i++){	
			total += que.top();
			que.pop();
		}
		cout<<total/i<<endl;
		que.pop();
	}
	return 0;
}

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

int value(int n){
  if(n < 0)
    n *= -1;
  return n;
}
int main(void){
  int d, x[3], tmp, cnt = 0;
  bool ans = false;
  for(int i = 0; i < 3; i++)
    cin >> x[i];
  cin >> d;
  tmp = value(x[0] - x[1]);
  if(tmp <= d)
    cnt++;
  tmp = value(x[1] - x[2]);
  if(tmp <= d)
    cnt++;
  tmp = value(x[0] - x[2]);
  if(tmp <= d)
    ans = true;
  if(cnt == 2)
    ans = true;
  if(ans) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


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

int main()
{
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if (s == u)
        a--;
    else if (t == u)
        b--;

    cout << a << ' ' << b << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]

a_sort = sorted(a)

a_max = a_sort[-1]
a_second = a_sort[-2]

for i in range(n):
    if a[i] == a_max:
        print(a_second)
    else:
        print(a_max)

Measured memory_bytes: 14112
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const int INF = 1e9;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int w, d, n; cin >> w >> d >> n;
    vector<int> x(n), y(n), z(n);
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i], x[i]--, y[i]--;
    vector<vector<int>> minv(w, vector<int>(d, -INF));
    vector<vector<int>> maxv(w, vector<int>(d, INF));
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < w; i++) {
            for (int j = 0; j < d; j++) {
                minv[i][j] = max(minv[i][j], z[k] - abs(i - x[k]) - abs(j - y[k]));
                maxv[i][j] = min(maxv[i][j], z[k] + abs(i - x[k]) + abs(j - y[k]));
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < d; j++) {
            if (minv[i][j] > maxv[i][j]) goto NO;
            ans += minv[i][j];
        }
    }
    cout << ans << endl;
    return 0;
NO:
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 3232
N,M=map(int,input().split())
like=[True]*M
for _ in range(N):
    A=list(map(int,input().split()))[1:]
    F=[False]*M
    for a in A:
        F[a-1]=True
    for i in range(M):
        like[i]=like[i]&F[i]
print(like.count(True))

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  string res;
  while (n) {
    --n;
    res += (n % 26) + 'a';
    n /= 26;
  }   
  reverse(res.begin(), res.end());
  cout << res << '\n';
  return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k, a, b;
  cin >> k >> a >> b;
  int foo = (a + k - 1) / k;
  int bar = b / k;
  if (bar >= foo) {
    cout << "OK" << '\n';
  } else {
    cout << "NG\n";
  }
  return 0;
}

Measured memory_bytes: 3584
import math
from sys import stdin
a,b,C = map(float, stdin.readline().split())

h = b * math.sin(math.radians(C))
S = a * h * 0.5
L = a + b + ((b*math.cos(math.radians(C))-a)**2 + h**2)**0.5

print(S)
print(L)
print(h)


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

int main() {
    int n;
    cin >> n;
    string s;
    string t;
    string u;
    cin >> s >> t;
    for(int i=0;i<n;i++) {
        u += s[i];
        u += t[i];
    }
    cout << u << endl;
    return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

class DSU {
private:
    vector<int> parents;
    vector<int> sizes;
    vector<int> weights;
public:
    DSU(int n, vector<int> w) {
        parents.resize(n+1);
        for(int i = 1; i <= n; ++i) parents[i] = i;
        sizes.resize(n+1);
        for(int i = 1; i <= n; ++i) sizes[i] = 1;
        weights = w;
    }

    int root(int i) {
        while(parents[i] != i) {
            parents[i] = parents[parents[i]];
            i = parents[i];
        }
        return i;
    }

    int getWeight(int i) {
        int r = root(i);
        return weights[r];
    }

    bool find(int a, int b) {
        return root(a) == root(b);
    }

    void join(int a, int b) {
        int root_a = root(a);
        int root_b = root(b);

        if(root_a == root_b) return;
        
        if(sizes[root_a] < sizes[root_b]) {
            parents[root_a] = parents[root_b];
            sizes[root_b] += sizes[root_a];
            weights[root_b] += weights[root_a];
        } else {
            parents[root_b] = parents[root_a];
            sizes[root_a] += sizes[root_b];
            weights[root_a] += weights[root_b];
        }
    }
};

struct edge {
    int a;
    int b;
    int weight;

    bool operator<(const edge& other) const {
        return weight < other.weight;
    }
};

edge make_edge(int aa, int bb, int w) {
    edge e;
    e.a = aa;
    e.b = bb;
    e.weight = w;
    return e;
}

int32_t main() {

    int n, m; cin >> n >> m;
    vector<int> x(n+1);
    for(int i = 1; i <= n; ++i) cin >> x[i];

    vector<vector<edge>> graph(n+1, vector<edge>());

    DSU dsu(n, x);
    vector<edge> edges(m);
    for(int i = 0; i < m; ++i)
        cin >> edges[i].a >> edges[i].b >> edges[i].weight;
    sort(edges.begin(), edges.end());

    vector<int> leftBehind(n+1, 0);
    int ret = 0;
    for(int i = 0; i < m; ++i) {
        edge& cur = edges[i];
        if(dsu.find(cur.a, cur.b)) {
            if(cur.weight > dsu.getWeight(cur.a)) {
                ret++;
                leftBehind[dsu.root(cur.a)]++;
            }
        } else {
            int ra = dsu.root(cur.a), rb = dsu.root(cur.b);
            dsu.join(cur.a, cur.b);
            int root = dsu.root(cur.a);
            int nw = dsu.getWeight(cur.a);
            leftBehind[root] = leftBehind[ra] + leftBehind[rb];
            //watch(root);
            //watch(nw);
            //watch(leftBehind[root]);
            //watch(cur.weight);

            if(cur.weight > nw) {
                leftBehind[root]++;
                ret++;
            } else {
                ret -= leftBehind[root];
                leftBehind[root] = 0;
            }
        }
    }
    
    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 8816
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n; vl a(n); long double sum = 0;
  rep(i,n){ ll x; cin >> x; a[i] = x; }
  
  for(ll i=0; i < n; i++){
    sum += 1.0/a[i];
  }
  
  cout << fixed << setprecision(10);
  cout << 1.0/sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define MAX 100005
#define ALPHA 26
int main()
{
    int i,j,N;
    scanf("%d",&N);
    N=N%10;
    if(N==3)
    {
        printf("bon");
    }
    else if(N==0||N==1||N==6||N==8)
    {
        printf("pon");
    }
    else
    {
        printf("hon");
    }
    return 0;
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,c=0;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)
    cin>>a[i];
  for(i=0;i<n;i++)
  {
    if(a[i]!=(i+1))
      c++;
  }
  if(c==2 || c==0)
  	cout<<"YES";
  else
    cout<<"NO";
}


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

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

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
const int INF = 1001001001;
const ll mod = 1e9+7;

vector<ll>v(50);
vector<ll>a(50);

ll d(ll i,ll x){
//  cout<<i<<'i'<<x<<'x'<<endl;
  if (x<=0)return 0;
  if (i==0)return 1;
  if (x<=v[i-1]+1)return (d(i-1,x-1));
  if (x==v[i-1]+2)return (a[i-1]+1);
  if (x>v[i-1]+2)return (a[i-1]+1+d(i-1,x-v[i-1]-2));
}

int main() {
  ll n,x;
  cin>>n>>x;


  v[0]=1;
  a[0]=1;
  rep(i,n-1){
    v[i+1]=v[i]*2+3;
    a[i+1]=a[i]*2+1;
  }
cout<<d(n,x);


}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n,a[400010],l,r,mid,ans;
bool _get(int x){ return !(x<=mid);}
bool check()
{
    for (int i=1;i<=n-1;i++)
    {
        if (_get(a[n+i-1])==_get(a[n+i])) return _get(a[n+i]);
        if (_get(a[n-i+1])==_get(a[n-i])) return _get(a[n-i+1]);
    }
    return _get(a[1]);
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=2*n-1;i++) scanf("%d",&a[i]);
    l=1;r=2*n-1;
    while (l<=r)
    {
        mid=(l+r)/2;
        if (!check()) r=mid-1,ans=mid;else l=mid+1;
    }
    cout<<ans;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
  int n;
  int a=0;
  int b;
  int c;

  scanf("%d",&n);

  c=n;
  while(c!=0)
  {
    b=c%10;
    a=a*10+b;
    c/=10;
  }

  if(a==n)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int matrix[2][n];
    for (int i=0; i < 2; i++){
        for (int j=0; j < n; j++){
            cin >> matrix[i][j];
        }
    }
    int ans = 0;
    for (int i=1; i <= n; i++){
        int A = 0;
        for (int j=0; j < i; j++) A += matrix[0][j];
        for (int j=i-1; j < n; j++) A += matrix[1][j];
        ans = max(ans, A);
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef int64_t i64;

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

i64 N; cin >> N;
VI A(N); rep(i, 0, N) cin >> A[i];
sort(ALL(A));

i64 ans0 = 0, ans1 = 0;
if (N%2){
    rep(i, 0, N/2) ans0 -= 2 * A[i];
    rep(i, N/2, N/2 + 2) ans0 += A[i];
    rep(i, N/2 + 2, N) ans0 += 2 * A[i];

    rep(i, 0, N/2 - 1) ans1 -= 2 * A[i];
    rep(i, N/2 - 1, N/2 + 1) ans1 -= A[i];
    rep(i, N/2 + 1, N) ans1 += 2 * A[i];
}
else {
    ans0 = A[N/2] - A[N/2 - 1];
    rep(i, 0, N/2 - 1) ans0 -= 2 * A[i];
    rep(i, N/2 + 1, N) ans0 += 2 * A[i];
}

cout << max(ans0, ans1) << endl;

}
// 書いて考える．場合分け
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



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

int main() {
    int X, N, p, ans = 0;
    cin >> X >> N;
    bool exist[102] = {};
    for (int i = 0; i < N; i++) {
        cin >> p;
        exist[p] = true;
    }
    for (int i = 0; i <= 101; i++) {
        if (!exist[i] && abs(i - X) < abs(ans - X)) ans = i;
    }
    cout << ans << endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	if(N%K) cout<<1<<endl;
	else cout<<0<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
import re
count = {}
alphabet = list("abcdefghijklmnopqrstuvwxyz")
while True:
    try:
        s = re.sub("[^a-z]", "", input().lower())
    except:
        break
    for abc in alphabet:
        tmp = count.setdefault(abc, 0)
        count[abc] = tmp + s.count(abc)
for abc in alphabet:
    print(abc + " : " + str(count[abc]))


Measured memory_bytes: 6512
#include <iostream>
#include <vector>
#include <algorithm>

#define int long long
#define MAXN 200000

int par[MAXN];

int root(int u) {
	if(par[u] < 0)
		return u;

	return par[u] = root(par[u]);
}

void merge(int u, int v) {
	u = root(u); v = root(v);
	if(u == v)
		return;

	if(par[u] > par[v])
		u ^= v ^= u ^= v;

	par[u] += par[v];
	par[v] = u;
}

signed main() {
	int n;
	std::cin >> n;

	std::pair<int, int> helpx[n], helpy[n];

	for(int i = 0; i < n; i++) {
		par[i] = -1;
		int x, y;
		std::cin >> x >> y;
		helpx[i] = {x, i};
		helpy[i] = {y, i};
	}

	std::sort(helpx, helpx+n);
	std::sort(helpy, helpy+n);

	std::vector<std::pair<int, std::pair<int, int> > > edges;

	for(int i = 1; i < n; i++) {
		edges.push_back({helpx[i].first - helpx[i-1].first, {helpx[i].second, helpx[i-1].second}});
		edges.push_back({helpy[i].first - helpy[i-1].first, {helpy[i].second, helpy[i-1].second}});
	}

	std::sort(edges.begin(), edges.end());

	int ans = 0;
	
	for(int i = 0; i < edges.size(); i++) {
		int u = edges[i].second.first;
		int v = edges[i].second.second;
		int w = edges[i].first;

		if(root(u) != root(v))
			ans += w;

		merge(u, v);
	}

	std::cout << ans << std::endl;

	return 0;
}



Measured memory_bytes: 13104
def roop(x,y):
	num = 0
	while True:
		x = x % y
		hogex = x
		hogey = y
		y = hogex
		x = hogey
		num += 1
		if y == 0:
			return x, num
			break
		
while True:
	try:
		data = map(int, raw_input().split())
		if data[0] == 0 and data[1] == 0:
			break
		elif data[0] > data[1]:
			x = data[0]
			y = data[1]
		else:
			x = data[1]
			y = data[0]
		ans1, ans2 = roop(x,y)
		print ans1, ans2
		
	except EOFError:
		break


Measured memory_bytes: 4244
// inputに入力データ全体が入る
function Main(input) {
	var ans = 0
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.trim().split("\n")
	// var arr = input.trim().split("\n")
	// var n = input[0].split(' ').map(n => parseInt(n))
	var b = input[0]
	var f = input[1]

	for (i = 0; i < b.length; i++){
		if (b[i] != f[i]) {
			ans++
		}
	}

	//出力
	console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

Measured memory_bytes: 33004
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll w, h, x, y;
  cin>>w>>h>>x>>y;
  
  ll d= (2*x)==w && (2*y)== h;
  printf("%.6lf %lld\n", ((double)w*(double)h)/2.0, d);
  
 return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
		unsigned long long a = 2;
	unsigned long long b =  1;
	int N;
	cin >> N;
	for(int i = 0; i < N - 1; i++)
		{
			unsigned long long temp = b;
			 b = a + b;
			a = temp;
			
			
		}
	cout << b;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var num = int.Parse(Console.ReadLine());
            var cards = new int[num];
            for (int i = 0; i < num; i++)
            {
                var inputs = Console.ReadLine().Split(' ');
                cards[i] = ChangeStringToCard(inputs[0], inputs[1]);
            }
            Array.Sort(cards);
            int index = 0;
            for (int i = 1; i <= 52; i++)
            {
                if (cards[index] != i)
                {
                    if (i <= 13) Console.WriteLine("S {0}", i);
                    else if ((13 < i) && (i <= (13 * 2))) Console.WriteLine("H {0}", i - 13);
                    else if ((13*2 < i) && (i <= (13 * 3))) Console.WriteLine("C {0}", i - 13 * 2);
                    else if ((13*3 < i) && (i <= (13 * 4))) Console.WriteLine("D {0}", i - 13 * 3);
                    continue;
                }
                index++;
                if (index == cards.Length) index--;
            }
            
        }
        public static int ChangeStringToCard(string suit, string rank)
        {
            switch (suit)
            {
                case "S":
                    return int.Parse(rank);
                case "H":
                    return int.Parse(rank) + 13;
                case "C":
                    return int.Parse(rank) + 13*2;
                case "D":
                    return int.Parse(rank) + 13*3;
                default:
                    return 0;
            }
        }
    }
}

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

int main(){
    int n,q;
    cin >> n>>q;
    string s;
    cin >>s;
    vector<int> t(n);
    
    rep(i,n-1){
        if(s[i]=='A' && s[i+1]=='C'){
            t[i+1]=t[i]+1;
        }else{
            t[i+1]=t[i];
        }
    }
    rep(i,q){
        int l,r;
        cin>>l>>r;
        cout<< t[r-1]-t[l-1] <<endl;
    }
    
    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }

    int ans = 0;
    int yui = 0, ptr = 0;
    rep(i, n) {
        if (yui & data[i]) {
            while ((yui - data[ptr]) & data[i]) {
                yui -= data[ptr];
                ptr++;
            }
            yui -= data[ptr++];
        }
        yui |= data[i];
        ans += i - ptr + 1;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

void Main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int> > grids(H, vector<int>(W, 0));
    int origBlack = 0;
    for (int i = 0; i < H; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < W; ++j) {
            if (s[j] == '#') {
                grids[i][j] = 1;
                ++origBlack;
            }
            else {
                grids[i][j] = 0;
            }
        }
    }

    vector<vector<int> > arrived(H, vector<int>(W, -1));
    queue<pair<int, int> > que;
    que.push(make_pair(0, 0));
    arrived[0][0] = 0;
    while (!que.empty()) {
        auto p = que.front();
        que.pop();
        int i = p.first;
        int j = p.second;
        int minStep = arrived[i][j];
        if (i < H - 1 && grids[i + 1][j] == 0 && arrived[i + 1][j] < 0) {
            arrived[i + 1][j] = minStep + 1;
            que.push(make_pair(i + 1, j));
        }
        if (0 < i && grids[i - 1][j] == 0 && arrived[i - 1][j] < 0) {
            arrived[i - 1][j] = minStep + 1;
            que.push(make_pair(i - 1, j));
        }
        if (j < W - 1 && grids[i][j + 1] == 0 && arrived[i][j + 1] < 0) {
            arrived[i][j + 1] = minStep + 1;
            que.push(make_pair(i, j + 1));
        }
        if (0 < j && grids[i][j - 1] == 0 && arrived[i][j - 1] < 0) {
            arrived[i][j - 1] = minStep + 1;
            que.push(make_pair(i, j - 1));
        }
    }

    int minStepPath = arrived[H - 1][W - 1];
    if (minStepPath == -1) {
        cout << -1 << endl;
        return;
    }
    cout << (H * W - 1 - minStepPath - origBlack) << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>
struct Card {
  char suit[3];
  char value;
  int i;
};

void BubbleSort(struct Card[], int);
void SelectionSort(struct Card[], int);
void Stable(struct Card[], int);

int main(){
  int N, i;
  struct Card C1[36];
  struct Card C2[36];

  scanf("%d",&N);
  for( i = 0 ; i < N ; i++ ){
    scanf("%s",&C1[i].suit);
    C1[i].value = C1[i].suit[1];
    C1[i].i = i;
    C2[i] = C1[i];
  }

  BubbleSort(C1, N);
  SelectionSort(C2, N);

  printf("%s",C1[0].suit);
  for( i = 1 ; i < N ; i ++ ){
    printf(" %s",C1[i].suit);
  }
  printf("\n");

  Stable(C1, N);

  printf("%s",C2[0].suit);
  for( i = 1 ; i < N ; i ++ ){
    printf(" %s",C2[i].suit);
  }
  printf("\n");

  Stable(C2, N);

  return 0;
}

void BubbleSort(struct Card C[], int N){
  int i, j;
  struct Card tmp;
  for( i = 0 ; i < N ; i++ ){
    for( j = N-1 ; j >= i+1 ; j-- ){
      if( C[j].value < C[j-1].value ){
        tmp = C[j];
        C[j] = C[j-1];
        C[j-1] = tmp;
      }
    }
  }
}

void SelectionSort(struct Card C[], int N){
  int i, j, minj;
  struct Card tmp;
  for( i = 0 ; i < N ; i++ ){
    minj = i;
    for( j = i ; j < N ; j++ ){
      if( C[j].value < C[minj].value ) minj = j;
    }
    tmp = C[i];
    C[i] = C[minj];
    C[minj] = tmp;
  }
}

void Stable(struct Card C[], int N){
  int i, flag=0;
  for( i = 0 ; i < N-1 ; i++ ){
    if( C[i].value == C[i+1].value ){
      if( C[i].i > C[i+1].i ){
        printf("Not stable\n");
        flag = 1;
        break;
      }
    }
  }
  if( flag == 0  )printf("Stable\n");
}



Measured memory_bytes: 2128
#include<iostream>
#include<algorithm>
#include<vector>
#include <cmath>
#include <limits>
#include <iomanip>
using namespace std;
const long long INF=20000000000;

int main(){
	long long n;
	cin>>n;
	long long a[n];
	long long b[n];
	long long c[n];
	for(long long i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
	
	long long dp[n][3];
	//0:umi 1:yama 2:ie of i day
	
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(long long i=1;i<n;i++){
		for(long long j=0;j<3;j++)dp[i][j]=0;
	}
	
	for(long long i=1;i<n;i++){
		dp[i][0]=max(dp[i][0],
					max(dp[i-1][1]+a[i],
						dp[i-1][2]+a[i]));
		dp[i][1]=max(dp[i][1],
					max(dp[i-1][0]+b[i]
						,dp[i-1][2]+b[i]));
		dp[i][2]=max(dp[i][2],
					max(dp[i-1][1]+c[i],
						dp[i-1][0]+c[i]));
	}
	//n=	2;
	//cout<<dp[1][0]<<dp[1][1]<<dp[1][2]<<endl;
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}


Measured memory_bytes: 4992
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1000000007;

int main() {
  ll n;
  cin >> n;
  dqll l;
  rep(i, n) {
    ll t;
    cin >> t;
    l.push_back(t);
  }
  Sort(l);

  dqll lcp = l;

  ll ans = 0;
  ll m = l.front();
  l.pop_front();
  ll pr = m, pl = m;
  ll turn = 0;
  while (!l.empty()) {
    if(l.size() == 1){
      ans += max(abs(pr - l.front()), abs(pl - l.front()));
      break;
    }
    if(turn == 0){
      ans += abs(pr - l.back());
      pr = l.back();
      l.pop_back();
      ans += abs(pl - l.back());
      pl = l.back();
      l.pop_back();
    } else {
      ans += abs(pr - l.front());
      pr = l.front();
      l.pop_front();
      ans += abs(pl - l.front());
      pl = l.front();
      l.pop_front();
    }
    turn = 1 - turn;
    //cout << ans << endl;
  }

  ll ansb = 0;
  m = lcp.back();
  lcp.pop_back();
  pr = m, pl = m;
  turn = 1;
  while (!lcp.empty()) {
    if(lcp.size() == 1){
      ansb += max(abs(pr - lcp.front()), abs(pl - lcp.front()));
      break;
    }
    if(turn == 0){
      ansb += abs(pr - lcp.back());
      pr = lcp.back();
      lcp.pop_back();
      ansb += abs(pl - lcp.back());
      pl = lcp.back();
      lcp.pop_back();
    } else {
      ansb += abs(pr - lcp.front());
      pr = lcp.front();
      lcp.pop_front();
      ansb += abs(pl - lcp.front());
      pl = lcp.front();
      lcp.pop_front();
    }
    turn = 1 - turn;
    //cout << ans << endl;
  }


  cout << max(ans, ansb) << endl;

  return 0;
}


Measured memory_bytes: 1920
<?php
  
//学習用 / 自作コードではありません
  
$n = trim(fgets(STDIN));
 
$list = explode(" ", trim(fgets(STDIN)));
if($n == 2){
    echo max($list);
    exit;
}

$left[0] = $list[0];
for($i=1;$i<$n;$i++){
    $left[$i]=gcd($left[$i-1], $list[$i]);
}

$right[$n-1] = $list[$n-1];
for($i=$n-2;$i>=0;$i--){
    $right[$i]=gcd($right[$i+1], $list[$i]);
}

$ans = max($right[1], $left[$n-2]);
for($i=0;$i<$n-2;$i++){
    $ans = max($ans, gcd($left[$i], $right[$i+2]));
}

echo $ans;
function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
 
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}

Measured memory_bytes: 23280
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
		int N,R=1;
    	cin >> N;
		string S;
    	cin >> S;
    	for(int i=0; i<N-1; i++){
    		if (S.at(i) != S.at(i+1)){
    			R++;
    		}
    	}
    	cout << R << endl;
    }

Measured memory_bytes: 512
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons, std.format;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}



void main() {
  auto cin = new Scanner;
  int n = cin.next!int;
  int[] v = cin.nextArray!int(n);
  int[] c = cin.nextArray!int(n);


  int res = int.min;
  foreach (i; 0 .. 1 << n) {
    int vs, cs;
    foreach (j; 0 .. n) {
      if (i & (1 << j)) {
        vs += v[j];
        cs += c[j];
      }
    }
    res = max(res, vs - cs);
  }
  res.writeln;
}


Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Array.Sort(input);
            if (input[0] + input[1] == input[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{ 
  int N;cin>>N;
  int MAX = 0;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
     chmax(MAX,vec[i]);
  }
  int P = INF;
  int R = -1;
  int H = MAX/2;
  for (int i = 0; i < N; i++)
  {
    if(P > abs(vec[i] - H)&&vec[i] != MAX)
    {
      P = abs(vec[i] - H);
      R = vec[i];
    }
  }
  
  cout<<MAX<<" "<<R<<endl;
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3992
#include <stdio.h>
 
int main(void)
{
    int H, W, i, j;
 


    while(1){
    scanf("%d %d", &H, &W);
        if(H!=0 || W!=0){
            for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                    printf("#");
                }
            printf("\n");
            }
            printf("\n");
            }
        else{
            break;
        }
    }
    return 0;
}  

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

typedef long long ll;

const ll MOD=1e9+7;
const ll MAX=1e6+5;

ll fac[MAX+5],inv_fac[MAX+5];

ll qpow(ll x, ll n)
{
    ll res = 1;
    while(n)
    {
        if(n & 1)
            res = (res * x) % MOD;
        x = (x * x) % MOD;
        n >>= 1;
    }
    return res;
}

void pre()
{
    fac[0] = 1;
    for(ll i = 1; i <= MAX; i++)
        fac[i] = (fac[i - 1] * i) % MOD;
    inv_fac[MAX] = qpow(fac[MAX], MOD - 2);
    for(ll i = MAX - 1; i >= 0; i--)
        inv_fac[i] = (inv_fac[i + 1] * (i + 1)) % MOD;
}



int main()
{
    ll x,y;
    cin>>x>>y;
    ll ans=0;

    if((2*y-x)%3||(2*x-y)%3||(2*y-x)<0||(2*x-y)<0) ans=0;
    else
    {
        pre();
        ll m=(2*y-x)/3,n=(2*x-y)/3;
        ans=1;
        for(ll i=(m+1);i<=(m+n);i++)
            ans=ans*i%MOD;
        ans=ans*inv_fac[n]%MOD;

    }
    cout<<ans%MOD;
}


Measured memory_bytes: 15872