akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
const int SIZE = 31;
const int INF = 1<<27;

int G[SIZE][SIZE], C[4];
int H, W;

struct State {
  int x, y, d, cost;
  State() {}
  State(int x, int y, int d, int cost) : x(x), y(y), d(d), cost(cost) {}
};
bool operator>(const State &s1, const State &s2) {
  return s1.cost>s2.cost;
}

int dijkstra() {
  int cost[4][SIZE][SIZE];
  priority_queue<State, vector<State>, greater<State> > pq;
  pq.push(State(0,0,0,0));
  fill(cost[0][0], cost[4][0], INF);
  cost[0][0][0] = 0;
  while(!pq.empty()) {
    const State s = pq.top(); pq.pop();
    if(cost[s.d][s.y][s.x] < s.cost) continue;
    if(s.x == W-1 && s.y == H-1) return s.cost;
    for(int i=0; i<4; i++) {
      State t = s;
      t.cost += ( G[s.y][s.x] == i ? 0 : C[i] );
      t.d = (s.d + i) % 4;
      t.x += dx[t.d], t.y += dy[t.d];
      if(0 <= t.x && t.x < W 
	 && 0 <= t.y && t.y < H 
	 && cost[t.d][t.y][t.x] > t.cost) {
	pq.push(t);
	cost[t.d][t.y][t.x] = t.cost;
      }
    }
  }
  
  return INF;
}

