akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> int2;



string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

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

#define COMMON_MOD 1000000007

ll mod_1097(ll a) {
  ll mod_a;
  if (a > COMMON_MOD) {
    mod_a = a % COMMON_MOD;
    // if (mod_a < 0) {
    //   mod_a += COMMON_MOD;
    // }
  } else {
    mod_a = a;
  }
  return mod_a;
}


ll calc_good(vector<ll> &a, int i, int b_length, vector<map<int, int>> &cache) {


  if (cache[i].find(b_length) != cache[i].end()) {
    return cache[i][b_length];
  }


  ll good_count = 0;
  for (int j = i; j < a.size(); j++) {
    if ((a[j] % (b_length + 1)) == 0) {
      good_count += 1;
      good_count += calc_good(a, j + 1, b_length + 1, cache);
      good_count = mod_1097(good_count);
    }
  }


  cache[i][b_length] = good_count;
  //debug(cache);

  return good_count;

}

vector<ll> get_primes(ll n) {
  vector<ll> primes = {};
  vector<ll> nums(n, 0);
  for (ll i = 2; i < n; i++) {
    if (nums[i] == 0) {
      primes.push_back(i);
      for (ll j = i*2; j < n; j += i) {
        nums[j] = i;
      }
    }
  }

  return primes;
}

vector<ll> sieve(ll n) {
  vector<ll> res(n+1, 0);
  res[n] = n;
  for (int i = 2; i < pow(n, 1/2); i++) {
    ll shuttle = i*i;
    while (shuttle < n) {
      res[shuttle] = i;
      shuttle += i;
    }
  }
  return res;
}




ll ceil_(ll a, ll b) {
  if (a % b == 0) {
    return a / b;
  } else {
    return a / b + 1;
  }

}


