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

using namespace std;

namespace {

#define VERA(i, a, b)for(auto i=(ll)(a);i<(ll)(b);++i)
#define ANDY(i, a, b)for(auto i=(ll)(a);i>(ll)(b);--i)

typedef long long ll;
typedef double dd;

template <class T> inline ll Size(const T& x) { return x.size(); }

ll first;

ll Ask(ll i) {
  cout << i << endl;
  string str;
  cin >> str;
  if (str == "Vacant") exit(0);
  else if (str == "Male") return 1;
  else return 0;
}

void Go(ll l, ll r) {
  const ll m = (l + r) / 2;
  if (Ask(m) == (first ^ (m % 2))) {
    Go(m + 1, r);
  } else {
    Go(l, m - 1);
  }
}

bool Solve(ll test_num) {
  (void) test_num;
  ll n;
  cin >> n;
  first = Ask(0);
  Go(0, n - 1);
  return false;
}

void Init() {
}

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("../input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand(1223);
  Init();
  ll test = 1;
  while (true)
    if (not Solve(test++))
      break;
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() /
                       static_cast<double>(chrono::system_clock::period::den)) << " s" << endl;
#endif
  return 0;
}


Measured memory_bytes: 852
#include <iostream>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
int main(void){
    // Here your code !
    int n, m;
    cin >> n >> m;
    char a[n][n], b[m][m];
    REP(i, n) {
        REP(j, n) {
            cin >> a[i][j];
        }
    }
    
    REP(i, m) {
        REP(j, m) {
            cin >> b[i][j];
        }
    }
    bool p = false, q = false;
    REP(i, n-m+1) {
        REP(j, n-m+1) {
            REP(k, m) {
                REP(l, m) {
                    if(a[i+k][j+l] != b[k][l]) {
                        p = true;
                        break;
                    }
                }
                if(p) break;
            }
            if(!p) {
                cout << "Yes" << endl;
                q = true;
                break;
            }
            p = false;
        }
        if(q) break;
    }
    
    if(!q) cout << "No" << endl;
    
}


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

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


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================


	int H, W;
	cin >> H >> W;

	vvint A(H), B(H);
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			int t;
			cin >> t;
			A[i].emplace_back(t);
			B[i].emplace_back(t);
		}
	}

	int count = 0;
	for (int h = 0; h < H; h++)
	{
		for (int w = 0; w < W-1; w++)
		{
			
			if (A[h][w] % 2 == 1)
			{
				//cout << h+1 << " " << w+1 << " " << h+1 << " " << w + 1+1 << endl;
				count++;
				A[h][w + 1]++;
			}
		}
	}

	for (int h = 0; h < H - 1; h++)
	{
		if (A[h][W - 1] % 2 == 1)
		{
			//cout << h+1 << " " << W-1+1 << " " << h + 1+1 << " " << W-1+1 << endl;
			count++;
			A[h + 1][W - 1] ++;
		}
	}


	cout << count << endl;
	for (int h = 0; h < H; h++)
	{
		for (int w = 0; w < W - 1; w++)
		{

			if (B[h][w] % 2 == 1)
			{
				cout << h+1 << " " << w+1 << " " << h+1 << " " << w + 1+1 << endl;
				B[h][w + 1]++;
			}
		}
	}

	for (int h = 0; h < H - 1; h++)
	{
		if (B[h][W - 1] % 2 == 1)
		{
			cout << h+1 << " " << W-1+1 << " " << h + 1+1 << " " << W-1+1 << endl;
			B[h + 1][W - 1] ++;
		}
	}



}





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

bool done[100001];
int ans[100001];

int main()
{
    int q;
    cin >> q;
    vector<int> l(q), r(q);
    for (int i = 0; i < q; i++)
        cin >> l[i] >> r[i];
    int max = 0;
    for (int i = 0; i < q; i++)
    {
        if (max < r[i])
            max = r[i];
    }
    done[0] = done[1] = false;
    done[2] = true;
    for (int n = 3; n <= max; n++)
    {
        done[n] = true;
        for (int i = 2; i <= sqrt(n); i++)
        {
            if (n % i == 0)
            {
                done[n] = false;
                break;
            }
        }
    }

    ans[0] = 0;
    for (int i = 1; i <= max; i++)
    {
        ans[i] = ans[i - 1] + (done[i] & done[(i + 1) / 2]);
    }

    for (int i = 0; i < q; i++)
    {
        cout << ans[r[i]] - ans[l[i] - 1] << endl;
    }
}

Measured memory_bytes: 1920
#include <cstdio>
#include <algorithm>
#include <climits>
typedef long long ll;

const int max_t = 20;
ll dist[max_t][max_t];

