akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
		using namespace std;
		#define int long long int
		#define loop(i,a,b) for(int i=a;i<b;i++)
		#define scan(arr,n) for (int i = 0; i < n; ++i) cin >> arr[i]
		#define vi vector<int>
		#define si set<int>
		#define pii pair <int, int>
		#define sii set<pii>
		#define vii vector<pii>
		#define mii map <int, int>
		#define pb push_back
		#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
		//Constants
		const int MOD = 1000000007; /* 1e9 + 7*/
		const int MAXN = 1000005; /*1e6 +5 */
		 
		int spf[1000009]; // stores the smallest prime factor of a number
		 
		void sieve()
		{
		spf[1] = 1;
			for (int i=2; i<MAXN; i++)
				spf[i] = i;
			for (int i=4; i<MAXN; i+=2)
				spf[i] = 2;
		 
			for (int i=3; i*i<MAXN; i++)
				if (spf[i] == i)
				{
					for (int j=i*i; j<MAXN; j+=i)
						if (spf[j]==j)
							spf[j] = i;
				}
			}
		
		 
		/* Iterative Function to calculate (x^y)%p in O(log y) */
		int power(int x,  int y, int p)
		{
			int res = 1;     // Initialize result
			x = x % p; // Update x if it is more than or
						// equal to p 
			if (x == 0) return 0; // In case x is divisible by p;     
			while (y > 0)
			{
				// If y is odd, multiply x with result
				if (y & 1)
					res = (res*x) % p;     
				// y must be even now
				y = y>>1; // y = y/2
				x = (x*x) % p;
			}
			return res;
		}
		
		 
		void solve()
		{
			int h,w,m;
			cin>>h>>w>>m;
			mii mp,mp1;
			//int cp=m;
			vi v1,v2;
			sii s;
			while(m--)
			{
				int x,y;
				cin>>x>>y;
				mp[x]++;
				mp1[y]++;
				v1.pb(x);v2.pb(y);
				s.insert({x,y});
				
			}
			mii ::iterator it;
			int pos=-1,pos1=-1;
			int maxm=-1,maxm1=-1;
			for(it=mp.begin();it!=mp.end();it++)
			{
				if(it->second>maxm)
				{
					maxm=it->second;
					pos=it->first;
				}
			}
			for(it=mp1.begin();it!=mp1.end();it++)
			{
				if(it->second>maxm1)
				{
					maxm1=it->second;
					pos1=it->first;
				}
			}
			vi row , col;
			
			for(it=mp.begin();it!=mp.end();it++)
			{
				if(it->second==maxm)
				row.pb(it->first);
			}
			
			for(it=mp1.begin();it!=mp1.end();it++)
			{
				if(it->second==maxm1)
				col.pb(it->first);
			}
			//int max=-1;
			/*for(auto x:row)
			cout<<x<<" ";
			cout<<endl;
			for(auto x:col)
			cout<<x<<" ";
			cout<<endl;
			cout<<maxm<<endl;
			cout<<maxm1<<endl;*/
			int ans=maxm+maxm1-1;
			for(int i=0;i<row.size();i++)
			{
				int flag=0;
				for(int j=0;j<col.size();j++)
				{
					
					auto ite=s.find({row[i],col[j]});
					if(ite==s.end())
					{
				
					ans=maxm+maxm1;
					flag=1;
					break;
				}
				}
				if(flag==1)
				break;
			}
			cout<<ans<<endl;
		}

		 
		int32_t main()
		{
			faster;
			/*sieve();*/
		   // compute();
		  // int t;cin>>t;
		 int t=1;
			while(t--)
			solve();
			
/*4 4 6
1 1
1 4
4 1
4 4
2 2
2 3*/		
		 
		 
			return 0;
		}


Measured memory_bytes: 72484
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef set<ii> sii;
typedef set<int> si;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;

const int INF = 1000000010;
const ll MOD = 1000000007;

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

int N = 1000000;
vi pr;

bool fact(int n, vi &fp) {
	si p;
	while (pr[n] != -1) {
		if (p.find(pr[n]) == p.end()) {
			fp[pr[n]]++;
			if (fp[pr[n]] > 1) 
				return true;
			p.insert(pr[n]);
		}
		n /= pr[n];
	}
	if (p.find(n) == p.end()) {
		fp[n]++;
		if (fp[n] > 1) 
			return true;
		p.insert(n);
	}
	return false;
}