int main() {
  while(cin >> W >> H, W+H) {
    for(int i=0; i<H; i++)
      for(int j=0; j<W; j++)
	cin >> G[i][j];
    
    for(int i=0; i<4; i++) cin >> C[i];
    
    cout << dijkstra() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1328
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s1,s2;
	cin >> s1 >> s2;
	int n1 = s1.length();
	int n2 = s2.length();
	vector <vector<int> > dp(n1+1,vector <int> (n2+1,0));
	// vector <vector<pair <int,int>>>dp2(n1+1,vector <pair<int,int>>(n2+1));
	for(int i=1;i<=n1;i++)
	{
		for(int j=1;j<=n2;j++)
		{
			// dbg2(i,j);
			if(s1[i-1]==s2[j-1])
			{
				dp[i][j]=1+dp[i-1][j-1];
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	// for(int i=0;i<=n1;i++)
	// {
	// 	for(int j=0;j<=n2;j++)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << "\n";
	// }
	int a=n1;
	int b=n2;
	vector <char> res;
	while (a>0 && b>0)
	{
		if(dp[a][b]==dp[a-1][b])
		{
			a-=1;

		}
		else if(dp[a][b]==dp[a][b-1])
		{
			b-=1;
		}
		else
		{
			a-=1;
			b-=1;
			res.push_back(s1[a]);
		}
	}
	reverse(res.begin(),res.end());
	for(auto a:res)
		cout << a;
	// for(int i=0;i<=n1;i++)
	// {
	// 	for(int j=0;j<=n2;j++)
	// 	{
	// 		cout << dp2[i][j].first << "," << dp2[i][j].second << " ";
	// 		if(dp[i][j]>=ans)
	// 		{
	// 			ans=dp[i][j];
	// 			a=dp2[i][j].first;
	// 			b=dp2[i][j].second;
	// 		}
	// 	}
	// 	cout << "\n";
	// }
	// cout << ans << "\n";
	// if(s1[a]==s2[b])
	// 	{
	// 		cout << s1[a];
	// 	}
	// while(a!=0&&b!=0)
	// {
	// 	a=dp2[a][b].first;
	// 	b=dp2[a][b].second;
	// 	dbg2(s1[a],s2[b]);
	// 	if(s1[a]==s2[b])
	// 	{
	// 		// cout << s1[a];
	// 	}

	// }
}

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


//SHORTCUTS

#define ll long long
#define endl '\n'
#define i1(a) cin>>a
#define i2(a,b) cin>>a>>b
#define i3(a,b,c) cin>>a>>b>>c
#define o1(a) cout<<a<<endl
#define o2(a,b) cout<<a<<" "<<b<<endl
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define f(i,a,b) for(int i = a;i<b;i++)
#define fe(i,a,b) for(int i = a;i<=b;i++)
#define fi(i,a,b) for(i=a;i<b;i++)
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair


// DEBUG CODE & FAST OUTPUT

#define printv(a) for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
#define printvl(a) for (int i = 0; i < a.size(); i++) cout << a[i] << endl;
#define printa(a, n) for (int i = 0; i< n; i++) cout << a[i] << ' ';
#define printal(a, n) for (int i = 0; i < n; i++) cout << a[i] << endl;


//DATA STRUCTURES

#define pq priority_queue
#define ms multiset
// #define y0 _y0_
// #define y1 _y1_
// #define div divi

typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;


//IMP CONSTANT
const int mod = 1e9 + 7, inf = 1e9 + 7;
const ll infll = 1e18 + 7;
bool google_contest = false;

//MODULAR OPERATIONS
ll myadd(ll a,ll b){
    ll ans = a+b;
    ans-= ans>=mod ? mod : 0;
    return ans; 
}
ll mysub(ll a, ll b){
    return (a-b+mod)%mod;
}
ll mymul(ll a,ll b){
    return (a*b)%mod;
}
ll mypow(ll a, ll b){
    ll ans = 1;
    while(b>0)
        if(b&1) ans = mymul(ans,a),b--;
        else a = mymul(a,a),b >>= 1;
    return ans;
}
ll nCr(ll n,ll r){
    if(r==0)return 1;
    if(r==1)return n;
    if(n==0)return 0;
    return mymul(n,mymul(nCr(n-1,r-1),mypow(r,mod-2)));
}




const int dx[4] = {1, -1, 0,  0};
const int dy[4] = {0, 0,  1, -1};
//    /\    |  |\  /|                      
//   /__\   |  | \/ |           
//  /    \  |  |    | 



int main(){

ios_base::sync_with_stdio(0);
cin.tie(0); 
cout.tie(0);

int t,tt;
t=1;
// i1(t);
if(google_contest)tt=1;

while(t--){

int x,y;
i2(x,y);

bool ok = false;

f(i,0,x+1){
    if(i*2+(x-i)*4==y)ok = true;
}
if(ok)o1("Yes");
else o1("No");


if(google_contest){
    cout<<"Case "<<tt++<<": ";
}
}

return 0;   
}


//    /\    |  |\  /|                      
//   /__\   |  | \/ |           
//  /    \  |  |    |   OVER!!!!


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

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

  int a,b;cin>>a>>b;
  if(a+b>=10){
    cout<<"error"<<endl;
  }else{
    cout<<a+b<<endl;
  }

  return 0;
}


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

using namespace std;

typedef long long ll;

#define F first
#define S second

const int MAXN = 4e5 + 10;

int n, m, from[MAXN], to[MAXN], w[MAXN], sec[MAXN], q;
int par[MAXN], ss[4010][4010];
ll sm;
vector<pair<int, int>>	adj[MAXN];
bool vis[4010];

bool cmp(int u, int v){return w[u] < w[v];}

int getPar(int v){return par[v]==v?v:par[v]=getPar(par[v]);}

void dfs(int v, int p, int z = -1){
	ss[p][v] = z;
	vis[v] = 1;
	for (auto e:adj[v])
		if (!vis[e.F])
			dfs(e.F, p, max(z, e.S));
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; i++)
		cin >> from[i] >> to[i] >> w[i], from[i]--, to[i]--;
	iota(sec, sec + m, 0);
	sort(sec, sec + m, cmp);
	iota(par, par + n, 0);
	for (int i = 0; i < m; i++){
		int e = sec[i];
		int u = from[e], v = to[e];
		int pu = getPar(u), pv = getPar(v);
		if (pu == pv)	continue;
		adj[u].push_back({v, w[e]});
		adj[v].push_back({u, w[e]});
		par[pu] = pv;
		sm += w[e];
	}
	for (int i = 0; i < n; i++){
		memset(vis, 0, sizeof(vis));
		dfs(i, i);
	}
	cin >> q;
	while (q--){
		int u, v;	cin >> u >> v, u--, v--;
		printf("%lld\n", sm - ss[u][v]);
	}
	return 0;
}


Measured memory_bytes: 79872
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
int a, b, c, d;
int ans;

int main() {
	while(~scanf("%d %d %d %d", &a, &b, &c, &d)) {
		ans = 0;
		for(int i = 0; i <= a; i++) {
			for(int j = 0; j <= b; j++) {
				for(int k = 0; k <= c; k++) {
					if(i * 500 + j * 100 + k * 50 == d) ans++;
				}
			}
		}
		printf("%d\n", ans);
	}
}

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

int main(){
  int Tc;
  cin>>Tc;
  while(Tc--){
    set<int> a,b;
    for(int i=0;i<6;i++){
      int x;
      cin>>x;
      a.insert(x);
    }
    for(int i=1;i<=13;i++)
      if(a.count(i)==0&&i!=7)b.insert(i);
    int l=6,r=8,ans;
    for(ans=1;;ans++){
      
      if(a.count(l)&&a.count(r)){
        if(a.count(1))a.erase(l),l--;
        else a.erase(r),r++;
      }else if(a.count(l)==1){
        a.erase(l),l--;
      }else if(a.count(r)==1){
        a.erase(r),r++;
      }

      if(a.empty())break;
      swap(a,b);
    }
    cout<< (ans&1?"yes":"no") <<endl;
  }
  return 0;
}

Measured memory_bytes: 3072
n=int(input())
a=list(map(int,input().split()))
def custom_round(number, ndigits=0):
    if type(number) == int:#整数ならそのまま返す
        return number
    d_point = len(str(number).split('.')[1])#小数点以下が何桁あるか定義
    if ndigits >= d_point:#求める小数点以下の値が引数より大きい場合はそのまま返す
        return number
    c = (10 ** d_point) * 2
    #小数点以下の桁数分元の数に0を足して整数にして2倍するための値(0.01ならcは200)
    return round((number * c + 1) / c, ndigits)
    #元の数に0を足して整数にして2倍して1を足して2で割る。元の数が0.01なら0.015にしてroundを行う
ave=custom_round(sum(a)/n)
ans=0
for i in a:
    ans+=(ave-i)**2
print(int(ans))

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;

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

	int N, M;
	cin >> N >> M;
	
	vector<pair<int, int>> edges;
	edges.resize(M * 6);

	vector<tuple<pair<int, int>, pair<int, int>*, pair<int, int>*>> links;
	links.reserve(M * 6 + 2);

	pair<int, int> pends, pdummy;
	links.emplace_back(make_pair(1, 0), &pends, &pdummy);
	links.emplace_back(make_pair(N, 0), &pdummy, &pends);

	for (int i=0 ; i<M ; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;

		int base = i * 6;

		links.emplace_back(make_pair(a, 0), &edges[base+0], &edges[base+5]);
		links.emplace_back(make_pair(a, c), &edges[base+1], &edges[base+0]);
		links.emplace_back(make_pair(b, c), &edges[base+2], &edges[base+1]);
		links.emplace_back(make_pair(b, 0), &edges[base+3], &edges[base+2]);
		links.emplace_back(make_pair(b, c), &edges[base+4], &edges[base+3]);
		links.emplace_back(make_pair(a, c), &edges[base+5], &edges[base+4]);
	}

	sort(links.begin(), links.end());

	int x = 0;
	pair<int, int> prev = make_pair(0, 0);
	for (auto link : links)
	{
		if (prev != get<0>(link))
		{
			prev = get<0>(link);
			x++;
		}

		get<1>(link)->first = x;

		get<2>(link)->second = get<0>(link).second ? x : -x;
	}
	x++;
	pends.second = -pends.second;

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

	vector<int> offsets;
	offsets.reserve(x);
	offsets.push_back(0);
	for (int i=1, j=0 ; i<x ; i++)
	{
		for ( ; j < edges.size() ; j++)
		{
			if (i <= edges[j].first)
			{
				break;
			}
		}

		offsets.push_back(j);
	}

	vector<int> distance(x, -1);
	priority_queue<pair<int, int>> q;

	q.emplace(0, pends.first);

	while (q.size())
	{
		pair<int, int> cur = q.top();
		q.pop();

		int dist = -cur.first;
		int node = cur.second;

		if (distance[node] < 0)
		{
			distance[node] = dist;

			for(int i=offsets[cur.second] ; i<edges.size() ; i++)
			{
				if (edges[i].first != cur.second)
				{
					break;
				}

				int next = edges[i].second;
				int ndist = dist;
				if (next < 0)
				{
					next = -next;
					ndist++;
				}

				q.emplace(-ndist, next);
			}
		}
	}

	cout << distance[pends.second] << "\n";
}


Measured memory_bytes: 47724
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, m;
    cin >> n >> m;
    vector<P> v(n);
    rep(i, n) cin >> v[i].first >> v[i].second;
    sort(all(v));
    int ans = 0, sum = 0;
    rep(i, n)
    {
        int a = v[i].first, b = v[i].second;
        if (sum + b > m)
        {
            ans += a * (m - sum);
            break;
        }
        sum += b;
        ans += a * b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc *bufio.Scanner
var out *bufio.Writer

func main() {
	sc = bufio.NewScanner(os.Stdin)
	//bytes, _ := ioutil.ReadFile("./stdin.txt")
	//sc = bufio.NewScanner(strings.NewReader(string(bytes)))
	out = bufio.NewWriter(os.Stdout)
	buf := make([]byte, 1<<20)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n, a, b := nextInt(), nextInt(), nextInt()
	h := make([]int, n)
	max := 0
	for i := 0; i < n; i++ {
		h[i] = nextInt()
		max = intMax(max, h[i])
	}
	high, low := max/b, 0
	for high >= low {
		mid := low + (high-low)/2
		atkCnt := 0
		for i := 0; i < n; i++ {
			atkCnt += int(math.Ceil(math.Max(0, float64(h[i]-b*mid)) / float64(a-b)))
		}
		if mid < atkCnt {
			low = mid + 1
		} else {
			high = mid - 1
		}
	}
	fmt.Fprintln(out, low)

}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func intMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 5280
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int c = s.find("C"); 
    int f = s.find("F", c);
    if(c >= s.length() || f >= s.length() || c > f)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

/*
Range Sum Query by FenwickTree(Binary Indexed Tree)

total number: n
queries:
    1. add(i, val): bit[i] += val
    2. sum(n): sum(bit[0] + ... + bit[n-1])
time complexity: O(log n)
space complexity: O(N)

Self-balancing binary search tree or Segment Tree can do the same, it takes longer to program and complexity also increases.

Thanks: http://hos.ac/slides/20140319_bit.pdf

used in ARC031 C, indeednow finalB E, DSL2B(AOJ), ARC033 C, yukicoder No.59
*/

template<typename T> struct RangeSumQuery {
  int N;
  vector<T> dat;

  RangeSumQuery(int N) : N(N) {
    assert(N > 0);
    dat.resize(N, 0);
  }

  void add(int k, T val) {
    assert(0 <= k && k < N);
    for (int x = k; x < N; x |= x + 1) {
      dat[x] += val;
    }
  }

  // [0, k)
  T sum(int k) {
    assert(k >= 0);
    T ret = 0;
    for (int x = k - 1; x >= 0; x = (x & (x + 1)) - 1) {
      ret += dat[x];
    }
    return ret;
  }
  // [l, r)
  T sum(int l, int r) {
    assert(0 <= l && l <= r && r <= N);
    return sum(r) - sum(l);
  }

  T index(int k) {
    assert(0 <= k && k < N);
    return sum(k+1) - sum(k);
  }

  int lower_bound(int l, int r, int t) {
    int left = l-1, right = r;
    while (left + 1 < right) {
      int mid = (left + right) >> 1;
      (sum(l, mid+1) >= t ? right : left) = mid;
    }
    return right;
  }
};


int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while (1) {
    int n, k, m; cin >> n >> k >> m;
    if (n == 0 and k == 0 and m == 0) break;
    m--;
    RangeSumQuery<int> fwt(n);
    REP(i, n) fwt.add(i, 1);
    fwt.add(m, -1);
    int now = m;
    REP(i, n-2) {
      //cout << now << endl;
      int move = k % (n-1 - i);
      if (not move) move = n-1 - i;
      if (move <= fwt.sum(now, n)) {
        int next = fwt.lower_bound(now, n, move);
        //cout << next << ' ' << move << endl;
        assert(fwt.sum(now, next+1) == move);
        assert(fwt.index(next) == 1);
        fwt.add(next, -1);
        now = next;
      } else {
        move -= fwt.sum(now, n);
        int next = fwt.lower_bound(0, n, move);
        //cout << next << ' ' << move << endl;
        assert(fwt.sum(0, next+1) == move);
        assert(fwt.index(next) == 1);
        fwt.add(next, -1);
        now = next;
      }
    }
    REP(i, n) {
      if (fwt.index(i)) {
        cout << i+1 << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3212
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T>
T factorial(T a){
    if(a == 2) return 2;
  return a * (factorial(a-1));
}

int main(){
    int N;
    cin >> N;
    vector<int> X(N), Y(N);
    for(int i = 0; i < N; i++) cin >> X[i] >> Y[i];
    vector<int> P(N);
    for(int i = 0; i < N; i++) P[i] = i;
    double length = 0;
    do{
        for(int i = 0; i < N - 1; i++){
            double dx = X[P[i]] - X[P[i + 1]];
            double dy = Y[P[i]] - Y[P[i + 1]];
            length += pow(dx * dx + dy * dy, 0.5);
        }
    }while(next_permutation(all(P)));
    cout << setprecision(10) << length / factorial(N) << endl;
}

Measured memory_bytes: 3728
import itertools
n = int(input())
points = [ list(map(int,input().split())) for _ in range(n)]
routes = list(itertools.permutations(points))
ans = 0
for route in routes:
    for i in range(len(route)-1):
        x,y = route[i][0],route[i][1]
        a,b = route[i+1][0],route[i+1][1]
        ans += ((x-a)**2+(y-b)**2 )**(0.5)
ans /= len(routes)        
print(ans)

Measured memory_bytes: 8180
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>


using namespace std;
typedef long long ll;
ll N;
//mapで節約してみた>成功！
//とても気持ちの良いDP
int main(){

    ll N, T;
    cin >> N >> T;

    vector<ll > t(N);

    for(ll i = 0; i < N; i++){
        cin >> t[i];
    }
    t.push_back((ll)114514191919);
    ll ans = 0;
    for(ll i = 1; i <= N; i++){
        ans += min(T, t[i] - t[i-1]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define il inline
#define rg register
using namespace std;
typedef long long LL;
const LL m_63=1061109567;
const LL m_127=2139062143;
const LL inf=2147483647;
const LL llf=9223372036854775807;
const LL N=1e5+7;
const LL M=1e9;
int a[600000];
int len,lg,lz,ly;
char s[500020];
il LL read(){
	LL x(0),ff(1);char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')ff=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
il void write(LL x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
il void fre(){
	freopen("heaven.in","r",stdin);
	freopen("heaven.out","w",stdout);
}
struct big{
	int len,num[20050],sum;
	big(){len=0;memset(num,0,sizeof(num));}
	il void init(int p){while(p)num[++len]=p%10,p/=10;}
	big operator +(const big &g)const
	{
		big ans;
		int lens=max(len,g.len);
		ans.len=lens;ans.sum=0;
		for(rg int i=1;i<=lens;++i)ans.num[i]=num[i]+g.num[i];
		for(rg int i=1;i<=lens;++i)ans.num[i+1]+=ans.num[i]/10,ans.num[i]%=10;
		if(ans.num[lens+1])++ans.len;
		for(rg int i=1;i<=ans.len;++i)ans.sum+=ans.num[i];
		return ans;
	}
	il void out()
	{
		if(!len)puts("0");
		while(!num[len]&&len>0)--len;
		for(rg int i=len;i>=1;--i)printf("%d",num[i]);
		puts("");
	}
}n;
big operator *(const big &g,int h)
{
	big ans;
	ans.len=g.len;
	for(rg int i=1;i<=g.len;++i)ans.num[i]=g.num[i]*h;
	for(rg int i=1;i<=g.len;++i)ans.num[i+1]+=ans.num[i]/10,ans.num[i]%=10;
	int tt=ans.num[g.len+1];
	while(tt)
	{
		++ans.len;
		ans.num[ans.len]=tt%10;
		tt/=10;
	}
	for(rg int i=1;i<=ans.len;++i)ans.sum+=ans.num[i];
	return ans;
}
int main(){
//	fre();
	scanf("%s",s);int len=strlen(s),sum=0;
	for(rg int i=1;i<=len;++i)a[i]=(s[len-i]-'0')*9;
	for(rg int i=1;i<=len;++i)a[i+1]+=a[i]/10,a[i]%=10;
	int tt=a[len+1];
	while(tt){
		++len;
		a[len]=tt%10;
		tt/=10;
	}
	for(rg int i=1;i<=len;++i)sum+=a[i];
	for(rg int k=1;k<=len*10;++k){
		a[1]+=9,sum+=9;
		for(rg int j=1;j<=len;++j){
			if(a[j]<10)break;
			sum-=10,a[j]-=10;
			++sum,++a[j+1];
			if(j==len&&a[j+1])len++;
		}
		if(sum<=9*k){
			printf("%d\n",k);return 0;
		}
	}
	return 0;
}
/*
80
*/

Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;

//D

//C
struct LLPoint {
	ll x = 0;
	ll y = 0;
	LLPoint() {}
	LLPoint(ll x, ll y) {
		this->x = x;
		this->y = y;
	}
};

// nPn�̏���ɑ΂��ď��������s����
void foreach_permutation(int n, std::function<void(int *)> f) {
	int *indexes = new int[n];
	for (int i = 0; i < n; i++) indexes[i] = i;
	do {
		f(indexes);
	} while (std::next_permutation(indexes, indexes + n));
	delete[] indexes;
}

ll N;
double sum = 0;
ll c = 0;
vector<LLPoint> P;

int main() {
	scanf("%lld", &N);
	P.resize(N);
	for (ll i = 0; i < N; i++) {
		scanf("%lld %lld", &P[i].x, &P[i].y);
	}

	//���s��
	foreach_permutation(N, [](int *indexes) {
		//indexes[0] ~ indexes[N - 1]
		for (ll i = 0; i < N - 1; i++) {
			//i -> i+1
			ll sx = P[indexes[i]].x - P[indexes[i + 1]].x;
			ll sy = P[indexes[i]].y - P[indexes[i + 1]].y;
			double d = sqrt((double)(sx * sx) + (double)(sy * sy));
			sum += d;
		}
		c++;
	});

	double result = sum / (double)c;

	printf("%0.10f\n", result);
}


//B
/*
int main() {
	ll N;
	scanf("%lld", &N);
	char S[220];
	scanf("%s", &S);

	bool result = true;

	if (N % 2 == 0) {
		ll half = N / 2;
		for (ll i = 0; i < half; i++) {
			if (S[i] != S[i + half]) {
				result = false;
				break;
			}
		}
	}
	else {
		result = false;
	}

	if (result) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}
*/

//A
/*
int main() {
	ll r;
	scanf("%lld", &r);

	ll result = r * r;

	printf("%lld\n", result);
}
*/



Measured memory_bytes: 256
def main():
    from sys import stdin
    readline = stdin.readline
    H, N = map(int, readline().split())
    AB = [list(map(int, readline().split())) for _ in range(N)]

    max_A = max(a for a, _ in AB)
    inf = float('inf')
    dp = [inf] * (H + max_A + 1)
    dp[0] = 0
    for i in range(H):
        if dp[i] == inf:
            continue
        for a, b in AB:
            t = dp[i] + b
            if t < dp[i + a]:
                dp[i + a] = t
    print(min(dp[H:]))


main()


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

#define OM ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define pi 3.14159265358979323846

typedef long long ll;

/*LETS BEGIN WITH THE NAME OF MAHADEV*/

int main(){
	OM;
	int n, x, t;
	cin >>  n >> x >> t;
	int m = ceil(n / (x * 1.0));
	cout << t * m << endl;
	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String N = scan.nextLine();
		boolean judge = true;
		for(int i = 0; i < N.length(); i++) {
			if(N.substring(i, i + 1).equals(N.substring(N.length() - i - 1, N.length() - i))) {
				
			} else {
				judge = false;
				break;
			}
		}
		if(judge) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		scan.close();

	}

}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //配列(vector)vの重複要素を削除


void solve(){
    int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << arr[k-1] << endl;
}

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

Measured memory_bytes: 256
N = int(input())
if N == 3:
  print(2, 5, 63)
  quit()

N -= 4
ans = [2, 3, 4, 9]
odd = []; even = []; mul6 = []
for i in range(6, 30001):
  if i in ans:
    continue
  if i % 6 == 0:
    mul6.append(i)
  elif i % 3 == 0:
    odd.append(i)
  elif i % 2 == 0:
    even.append(i)

odd = odd[::-1]; even = even[::-1]
while N:
  if N >= 2:
    N -= 2
    if len(odd) >= 2:
      ans.append(odd.pop()); ans.append(odd.pop())
    elif len(even) >= 2:
      ans.append(even.pop()); ans.append(even.pop())
    else:
      ans.append(mul6.pop()); ans.append(mul6.pop())
  else:
    N -= 1
    ans.append(mul6.pop())

print(*ans)

Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;

int main(){
	long long x; cin>>x;
	long long ans=0;

	ans += (x/11)*2;
	x = x%11;
	if(x>6) ans+=2;
	else if(x>0) ans+=1;

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		try (InputStreamReader isr = new InputStreamReader(System.in);
				BufferedReader br = new BufferedReader(isr);) {
			String rec = br.readLine();
			System.out.println(rec.substring(0, 3));
		}
	}

}


Measured memory_bytes: 32500
#include<bits/stdc++.h>
using namespace std;
int m,d,ans=0;
int main()
{
	scanf("%d%d",&m,&d);
	for(int i=1;i<=m;i++)
		for(int j=22;j<=d;j++)
			if((j/10)*(j%10)==i&&j%10>=2) ++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
S = input()

year = int(S[:4])
month = int(S[5:7])
day = int(S[-2:])

if year < 2019:
    print('Heisei')
else:
    if 1 <= month < 4:
        print('Heisei')
    elif month == 4:
            print('Heisei')
    else:
        print('TBD')


Measured memory_bytes: 3060
N=int(input()) 
h=list(map(int,input().split())) 
cnt=1 
h[0]-=1 
if N==1: 
    print("Yes")
else:
    while cnt<=N-1:
        if h[cnt]-h[cnt-1]>=1:
            h[cnt]-=1
        elif h[cnt]-h[cnt-1]<0:
            print("No")
            break
        cnt+=1
        
    else:
        print("Yes")

Measured memory_bytes: 14252
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc160_b solver = new abc160_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc160_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long X = in.nextLong();
            long amari = 0;
            long score = 0;

            score += ((int) (X / 500)) * 1000;
            amari = X % 500;
            score += ((int) (amari / 5)) * 5;
            out.println(score);
        }

    }
}



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

using namespace std;
typedef long long LL;
typedef pair<LL,LL>  PII;

LL MOD = 1000000007;

const int MAXN = 2020;
LL  dp[MAXN][MAXN];

LL comb[MAXN][MAXN];
LL ruiseki[MAXN][MAXN];
void init() {
	for(int i=0; i<MAXN; i++)
		for(int j=0; j<MAXN; j++) {
			dp[i][j] = 0;
			comb[i][j] = 0;
		}
	comb[0][0] = 1;
	
	for(int i=0; i<MAXN; i++)
		comb[i][i] = comb[i][0] = 1;
		
	for(int i=0; i<MAXN; i++) {
		for(int j=1; j<i; j++) {
			comb[i][j] = comb[i-1][j] + comb[i-1][j-1];
			comb[i][j] %= MOD;
		}
	}
	for(int i=0; i<MAXN; i++) {
		ruiseki[i][0] = comb[i][0];
		for(int j=1; j<MAXN; j++) {
			ruiseki[i][j] = ruiseki[i][j-1] + comb[i][j];
			ruiseki[i][j] %= MOD;
		}
	}
	
}


int main() {
	init();
	int A, B;
	cin >> A >> B;
	LL ans = A+1;
	for(int i=0; i<A; i++) {
		for(int j=0; j<=B-1; j++) {
			if(i+j <= A)
				dp[i+j][B-j] += comb[B-1][j];
			if(i+j==A)
				ans += comb[B-1][j];
		}
	}
	dp[A][0]++;
	/*
	for(int i=0;i<B; i++, cout << endl)
		for(int j=0; j<A; j++)
			cout << dp[j][i] << " ";
	*/
//	LL ans = A+1;
	for(int j=1; j<B; j++) {
		LL sum = 0;
		for(int i=0; i<A; i++) {
			sum += dp[i][j];
			sum %= MOD;
			int last = min(B-1-j, A-i);
			ans += sum * ruiseki[B-1-j][last];
			ans %= MOD;
		}
		ans += sum;
	}
	ans %= MOD;
	cout << ans << endl;
	
	return 0;	
}

Measured memory_bytes: 95872
fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];

    let x = if a > 0 { a * (a - 1) / 2 } else { 0 };
    let y = if b > 0 { b * (b - 1) / 2 } else { 0 };
    println!("{}", x + y);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define MOD(x) ((x)>=mod?(x)-mod:(x))
using namespace std;
const int maxn=500010, inf=1e9, mod=1e9+7;
struct poi{int x, v;}q[maxn];
int n;
int l[maxn], r[maxn], f[maxn], pos[maxn], pos2[maxn];

bool operator < (poi a, poi b){return a.x<b.x;}

inline bool cmp(int a, int b){return q[a].v<q[b].v;}

int main()
{
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d%d", &q[i].x, &q[i].v);
	sort(q+1, q+1+n); for(int i=1;i<=n;i++) pos[i]=i;
	sort(pos+1, pos+1+n, cmp);
	for(int i=1;i<=n;i++) pos2[i]=pos[i];
	for(int i=1;i<=n;i++) pos[pos2[i]]=i;
	for(int i=1;i<=n;i++) l[i]=r[i]=i;
	for(int i=2;i<=n;i++) r[pos[i]]=max(r[pos[i]], r[pos[i-1]]);
	for(int i=n-1;i;i--) l[pos[i]]=min(l[pos[i]], l[pos[i+1]]);
	sort(l+1, l+1+n); sort(r+1, r+1+n);
	f[0]=1;
	for(int i=1, j=0, ans=1;i<=n;i++)
	{
		while(j<l[i]-1) ans=MOD(ans-f[j]+mod), j++;
		f[r[i]]=MOD(f[r[i]]+ans);
		ans=MOD(ans+ans);
	}
	printf("%d\n", f[n]);
}

Measured memory_bytes: 11392
#include <iostream>
#include <algorithm>
#include <stdlib.h>

using namespace std;

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

	if (abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long long int  x;
  cin >> x;
  if(x<11){
    if(x<=6) cout << 1<<endl;
    else cout <<2<<endl;
  }
  else if(x%11==0){
    cout << (x/11)*2<<endl;
  }
  else{
    if(x%11<=6) cout << (x/11)*2+1<<endl;
    else cout << (x/11)*2+2<<endl;
  }
}


Measured memory_bytes: 256
N = int(input())
*A, = map(int, input().split())
for i in range(N): A[i] ^= i&1
B = []
prev = A[0]; cnt = 0
for i in range(N):
    if prev != A[i]:
        B.append(cnt)
        cnt = 1
    else:
        cnt += 1
    prev = A[i]
B.append(cnt)
if len(B) == 1:
    print(B[0])
elif len(B) == 2:
    print(B[0] + B[1])
else:
    print(max(B[i]+B[i+1]+B[i+2] for i in range(len(B)-2)))

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

int main(void) {

	int A=0,B=0,C=3;

	scanf("%d", &A);
	scanf("%d", &B);

	if(C-A == 0 || C-B == 0){
		C=2;
	}

	if(C-A == 0 || C-B == 0){
		C=1;
	}

	printf("%d", C);

	return 0;
}


Measured memory_bytes: 128
/*
 *    author:  Gary Shih
 *    created: 2020-05-03 22:08:09
 */
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.setf(ios::fixed), cout.precision(9);
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];

  vector<int> dp(n);
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; ++i) {
    dp[i] =
        min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2]);
  }
  cout << dp.back() << '\n';
}