int main() {
	//freopen("aoj0189.txt", "r", stdin);
	while (1) {
		int n, t = 0;
		scanf("%d", &n);
		if (n == 0) break;
		
		for (int i = 0; i < max_t; i++) {
			std::fill(dist[i], dist[i] + max_t, INT_MAX);
		}
		for (int i = 0; i < n; i++) {
			int from, to;
			ll d;
			scanf("%d%d%lld", &from, &to, &d);
			t = std::max(t, from);
			t = std::max(t, to);
			dist[from][to] = d;
			dist[to][from] = d;
		}
		for (int i = 0; i <= t; i++) {
			dist[i][i] = 0;
		}

		for (int k = 0; k <= t; k++) {
			for (int i = 0; i <= t; i++) {
				for (int j = 0; j <= t; j++) {
					if (dist[i][k] != INT_MAX && dist[k][j] != INT_MAX)
						dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
				}
			}
		}

		ll min_len = INT_MAX;
		int start = -1;
		for (int i = 0; i <= t; i++) {
			ll len = 0;
			for (int j = 0; j <= t; j++) {
				if (j == i) continue;

				len += dist[i][j];
			}
			if (len < min_len) {
				min_len = len;
				start = i;
			}
		}

		printf("%d %lld\n", start, min_len);
	}
	return 0;
}

Measured memory_bytes: 1028
#template
def inputlist(): return [int(j) for j in input().split()]
def listinput(): return input().split()
#template
K,N = inputlist()
A = inputlist()
dis = [0]*(N)
for i in range(N):
    if i == N-1:
        dis[i] = K+A[0] - A[i]
        continue
    dis[i] = A[i+1] - A[i]
dis.sort()
print(sum(dis[:-1]))

Measured memory_bytes: 31604
#include <stdio.h>
int main (void){

  int n , i , mul=100000;
  
  scanf ("%d",&n);
  
  for (i = 1 ; i <= n ; i++){
    mul *= 1.05 ;
    if (mul %1000 != 0){
      mul = mul - mul%1000 + 1000 ;
    }
  }
  
  
  printf ("%d\n",mul);
  
  return 0 ;
}

    

Measured memory_bytes: 592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DIVERTA2019A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
            var output = 0;

            output = input[0] - input[1] + 1;

            Console.WriteLine(output);
        }
    }
}



Measured memory_bytes: 13268
n=int(input())
mat=[[0 for i in range(20)] for j in range(15)]
for i in range(n):
    b,f,r,v=list(map(int,input().split()))
    h=(b-1)*4+f-1
    w=2*r-1
    n=v
    mat[h][w]+=n
for x in range(15):
    for y in range(20):
        if x%4==3:
            mat[x][y]="#"
        elif y%2==0:
            mat[x][y]=" "
        print(mat[x][y],end="")
    print()
    


Measured memory_bytes: 5644
k=input()
d=int(input())
l=len(k)
N=10**9 + 7
dp=[[[0]*2 for _ in range(d+5)] for i in range(l+5)]
prefs=[int(k[0])%d]
for i in range(1,l):
    prefs.append((prefs[i-1]+int(k[i]))%d)
for i in range(0,int(k[0])):
    dp[0][i%d][1]+=1
dp[0][int(k[0])%d][0]+=1
for i in range(1,l):
    for r in range(d):
        for dig in range(10):
            dp[i][r][1]=(dp[i][r][1]+dp[i-1][(r-dig+d)%d][1])%N
        for dig in range(0,int(k[i])):
            dp[i][r][1] = (dp[i][r][1] + dp[i - 1][(r - dig + d) % d][0]) % N
        if prefs[i]==r:
            dp[i][r][0]=(dp[i][r][0]+1)%N
print((dp[l-1][0][1]+dp[l-1][0][0]-1+N)%N)





Measured memory_bytes: 166716
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    string s; cin >> s;
    string ans = "Yes";
    
    rep(i,s.size()){
        if(i%2==0){
            if(s[i]=='L'){
                ans = "No";
                break;
            }
        }
        else{
            if(s[i]=='R'){
                ans = "No";
                break;
            }
        }
    }

    cout << ans << ln;
    return 0;
 }

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

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

using namespace std;
using ll = long long;

int main() {
    int A; cin >> A;
    int B; cin >> B;
    int C; cin >> C;
    
    if (A + B + C >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}


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

using ll = long long;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};