int main() {FIN
	
	int n, i, j, _gcd = 0;
	cin >> n;
	vi ns(n);
	for (i = 0; i < n; i++) {
		cin >> ns[i];
		if (i == 1)
			_gcd = gcd(ns[i-1], ns[i]);
		else if (i > 1)
			_gcd = gcd(_gcd, ns[i]);
	}
	
	if (_gcd > 1) cout << "not coprime\n";
	else {
		pr = vi(N+1,-1);
		vi fp(N+1, 0);
		for (i = 4; i <= N; i += 2) pr[i] = 2;
		for (i = 3; i*i <= N; i += 2) {
			if (pr[i] == -1) {
				for (j = i*i; j <= N; j += 2*i)
					pr[j] = i;
			}
		}
		
		bool is = false, r;
		for (i = 0; i < n; i++) {
			if (ns[i] > 1) {
				r = fact(ns[i], fp);
				if (r) {
					is = true;
					break;
				}
			}
		}
		if (is) 
			cout << "setwise coprime\n";
		else
			cout << "pairwise coprime\n";
	}
	
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int n,m;cin>>n>>m;
  std::vector<ll> a(n),b(n),c(m),d(m);
  for(int i=0;i<n;i++) cin>>a[i]>>b[i];
  for(int i=0;i<m;i++) cin>>c[i]>>d[i];
  for(int i=0;i<n;i++){
      ll num,mi=INF;
      for(int j=0;j<m;j++){
          ll tmp=abs(a[i]-c[j])+abs(b[i]-d[j]);
          if(tmp<mi){
              num=j+1;
              mi=tmp;
          }
      }
      cout<<num<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b; cin >> a >> b;
    if (a <= 8 && b <= 8)
    {
        cout << "Yay!\n";
    } else {
        cout << ":(\n";
    }
    return 0;
}

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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 305;

int n, m, ans, f[N][N][N];
char s[N];

inline int Solve(int l, int r, int k) {
  if (l >= r) {
    return r - l + 1;
  }
  if (f[l][r][k]) {
    return f[l][r][k];
  }
  f[l][r][k] = max(Solve(l + 1, r, k), Solve(l, r - 1, k));
  if (s[l] == s[r]) {
    CheckMax(f[l][r][k], Solve(l + 1, r - 1, k) + 2);
  } else if (k) {
    CheckMax(f[l][r][k], Solve(l + 1, r - 1, k - 1) + 2);
  }
  return f[l][r][k];
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  scanf("%s", s + 1), n = strlen(s + 1), Read(m);
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      CheckMax(ans, Solve(i, j, m));
    }
  }
  printf("%d\n", ans);
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 110464
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
#define PI 3.1415926535

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}

char upper(char c){
    if('a' <= c && c <= 'z'){
        c = c - ('a' - 'A');
    }
    return c;
}

char lower(char c){
    if('A' <= c && c <= 'Z'){
        c = c + ('a' - 'A');
    }
    return c;
}

const ll INF = 1000000000000000000;

//input



//processing



//dpTable
//int dp[100050];

int main(){
    int X,Y;
    cin >> X >> Y;
    if (Y % 2 == 1){
        cout << "No" << endl;
    }
    else {
        if (2 * X <= Y && 4 * X >= Y){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

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

int N, A, B, X[100005];

int main() {
	scanf("%d%d%d", &N, &A, &B);
	for (int i = 0; i < N; i++) scanf("%d", &X[i]);
	long long ans = 0;
	for (int i = 1; i < N; i++) ans += min((long long)A * (X[i] - X[i - 1]), (long long)B);
	printf("%lld\n", ans);
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


void solve() {
    int m, n, a, b;
    cin >> m >> n >> a >> b;
    vector<vector<int> > d(m, vector<int>(n, 1));
    for (int i = 0; i < b; ++i) {
        for (int j = 0; j < a; ++j) {
            d[i][j] = 0;
        }
    }
    for (int i = b; i < m; ++i) {
        for (int j = a; j < n; ++j) {
            d[i][j] = 0;
        }
    }
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j)
            cout << d[i][j];
        cout << "\n";
    }

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //fclose(stderr);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 5248
ans = [0, 0]
while  True:
    try:
        a, b, c = map(int, input().split(','))
    except:
        break
    if a**2 + b**2 == c**2:
        ans[0] += 1
    if a == b:
        ans[1] += 1
print(*ans, sep="\n")

Measured memory_bytes: 7592
#include<stdio.h>
#include<string.h>
 
#define M 1000003
#define L 14
 
char H[M][L]; /* Hash Table */
 
int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}
 
/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
 
int h1(int key){ return key%M; }
int h2(int key){ return 1+key%(M-1); }
 
int find(char str[]){
  int i=0,j,ke=getKey(str);
  while(1){
    j=(h1(ke)+h2(ke)*i)%M;
    if(strcmp(H[j],str)==0){
      return 1;
    }
    else i++;
    if(i==M||H[j][0]=='\0') break;
     
  }
  return 0;
   
   
   
}
 
int insert(char str[]){
  int j,i=0,ke=getKey(str);
  while(1){
    j=(h1(ke)+h2(ke)*i)%M;
    if(H[j][0]=='\0'){
       
      strcpy(H[j],str);
      return j;
    }
    else i++;
     
    if(i==M)break;
  }
}
 
int main(){
  int i, n  ;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
   
  scanf("%d", &n);
     
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
     
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)==1){
        printf("yes\n");
      } else {
        printf("no\n");
        }
    }
  }
   
  return 0;
}