Measured memory_bytes: 1024
n = int(input())
X = []
Y = []
for i in range(n):
  x, y = map(int, input().split())
  X.append(x)
  Y.append(y)

def length(a, b):
  return ((X[a]-X[b])**2 + (Y[a]-Y[b])**2)**0.5
def total_len(L):
  n = len(L)
  total = 0
  for i in range(n-1):
    total += length(L[i], L[i+1])
  return total

from itertools import permutations as prm
import math
s = 0
for i in prm(list(range(0, n)), n):
  s += total_len(i)
print(s / math.factorial(n))

Measured memory_bytes: 41452
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define mp(x,y)          make_pair(x,y)
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto& i: a)
#define loop(n,i,a)      for(int i=a;i<n;i++)
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        loop(n,i,0){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define pp               pop_back
#define endl              "\n"
#define copy(a,b)         copy(all(a),back_inserter(b));
#define intersect(a,b,w)    set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w)      set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define diff(a,b,w)       set_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define symdiff(a,b,w)    set_symmetric_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
//int m=10000009;
//int arr[100000];
#define M                   1000000007
#define mm  998244353  
//set<int> st;

signed main()
{
    fast
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
}


Measured memory_bytes: 256
n = int(input())
data = []
for i in range(n):
    a = int(input())
    d = []
    for j in range(a):
        xy = list(map(int,input().split()))
        d.append(xy)
    data.append(d)
ans = 0
def search(honest):
    if len(honest)==n:
        global ans
        ok = True
        for i in range(n):
            if honest[i]:
                for d in data[i]:
                    if honest[d[0]-1]!=d[1]:
                        ok = False
        if ok: ans = max(ans,honest.count(1))
    else:
        search(honest+[0])
        search(honest+[1])
search([])
print(ans)

Measured memory_bytes: 56536
#include<iostream>

using namespace std;

int main(void){

    int p, q, r, ans;

    cin >> p >> q >> r;

    if(p+q <= p+r && p+q <= q+r){
        ans = p+q;
    }else if(p+r <= p+q && p+r <= q+r){
        ans = p+r;
    }else{
        ans = q+r;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int a=S.size();
  int n,w,s,e;
  n=0; w=0; s=0; e=0; 
  for(int i=0;i<a;i++){
    if(S.at(i)=='N')n++;
    else if(S.at(i)=='W')w++;
    else if(S.at(i)=='S')s++;
    else if(S.at(i)=='E')e++;
  }
  if((n>=1 && s==0) || (n==0 && s>=1)){
    cout << "No" << endl;}
  else if((w>=1 && e==0) || (w==0 && e>=1)){
    cout << "No" << endl;}
  else{
    cout << "Yes" << endl;}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int A, B, K;
	vector<int> v;

	cin >> A >> B >> K;

	for (int i = A; i < A + K&&i<=B; i++)
	{
		v.push_back(i);
	}

	
	for (int i = B; i >B-K&&i>=A; i--)
	{
		v.push_back(i);
	}

	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());

	for (vector<int>::iterator it = v.begin();it != v.end();it++) {
		cout << *it << endl;
	}

	return 0;
}

Measured memory_bytes: 384
// Problem : D - Not Divisible
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 1e6+10;
bool vis[N];
int mp[N];		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
  
    while(tt--)
    {
		int n,ct=0;
		cin>>n;
		int arr[n];
		for(int i=0;i<n;++i)
		{
			cin>>arr[i];
			mp[arr[i]]++;
		}
		sort(arr,arr+n);
		int maxx = arr[n-1];
		for(int i=0;i<n;++i)
		{
			if(vis[arr[i]]==false)
			{
				if(mp[arr[i]]==1)
				ct++;
				for(int j=arr[i];j<=maxx;j+=arr[i])
				{
					vis[j] = true;
				}
			}
		}
		cout<<ct;
    }
    return 0;
}