// 座標圧縮
map<ll, int> compress(vector<ll> &x, bool sorted = false) {
  map<ll, int> comp;
  if (!sorted) sort(x.begin(), x.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  for (int i = 0; i < x.size(); i++) comp[x.at(i)] = i;
  return comp;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<ll> x, y; // 座標圧縮用
  x.emplace_back(0);
  x.emplace_back(-1e9);
  x.emplace_back(1e9);
  y.emplace_back(0);
  y.emplace_back(-1e9);
  y.emplace_back(1e9);
  
  vector<vector<ll>> hor(n, vector<ll>(3)), ver(m, vector<ll>(3));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> hor.at(i).at(j);
    }
    x.emplace_back(hor.at(i).at(0));
    x.emplace_back(hor.at(i).at(1));
    y.emplace_back(hor.at(i).at(2));
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> ver.at(i).at(j);
    }
    x.emplace_back(ver.at(i).at(0));
    y.emplace_back(ver.at(i).at(1));
    y.emplace_back(ver.at(i).at(2));
  }
  
  map<ll, int> mpx = compress(x), mpy = compress(y);
  vector<vector<int>> grid(mpx.size() * 2, vector<int>(mpy.size() * 2, 0)); // -1:壁, 0:未訪問, 1:訪問
  for (int i = 0; i < n; i++) {
    int xleft = mpx[hor.at(i).at(0)] * 2, xright = mpx[hor.at(i).at(1)] * 2, yy = mpy[hor.at(i).at(2)] * 2;
    for (int xx = xleft; xx <= xright; xx++) {
      grid[xx][yy] = -1;
    }
  }
  for (int i = 0; i < m; i++) {
    int xx = mpx[ver.at(i).at(0)] * 2, ybottom = mpy[ver.at(i).at(1)] * 2, ytop = mpy[ver.at(i).at(2)] * 2;
    for (int yy = ybottom; yy <= ytop; yy++) {
      grid[xx][yy] = -1;
    }
  }
  
  queue<pair<int, int>> q;
  grid[mpx[0] * 2][mpy[0] * 2] = 1;
  q.push(make_pair(mpx[0] * 2, mpy[0] * 2));
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if (0 <= nx && nx < grid.size() && 0 <= ny && ny < grid[0].size() && grid[nx][ny] == 0) {
        grid[nx][ny] = 1;
        q.push(make_pair(nx, ny));
        if (nx == 0 || nx == grid.size() - 1 || ny == 0 || ny == grid[0].size() - 1) {
          cout << "INF\n";
          return 0;
        }
      }
    }
  }
  
  // 圧縮座標->元の座標 へのmap
  map<int, ll> mpx2, mpy2;
  for (auto i : mpx) mpx2[i.second] = i.first;
  for (auto i : mpy) mpy2[i.second] = i.first;
  
  ll ans = 0;
  for (int i = 0; i < grid.size(); i++) {
    ll xwid = 0;
    if (i % 2 == 1) xwid = mpx2[(i + 1) / 2] - mpx2[i / 2];
    for (int j = 0; j < grid[0].size(); j++) {
      if (grid[i][j] == 1) {
        ll ywid = 0;
        if (j % 2 == 1) ywid = mpy2[(j + 1) / 2] - mpy2[j / 2];
        ans += xwid * ywid;
      }
    }
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 145520
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

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

	string s, ans;
	cin >> s;
	rep(i, s.size()) {
		if (i % 2 == 0) {
			ans = ans + s[i];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 656
#include <stdio.h>
#include <string.h>

int main(void){
	int n, m, flag = 1;
	char a[51][51], b[51][51];

	scanf("%d%d", &n, &m);
	for(int i=0; i < n; i++)
		scanf("%s", a[i]);
	for(int i=0; i < m; i++)
		scanf("%s", b[i]);

	for(int i=0; i < n; i++) {
		for(int j=0; j < n; j++) {
			for(int k=0; k < m; k++) {
				for(int l=0; l < m; l++) {
					if(a[i+k][j+l] != b[k][l])
						flag = 0;
				}
			}
			if(flag) {
				printf("Yes");
				return 0;
			}
			flag = 1;
		}
	}
	printf("No");

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
//#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;


int main(){
    int N,Z,W;
    cin >> N >> Z >> W;
    int a[N];
    for (int i =0; i< N; i++){
        cin >> a[i];
    }

    if(N == 1){
        cout << abs(a[N-1] - W) << endl;
    }else{
        if(abs(a[N-1]-W) > abs(a[N-2]-a[N-1])){
            cout << abs(a[N-1]-W) << endl;
        }else{
            cout << abs(a[N-2]-a[N-1]) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
N, Q = list(map(int, input().split()))
S = input()
w = [0]
v = 0
for a in range(len(S)-1):
    if S[a] == 'A' and S[a+1] == 'C':
        v += 1
    w.append(v)
for n in range(Q):
    l, r = list(map(int, input().split()))
    print(w[r-1] - w[l-1])


Measured memory_bytes: 6116
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
int main(){
	int W,H;cin>>W>>H;
	long P[W+1],Q[H+1]; P[W] = Q[H] = inf;
	long sum = 0;
	rep(i,0,W){ cin>>P[i]; sum += P[i]; }
	rep(i,0,H){ cin>>Q[i]; sum += Q[i]; }
	sort(P, P+W); sort(Q, Q+H);
	int j = 0;
	rep(i,0,W){
		while(P[i] > Q[j]) j++;
		sum += P[i] * (H - j);
	}
	j = 0;
	rep(i,0,H){
		while(Q[i] >= P[j]) j++;
		sum += Q[i] * (W - j);
	}cout<<sum<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
int n;
struct treasure{
	int v;
	int c;
	int vv;
};
treasure a[22];

int main(){
	int ans=0;
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i].v;
	}
	for (int i=0;i<n;i++){
		cin>>a[i].c;
	}
	for (int i=0;i<n;i++){
		a[i].vv=a[i].v-a[i].c;
	}
	for (int i=0;i<n;i++){
		if (a[i].vv>0) ans+=a[i].vv;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import array
N = int(input())
H = list(map(int, input().split()))
dp = array.array('i', [- 1]*N)
dp[-1] = 0
for i in range(N - 2, - 1, - 1):
    if H[i] >= H[i + 1]:
        dp[i] = dp[i + 1] + 1
    else:
        dp[i] = 0
print(max(dp))

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  
  int judge = (a * b) % 2;
  
  if (judge == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}

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

using namespace std;

long long Calc(vector<int> res) {
    long long total = 0;
    int n = res.size();
    for (int i = 1; i < n; ++i)
        total += abs(res[i] - res[i - 1]);
    return total;
}

pair<long long, vector<int>> Solve(vector<int> v) {
    int n = v.size();
    long long ret = 0;
    for (int first = n / 2 - 1; first <= n / 2 + 1 && first < n; ++first) {
        for (int second = first + 1; second <= n / 2 + 1 && second < n; ++second) {
            deque<int> w(v.begin(), v.end()); 
            int e1 = w[first], e2 = w[second];
            w.erase(w.begin() + second);
            w.erase(w.begin() + first);

            vector<int> res = {e1};
            for (int i = 0; i < n - 2; ++i) {
                if (i % 2 == 0) res.push_back(w.front()), w.pop_front();
                else res.push_back(w.back()), w.pop_back();
            }   
            res.push_back(e2);
            ret = max(ret, Calc(res));
            swap(res.front(), res.back());
            ret = max(ret, Calc(res));
        }
    }

    return {ret, {}};
}

int main() {
    int n; cin >> n;
    vector<int> v(n);
    for (auto& x : v) cin >> x;
    sort(v.begin(), v.end());

    pair<long long, vector<int>> best;
    for (int it = 0; it < 2; ++it) {
        best = max(best, Solve(v));
        reverse(v.begin(), v.end());
    }
    cout << best.first << endl;
}


Measured memory_bytes: 2364
n = int(input())
a = list(map(int,input().split()))

minus_cnt = 0
for i in range(n):
  if a[i] < 0:
    minus_cnt += 1
    a[i] *= -1
  
s = sum(a)
a.sort()
if(minus_cnt % 2 == 1):
  s -= a[0] * 2

print(s)

Measured memory_bytes: 14332
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll a[200001] = {};
ll s[200001] = {};
int main() {
	ll n; cin >> n;
	ll sum = 0;

	repe(i, 1, n) {
		cin >> a[i];
		sum += a[i];
	}
	//sort(a + 1, a + n + 1);
	repe(i, 1, n) {
		s[i] += s[i - 1] + a[i];
	}

	ll minV = MAX_L;
	rep(i, 1, n) {
		minV = min(minV, abs(s[i] - (sum - s[i])));
	}

	cout << minV << endl;
	return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int X = A + B;
  int Y = C + D;
  
  if (X < Y) {
    cout << "Right" << endl;
  }
  else if (X > Y) {
    cout << "Left" << endl;
  }
  else if (X == Y) {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#ifdef PERVEEVM_LOCAL
    #define debug(x) std::cerr << (#x) << ":\t" << (x) << std::endl
#else
    #define debug(x) 238;
#endif

#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define NAME "File"

using ll = long long;
using ld = long double;

#ifdef PERVEEVM_LOCAL
    std::mt19937 rnd(238);
#else
    std::mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const double PI = atan2(0.0, -1.0);
const int INF = 0x3f3f3f3f;
const ll LINF = (ll)2e18;
const int N = 110;
const int M = 100100;

int a[N];
int dp[M];

void run() {
    int n, k;
    scanf("%d%d", &n, &k);

    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }

    for (int i = 1; i <= k; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i - a[j] >= 0 && dp[i - a[j]] == 0) {
                dp[i] = 1;
            }
        }
    }

    if (dp[k] == 0) {
        printf("Second\n");
    } else {
        printf("First\n");
    }
}

int main(void) {
    // freopen(NAME".in", "r", stdin);
    // freopen(NAME".out", "w", stdout);

    auto start = std::chrono::high_resolution_clock::now();
    run();
    auto end = std::chrono::high_resolution_clock::now();

    #ifdef PERVEEVM_LOCAL
        std::cerr << "Execution time: "
                  << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()
                  << " ms" << std::endl;
    #endif

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)  ((a)*((b)/gcd(a,b)))
#define pi 3.14159265358979323846
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;

//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
    int x;
    cin>>x;
    if(x>=30)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    
    
	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#define MAX 500000
#define INFTY 2000000000
int cou=0;

 void merge(int A[],int left,int mid,int right){
  int n1=mid-left,n2=right-mid;
  int i,j,L[MAX/2+2],R[MAX/2+2],k; 
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=R[n2]=INFTY;

  i=j=0;

  for(k=left;k<right;k++){
    cou++;
    if(L[i]<=R[j]){A[k]=L[i];i++;}
    else {A[k]=R[j];j++;}

  }
}
void mergeSort(int A[],int left,int right){
  int mid;
  if(left+1 < right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}


int main(){
  int i,n,S[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&S[i]);

  mergeSort(S,0,n);

  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n%d\n",cou);
  return 0;
}

Measured memory_bytes: 4508
#include <iostream>

int main(int argc, char **argv)
{
    int s;

    std::cin >> s;
    int s1 = s / 100;
    int s2 = s % 100;
    bool f1 = s1 >= 1 && s1 <= 12;
    bool f2 = s2 >= 1 && s2 <= 12;
    std::string msg = f1 && f2 ? "AMBIGUOUS" :
                            f2 ? "YYMM" :
                      f1       ? "MMYY" : "NA";
    std::cout << msg << std::endl;

    return 0;
}

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

int main() {
  int N, n, r, s;
  cin >> N;
  n = N;
  s = 0;
  
  for (int i = 0; i < 9; i++) {
    r = n % 10;
    s += r;
    n /= 10;
  }
  
  if ((N % s) == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

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



int main(void) {
	int N;
	cin >> N;
	int ans=0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (i % 2 == 0) {
			if (a % 2 == 1) ans++;
		}
	}
	

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <tuple>


using namespace std;

#define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i,n) FOR((i),0,(n))
#define FORCLS(i,a,b) for(int (i) = (a); i <= (b); (i)++)
#define REPCLS(i,n) FORCLS((i),1,(n))

using Int = long;
const int N_MAX = 100003;
Int uf_city[N_MAX]; // union find;

Int root(Int i) {
    if (uf_city[i] == i) return i;
    return uf_city[i] = root(uf_city[i]);
}
void join(Int i, Int j){
    uf_city[root(j)] = root(i);
}

bool isSame(Int i, Int j){
    return root(i) == root(j);
}

Int n;
tuple<Int, Int, Int> xys[N_MAX];
tuple<Int, Int, Int> yxs[N_MAX];

void solve() {
    cin >> n;
    REP(i, n){
        Int x,y;
        cin >> x >> y;
        xys[i] = make_tuple(x,y,i);
        yxs[i] = make_tuple(y,x,i);
    }
    sort(xys, xys + n);
    sort(yxs, yxs + n);
    priority_queue<tuple<Int,Int,Int>,vector<tuple<Int,Int,Int>>, greater<tuple<Int,Int,Int>>> q;
    
    REP(i, n-1){
        Int x0,y0,i0;
        Int x1, y1, i1;
        Int d;
        tie(x0,y0,i0) = xys[i];
        tie(x1,y1,i1) = xys[i + 1];
        d = min(x1 - x0, abs(y1 - y0));
        q.push(make_tuple(d, i0, i1));
        
        tie(y0,x0,i0) = yxs[i];
        tie(y1,x1,i1) = yxs[i + 1];
        d = min(abs(x1 - x0), y1 - y0);
        q.push(make_tuple(d, i0, i1));
    }
    REP(i, n){
        uf_city[i] = i;
    }
    Int money = 0;
    while (!q.empty()) {
        Int d,i,j;
        tie(d,i,j) = q.top(); q.pop();
        if (!isSame(i, j)) {
            money += d;
            //cout << "join" << i << j << endl;
            join(i, j);
        }
//        REP(k ,n){
//            cout << k << ":" << uf_city[k] << ", ";
//        }
//        cout << endl;
    }
    cout << money << endl;
}

#ifdef DEBUG
#define MAIN hoge
#else
#define MAIN main
#endif

int MAIN() {
    solve();
    
    return 0;
}


Measured memory_bytes: 13168
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()

A = LIST()

n = max(A).bit_length()

ans = 0
r = 0
tmp = 0

for l in range(N):
	while r < N and tmp^A[r] == tmp+A[r]:
		tmp ^= A[r]
		r += 1
	ans += r-l
	tmp ^= A[l]

print(ans)

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

int main(){

    int n; cin >> n;
    vector<int> w(n, 0);
    vector<int> e(n, 0);
    string s; cin >> s;
    for(int i = 0; i < n; i++){
        if(s[i] == 'W') w[i] = 1;
        else e[i] = 1;
    }

    for(int i = 1; i <= n; i++) w[i] += w[i - 1];

    for(int i = n - 2; i >= 0; i--) e[i] += e[i + 1];
    

    int ans = 1000000000;
    for(int i = 0; i < n; i++){

        int tmp = 0;

        if(i != 0){
            tmp += w[i - 1];
        }

        if(i != n - 1) tmp += e[i + 1];
    
        ans = min(ans, tmp);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3204
import sys
H,W = map(int,input().split())
S = []
for i in range(H):
    S.append(list(input()))
    S[i].append('0')
S.append(['0']*W)    
for i in range(H):
    for j in range(W):
        black = [S[i][j-1],S[i][j+1],S[i+1][j],S[i-1][j]]
        if S[i][j] == '#':
            if '#' not in black:
                print('No')
                sys.exit()
print('Yes')

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

using namespace std;

int main()
{
    long long int i,j,n,k;
    cin >> n >> k;
    if(n<=1){
     cout << 0 <<endl;
     return 0;
    }
    vector<long long int>h(n);
    for(i=0;i<n;++i)
    cin >> h[i];
    vector<long long int>dp(n,INT_MAX);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(i=2;i<n;++i){
        for(j=1;j<=k && (i-j)>=0;++j){
           dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
        }
    }
    cout <<dp[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 4792
let range = (0..<Int(readLine()!)!-1).reverse()
var H = readLine()!.characters.split(" ").map{Int(String($0))!}
for i in range {
    if H[i] > H[i+1] {
        H[i] -= 1
    }
}
var ans = "Yes"
for i in range {
    if H[i] > H[i+1] {
        ans = "No"
    }
}
print(ans)

Measured memory_bytes: 7736
s = str(input())
for i in range(len(s)):
    s = s[:-1]
    if len(s) % 2 == 0:
        flag = 0
        for j in range(int(len(s)/2)):
            if s[j] == s[j+int((len(s)/2))]:
                flag += 1
        if flag == (int(len(s)/2)):
            print(len(s))
            break

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back
const long long INF = 1LL << 60;


int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> h(N);
  vector<ll> dp(N+K, INF);

  rep(i, N){
    cin >> h[i];
  }

  dp[0] = 0;
  for(int i = 0; i < N; i++){
    for(int j = i+1; j <= K+i; j++){ // とりあえずKまで代入しちゃう
      dp[j] = min(dp[j], dp[i] + abs(h[j]-h[i]));
    }
  }
  // rep(i, N){
  //   cout << dp[i] << " " ;
  // }
  
  cout << dp[N-1] << endl;

}


Measured memory_bytes: 1792
f=lambda:map(int,input().split())
n,m,x=f()
lc,ll=[],[]
for _ in range(n): c,*l=f(); lc+=[c]; ll+=[l]
a=10**9
for i in range(2**n):
  lm,t=[0]*m,0
  for j in range(n):
    if i>>j&1:
      for k in range(m): lm[k]+=ll[j][k]
      t+=lc[j]
  if all(s>=x for s in lm): a=min(a,t)
print([-1,a][a<10**9])

Measured memory_bytes: 9224
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = InputNumList();

            int dis1 = Math.Abs(a[0] - a[1]);
            int dis2 = Math.Abs(a[0] - a[2]);

            WriteLine(dis1 > dis2 ? "B" : "A");
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int MAX_N=100005;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

//Ｏ(n*log(logn))≒Ｏ(n)
int prime[MAX_N];         //i番目の素数
bool is_prime[MAX_N+1];    //is_prime[i]がtrueならiは素数

//n以下の素数の個数を返す。
int sieve(int n){
  int p=0;
  for(int t=0;t<=n;t++)is_prime[t]=true;
  is_prime[0]=is_prime[1]=false;
  for(int t=2;t<=n;t++){
    if(is_prime[t]==true){
      prime[p++]=t;
      for(int i=2*t;i<=n;i+=t)is_prime[i]=false;
    }
  }
  return p;
}

int dp[100005]; //dp[n]:=1からｎまでの２０１７に似た数の個数。

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

  int temp=sieve(100001);

  dp[1]=0;
  for(int r=3;r<100000;r+=2){
    bool flag=is_prime[r]&&is_prime[(r+1)/2];
    if(flag){
      dp[r]=dp[r-2]+1;
    }else{
      dp[r]=dp[r-2];
    }
  }

  queue<int>q;
  for(int t=0;t<Q;t++){
    int l,r;
    cin>>l>>r;
    int ans=dp[r]-dp[l-2];
    q.push(ans);
  }
  for(int t=0;t<Q;t++){
    cout<<q.front()<<"\n";
    q.pop();
  }
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,m,l[100002],r[100002],l_mx=0,r_mn=INF;
    cin >> n >> m;
    rep(i,m){
        cin >> l[i] >> r[i];
        l_mx = max(l_mx,l[i]);
        r_mn = min(r_mn,r[i]);
    }
    if(r_mn-l_mx < 0) cout << 0 << endl;
    else cout << r_mn-l_mx+1 << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>

int cek_faktor(int angka){
	int c=0;
	for(int i=1; i<=angka; i++){
		if(angka%i==0){
			c++;
		}
	}
	
	return c;
}

int main(){
	int a,b=0;
	scanf("%d", &a);
	for(int i=1; i<=a; i++){
		if(cek_faktor(i)==8&&i%2==1){
			b++;
		}
	}
	
	printf("%d\n", b);
	
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    a--; b--; c--; d--;

    if (c < d) {
        bool ans = true;
        int cnt = 0;
        for (int i = b; i <= d; i++) {
            if (s[i] == '#') {
                cnt++;
                if (cnt >= 2) {
                    ans = false;
                }
            } else {
                cnt = 0;
            }
        }

        cnt = 0;
        for (int i = a; i <= c; i++) {
            if (s[i] == '#') {
                cnt++;
                if (cnt >= 2) {
                    ans = false;
                }
            } else {
                cnt = 0;
            }
        }

        if (ans) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    } else {
        bool ans = true;
        int cnt = 0;
        for (int i = b; i <= d; i++) {
            if (s[i] == '#') {
                cnt++;
                if (cnt >= 2) {
                    ans = false;
                }
            } else {
                cnt = 0;
            }
        }

        cnt = 0;
        for (int i = a; i <= c; i++) {
            if (s[i] == '#') {
                cnt++;
                if (cnt >= 2) {
                    ans = false;
                }
            } else {
                cnt = 0;
            }
        }

        bool flag = false;
        int blank = 0;
        for (int i = b-1; i <= d+1; i++) {
            if (s[i] == '.') {
                blank++;
                if (blank >= 3) {
                    flag = true;
                }
            } else {
                blank = 0;
            }
        }

        if (!flag) ans = false;

        if (ans) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }

    return 0;
}

Measured memory_bytes: 888
n = int(input())
b = list(map(int, input().strip("").split(" ")))

sum = 0

for i in range(n-2):
    if b[i+1] > b[i]:
        sum += b[i]
    else:
        sum += b[i+1]
        
ans = sum + b[0] + b[n-2]

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p;
  
  for (int i = 1; i <= n; i++) {
    int pi;
    cin >> pi;
    p.push_back(pi);
  }
  
  int count = 0;
  for (int i = 1; i + 2 <= n; i++) {
    if ((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1]))
      count++;
  }
  
  cout << count << endl;
  return 0;
}


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

int main(){
    string S;
    cin >> S;

    int ans=0;
    int sum=0;
    rep(i, 3){
        if(S[i]=='R'){
            sum++;
            if(ans<sum) ans=sum;
        }else{
            if(ans<sum) ans=sum;
            sum=0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
A = int(input())
B = int(input())
C = int(input())
X = int(input())
x = 0
ans = 0
y = 0
a = [i for i in range((A + 1)* (B + 1) * (C + 1))]
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            x = 500 * i + 100 * j + 50 * k
            a[y] = x
            y += 1
ans = a.count(X)
print(ans)






Measured memory_bytes: 14192
import sys,bisect
sys.setrecursionlimit(15000)
h,w = map(int,sys.stdin.readline().split())
dp = [[0]*w for _ in range(h)]
m = 0
for i in range(h):
  a = list(map(int,sys.stdin.readline().split()))
  for j in range(w):
    if a[j] == 1:
      dp[i][j] = 0
    elif i == 0 or j == 0:
      dp[i][j] = 1
      m = max(m,dp[i][j])
    else:
      dp[i][j] = min(dp[i][j-1],dp[i-1][j],dp[i-1][j-1])+1
      m = max(m,dp[i][j])
print(m*m)


Measured memory_bytes: 43804
package main

import (
	"fmt"
	"strings"
)

func hasAllValue(m map[string]int, expect int) bool {
	for _, v := range m {
		if v != expect {
			return false
		}
	}
	return true
}

func main() {
	var s string
	fmt.Scan(&s)

	a := strings.Split(s, "")
	m := map[string]int{}
	for _, v := range a {
		m[v]++
	}

	if len(m) == 2 && hasAllValue(m, 2) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k, x;
  cin >> k >> x;
  if(k*500LL>=x){
    cout << "Yes" << "\n";
  }else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a <= c && b >= c || a >= c && b <= c) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

}


Measured memory_bytes: 23764
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, T;
    scan(N, T);
    auto A = aryread();
    long ans;
    foreach (i; 1 .. N)
    {
        ans += min(A[i] - A[i - 1], T);
    }
    writeln(ans + T);
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int N,P;

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
	set<ll> visit;

	bool CanReachImpl(int start,int end){
		bool reach=false;
		if(start==end) return true;

		for(int i=0,ei=graph[start].size();i<ei;i++){
			auto res = visit.emplace(graph[start][i].first);
			if(!res.second) continue;
			reach |= CanReachImpl(graph[start][i].first,end);
		}
		return reach;
	}
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddConnection2(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}

	bool CanReach(int start,int end){
		visit.clear();
		visit.emplace(start);
		return CanReachImpl(start,end);
	}
};

class BellmanFord{
	vector<ll> dist;
public:
	pair<ll,bool> CalcShortestPath(int start,int end,ConnectNodeInfo& connect){
		dist.resize(connect.size(),1LL<<60);

		dist[start] = 0;
		for(int i=0,ei=dist.size();i<ei;i++){
			for(int u=0,eu=connect.size();u<eu;u++){
				for(int v=0,ev=connect[u].size();v<ev;v++){
					auto& e = connect[u][v];

					if(dist[e.first]>dist[u]+e.second){
						dist[e.first] = dist[u]+e.second;
						if(i==ei-1 && connect.CanReach(start,u) && connect.CanReach(u,end)){
							return make_pair(dist[end],false);
						}
					}
				}
			}
		}
		return make_pair(dist[end],true);
	}
};

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

	N=in();
	int M=in();
	P=in();
	ConnectNodeInfo connect(N);
	REP(i,M){
		int u=in()-1,v=in()-1,w=in();
		connect.AddConnection2(u,v,-(w-P));
	}

	BellmanFord BF;
	auto res = BF.CalcShortestPath(0,N-1,connect);

	out(res.second? max(0LL,-res.first) : -1);
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c,d;
    scanf("%d %d %d\n",&a,&b,&c);
    
    if(a>=b){
        if(a>=c){
            d=10*a+b+c;
        }
        else{
            d=a+b+10*c;
        }
    }
    else{
        if(b>=c){
            d=a+10*b+c;
        }
        else{
            d=a+b+10*c;
        }
    }
    
    printf("%d",d);
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

template <int64_t MOD>
class Modint {
  using Self = Modint<MOD>;

  int64_t m_value;

 public:
  Modint() : m_value(0) {}
  Modint(int64_t value) : m_value((value % MOD + MOD) % MOD) {}
  Self pow(int64_t e) const {
    if (e == 0) {
      return (Self)1;
    } else if (e % 2 == 0) {
      return ((*this) * (*this)).pow(e / 2);
    } else {
      return (*this).pow(e - 1) * (*this);
    }
  }
  Self inv() const { return pow(MOD - 2); }
  Self& operator=(const Self& rh) {
    m_value = rh.m_value;
    return *this;
  }
  Self operator-() const { return Self(-m_value); }
  Self operator+(const Self& other) const {
    return Self(m_value + other.m_value);
  }
  Self operator-(const Self& other) const {
    return Self(m_value - other.m_value);
  }
  Self operator*(const Self& other) const {
    return Self(m_value * other.m_value);
  }
  Self operator/(const Self& other) const { return (*this) * other.inv(); }
  Self& operator+=(const Self& rh) { return (*this) = (*this) + rh; }
  Self& operator-=(const Self& rh) { return (*this) = (*this) - rh; }
  Self& operator*=(const Self& rh) { return (*this) = (*this) * rh; }
  Self& operator/=(const Self& rh) { return (*this) = (*this) / rh; }
  int64_t value() const { return m_value; }
};

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

  vector<int> a(N), b(N);
  rep(i, N) { cin >> a[i] >> b[i]; }

  const int AMAX = 2'000;
  const int M = AMAX * 2 + 1;

  using Mint = Modint<1'000'000'007>;
  vector<vector<Mint>> dp(M, vector<Mint>(M, 0));
  rep(i, N) { dp[AMAX - a[i]][AMAX - b[i]] += 1; }

  rep(i, M) rep(j, M) {
    if (i - 1 >= 0) {
      dp[i][j] += dp[i - 1][j];
    }
    if (j - 1 >= 0) {
      dp[i][j] += dp[i][j - 1];
    }
  }

  Mint result = 0;
  rep(i, N) { result += dp[a[i] + AMAX][b[i] + AMAX]; }

  vector<Mint> fact(AMAX * 4 + 1);
  fact[0] = 1;
  rep(i, AMAX * 4) { fact[i + 1] = fact[i] * (i + 1); }

  rep(i, N) {
    result -= fact[2 * (a[i] + b[i])] / (fact[2 * a[i]] * fact[2 * b[i]]);
  }
  result /= 2;
  cout << result.value() << endl;

  return 0;
}

Measured memory_bytes: 130216
#include <bits/stdc++.h>
#define MOD 1000000007
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
int A[500005];
vector <int> pos[500005];
int sum[500005];
 
int get(int s,int t)
{
	if(s>t) return 0;
	return sum[t]-sum[s-1];
}
int main()
{
	int n;
	scanf("%d",&n);
	vector <int> pxor;
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		A[i]=A[i-1]^x;
		pxor.push_back(A[i]);
	}
	pxor.push_back(0);
	sort(pxor.begin(),pxor.end());
	pxor.erase(unique(pxor.begin(),pxor.end()),pxor.end());
	
	for(int i=1;i<=n;i++)
	{
		A[i]=lower_bound(pxor.begin(),pxor.end(),A[i])-pxor.begin();
		pos[A[i]].push_back(i);
		sum[i]=sum[i-1]+(A[i]==0);
	}
	//for(int i=0;i<n;i++) printf("%d ",A[i]);puts("");
	ll ret=0;
	if(A[n]==0)//all 0
	{
		int cnt=pos[0].size()-1;
		ret=1;
		for(int i=0;i<cnt;i++) ret=ret*2LL%MOD;
	}
	
	for(int i=1;i<pxor.size();i++)
	{
		if(A[n]!=0&&A[n]!=i) continue;
		ll odd=0,even=1;
		int bef=0;
		for(int j=0;j<pos[i].size();j++)
		{
			int to=pos[i][j];
			even+=odd*(ll) get(bef,to-1)%MOD;
			if(even>=MOD) even-=MOD;
			odd+=even;
			if(odd>=MOD) odd-=MOD;
			bef=to+1;
		}
		if(A[n]==0)
		{
			ret+=odd;
			ret%=MOD;
		}
		else
		{
			ret+=even;
			ret%=MOD;
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 27504