Measured memory_bytes: 14280
import fractions
import functools

def main():
    N, X = map(int, input().split())
    x = [X] + list(map(int, input().split()))
 
    sort_x = sorted(x)
    diff = [0] * N
    for i in range(N):
        diff[i] = sort_x[i + 1] - sort_x[i]

    ans = functools.reduce(fractions.gcd, diff)

    print(ans)

    


main()

Measured memory_bytes: 88172
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
// http://drken1215.hatenablog.com/entry/2019/01/14/033200
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    vector<int> B(M);
    REP(i, N) { cin >> A[i]; }
    REP(i, M) { cin >> B[i]; }
    A.push_back(0);
    B.push_back(0);
    // N行M列
    //重複がない
    sort(A.begin(), A.end(), greater<int>());
    sort(B.begin(), B.end(), greater<int>());
    ll res = 1;
    // A, B でXより大きいのが何個有るのか
    int biggerX_a = 0;
    int biggerX_b = 0;
    // 各マスに何が入りうるのかを考える
    // 各数字がどこのマスに入りうるのかを考える
    for(int x = N * M; x >= 1; x--) {
        ll tmp = 1;
        if(A[biggerX_a] == x and B[biggerX_b] == x) {
            //一意にきまる
            tmp = 1;
            biggerX_a++;
            biggerX_b++;
        } else if(A[biggerX_a] == x) {
            tmp = biggerX_b;
            biggerX_a++;
        } else if(B[biggerX_b] == x) {
            tmp = biggerX_a;
            biggerX_b++;
        } else {
            tmp = biggerX_a * biggerX_b - (N * M - x);
            if(tmp < 0) {
                cout << 0 << endl;
                return 0;
            }
        }
        res = (res * tmp) % MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    input = input.split(" ");
  	for(let i=0; i < input.length; i++){
      	input[i].replace("\n","");
    	if(input[i] == 0){
        	console.log(i+1);
        }
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29596
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		for(int j=1; j<=9; j++)
			for(int i=1; i<=9; i++)
				println(j+"x"+i+"="+j*i);
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : (x))
#define all(x) x.begin(), x.end() // sort(all(x))
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair((x), (y))

typedef long long ll;

typedef double T;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<T> vt;
typedef vector<vt> vvt;
typedef vector<pii> vpi;
typedef vector<pii> vpl;
typedef vector<vpi> graph;
typedef complex<T> Pt;
typedef pair<Pt, Pt> Line;

const ll MOD = 1e9 + 7; // 998244353;
const T EPS = 1e-10;
const int INF = 1e9 + 1;

/* Mod Library */

struct Mod {
    ll x;
    Mod (ll x = 0) : x(x) {}
    Mod operator+(Mod b) { return Mod((x + b.x)%MOD); }
    Mod operator-(Mod b) { return Mod((x - b.x + MOD)%MOD); }
    Mod operator*(Mod b) { return Mod((x * b.x)%MOD); }
    Mod operator/(Mod b) { return *this * inverse(b); }
    Mod operator%(Mod b) { return Mod(x % b.x); }

    static ll euclid(ll a, ll b, ll &x, ll &y) {
        if (b) {
            ll d = euclid(b, a%b, y, x);
            y -= a/b*x;
            return d;
        }
        x = 1; 
        y = 0;
        return a;
    }
    
    Mod inverse(Mod a) {
        ll x, y, g = euclid(a.x, MOD, x, y);
        assert(g == 1);
        return Mod((x + MOD)%MOD);
    }

    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this^(e/2);
        r = r*r;
        return e&1 ? *this*r : r;
    }
};

/* Input Library */
template <typename A, typename B>
istream& operator>>(istream &in, pair<A, B> &p) {
    in >> p.first >> p.second;
    return in;
}

template <typename A, typename B>
ostream& operator<<(ostream &out, pair<A, B> &p) {
    out << p.first << " " << p.second;
    return out;
}

template <typename I>
istream& operator>>(istream &in, vector<I> &a) {
    trav(i, a) in >> i;
    return in;
}

template <typename I>
ostream& operator<<(ostream &out, vector<I> &a) {
    rep(i, 0, sz(a)) {
        if (i) out << " ";
        out << a[i];
    }
    return out;
}

void fast_io() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    //cout.tie(0);
    cin.exceptions(cin.failbit);
} 

void solve_test() {
  int n, k;
  cin >> n >> k;
  vi a(n);
  cin >> a;

  for (int i = 0; i < k; ++i) {
    int min_el = n;
    for (auto &el : a) min_el = min(min_el, el);
    if (min_el == n) {
      break;
    }

    vector<int> diff(n+1, 0); 
    for (int j = 0; j < n; ++j) {
      int lo = max(0, j - a[j]);
      int hi = min(n, j + a[j] + 1);
      diff[lo]++;
      diff[hi]--;
    }
    int tot = 0;
    for (int j = 0; j < n; ++j) {
      tot += diff[j];
      a[j] = tot;
    }
  }
  cout << a << endl;
}