Measured memory_bytes: 13856
#include <cstdio>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

int n,m,x,y,a,b,c,d,ans[510][510];
bool flag;

int main()
{
    scanf("%d%d%d%d",&n,&m,&x,&y);
    if (!(n%x))
        swap(n,m),swap(x,y),flag=1;
    if (!(n%x))
    {
        puts("No");
        return 0;
    }
    puts("Yes");
    a=n%x,b=x-a,c=m%y,d=y-c;
    for (int i=1,t1=1; i<=n; i+=t1&1?a:b,t1^=1)
        for (int j=1,t2=1; j<=m; j+=t2&1?c:d,t2^=1)
            if (c || t2)
                ans[i][j]=t1&1?1e9-1:-1e9;
    if (flag)
        repu(i,1,m)
        {
            repu(j,1,n)
                printf("%d ",ans[j][i]);
            puts("");
        }
    else
        repu(i,1,n)
        {
            repu(j,1,m)
                printf("%d ",ans[i][j]);
            puts("");
        }
    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll oo = 1e18;
const ll mod = 1e9 + 7,maxn = 100000000;
const double PI = acos(-1);

string compare(string a, string b){
    if (a.size() > b.size() || (a.size() == b.size() and a > b)) return "GREATER";
    if (a == b) return "EQUAL";
    return "LESS";
}
int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string a, b;
    cin >> a >> b;
    string ans = compare(a, b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
H = [-1] + [int(h) for h in input().split()]

count = 0
max_count = 0
for n in range(1, N):
    if H[n] >= H[n+1]:
        count += 1
        max_count = max(max_count, count)
    else:
        count = 0

print(max_count)

Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {
	public static int partition(int[] A, int p, int r) {
		int x = A[r];
		int i = p - 1;
		int oki = 0;
		for (int j = p; j < r; j++) {
			if (A[j] <= x) {
				i = i + 1;
				oki = A[i];
				A[i] = A[j];
				A[j] = oki;
			}
		}
		oki = A[i + 1];
		A[i + 1] = A[r];
		A[r] = oki;
		return i + 1;

	}

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] A = new int[n];
		for (int i = 0; i < n; i++) {
			A[i] = scanner.nextInt();
		}
		int r = n - 1;
		int partition = partition(A, 0, r);
		System.out.print(A[0]);
		for (int i = 1; i < n; i++) {
			if (i == partition) {
				System.out.print(" [" + A[partition] + "]");
			} else {
				System.out.print(" " + A[i]);
			}
		}
		System.out.println();
		scanner.close();
	}

}