//sort(a.begin(), a.end(), less<ll>());
// string s;
// cin >> s;
//ios::sync_with_stdio(false);
//cin.tie(0);

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  string s;
  cin >> s;
  ll res = 0;
  ll white_count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'B') {
      white_count++;
    } else {
      res+=white_count;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 720
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, tmp, m, h, w, x, y, sum, k, q;
ll d;

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

  cin >> n >> d;
  rep(i, n) {
    cin >> x >> y;
    ll anss;
    anss = x * x + y * y;
    if (anss <= d * d) ans++;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N;
    cin >> N;
    ll ans = 1000, bc = -1, bn = -1;
    REP(i, N) {
        int A;
        cin >> A;
        if (bn == A) continue;
        if (bn != -1) {
            if (bn < A) {
                ans += bc * A;
                bc = -1;
            } else if (bn > A) {
                ans += bc * bn;
                bc = -1;
            }
        }

        bc = ans / A;
        bn = A;
        ans -= bc * bn;
    }
    ans += bc * bn;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

struct P{double x, y;};

vector<P> p;
ll n;

double dist(P p, P q){
  double res;
  double dx=p.x-q.x;
  double dy=p.y-q.y;
  res=sqrt(dx*dx+dy*dy);
  return res;
}

double f(double x, double y){
  double res=0;
  REP(i,n){
    res=max(res, dist((P){x,y},p[i]));
  }
  return res;
}

double g(double x){
  double l=0,r=1000;
  REP(hoge,80){
    double c1=(l*2+r)/3;
    double c2=(l+2*r)/3;
    if(f(x,c1)>f(x,c2))l =c1;
    else r=c2;
  }
  return f(x,l);
}

int main(){
  cin>>n;
  p=vector<P>(n);
  REP(i,n)cin>> p[i].x >> p[i].y;

  double l=0,r=1000;
  REP(hoge,80){
    double c1=(l*2+r)/3;
    double c2=(l+2*r)/3;
    if(g(c1)>g(c2))l =c1;
    else r=c2;
  }
  double ans=g(l);
  printf("%.10f\n",ans);
  return 0;
}


Measured memory_bytes: 384
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

class Program
{
	static void Main(string[] args)
	{
		string A = Console.ReadLine();
		string B = Console.ReadLine();
		string C = Console.ReadLine();

		string s = "a";

		while (true)
		{
			if (s == "a")
            {
				int len = A.Length;
				if (len == 0)
				{
					Console.WriteLine("A");
					return;
				}
				s = A.Substring(0, 1);
				if (len != 1)
                {
					A = A.Substring(1);
				}
                else
                {
					A = "";
                }
			}
			else if (s == "b")
			{
				int len = B.Length;
				if (B.Length == 0)
				{
					Console.WriteLine("B");
					return;
				}
				s = B.Substring(0, 1);
				if (len != 1)
				{
					B = B.Substring(1);
				}
				else
				{
					B = "";
				}
			}
			else if (s == "c")
			{
				int len = C.Length;
				if (C.Length == 0)
				{
					Console.WriteLine("C");
					return;
				}
				s = C.Substring(0, 1);
				if (len != 1)
				{
					C = C.Substring(1);
				}
				else
				{
					C = "";
				}
			}
		}
	}

	/// <summary>
	/// アナグラム
	/// </summary>
	/// <param name="word1"></param>
	/// <param name="word2"></param>
	/// <returns></returns>
	static bool IsAnagramOf(string word1, string word2)
	{
		return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
	}
	/// <summary>
	/// 最小公倍数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Lcm(long a, long b)
	{
		return a * b / Gcd(a, b);
	}

	/// <summary>
	/// 最大公約数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Gcd(long a, long b)
	{
		if (a < b)
			// 引数を入替えて自分を呼び出す
			return Gcd(b, a);
		while (b != 0)
		{
			var remainder = a % b;
			a = b;
			b = remainder;
		}
		return a;
	}
}




//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();
//Console.WriteLine(cnt);

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];


Measured memory_bytes: 25748
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	ll k;
	cin >> k;
	if (k <= 9) {
		cout << k;
		return 0;
	}
	queue<ll> v;
	ll x;
	reps(i, 1, 10) v.push(i);
	rep(i, k) {
		x = v.front();
		if (x % 10 != 0) v.push(10 * x + x % 10 - 1);
		v.push(10 * x + x % 10);
		if(x % 10 != 9) v.push(10 * x + x % 10 + 1);
		v.pop();
	}
	cout << x;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (double)(acos(-1))

int main() {
  double r;
  cin >> r;
  cout << fixed;
  cout << setprecision(8) <<(double) r * r * PI << " " <<(double) 2 * r * PI << endl;
  //cout <<(double) r * r * PI << " " <<(double) 2 * r * PI << endl;
  return 0;
}



Measured memory_bytes: 3268
N,M,Q=map(int,input().split())
qs=[list(map(int,input().split()))for i in range(Q)]
from itertools import combinations_with_replacement
com=combinations_with_replacement(range(1,M+1),N)
#print(list(com))
ans=0
for A in com:
    #print(A)
    tmp=0
    for a,b,c,d in qs:
        if (A[b-1]-A[a-1]==c):
            tmp+=d
    ans=max(ans,tmp)

print(ans)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
const int  N = 2e2 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
ll a[N][N];
void solve(){
    int n,d;
    cin >> n >> d;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= d; ++j) {
            cin >> a[i][j];
        }
    }
    ll cnt = 0;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j) {
            if(i != j) {
                double ds = 0;
                for(int k = 1; k <= d; ++k) {
                    ds += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
                }
                ds = sqrt(ds);
                if(int(ds) == ds) {
                    cnt ++;
                } 
            }
        }
    }
    cout << cnt/2;
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 256
T=input()
ans=''
i=0
N=len(T)
if N==1 and T=='?':
  print('D')
  exit(0)
while i<N:
  if T[i]!='?':
    ans=ans+T[i]
  else:
    if i>0 and i<N-1:
      if ans[-1]=='P':
        ans=ans+'D'
      elif ans[-1]=='D' and T[i+1]=='D':
        ans=ans+'P'
      elif ans[-1]=='D' and T[i+1]=='P':
        ans=ans+'D'
      elif ans[-1]=='D' and T[i+1]=='?':
        ans=ans+'PD'
        i+=1
    elif i==0:
      if T[i+1]=='D':
        ans=ans+'P'
      elif T[i+1]=='?':
        ans=ans+'PD'
        i+=1
      else:
        ans=ans+'D'
    elif i==N-1:
      ans=ans+'D'

        
  i+=1