void setup() {
}

int main() {
    setup();
    srand(time(0));
    fast_io();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve_test();
    }
}


Measured memory_bytes: 4940
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i, n) FOR(i,0,n)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = INF + 7;

int N;
map<int,int> pf[1001];
map<int,int> prime_factor(int n){
    map<int,int> res;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if(n!=1) res[n] = 1;
    return res;
}

void solve(){
    ll res = 1;
    FOR(i,1,N+1){
        pf[i] = prime_factor(i);
    }
    FOR(i,2,N+1){
        ll cur_num = 0;
        FOR(j,1,N+1){
            cur_num +=pf[j][i];
        }
//        cout << i << ":" << cur_num << "\n";
        res *= cur_num+1;
        res %= MOD;
    }
    cout << res << "\n";

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    solve();
    return 0;
}

Measured memory_bytes: 47104
#include <iostream>
#include <cmath>
#include <string>
#include <utility>
using namespace std;
typedef long long int ll;

template<class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

const ll INF = 1LL << 60;

int main() {
  int N, h[100010];
  ll dp[100010];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> h[i];
  for (int i = 0; i < N; i++) dp[i] = INF;
  dp[0] = 0;
  for (int i = 0; i <= N; i++) {
    chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
    chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned ll;
using ld = long double;
using pll = pair<ll, ll>;
using pss = pair<string, string>;
using pdd = pair<ld, ld>;
using graph = vector<vector<int>>;

const ll MOD = 1000000007;
const ld EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ex[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ey[8] = {0, 1, 1, 1, 0, -1, -1, -1};

template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }

ll intabs(ll a)
{
    if (a >= 0)
        return a;
    else
        return -a;
}

ll intpow(ll a, ll b, ll p = LLONG_MAX)
{
    ll ret = 1;
    while (b != 0)
    {
        if ((b & 1) == 1)
            ret *= a;
        a *= a;
        if (a >= p)
            a %= p;
        if (ret >= p)
            ret %= p;
        b = b >> 1;
    }
    return ret;
}

int digit(ll a, ll b = 10)
{
    int ret = 0;
    while (a != 0)
    {
        a /= b;
        ret++;
    }
    return ret;
}

ll gcd(ll x, ll y)
{
    while (y != 0)
    {
        ll cnt = x % y;
        x = y;
        y = cnt;
    }
    return x;
}

ll modinv(ll a, ll m)
{
    ll b = m, u = 1, v = 0;
    while (b)
    {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

class UnionFind
{
    vector<int> par, sz;

public:
    UnionFind(int n) : par(n), sz(n)
    {
        for (int i = 0; i < n; i++)
        {
            par[i] = i;
            sz[i] = 1;
        }
    }
    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
        sz[ry] += sz[rx];
    }
    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
    int size(int x)
    {
        return sz[root(x)];
    }
};

int main()
{
    int i, j, k, cnt;
    ll n, c;
    cin >> n >> c;
    ll x[n + 1], v[n + 1];
    x[0] = 0;
    v[0] = 0;
    for (i = 1; i <= n; i++)
    {
        cin >> x[i] >> v[i];
    }
    ll s[n + 1], rs[n + 1];
    s[0] = 0;
    rs[0] = 0;
    for (i = 1; i <= n; i++)
    {
        s[i] = s[i - 1] + v[i];
        rs[i] = rs[i - 1] + v[n - i + 1];
    }
    ll ms[n + 1], ms2[n + 1], mrs[n + 1], mrs2[n + 1];
    ms[0] = 0;
    ms2[0] = 0;
    mrs[0] = 0;
    mrs2[0] = 0;
    for (i = 1; i <= n; i++)
    {
        ms[i] = max(ms[i - 1], s[i] - x[i]);
        ms2[i] = max(ms2[i - 1], s[i] - 2 * x[i]);
        mrs[i] = max(mrs[i - 1], rs[i] - (c - x[n - i + 1]));
        mrs2[i] = max(mrs2[i - 1], rs[i] - 2 * (c - x[n - i + 1]));
    }
    ll ans = 0;
    for (i = 0; i <= n; i++)
    {
        chmax(ans, max(ms[i] + mrs2[n - i], ms2[i] + mrs[n - i]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 6528
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val monsterHP = sc.nextInt()
    val araigumaAttackKinds = sc.nextInt()
    val araigumaAttackPoints = Array.fill(araigumaAttackKinds)(sc.nextInt())

    val attackPointSum = araigumaAttackPoints.sum

    val ans = if (attackPointSum >= monsterHP) "Yes" else "No"

    println(ans)
  }
}


Measured memory_bytes: 52172
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int n;
int a[10];

int main(int argc, char const* argv[])
{
	cin >> n;
	for(int i = 0; i < n; i++){
			for(int j = 0; j < 10; j++){
					cin >> a[j];
			}
			int l = 0;
			int r = 0;
			bool flag = true;
			for(int j = 0; j < 10; j++){
					if(!flag)break;
					if(a[j] <= l && a[j] <= r){
							flag = false;
					}else if(a[j] <= l && a[j] > r){
							r = a[j];
					}else if(a[j] > l && a[j] <= r){
							l = a[j];
					}else{
							if(l > r){
									l = a[j];
							}else{
									r = a[j];
							}
					}
			}
			if(!flag)cout << "NO" << endl;
			else cout << "YES" << endl;
	}
	return 0;
}



Measured memory_bytes: 2984
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<ll> A;
vector<ll> S;

map<ll, ll> counter;

int main(void) {
    ll N, K;
    cin >> N >> K;

    A.resize(N + 1, 0);
    S.resize(N + 1, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i + 1];
        S[i + 1] = S[i] + A[i + 1];
    }

    ll acc = 0;
    for (int i = 0; i <= N; i++) {
        ll x = (S[i] - i) % K;
        // printf("i: %d, S[i]: %lld, x: %lld\n", i, S[i], x);
        if (i - K >= 0) {
            ll y = (S[i - K] - (i - K)) % K;
            counter[y]--;
        }
        acc += counter[x];
        counter[x]++;
    }

    cout << acc << endl;

    return 0;
}


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

int main(void) {
    int n;
    long long int ans = 1, div = 1000000007;
    cin >> n;
    vector<int> a, b;
    for(int i = 0; i < n; i++) {
        int in;
        cin >> in;
        a.push_back(in);
        b.push_back(abs((n-i-1) - i));
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    if(a != b){
        cout << "0" << endl;
        return 0;
    }

    for(int i = 0; i < n/2; i++) {
        ans = ans*2%div;
    }

    cout << ans << endl;


    return 0;
}

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

const bool DEBUG = false;

int main(int argc, char const *argv[]) {
  double a, b, x;
  cin >> a >> b >> x;
  x /= a;  // 2次元で考える
  double c = 2.0 / a * x - b;
  if (c > 0) {
    double d = b - c;
    double theta_rad = M_PI / 2.0 - atan(a / d);

    cout << setprecision(10) << theta_rad * 180.0 / M_PI << endl;
  } else {
    c = 2.0 * x / b;
    double theta_rad = atan(b / c);
    cout << setprecision(10) << theta_rad * 180.0 / M_PI << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int nums[50],tnums[50],i,j,n,count=0,temp;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&nums[i]);
    }
    memcpy(tnums,nums,sizeof(nums));

    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            if(nums[i]>nums[j]){
                temp = nums[j];
                nums[j] = nums[i];
                nums[i] = temp;
            }
        }
    }
    for(i=0;i<n;i++){
        if(tnums[i]!=nums[i]){
            count++;
        }
    }
    if(count>2){
        printf("NO");
    }else{
        printf("YES");
    }
}

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

int main()
{
	int h, w;
	int s_state[10][10000];

	int cnt,sum,ans;

	int i, j, k;

	while ( (cin >> h >> w) , h)
	{
		for (i = 0; i < h; i++)
		{
			for (j = 0; j < w; j++)
			{
				cin >> s_state[i][j];
			}
		}

		ans = 0;

		for (k = 0; k < (1 << h); k++)
		{
			sum = 0;
			for (i = 0; i < w; i++)
			{
				cnt = 0;
				for (j = 0; j < h; j++)
				{
					cnt += s_state[j][i]^(k>>j&1) ;
				}
				sum += max(cnt, h - cnt);
			}
			ans = max(ans, sum);
		}

		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3472
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int N,K;cin>>N>>K;
    bool have[N];
    REP(i,N)have[i]=false;
    REP(i,K){
        int a;cin>>a;
        REP(j,a){
            int b;cin>>b;b--;
            have[b]=true;
        }
    }
    int ans=0;
    REP(i,N){
        if(!have[i])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define P pair<ll,ll>
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S>
void print(vector<S> &v){
	for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

int main(){
	int a,b,c,d,e; cin >> c >> d >> a >> b >> e;
	cout << max(0, a*60 + b - c*60 - d - e) << endl;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int yoko[1002][102];
int n,m,a,h,p,q,maxm;
int main(){
	while(1){
		cin >> n>>m >>a;
		if(!(n||m||a))break;
		for(int i=1;i<=1001;i++){
			for(int j=1;j<=101;j++){
				yoko[i][j]=0;
			}
		}
		maxm=0;
		for(int i=0;i<m;i++){
			cin>>h>>p >>q;
			yoko[h][p]=1;
			if(maxm<h)maxm=h;
		}
		for(int i=maxm;i>0;i--){
			if(yoko[i][a]==1){
				a++;
			}else if(yoko[i][a-1]==1){
				a--;
			}
		}
		cout <<a<<endl;
	}
}

Measured memory_bytes: 3488
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
struct CITY{
  vector<int> to;
  vector<int> pay;
  int cost;
  bool done;
};
int main(){
  int n,m,a,b,c,d,x,y,z,w,ans_cost=0;
  CITY vil[30];
  cin >>n>>m;
  for(int i=0; i<m; i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    vil[a-1].to.push_back(b-1);
    vil[a-1].pay.push_back(c);
    vil[b-1].to.push_back(a-1);
    vil[b-1].pay.push_back(d);
  }
  scanf("%d,%d,%d,%d",&x,&y,&z,&w);
  x--;y--;
    for(int i=0; i<n; i++){vil[i].cost = 999999;vil[i].done = false;}
  vil[x].cost = 0;
  for(int j=0; j<n; j++){
    int r = 0,p = 9999999;
    for(int i=0; i<n; i++){
      if(!vil[i].done){if(vil[i].cost<p){p = vil[i].cost;r = i;}}
    }
    vil[r].done = true;
    for(int i=0; i<vil[r].to.size(); i++){
      vil[vil[r].to[i]].cost = min(vil[vil[r].to[i]].cost,vil[r].cost+vil[r].pay[i]);
    }
  }
  ans_cost+=vil[y].cost;
    for(int i=0; i<n; i++){vil[i].cost = 999999;vil[i].done = false;}
  vil[y].cost = 0;
  for(int j=0; j<n; j++){
    int r = 0,p = 9999999;
    for(int i=0; i<n; i++){
      if(!vil[i].done){if(vil[i].cost<p){p = vil[i].cost;r = i;}}
    }
    vil[r].done = true;
    for(int i=0; i<vil[r].to.size(); i++){
      vil[vil[r].to[i]].cost = min(vil[vil[r].to[i]].cost,vil[r].cost+vil[r].pay[i]);
    }
  }
  ans_cost+=vil[x].cost;
  cout <<z-w-ans_cost<<endl;
  return 0;
}

Measured memory_bytes: 1264
S = input()
N = len(S) + 1

tmp = S[0]
cnt = 0
cnt2 = 0
l = []
for i in range(N-1):
    if S[i] == tmp:
        cnt += 1
    else:
        tmp = S[i]
        l.append(cnt)
        cnt = 1

else:
    l.append(cnt)


if S[0] == '>':
    l = [1] + l    
if len(l) % 2 == 1:
    l.append(1)

ans = 0    
for i in range(0, len(l), 2):
    a, b = max(l[i], l[i+1]), min(l[i], l[i+1])
    ans += ((a * (a+1)) //2) + ((b * (b-1)) //2)

print(ans)    

Measured memory_bytes: 8220
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 30

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

    int n; cin >> n;
    vector<tuple<ll,ll,ll>> v;

    REP(i,n){
        ll a,b; cin >> a >> b;
        v.push_back(make_tuple(a+b, a, b));
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    ll score = 0;
    REP(i,n){
        if(i%2==0) score+=get<1>(v[i]);
        else score-=get<2>(v[i]);
    }

    cout << score << endl;

    return 0;
}


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

int main() {
double n; cin >> n;
double ret = 100000;
for(int i=0; i<n; i++) {
ret *= 1.05;
ret /= 1000;
ret = ceil(ret) * 1000;
}
cout << (int)ret << endl;
return 0;
}

Measured memory_bytes: 1224
q, h, s, d = map(int, input().split())
n = int(input())
h = min(h, q * 2)
s = min(s, h * 2)
if (d > s * 2):
  print(n * s)
elif (n % 2):
  print((n // 2) * d + s)
else:
  print((n // 2) * d)

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int memo[210][210] = {};
    auto calc = [&](auto func,int a,int b){
        if(memo[a][b] != 0)return memo[a][b];
        return b ? memo[b][a] = memo[a][b] = func(func,b,a%b) : memo[b][a] = memo[a][b] = a ;
    };

    int k;cin >> k;
    ll ans = 0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                    ans += calc(calc, calc(calc,a,b), c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3836
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

ll aa[205][205];
long  arr[10];

int main(int argc, char* argv[])
{
    long n,m,r;
    scanf("%ld%ld%ld", &n, &m, &r);

    long rr[205]={0};
    long i,j;
    for(i=0; i<r; i++) {
        scanf("%ld", &rr[i]);
        rr[i]--;
    }

    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
            aa[i][j] = (i==j? 0: MOD);
        }
    }

    for(i=0; i<m; i++) {
        long a,b,c;
        scanf("%ld%ld%ld", &a, &b, &c);
        aa[a-1][b-1]=c;
        aa[b-1][a-1]=c;
    }

    long k;
    for(k=0; k<n; k++){
        for(i=0; i<n; i++) {
            for(j=0; j<n; j++) {
                aa[i][j] = MIN(aa[i][j], aa[i][k] + aa[k][j]);
            }
        }
    }

    ll min0=MOD;

    for(i=0; i<r; i++) {
        arr[i]=i;
    }
    do {
        ll sum=0;
        for(i=0; i<r-1; i++) {
            sum += aa[rr[arr[i]]][rr[arr[i+1]]];
        }
        min0 = MIN(min0, sum);
     
    } while(next_permutation(arr+0, arr+r));

    printf("%lld\n", min0);
  
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    int i, n, m, sum, hit;

    while (EOF != scanf(" %d", &n)) {
        if (n == 0) {
            break;
        }

        sum = 0;
        m = n / 4;

        for (i = 0; i < m; i++) {
            scanf(" %d", &hit);
            sum += hit;
        }
        printf("%d\n", sum);
    }

    return 0;
}

Measured memory_bytes: 600
import java.util.*;
import java.awt.geom.*;
import java.io.*;

public class Main{
	int INF = 1 << 24;
	int [] vx = {0,1,0,-1};
	int [] vy = {-1,0,1,0};
	
	class State implements Comparable<State>{
		int x,y,dir,cost;

		public State(int x, int y,int dir, int cost) {
			this.x = x;
			this.y = y;
			this.dir = dir;
			this.cost = cost;
		}

		@Override
		public int compareTo(State o) {
			return this.cost - o.cost;
		}

		@Override
		public String toString() {
			return "State [x=" + x + ", y=" + y + ", dir=" + dir + ", cost="
					+ cost + "]";
		}
		
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if((w|h) == 0) break;
			int [][] data = new int[h][w];
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					data[i][j] = sc.nextInt();
				}
			}
			int [] costT = new int[4];
			for(int i = 0; i < 4; i++){
				costT[i] = sc.nextInt();
			}
			
			PriorityQueue<State> open = new PriorityQueue<Main.State>();
			open.add(new State(0, 0, 1, 0));
			int [][][] close = new int[h][w][4];
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w;j++){
					Arrays.fill(close[i][j], INF);
				}
			}
			close[0][0][1] = 0;
			int ans = -1;
			while(! open.isEmpty()){
				State now = open.poll();
				if(now.x == w - 1 && now.y == h - 1){
					ans = now.cost;
					break;
				}
				
				int sign = data[now.y][now.x];
				for(int i = 0; i < 4; i++){
					int ndir = (now.dir + i) % 4;
					int xx = now.x + vx[ndir];
					int yy = now.y + vy[ndir];
					if(isOK(xx,yy, w,h)){
						int nextcost = now.cost;
						if(sign != i){
							nextcost += costT[i];
						}
						if(close[yy][xx][ndir] <= nextcost) continue;
						open.add(new State(xx, yy, ndir, nextcost));
						close[yy][xx][ndir] = nextcost;
					}
					
				}
			}
			System.out.println(ans);
		}
		
	}
	private boolean isOK(int xx, int yy, int w, int h) {
		return (0 <= xx && xx < w && 0 <= yy && yy < h);
	}
	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 49488
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-09 20:13:15
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

template <class T>
class CumulativeSum {
 public:
  CumulativeSum(const std::vector<T>& vec) : vec_(vec) { Build(); }

  // return sum of [left, right]
  T Get(int left, int right) {
    return sum_[right + 1] - sum_[left];    
  }

 private:
  std::vector<T> vec_;
  std::vector<T> sum_;

  void Build() {
    sum_.assign(vec_.size() + 1, static_cast<T>(0));
    for (size_t i = 0; i < vec_.size(); ++i) {
      sum_[i + 1] = sum_[i] + vec_[i];
    }
  }
};

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

  int n, k; cin >> n >> k;
  vector<double> p(n); cin >> p;
  debug(p);

  CumulativeSum<double> cs(p);

  double ans = -1;

  for (int i = 0; i < n - k + 1; ++i) {
    ans = max(ans, cs.Get(i, i + k - 1) * 0.5 + 0.5 * k);
  }

  cout << setprecision(15) << ans << endl;

  return 0;
}

Measured memory_bytes: 5504
n=int(input())
a=list(map(int,input().split()))
amo=0
while True:
    sum=0
    for i in range(n):
        if a[i]%2==0:
            sum+=1
    if sum==n:
        amo+=1
        for i in range(n):
            a[i]=int(a[i]*0.5)
    else:
        break
print(amo)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b;
	while(cin>>a>>b){
	int t=8000;
	for(int i=t;i;i--){
		for(int j=i;j;j--){
			if(i+j==2)a+=b;
		}
	}
	int cnt=0;
	while(a)a/=10,cnt++;
	cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 2984
MOD = 1000000007

def xGCD(a, b, x, y):
    if (b == 0):
        x[0] = 1
        y[0] = 0
        return a
    x1 = [0]
    y1 = [0]
    gcd = xGCD(b, a%b, x1, y1)
    x[0] = y1[0]
    y[0] = x1[0] - (a//b)*y1[0]
    return gcd

def modfact(n):
    result = 1
    while (n > 1):
        result = (result*n)%MOD
        n -= 1
    return result

def modmult(a, b):
    return (a*b)%MOD

def inverse(a):
    x = [0]
    y = [0]
    xGCD(a, MOD, x, y)
    return x[0]

def bc(n, k):
    return modmult(modmult(modfact(n), inverse(modfact(k))), inverse(modfact(n - k)))

x, y = map(int, input().split())
if (x+y)%3 != 0:
    print(0)
else:
    row = (x+y)//3
    k = x-row
    if (0 <= k and k <= row):
        print(bc(row, k))
    else:
        print(0)


Measured memory_bytes: 39024
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll diff(ll a,ll b){
	return (a>b)?a-b:b-a;
}

int main(){
	ll a,b,v,w,t;
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;
	if(w>=v)
		cout << "NO" << endl;
	else if(diff(a,b)<=(v-w)*t)
		cout << "YES" << endl;
	else 
		cout << "NO" << endl;
}

Measured memory_bytes: 3632
import math

A, B, H, M = map(int, input().split())
minutes = H*60 + M
shortArg = 0.5 * minutes
#print(shortArg)
longArg = 6 * M
#print(longArg)

arg = abs(shortArg - longArg)
C2 = A**2 + B**2 - 2 * A * B * math.cos(math.radians(arg))

#print(math.cos(math.radians(arg)))

print(C2**(1/2))

Measured memory_bytes: 9504
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string S;
	cin >> S;
	int Z = S.size();
	int a = 0;
	int z = 0;
	rep(i, Z) {
		if (S[i] == 'A') {
			a = i;
			break;
		}
	}
	rep(i, Z) {
		if (S[i] == 'Z') {
			z = i;
		}
	}
	cout << z - a +1<< endl;
}

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



int main(){
	long long x,y;
	cin>>x>>y;

	long long ans=1e+18;
	if(x<=y)
		ans=min(ans,y-x);
	if(-x<=y)
		ans=min(ans,y+x+1);
	if(x<=-y)
		ans=min(ans,-y-x+1);
	if(-x<=-y)
		ans=min(ans,-y+x+2);

	cout<<ans<<endl;

}


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

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

    vector<ll> T(N),A(N);
    rep(i, N) cin >> T[i] >> A[i];

    ll t = T[0];
    ll a = A[0];

    for(int i=1;i<N;i++){
        ll n = (t + T[i] - 1) / T[i];
        n = max(n, (a + A[i] - 1) / A[i]);

        t = T[i]*n;
        a = A[i]*n;
//        cerr << t << "," << a << endl;
    }

    cout << t + a << endl;
}


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

int solve(int N, const vector<int> &perm){
  using coord= int;
  constexpr char block= '#';
  constexpr char vacant= '.';
  const vector<pair<int,int>> diff= {make_pair(0,-1), make_pair(-1,0), make_pair(1,0), make_pair(0,1) }; // 探索方向

  vector<string> board(N, string(N, block));
  vector<vector<int>> dist(N, vector<int>(N));
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      dist.at(i).at(j)= min(min(i, N-1-i), min(j, N-1-j));
    }
  }

  int ans= 0;
  for(size_t i=0; i<perm.size(); i++){
    int s= perm.at(i);
    int s_x= s/ N;
    int s_y= s% N;

    ans+= dist.at(s_x).at(s_y);
    board.at(s_x).at(s_y)= vacant;

    deque<coord> bfs;
    bfs.push_front(s);
    while( !bfs.empty() ){
      coord p= bfs.front();
      bfs.pop_front();
      int x= p/ N;
      int y= p% N;

      for(auto& [dx,dy]:diff){
        if(x+dx <= -1 || x+dx >= N || y+dy <= -1 || y+dy >= N){ continue; }
        else if(board.at(x).at(y)!=block){
          if(dist.at(x+dx).at(y+dy) > dist.at(x).at(y)){
            dist.at(x+dx).at(y+dy)= dist.at(x).at(y);
            bfs.push_front((x+dx)*N+ y+dy);
          }
        }
        else{// if(board.at(x).at(y)==block)
          if(dist.at(x+dx).at(y+dy) > dist.at(x).at(y)+ 1){
            dist.at(x+dx).at(y+dy)= dist.at(x).at(y)+ 1;
            bfs.push_front((x+dx)*N+ y+dy);
          }
        }
      }
    }
  }

  return ans;
}

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

  vector<int> perm(N*N);
  for(size_t i=0; i<perm.size(); i++){
    cin >> perm.at(i);
    perm.at(i)--; // 1-indexed -> 0-indexed
  }

  int ans= solve(N, perm);

  cout << ans << endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    for (int i = n; i <= 999; i++)
    {
        string s = to_string(i);
        bool flag = 0;
        rep(i, s.size()) if (s[i] != s[0]) flag = 1;
        if (flag == 0)
        {
            OP(i);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256