Measured memory_bytes: 70880
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int a, b,c;
  double x;
  cin >> a >> b;
  c = x = (a+b)/2.0;
  if(c!=x) c++;
  cout << c fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
A, B, C = map(int, input().split())

# A の倍数の総和なので、 総和は A の倍数
# (n * A) % B == C

remain_list = []
for i in range(1, B + 1):
  tmp = (i * A) % B
  if tmp in remain_list:
    break
  else:
    remain_list.append(tmp)
      
if C in remain_list:
  print("YES")
else:
  print("NO")
  


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


int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];
  int ans = 0, over = 0;
  int base = 400;
  int rate[8];
  rep(i, 8) {
    rate[i] = 0;  
  }
  rep(i, n){
    int check = -1;
    if(a[i] >= 1 && a[i] < base) {
      rate[0]++; check = 0;
    }else if(a[i] >= base && a[i] < base * 2) {
      rate[1]++; check = 1;
    }else if(a[i] >= base * 2 && a[i] < base * 3) {
      rate[2]++; check = 2;
    }else if(a[i] >= base * 3 && a[i] < base * 4) {
      rate[3]++; check = 3;
    }else if(a[i] >= base * 4 && a[i] < base * 5) {
      rate[4]++; check = 4;
    }else if(a[i] >= base * 5 && a[i] < base * 6) {
      rate[5]++; check = 5;
    }else if(a[i] >= base * 6 && a[i] < base * 7) {
      rate[6]++; check = 6;
    }else if(a[i] >= base * 7 && a[i] < base * 8) {
      rate[7]++; check = 7;
    }else {
      over++;
    }
    if(check != -1 && rate[check] == 1) ans++;
  }
  if (over > 0 && ans == 0) {
    ans ++;
    over --;
  }
  cout << ans << " " << ans+over << endl;
  
}