print(ans)

Measured memory_bytes: 9472
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    String t = sc.next();
    
    String s1 = s.substring(0, 1);
    String s2 = s.substring(1, 2);
    String s3 = s.substring(2, 3);
    
    String t1 = t.substring(0, 1);
    String t2 = t.substring(1, 2);
    String t3 = t.substring(2, 3);
    
    if (s1.equals(t3) && s2.equals(t2) && s3.equals(t1)) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int a[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 };
signed main() {
	int k;
	cin >> k;
	cout << a[k - 1] << endl;
	ggr
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

ll b[100010];

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[i];
  b[0]=a[0];
  rep(i,n){
    b[i+1]=b[i];
    if((i+1)%2==0)b[i+1]+=a[i+1];
    else b[i+1]-=a[i+1];
  }
  rep(i,n){
    int temp1=i+1;
    if(temp1==n)temp1=0;
    int temp2=i-1;
    if(temp2==-1)temp2=n-1;
    ll ans=0;
    ans=2*b[temp2]-b[n-1];
    cout << abs(ans) << ' ' ;
  }

  cout << endl;
return 0;}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  int m=1;
  for(int i=0;i<N;i++){
    if(m*2<=m+K){
      m=m*2;
    }
    else{
      m=m+K;
    }
  }
  cout<<m<<endl;
}
    

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    if (A == B && B != C){
    	printf("Yes");
	}
    else if (A == C && C != B){
    	printf("Yes");
	}
    else if (B == C && C != A){
    	printf("Yes");
	}
    else{
    	printf("No");
	}
    return 0;
}

Measured memory_bytes: 3172
import java.util.Arrays;
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);

	void solve(){
		int n=gInt();
		int[]v=INTS(n).toArray();
		int[]dpl=new int[n+2];
		int[]dpr=new int[n+2];
		
		for(int i:rep(n))
			dpl[v[i]]=Math.max(dpl[v[i]],dpl[v[i]-1]+1);
		for(int i:rrep(0,n-1))
			dpr[v[i]]=Math.max(dpr[v[i]],dpr[v[i]+1]+1);
		
		System.out.println(
				n-
				IntStream.concat(
						Arrays.stream(dpl),
						Arrays.stream(dpr)
						)
				.max().getAsInt()
				);
	}

	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}
class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

}

Measured memory_bytes: 52148
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define eps 1e-8
using namespace std;
const ll maxn = 1e6 + 5;
ll n,m,book[maxn],k,c;
char str[maxn];
int main()
{
    cin >> n >> k >> c >> (str + 1);
    int cnt = c,t = k;
    for(int i = 1; i <= n; i++){
        if(str[i] == 'o' && cnt >= c)
            t--,book[i]++,cnt = 0;
        else
            cnt++;
    }
    if(t < 0)
        return 0;
    cnt = c,t = k;
    for(int i = n; i >= 1; i--){
        if(str[i] == 'o' && cnt >= c)
            t--,book[i]++,cnt = 0;
        else
            cnt++;
    }
    for(int i = 1; i <= n; i++)
        if(book[i] == 2)
            cout << i << endl;
    return 0;
}


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