Measured memory_bytes: 3604
import java.util.*;
import java.util.Map.Entry;

//文字操作
class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		while(sc.hasNext()){
			char[] str=sc.next().toCharArray();

			boolean iso=false;
			for(int i=0;i<3;i++){
				if(str[i*3+0]=='o'&&str[i*3+1]=='o'&&str[i*3+2]=='o'){
					iso=true;
				}
				if(str[i+3*0]=='o'&&str[i+3*1]=='o'&&str[i+3*2]=='o'){
					iso=true;
				}
			}
			if(str[0]=='o' && str[4]=='o' && str[8]=='o'){
				iso=true;
			}
			if(str[2]=='o' && str[4]=='o' && str[6]=='o'){
				iso=true;
			}

			boolean isx=false;
			for(int i=0;i<3;i++){
				if(str[i*3+0]=='x'&&str[i*3+1]=='x'&&str[i*3+2]=='x'){
					isx=true;
				}
				if(str[i+3*0]=='x'&&str[i+3*1]=='x'&&str[i+3*2]=='x'){
					isx=true;
				}
			}
			if(str[0]=='x' && str[4]=='x' && str[8]=='x'){
				isx=true;
			}
			if(str[2]=='x' && str[4]=='x' && str[6]=='x'){
				isx=true;
			}