int main() {
  int N, A, a;
  
  cin >> N >> A;

  if (N <= A) {
    cout << "Yes" << endl;
  }
  else{
    a = N % 500;
    if(a <= A){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;
typedef pair<int,ll>pl;

const int MAX_N = 40;

ll a[MAX_N];
vector<pl> x,y;

void solve(int s,int t,vector<pl> &x)
{
	int z = t-s;
	rep(i,1<<z){
		pl p = pl(0,0);
		rep(j,z){
			if(i&(1<<j)){
				p.first++;
				p.second += a[s+j];
			}
		}
		x.push_back(p);
	}
}

int main()
{
	int n,k;
	ll l,r;
	cin >> n >> k >> l >> r;
	rep(i,n){
		scanf("%lld",&a[i]);
	}
	solve(0,n/2,x);
	solve(n/2,n,y);
	sort(y.begin(),y.end());
	ll ans = 0;
	rep(i,x.size()){
		ans += upper_bound(y.begin(),y.end(),pl(k-x[i].first,r-x[i].second))-lower_bound(y.begin(),y.end(),pl(k-x[i].first,l-x[i].second));
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 43796
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<double,P> PP;
struct edge { int to; int cost; };
string ans[] = { "NA","MMYY","YYMM","AMBIGUOUS" };
signed main() {
	int n, k; cin >> n >> k;
	string s; cin >> s;
	s[k - 1] += 32;
	cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int(i) = 0;(i) < (n); (i)++)
int main(){
    string S;
    int n = 0;
    cin >> S;
    if(S.at(2) == S.at(3)){
        if(S.at(4) == S.at(5)){
            n++;
        }
    }
    if(n > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
"use strict"

const arg_str = require('fs').readFileSync('/dev/stdin', 'UTF-8')
const args_lines = arg_str.split('\n')
const n = args_lines[0]
const monsters = args_lines[1].split(' ')
const stocks = args_lines[2].split(' ')

let total_kill_cnt = 0
let index = 0

stocks.forEach((item, index)=>{
  // i番目の街を攻撃
  if(parseInt(monsters[index]) < parseInt(stocks[index])){
    const kill_cnt = parseInt(monsters[index])
    total_kill_cnt += kill_cnt
    stocks[index] -= kill_cnt
    monsters[index] -= kill_cnt
  }else{
    const kill_cnt = parseInt(stocks[index])
    total_kill_cnt += kill_cnt
    stocks[index] -= kill_cnt
    monsters[index] -= kill_cnt
  }
  // 余力があればi+1番目の街を攻撃
  if(parseInt(stocks[index]) > 0 && index + 1 <= monsters.length - 1){
    if(monsters[index+1] < stocks[index]){
      const kill_cnt = parseInt(monsters[index+1])
      total_kill_cnt += kill_cnt
      stocks[index] -= kill_cnt
      monsters[index+1] -= kill_cnt
    }else{
      const kill_cnt = parseInt(stocks[index])
      total_kill_cnt += kill_cnt
      stocks[index] -= kill_cnt
      monsters[index+1] -= kill_cnt
    }
  }
})

console.log(total_kill_cnt)

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

using namespace std;

#define pt pair<int, int>
#define x first
#define y second
#define what_is(x) cerr << #x << " is " << x << endl;
#define endl '\n'
#define int long long
#define ld long double
random_device rd;
mt19937 rnd(rd());
const int inf = __LONG_LONG_MAX__;

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

	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c > 21)
		cout << "bust" << endl;
	else
		cout << "win" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  vector<P> x;
  int i,n,a,b,y,z;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a >> b;
    x.push_back(P(a,b));
  }
  sort(x.begin(),x.end());
  if(n%2==1){
    y=x[(n-1)/2].first;
  }
  else{
    y=x[(n-1)/2].first+x[(n+1)/2].first;
  }
  for(i=0;i<n;i++){
    swap(x[i].first,x[i].second);
  }
  sort(x.begin(),x.end());
  if(n%2==1){
    z=x[(n-1)/2].first;
  }
  else{
    z=x[(n-1)/2].first+x[(n+1)/2].first;
  }
  cout << z-y+1 << endl;
  return 0;
}

Measured memory_bytes: 5376
#include<stdio.h>
 int main()
 {
    int a;
    scanf("%d", &a);
    
    int h=a/3600;
    int m=(a-h*3600)/60;
    int s=a-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
 }


Measured memory_bytes: 2712
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define pii pair<ll,ll>
#define ff first
#define ss second
#define mxx 100005
#define endl "\n"
const ll mod=1e9+7;

ll a=1e18;

int main()
{
    ll n,k=0;
    cin>>n;
    vector<ll>v;
    while(n--)
    {
        ll x;
        cin>>x;
        v.pb(x);
        if(x==0)
        {
            k=1;
        }
    }

    if(k)
    {
        cout<<0<<endl;
        return 0;
    }

    ll ans=1;
    for(auto it:v)
    {
       if(it>a/ans)
       {
           ans=-1;
           break;
       }
       ans*=it;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	REP(i, N) scanf("%d", A.begin() + i);
	sort(ALL(A));
	
	int ans = 0;
	set<pii> ss;
	REP(i, N) ss.insert(pii(A[i], i));
	for (int i = N - 1; i >= 0; i--) {
		if (ss.find(pii(A[i], i)) == ss.end()) continue;
		int b;
		for (int j = 29; j >= 0; j--) if (A[i] >> j & 1) {
			b = (1<<j+1) - A[i];
			break;
		}
		
		auto it = ss.lower_bound(pii(b, -1));
		if (it == ss.end() || it->fi != b || it->se == i) continue;
		ss.erase(pii(A[i], i));
		ss.erase(it);
		ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}




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

int cmf(const void *p, const void *q){
    return *(int*)p - *(int*)q;
}

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

    qsort(a, n, sizeof(int), cmf);

    int result = 0;
    for(int i = n-1; i >= 0; i -= 2){
        result += a[i];
    }
    for(int i = n-2; i >= 0; i -= 2){
        result -= a[i];
    }

    cout << result << endl;
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m, e[701][700];
vector<int> g[700];

bool dp[700][1400];

int c[700];
bool dfs(int i, int s, pair<int, int> & x) {
	if(c[i] != 0) { return (c[i] == s); }
	
	c[i] = s;
	(s == +1 ? x.FI : x.SE) += 1;
	for(auto && e: g[i]) {
		if(! dfs(e, -s, x)) { return false; }
	}
	return true;
}

int main() {
	cin >> n >> m;
	inc(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		e[a][b] = 1;
		e[b][a] = 1;
	}
	
	inc(i, n) {
	inc(j, n) {
		if(i != j && e[i][j] == 0) { g[i].PB(j); }
	}
	}
	
	vector<pair<int, int>> v;
	bool flag = true;
	inc(i, n) {
		pair<int, int> x = MP(0, 0);
		if(c[i] == 0) {
			if(! dfs(i, +1, x)) { flag = false; break; }
		}
		if(x != MP(0, 0)) { v.PB(x); }
	}
	if(! flag) { cout << -1 << endl; return 0; }
	
	dp[0][0] = true;
	inc(i, v.size()) {
	inc(j, n) {
		if(dp[i][j]) {
			dp[i + 1][j + v[i].FI] = true;
			dp[i + 1][j + v[i].SE] = true;
		}
	}
	}
	
	int x = -1;
	incII(j, 0, n / 2) {
		if(dp[v.size()][j]) { x = j; }
	}
	int y = n - x;
	
	// cout << "xy: " << x << "  " << y << endl;
	
	cout << (x * (x - 1) / 2) + (y * (y - 1) / 2) << endl;
	
	return 0;
}


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

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1(size);
    for (auto& v : vec1) {
        v = cin2var<T>();
    }
    return vec1;
}

void sub()
{
    const auto M(cin2var<size_t>());
    const auto N(cin2var<size_t>());

    vec1<tuple<int64_t, size_t>> vs;
    for (size_t i = 0; i < M; ++i) {
        const auto    As(cin2vec<int64_t>(N));
        const int64_t sum = accumulate(As.cbegin(), As.cend(), 0ull);
        vs.push_back(make_tuple(sum, i + 1));
    }
    sort(vs.rbegin(), vs.rend());

    cout << get<0>(vs.front()) << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    sub();
    return 0;
}


Measured memory_bytes: 3176
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
  int a,b,c,q,x;
  a=0;
  scanf("%d",&x);
  for(b=1;b<33;b++){
   for(q=2;q<11;q++){
     c=pow(b,q);
     if(c<=x){
       a=fmax(a,c);
     }
   }
 }
  printf("%d",a);
  return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;

    int res = 0;
    int ptr = 1;
    for (int i = 0; i < n; ++i){
        int a;
        cin >> a;
        // cout << ptr << " " << a << endl;
        // cout << res << endl;
        if(a != ptr) res++;
        else ptr++;
    }
    if(res==n)cout << -1 << endl;
    else cout << res << endl;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TemplateAlgorithm
{
    class Program
    {
        public const long Inf = (long)1e18;
        public const double eps = 1e-6;
        public const string alfa = "abcdefghijklmnopqrstuvwxyz";
        public const string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        public const int MOD = 1000000007;


        static void Main(string[] args)
        {
            var data = IO.ReadIntArr();
            int N, X;
            N = data[0];
            X = data[1];

            long[] L;
            L = IO.ReadLongArr();

            var D = new long[N + 1];
            D[0] = 0;

            for (var i = 0; i < N; i++)
            {
                D[i + 1] = D[i] + L[i];
            }


            WriteLine(D.Where(i => i <= X).Count());
        }

        static int ToInt(char c) => c - '0';



        #region MIN,MAX

        /// <summary>
        /// 最大値を返す
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="vals"></param>
        /// <returns></returns>
        public static T MaxValue<T>(params T[] vals) => vals.Max();

        /// <summary>
        /// 最小値を返す
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="vals"></param>
        /// <returns></returns>
        public static T MinValue<T>(params T[] vals) => vals.Min();
        #endregion
    }

    #region IO

    /// <summary>
    /// IO
    /// </summary>
    public class IO
    {
        public static string ReadStr(bool isTrim = false) => (isTrim) ? ReadLine().Trim() : ReadLine();
        public static int ReadInt() => int.Parse(ReadStr());

        public static long ReadLong() => long.Parse(ReadStr());

        public static decimal ReadDecimal() => decimal.Parse(ReadStr());
        public static double ReadDouble() => double.Parse(ReadStr());
        public static string[] ReadStrArr(char separator = ' ') => ReadLine().Split(separator);
        public static int[] ReadIntArr() => Array.ConvertAll(ReadStrArr(), int.Parse);
        public static long[] ReadLongArr() => Array.ConvertAll(ReadStrArr(), long.Parse);

        public static decimal[] ReadDecimalArr() => Array.ConvertAll(ReadStrArr(), decimal.Parse);
        public static double[] ReadDoubleArr() => Array.ConvertAll(ReadStrArr(), double.Parse);

        public static void Cout<T>(T value) => WriteLine(value);
        public static void CoutJoin<T>(T[] values, string separator = " ") => Cout(string.Join(separator, values));
    }

    #endregion    
}


Measured memory_bytes: 11348
#include <iostream>

using namespace std;

typedef long long ll;
const ll N = 1e5 + 7;
ll n, a[N], b[N], ans, minn;

int main()
{
	cin >> n;
	for (ll i = 1; i <= n + 1; i++) cin >> a[i];
	for (ll i = 1; i <= n; i++) cin >> b[i];
	for (ll i = 1; i <= n; i++)
	{
		minn = min(a[i], b[i]);
		a[i] -= minn;
		b[i] -= minn;
		ans += minn;
		minn = min(a[i + 1], b[i]);
		a[i + 1] -= minn;
		b[i] -= minn;
		ans += minn;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

string a, b;

int main() {
    fastio();

    cin >> a >> b;

    if (a.size() > b.size()) {
        cout << "GREATER" << endl;
    } else if (a.size() < b.size()) {
        cout << "LESS" << endl;
    } else {
        if (a == b) {
            cout << "EQUAL" << endl;
        } else if (a > b) {
            cout << "GREATER" << endl;
        } else {
            cout << "LESS" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#coding: utf-8
from itertools import product

N = int(input())
F = [[int(x) for x in input().split()] for _ in range(N)]
P = [[int(x) for x in input().split()] for _ in range(N)]

ret = -10 ** 18

# skip (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
itr = product([0, 1], repeat=10)
itr.__next__()
for bit in itr:
    cand = sum((P[i][sum((f*b for f, b in zip(F[i], bit)))] for i in range(N)))
    ret = max(ret, cand)

print(ret)


Measured memory_bytes: 9204
#include<stdio.h>
int main(){
	int a,b,x,i;
	char z;
	for(i=0;i<=100000;i++){
		scanf("%d %c %d",&a,&z,&b);
		if(z == '+'){x=a+b;};
		if(z == '-'){x=a-b;};
		if(z == '*'){x=a*b;};
		if(z == '/'){x=a/b;};
		if(z == '?'){break;};
		printf("%d\n",x);
		}
	return 0;}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    int Max = 1;
    int i = 1;
    while (i * i <= n) {
        Max = i * i;
        i++;
    }

    cout << Max << endl;

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

char b[64][64];
int w, h;

inline int id(int x, int y){
  return y * w + x;
}

int dx[6] = { 0, 1, 1, 0, -1, -1 };
int dy[2][6] = {
  { 1, 1, 0, -1, 0, 1 },
  { 1, 0, -1, -1, -1, 0 }
};

#define REPEX(x, y, xx, yy) \
 for(int _ = 0, xx, yy; (_ < 6) && ((xx = x + dx[_]), (yy = y + dy[x % 2][_]), true); _++)

int memo[64][64];

int dfs(int y, int x, int id){
  int ret = 1;
  memo[y][x] = id;
  REPEX(x, y, xx, yy) if(ISIN(xx, yy, w, h) && b[yy][xx] == b[y][x] && memo[yy][xx] == -1){
    ret += dfs(yy, xx, id);
  }
  return ret;
}

void printBoard(){
  REP(i,h){
    puts(b[h - i - 1]);
  }
}

bool erase(){
  bool ret = false;
  REP(i,h) REP(j,w) memo[i][j] = -1;
  int id = 0;
  vector<int> e(h * w);
  REP(i,h) REP(j,w) if(memo[i][j] == -1 && b[i][j] != '.'){
    const int cnt = dfs(i, j, id);
    if(cnt >= 3){ e[id] = 1; ret = true; }
    id++;
  }
  REP(i,h) REP(j,w) if(memo[i][j] != -1 && e[memo[i][j]])
    b[i][j] = '.';
  // printBoard(); REP(i,h){ REP(j,w) printf("%d ", memo[i][j]); puts(""); }
  return ret;
}

bool canDrop(int x, int y){
  for(int i = 2; i <= 4; i++){
    const int xx = x + dx[i];
    const int yy = y + dy[x % 2][i];
    if(ISIN(xx, yy, w, h) && b[yy][xx] != '.') return false;
  }
  return true;
}

bool drop(){
  bool ret = false;
  REP(i,h - 1){
    const int y = i + 1;
    for(int x = 1; x < w; x += 2){
      if(b[y][x] == '.') continue;
      int yy = y;
      while(yy > 0 && canDrop(x, yy)){ yy--; ret = true; }
      if(y != yy) swap(b[yy][x], b[y][x]);
    }
    for(int x = 0; x < w; x += 2){
      if(b[y][x] == '.') continue;
      int yy = y;
      while(yy > 0 && canDrop(x, yy)){ yy--; ret = true; }
      if(y != yy) swap(b[yy][x], b[y][x]);
    }
  }
  // printf("drop: %d\n", ret);
  return ret;
}

bool rotate(int x, int y){
  REPEX(x, y, xx, yy) if(!ISIN(xx, yy, w, h)) return false;

  for(int i = 0; i < 5; i++){
    const int p = (6 - i) % 6;
    const int q = (5 - i) % 6;
    swap(b[y + dy[x % 2][p]][x + dx[p]],
         b[y + dy[x % 2][q]][x + dx[q]]);
  }

  return true;
}

void process(){
  while(drop() || erase());
}

int main(){
  h = getInt(); w = getInt();
  REP(i,h) scanf("%s", b[h - i - 1]);

  process();
  const int q = getInt();
  REP(_,q){
    const int x = getInt();
    const int y = getInt();
    if(rotate(x, y)) process();
  }

  printBoard();
  return 0;
}


Measured memory_bytes: 1052
/**
 * ???????????£??????????????? 3?¬?????????????
 */

// #include {{{
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <random>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>
// }}}

using namespace std;

// macros {{{
template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

template<typename T>
void PRINT_MATRIX(T mat, size_t nr, size_t nc)
{
    for(size_t r = 0; r < nr; ++r) {
        for(size_t c = 0; c < nc; ++c) {
            cout << mat[r][c] << (c==nc-1 ? "" : " ");
        }
        cout << "\n";
    }
}

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)
// }}}

// types {{{
using ll  = long long;
using ull = unsigned long long;
// }}}

constexpr int INF = numeric_limits<int>::max();

int V;
int E;
vector<vector<vector<int>>> dp;

void warshallfloyd()
{
    FOR(k, 0, V) {
        REP(i, V) {
            REP(j, V) {
                if(dp[k][i][k] == INF || dp[k][k][j] == INF) {
                    dp[k+1][i][j] = dp[k][i][j];
                }
                else {
                    dp[k+1][i][j] = min(dp[k][i][j], dp[k][i][k] + dp[k][k][j]);
                }
            }
        }
    }
}

void solve()
{
    warshallfloyd();

    bool ok = true;
    REP(v, V) {
        if(dp[V][v][v] < 0) ok = false;
    }

    if(!ok) {
        cout << "NEGATIVE CYCLE" << "\n";
    }
    else {
        REP(i, V) {
            REP(j, V) {
                int d = dp[V][i][j];
                if(d == INF) {
                    cout << "INF";
                }
                else {
                    cout << d;
                }
                cout << (j == V-1 ? "\n" : " ");
            }
        }
    }
}

int main()
{
    cin >> V >> E;
    dp.resize(V+1);
    for(auto& mat : dp) {
        mat.resize(V);
        for(auto& row : mat) {
            row.resize(V);
        }
    }

    REP(from, V) {
        REP(to, V) {
            dp[0][from][to] = (from == to ? 0 : INF);
        }
    }

    REP(_, E) {
        int s, t, d;
        cin >> s >> t >> d;
        dp[0][s][t] = d;
    }

    solve();

    return 0;
}

Measured memory_bytes: 7020
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, M;

int main() {

	cin >> N >> M;



	if (N - M)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(){
	char n[3];
	int i;
	for(i=0;i<3;++i){
		scanf("%c",&n[i]);
	}
	
	if(n[0] == '7' || n[1] == '7' || n[2] == '7'){
		puts("Yes");
	}else{
		puts("No");
	}
	
	return 0;
}

Measured memory_bytes: 1588
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 1e+9

int main() {
	int n;
    while(cin>>n){
        if(!n)break;
        
        int a,b,c,v=0,d[11][11];
        
        for(int i=0;i<11;i++){
            for(int j=0;j<11;j++){
                if(i==j)d[i][j]=0;
                else d[i][j]=INF;
            }
        }
        
        for(int i=0;i<n;i++){
            cin>>a>>b>>c;
            d[a][b]=c;
            d[b][a]=c;
            v=max(max(v,a),b);
        }
        
        for(int k=0;k<=v;k++){
            for(int i=0;i<=v;i++){
                for(int j=0;j<=v;j++)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
        int  ans1=INF,ans2;
        for(int i=0;i<=v;i++){
            int count=0;
            for(int j=0;j<=v;j++){
                count+=d[i][j];
            }
            if(ans1>count){
                ans1=count;
                ans2=i;
            }
        }
        
        cout<<ans2<<" "<<ans1<<endl;
    }
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#pragma GCC target("avx2")
using namespace std;

const int inf = 1e9 + 13;

signed main () {
    int n;
    cin >> n;
    vector < int > need(4);
    for (int i = 1; i < 4; ++i)
        cin >> need[i];
    vector < int > l(n);
    for (int i = 0; i < n; ++i)
        cin >> l[i];
    sort(l.rbegin(), l.rend());
    int ans = inf;
    for (int mask = 0; mask < (1 << (2 * n)); ++mask) {
        vector < int > sum(4);
        vector < int > cnt(4);
        int m = mask;
        for (int i = 0; i < n; ++i) {
            if (m & 3) {
                sum[m & 3] += l[i];
                ++cnt[m & 3];
            }
            m >>= 2;
        }
        int here = 0;
        bool can = 1;
        for (int i = 1; i <= 3; ++i) {
            if (cnt[i] == 0)
                can = 0;
            else 
                here += abs(need[i] - sum[i]) + (cnt[i] - 1) * 10;
        }
        if (can)
            ans = min(here, ans);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256