			if(iso){
				ln("o");
			}else if(isx){
				ln("x");
			}else{
				ln("d");
			}
		}
	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 11000
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

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

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int a, b;
    cin >> a >> b;
    if((a + b) % 2 == 0){
        cout << (a + b) / 2 << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
    
}

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

int main(){
    int a,b;
    cin>>a>>b;
    char c;
    for(int i=1;i<=a;i++){
        cin>>c;
        if(c<'0'||'9'<c){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cin>>c;
    if(c!='-'){
        cout<<"No"<<endl;
        return 0;
    }
    for(int i=1;i<=b;i++){
        cin>>c;
        if(c<'0'||'9'<c){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


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

int main() {
	int n, l; cin >> n >> l;
	vector<string>s(n); for (auto&& x : s)cin >> x;
	sort(s.begin(), s.end());
	for (auto&& x : s)cout << x;
	cout << endl;

	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S = in<string>();
    cout << (S[0] == '9' || S[1] == '9' ? "Yes" : "No")<< "\n";
}

Measured memory_bytes: 256
time=int(input())
nums=[int(i) for i in input().split()]
odd=0
even=0
even35=0
for j in range(time):
    if nums[j]%2==0:
        even+=1
        if nums[j]%3!=0 and nums[j]%5!=0:
            continue
        else:
            even35+=1
    else:
        odd+=1
        
if even35==even:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;cin>>n;
  int i,j,k;
  vector<int> v;
  for(i=0;i<n;i++){
    cin >> k;
    v.push_back(k);
  }
  for(j=0;j<n;j++) cout << v[j] << (j==n-1?'\n':' ');
  for(i=1;i<n;i++){
    for(j=0;j<i;j++){
      if(v[j]>v[i]){
	k=v[i];
	v.erase(v.begin()+i);
	v.insert(v.begin()+j,k);
	break;
      }
    }
    for(j=0;j<n;j++) cout << v[j] << (j==n-1?'\n':' ');
  }
  return 0;
}



Measured memory_bytes: 3164
import Control.Applicative

import Data.List
    (intersperse)
    
import Text.Printf
    (printf)
    
type Vector = [Double]

type Problem = (Vector, Vector)

type Result = [Double]

minkowski :: Vector -> Vector -> Double -> Double

minkowski xs ys p
    = sum ss ** (1 / p) where
        ds = map abs $ zipWith (-) xs ys
        ss = map (** p) ds
        
chebyshev :: Vector -> Vector -> Double

chebyshev xs ys
    = maximum $ map abs $ zipWith (-) xs ys

solve :: Problem -> Result

solve (xs, ys)
    = map (minkowski xs ys) [1, 2, 3] ++ [chebyshev xs ys]

output :: Result -> String

output result
    = concat $ intersperse "\n" $ map (printf "%.6f") result
    
input :: IO Problem

input
    = do
        getLine
        xs <- map read.words <$> getLine
        ys <- map read.words <$> getLine
        return (xs, ys)

main :: IO ()

main
    = putStr.output =<< solve <$> input

Measured memory_bytes: 4552
import numpy as np

n, l = map(int, input().split())

if l < 0:
    if l + n <= 0:
        # 絶対値最小が0以下の場合は最右を削る
        taste = sum(range(l, l+n-1))
    else:
        # 0を挟む場合はそのまま全部足す
        taste = sum(range(l, l+n))
else:
        # 絶対値最小が0以上の場合は最左を削る
        taste = sum(range(l+1, l+n))

print(taste)


Measured memory_bytes: 12452