akhauriyash/Code-Regression huggingface dataset:
// 2020-08-23 19:43:21
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

const int inf = 1e9+5;
void answer() {
  int n, t;
  cin >> n >> t;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = 1;
  {
    int minai = 0, maxd = -inf-10;
    REP(i, 1, n) {
      if(chmax(maxd, a[i] - a[minai])) ans = 0;
      if(maxd == a[i] - a[minai]) ans++;
      if(a[i] < a[minai]) minai = i;
    }
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3728
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

ll gcd(ll a, ll b){
    ll temp;
	while (a % b != 0){
		temp = b;
		b = a % b;
		a = temp;
	}
	return b;
}

ll lcm(ll a, ll b){
  return a * b / gcd(a,b);
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};

ll digit__(ll num){
    ll cnt=1;
    while(num > 10){
        cnt ++;
        num /= 10;
    }
    return cnt;
}


int main(){
    int N,a;
    cin >> N;
    rep(i,N){
        cin >> a;
        if (a%2==0){
            if (a%3!=0 && a%5!=0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;

    return 0;
}


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

bool j(string s){
    string t = s;
    reverse(t.begin(),t.end());
    return t == s;
}

int main(){
    string s;

    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5])  puts("Yes");
    else
    {
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans = 0
now = 1
for i in range(N):
	if A[i] == now:
		now += 1
		continue
	else:
		ans += 1
if now == 1 and ans == N:
	print(-1)
else:
	print(ans)


Measured memory_bytes: 32396
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
vector<int>a[1000001];
int n,m;
int p[1000001];
int vis[1000001];
int cnt;map<pair<int,int>,int>p1;
void dfs(int node,int fa){
	if(vis[node])
	return ;
	vis[node]=1;
	int flag=0;
	for(auto u:a[node]){
			if(p[u]<p[node]){
				continue;
			}
			else
			flag=1;
		//cout<<node<<" "<<u<<endl;
	}
	if(!flag) {
		//cout<<node<<endl;
		cnt++;
	}
	for(auto u:a[node]){
		if(u!=fa){
			dfs(u,node);
		}
	}
	
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>n>>m;
    rep(i,1,n+1) cin>>p[i];
    rep(i,1,m+1){
    	int x,y;
    	cin>>x>>y;
    		a[x].pb(y);
    		a[y].pb(x);
	}
	rep(i,1,n+1){
		if(!vis[i]){
			//cout<<i<<endl;
			dfs(i,0);
		}
		
	}
	cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 31864
N, W = list(map(int, input().split()))
dp = [-1] * (W + 1)
dp[0] = 0
for i in range(N):
    w, v = list(map(int, input().split()))
    next = dp[:]
    for i in range(W):
        if dp[i] >= 0 and i + w <= W:
            next[i+w] = max(dp[i+w], dp[i] + v)
    dp = next

print(max(dp))


Measured memory_bytes: 68004
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto A = new long[](N);
	foreach (i; 0..N)
		A[i] = RD;

	auto B = new long[](N+1);
	auto C = new long[](N+1);
	foreach (i; 0..N)
	{
		B[i+1] = max(B[i], A[i]);
	}
	foreach_reverse (i; 0..N)
	{
		C[i] = max(C[i+1], A[i]);
	}
	foreach (i; 0..N)
	{
		writeln(max(B[i], C[i+1]));
	}
	stdout.flush();
	debug readln();
}


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,x;cin>>n>>x;
  vector<ll>m(n);
  rep(i,0,n)cin>>m[i];
  sort(ALL(m));
  rep(i,0,n){
    buf+=m[i];
  }
  cout<<n+(x-buf)/m[0]<<endl;
  return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	string S, T; cin >> S >> T;
	int cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != T[i]) cnt++;
	}
	cout << cnt << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3800
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using StructLayoutAttribute = System.Runtime.InteropServices.StructLayoutAttribute;
using FieldOffsetAttribute = System.Runtime.InteropServices.FieldOffsetAttribute;
using System.Runtime.CompilerServices;

static class P
{
    static void Main()
    {
        var n = Read();
        var k = Read();
        int[] bitCount = new int[40];
        for (int i = 0; i < n; i++)
        {
            var value = Read();
            for (int j = 0; j < 40; j++) bitCount[j] += (int)((value >> j) & 1);
        }
        long restrictedMax = 0;
        long freeMax = 0;
        for (int i = 0; i < 40; i++)
        {
            var scoreOne = (n - bitCount[i]) * (1L << i);
            var scoreZero = bitCount[i] * (1L << i);
            if (((k >> i) & 1) == 1) restrictedMax = Max(freeMax + scoreZero, restrictedMax + Max(scoreZero, scoreOne));
            else restrictedMax += scoreZero;
            freeMax += Max(scoreZero, scoreOne);
        }
        Console.WriteLine(restrictedMax);
    }

    static readonly TextReader In = Console.In;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static long Read()
    {
        long res = 0;
        int next = In.Read();
        while (48 > next || next > 57) next = In.Read();
        while (48 <= next && next <= 57)
        {
            res = res * 10 + next - 48;
            next = In.Read();
        }
        return res;
    }
}


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

bool digitsodd(int x){
  int count=0;
  while(x>0){
    x/=10;
    count++;
  }
  return count%2!=0;
}

int main() {
  int N;
  cin >> N;
  int count=0;
  for(int i=1;i<=N;i++){
    if(digitsodd(i)) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3588
d={}
for _ in[0]*int(input()):
 k,v=input().split()
 d[k]=d.get(k,0)+int(v)
for k in sorted(d,key=lambda x:(sum(27**i*(ord(k)-64)for i,k in enumerate(x[::-1])),x)):
 print(k,d[k])


Measured memory_bytes: 5684
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var pp = input.ReadLine().Trim();//ToIntArray(input.ReadLine(), n);
        var qq = input.ReadLine().Trim();//ToIntArray(input.ReadLine(), n);

        var ary = new int[n];
        for (int i = 0; i < n; i++) ary[i] = i+1;

        var list = AllPattern(ary);
        var slist = new List<string>();
        foreach(var x in list) {
            var b = new StringBuilder(n * 2);
            foreach(var y in x) {
                b.Append(y);
                b.Append(' ');
            }
            slist.Add(b.ToString().Trim());
        }

        slist.Sort();
        var pn = 0;
        var qn = 0;
        for(int i=0; i<slist.Count; i++) {
            if (slist[i] == pp) pn = i;
            if (slist[i] == qq) qn = i; 
        }

        return Math.Abs(pn-qn);
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }

    static List<T[]> AllPattern<T>(T[] input) {
        return AllPattern(input, new HashSet<int>());
    }
    static List<T[]> AllPattern<T>(T[] input, HashSet<int>usedidx) {
        var ret = new List<T[]>();

        for(int i=0; i<input.Length; i++) {
            if (usedidx.Contains(i)) continue;

            if (usedidx.Count == input.Length-1) {
                var ary = new T[input.Length];
                ary[usedidx.Count] = input[i];
                ret.Add(ary);
            } else {
                var usedidx2 = new HashSet<int>(usedidx);
                usedidx2.Add(i);
                var sublist = AllPattern(input, usedidx2);
                //usedidx.Add(i);
                //var sublist = AllPattern(input, usedidx);
                //usedidx.Remove(i);

                foreach (var sub in sublist) {
                    var ary = new T[input.Length];
                    Array.Copy(sub, ary, ary.Length);
                    ary[usedidx.Count] = input[i];
                    ret.Add(ary);
                }
            }
        }

        return ret;
    }
}


Measured memory_bytes: 31648
#include <stdio.h>
int main(){
	int x, y;

	while (1){
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0)break;

		if (x > y){
			printf("%d %d\n", y, x);
		}
		else{
			printf("%d %d\n", x, y);
		}
	}

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define fi first
#define se second
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5 + 5;
 
int n;
ll a[N], p[62];
 
void insert(ll x) {
    for(int i = 60; i >= 0; i--) {
        if(x >> i & 1) {
            if(!p[i]) {
                p[i] = x;
                break;
            }
            x ^= p[i];
            //cout<<x<<endl;
        }
    }
}
 
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    ll all = 0;
    for(int i = 1; i <= n; i++) cin >> a[i], all ^= a[i];
    for(int i = 0; i <= 60; i++) {
        if(all >> i & 1) {
            for(int j = 1; j <= n; j++) {
                if(a[j] >> i & 1) a[j] -= (1ll << i);
            }
        }
    }
    for(int i = 1; i <= n; i++) insert(a[i]);//,cout<<a[i]<<endl;;
    ll ans = 0;
    for(int i = 60; i >= 0; i--) {
    	//cout<<i<<" "<<p[i]<<" "<<(ans&(1ll<<i)==0)<<endl;
    	
    	if((p[i]!=0)&&((ans&(1ll<<i))==0))
    	{
    		ans=p[i]^ans;
    		//cout<<ans<<endl;
		}
    	
    }
    //cout<<ans<<endl;
    cout << ans + (ans ^ all);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;

ll h,w;

int main(){
	cin>>h>>w;
	if(h==1||w==1){
		cout<<1<<endl;
		return 0;
	}
	ll ans=(h*w+1ll)/2ll;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  Node y;

  if(x->right != NIL) return treeMinimum(x->right);
  
  y = x->parent;
  
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  
  if(y->left != NIL) x = y->left;
  else x = y->right;
  
  if(x != NIL) x->parent = y->parent;
  
  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;
  
  if(y != z){
    z->key = y->key;
    
  }  
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;

    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;  
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }
}

void preorder(Node u){
  if(u != NIL){
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      
      Node t = treeSearch(root, x);
      
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } 
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  
  return 0;
}

Measured memory_bytes: 24040
#include<stdio.h>

static const int MAX = 500;
static const int INF = (1<<21);

main(){
  int n, i, j, e, sum;
  int M[MAX][MAX];
  int u, v;
  int minv;
  int d[MAX];
  int p[MAX];
  int vis[MAX];

  scanf("%d", &n);

  for(i=0;i<n;i++){
    for (j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j]=(e==-1)?INF:e;
    }
  }

  for(i=0;i<n;i++) {
    d[i]=INF;
    p[i]=-1;
    vis[i]=0;
  }

  d[0]=0;

  while(1){
    minv=INF;
    u=-1;
    for (i=0;i<n;i++){
      if (minv>d[i]&&!vis[i]){
	u=i;
	minv=d[i];
      }
    }
    if (u==-1)break;
    vis[u]=1;
    for(v=0;v<n;v++){
      if (!vis[v] && M[u][v] != INF){
	if (d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	}
      }
    }
  }

  sum=0;

  for(i= 0;i<n;i++)if(p[i]!=-1)sum+=M[i][p[i]];

  printf("%d\n",sum);

  return 0;
}



Measured memory_bytes: 2088
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]

a_odd = [[False if ele%2==0 else True for ele in row] for row in a]

link = [[None]*w for _ in range(h)]
route = [[i,j] if i%2==0 else [i,w-1-j] for i in range(h) for j in range(w)]

linking = False
cnt = 0
tmp = 0
valid_n = -1
for n, [i,j] in enumerate(route):
    if a_odd[i][j] and not(linking):
        linking = True
    elif a_odd[i][j] and linking:
        linking = False
        link[i][j] = prev
        cnt += tmp+1
        tmp = 0
        valid_n = n
    elif not(a_odd[i][j]) and linking:
        link[i][j] = prev
        tmp += 1
    else:
        pass
    prev = [i,j]

print(cnt)
for n,[i,j] in enumerate(route):
    if link[i][j] and n<=valid_n:
        print(link[i][j][0]+1, link[i][j][1]+1, i+1, j+1)
    else:
        pass

Measured memory_bytes: 53168
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;

/*----------macros----------*/

//input, output================
#define fastio                          \
std::ios::sync_with_stdio(false);       \
std::cin.tie(nullptr);                  \
std::cout.tie(nullptr)

#define endl '\n'
#define fcout(a)                        \
cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF    = (ll)1e9 + 1;
constexpr ll INFll  = (ll)1e18 + 1;
constexpr ll MOD1   = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define snd second

//others================
#define sz(x)                           \
(int) x.size()

#define all(x)                          \
(x).begin(), (x).end()

#define rall(x)                         \
(x).rbegin(), (x).rend()

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

#define reps(i, n)                      \
for(int i = 1; (i) <= (n); ++(i))

#define rrep(i, n)                      \
for(int i = n - 1; (i) >= 0 ; --(i))

#define repbit(bit, n)                  \
for(int bit = 0; (bit) < (1 << (n)); ++(bit))

#define ifbit(bit, i)                   \
if((bit) & (1 << (i)))

#define CtoI(c)                         \
int((c)) - int('0')

#define ItoC(c)                         \
char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b)
{ return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b)
{ return a > b && (a = b, true); }

// Vi  dx = {1, 0, -1, 0},
//     dy = {0, 1, 0, -1};

// Vi  dx2 = { 1,1,0,-1,-1,-1,0,1 },
//     dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
fastio;

    int d; cin >> d;
    switch(d){
        case 25: cout << "Christmas" << endl; break;
        case 24: cout << "Christmas Eve" << endl; break;
        case 23: cout << "Christmas Eve Eve" << endl; break;
        case 22: cout << "Christmas Eve Eve Eve" << endl; break;
    }

return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main(){

  for(;;){
    int n,m;
    cin>>n>>m;
    if(n==0) break;

    if(n<m) swap(n,m);

    int c,r=0;
    for(;m;){
      c=n%m;
      n=m;
      m=c;
      r++;
    }
    cout<<n<<" "<<r<<endl;
  }

  return 0;

}



Measured memory_bytes: 2992
import datetime
from datetime import timedelta
from datetime import date

def ad2mayan(y, m, d):
    days = 0
    while datetime.MAXYEAR < y:
        days += 365 * 400 + 97
        y -= 400

    days += (date(y, m, d) - date(2012, 12, 21)).days
    
    ki, days = days % 20, days // 20
    w, days = days % 18, days // 18
    t, days = days % 20, days // 20
    ka, days = days % 20, days // 20
    b = days % 13
    
    return b,ka,t,w,ki

def mayan2ad(b, ka, t, w, ki):
    ka += b * 20
    t += ka * 20
    w += t * 18
    ki += w * 20
    dt = datetime.date(2012, 12, 21) + timedelta(ki)
    return dt.year, dt.month, dt.day

import sys
f = sys.stdin


for line in f:
    if line[0] == '#':
        break
    t = list(map(int, line.split('.')))
    
    if len(t) == 3:
        print('.'.join(map(str, ad2mayan(*t))))
    elif len(t) == 5:
        print('.'.join(map(str, mayan2ad(*t))))

Measured memory_bytes: 7120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

vector<vector<pair<int, int>>> g;
VI edge;
bool solve(int now, int par, int& b, int& task) {
    if (now == b)return true;
    each(next, g[now]) {
        int to, num; tie(to, num) = next;
        if (to == par)continue;
        if (solve(to, now, b, task)) {
            edge[num] |= (1 << task);
            return true;
        }
    }
    return false;
}
int main() {
    init();

    int n; cin >> n;
    g.resize(n);
    edge.resize(n - 1);
    FOR(i, 0, n - 1) {
        int a, b; cin >> a >> b;
        --a, --b;
        g[a].emplace_back(b, i);
        g[b].emplace_back(a, i);
    }

    int m; cin >> m;
    FOR(i, 0, m) {
        int a, b; cin >> a >> b;
        --a, --b;
        solve(a, -1, b, i);
    }

    auto dp = vec<ll>(1 << m);
    dp[0] = 1;
    FOR(i, 0, n - 1)rFOR(bit, 0, 1 << m) {
        dp[bit | edge[i]] += dp[bit];
    }
    cout << dp[(1 << m) - 1] << "\n";
}

Measured memory_bytes: 8448
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll dp[101][100001];

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

	int N, W;
	cin >> N >> W;
	vector<int> w(N), v(N);
	REP(i, N) cin >> w[i] >> v[i];
	REP(i, N)REP(j, W + 1) {
		dp[i + 1][j] = dp[i][j];
		if (j - w[i] >= 0) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
		}
	}
	cout << dp[N][W] << endl;

	return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;

const int MAXN=200005;
int dp[MAXN],a[MAXN],ans;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=1;i<=n;++i) {
		dp[a[i]]=dp[a[i]-1]+1;
		ans=max(ans,dp[a[i]]);
	}
	cout<<n-ans<<endl;

}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;

#define rp(i,t) for(int i=0;i<(t);i++)
#define rep(i,s,t) for(int i=(s);i<=(t);i++)
#define rsp(i,s,t) for(int i=(s);i<(t);i++)
#define rrp(i,t,s) for(int i=(t);i>=(s);i--)
#define rcp(i,s,b,d) for(int i=(s);b;d)
#define mst(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define N 100002

#define Dp puts("")
#define Dw printf
#define Ds printf("#")

typedef long long ll;
char ch;
int n,a[N],b[N],c[N],B,C;
ll s[N],ans;

inline void read(int &x){x=0;do{ch=getchar();}while(ch<'0'||'9'<ch);do{x=x*10+ch-'0';ch=getchar();}while('0'<=ch&&ch<='9');}

int main(void)
{
	read(n);
	rep(i,1,n)read(a[i]);sort(a+1,a+n+1);
	rep(i,1,n)read(b[i]);sort(b+1,b+n+1);
	rep(i,1,n)read(c[i]);sort(c+1,c+n+1);
	B=C=1;
	rep(i,1,n)
	{
		while(b[i]>=c[C]&&C<=n)C++;
		s[i]=s[i-1]+n-C+1;
	}
	rep(i,1,n)
	{
		while(a[i]>=b[B]&&B<=n)B++;
		ans+=s[n]-s[B-1];
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 2684
#include<iostream>
#include<string>

using namespace std;

int main()
{
    long long A,B,C;cin >> A>>B>>C;
    string K;cin>>K;
    if((K[K.size()-1]-'0')%2==0)
    {
        cout << A-B<<endl;
    }else
    {
        cout << B-A<<endl;
    }
    
}

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

int main() {
  int64_t d, t, s;
  cin >> d >> t >> s;
  if(s*t>=d) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;
#define MAX 411
#define mod 1000000007
#define inf 1000000000000000000
#define ll long long
#define endl '\n'
ll dp[MAX][MAX],sum[MAX];
ll ans = 0;
ll memo(int p,int l){
	if(dp[p][l] != inf)return dp[p][l];
	ll mn = inf;
	for(int i = p ; i < p + l - 1 ; i++){
		mn = min(mn , memo(p,i - p + 1) + memo(i+1,p + l - (i + 1) ));
	}
	dp[p][l] = mn + sum[p + l - 1] - sum[p-1];
	return dp[p][l];
}

int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i = 1 ; i <= n ; i++)cin>>dp[i][1],sum[i] += sum[i-1] + dp[i][1];

	for(int i = 1 ; i <= n ; i++)
		for(int j = 2; j <= n ; j++)dp[i][j] = inf;

	cout<<memo(1,n) - sum[n];
	return 0; 
} 

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	
	Tuple<int,int>[] ba = new Tuple<int,int>[n];
	for(int i = 0; i < n; i++)
	{
	    var tmp = ReadIntArray();
	    int a = tmp[0], b = tmp[1];
	    ba[i] = new Tuple<int,int>(b, a);
	}
	Array.Sort(ba);

	int time = 0;
	for (int i = 0; i < n; i++)
	{
	    int b = ba[i].Item1;
	    int a = ba[i].Item2;
	    time += a;
	    if (time > b)
	    {
		WriteLine("No");
		return;
	    }
	}
	WriteLine("Yes");
    }
}


Measured memory_bytes: 23628
#include <bits/stdc++.h>
#include <string>
//#define local
#ifdef local
    #include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
    #include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define vi std::vector<int>
#define pi std::pair<int, int>
#define mp std::make_pair
#define stdabs std::abs
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation
#define Yes std::cout << "Yes" << std::endl
#define No std::cout << "No" << std::endl
#define YES std::cout << "YES" << std::endl
#define NO std::cout << "NO" << std::endl
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy8[8] = {0, 1, 0, -1, 1, -1, 1, -1};
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll& x, ll& y);
ll nCr(ll n, ll r);
void stat();
template <typename T> T fact(T num);
unsigned long long modpow(int x__, int n__, long long mod__);
template <typename T> void debug(const T& t);
constexpr ll mod10_9p7 = 1000000000 + 7;

/**************************************************************/
int main()
{
    stat();
string s;cin>>s;
if(s[s.size()-1]=='s'){cout<<s<<"es"<<endl;}else{
	cout<<s<<"s"<<endl;
}


    return 0;
}
/**************************************************************/
ll extgcd(ll a, ll b, ll& x, ll& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (unsigned ll j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat(){
#ifdef local
    rep(i, 2){std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

template <typename T> T fact(T num)
{
    if (num == 1) { return 1; }
    return num * fact(num - 1);
}

unsigned long long modpow(int x__, int n__, long long mod__)
{
    long long ret__ = 1;
    for (long long i__ = 0; i__ < n__; ++i__) {
        ret__ = ret__ * x__ % mod__;
    }
    return ret__;
}

template <typename T> void debug(const T& t)
{
#ifdef local
    dbg(t);
#endif
}


Measured memory_bytes: 3632
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
long n=sc.nextLong();
     String s="abcdefghijklmnopqrstuvwxyz";
     char[] c=s.toCharArray();
   StringBuilder s1=new StringBuilder();
     while(n>0)
     {
    	
       long x=Math.abs(n%26);
  
       if(x!=0)
       {
    	   int y=(int)x;
           s1.append(c[y-1]);
         
         n=n/26;
        
       }
       else
      {
         s1.append(c[25]);
          n=n/26;
	 n=n-1;
      }
       
      
     }
 s1.reverse();
   System.out.println(s1);
  }
}

Measured memory_bytes: 35716
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(int[] a) {
    int x = a[0];
    int index = 0;
    for (int i = 0; i < a.length; i++) {
        if (abs(x) < abs(a[i])) {
            x = a[i];
            index = i;
        }
    }

    int[][] ans;
    for (int i = 0; i < a.length; i++) {
        if (i == index) continue;
        ans ~= [index, i];
    }

    if (a[index] >= 0) {
        // 左端から累積和をとる
        for (int i = 1; i < a.length; i++) {
            ans ~= [i - 1, i];
        }
    }
    else {
        // 右端から累積和をとる
        for (int i = cast(int) a.length - 2; i >= 0; i--) {
            ans ~= [i + 1, i];
        }
    }

    writeln(ans.length);
    foreach (e; ans) {
        writeln(e[0] + 1, " ", e[1] + 1);
        a[e[1]] += a[e[0]];
    }
}

void main() {
    readint;
    auto a = readints;
    calc(a);
}


Measured memory_bytes: 256
from math import ceil
def main():
    A, B = [int(i) for i in input().split()]
    one = A
    many = 0
    for N in range(20):
        if A * 1 + (A-1) * N >= B:
            many = N + 1
            break
    if B == 1:
        print(0)
        exit()
    if A >= B:
        print(1)
    else:
        print(many)
main()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 +7  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
    int n , m ;
    cin >> n >> m ;
    vector < string > s(n) ;
    for( int i = 0 ; i < n ; i++) cin >> s[i] ;
    vector < vector < int > > l(n,vector<int>(m)) , r(n,vector<int>(m)) , u(n,vector<int>(m)) , d(n,vector<int>(m)) ;
    for( int i = 0 ; i < n ; i++){
        if(s[i][0]=='.') l[i][0] = 1 ;
        for( int j = 1 ; j < m ; j++){
            if(s[i][j]=='.') l[i][j] = l[i][j-1] + 1 ;
        }
    }
    for( int i = 0 ; i < n ; i++){
        if(s[i][m-1]=='.') r[i][m-1] = 1 ;
        for( int j = m-2 ; j >=0 ; j--){
            if(s[i][j]=='.') r[i][j] = r[i][j+1] + 1 ;
        }
    }
    for( int j = 0 ; j < m ; j++){
        if(s[0][j]=='.') u[0][j] = 1 ;
        for( int i = 1 ; i < n ; i++){
            if(s[i][j]=='.') u[i][j] = u[i-1][j] + 1 ;
        }
    }
    for( int j = 0 ; j < m ; j++){
        if(s[n-1][j]=='.') d[n-1][j] = 1 ;
        for( int i = n-2 ; i >=0 ; i--){
            if(s[i][j]=='.') d[i][j] = d[i+1][j] + 1 ;
        }
    }
    int ans = 0 ;
    for( int i = 0 ; i < n ; i++){
        for( int j = 0 ; j < m ; j++){
            if(s[i][j]=='.'){
                int cur = 0 ;
                cur = l[i][j] + r[i][j] + u[i][j] + d[i][j] -3 ;
                ans = max(ans,cur);
            }
        }
    }
    cout << ans ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t ;
    t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}
// number of subset having xor in 2ki ow


Measured memory_bytes: 67328
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    cin>>N;
    vec mods(N, 0);
    ll temp = 7%N, ans = 1;
    mods[temp] = 1;
    while(mods[0] == 0){
        ++ans;
        ((temp *= 10) += 7)%=N;
        if(mods[temp] == 1){
            cout<<-1<<endl;
            return 0;
        }else{
            mods[temp] = 1;
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

const int MAXN = 310;

int n,p[MAXN],a,b,c;
double dp[MAXN][MAXN][MAXN];

double rek(int a, int b, int c) {
	if(!a && !b && !c) return 0;
	double &ret = dp[a][b][c];
	if(ret != -1) return ret;
	ret = 0;
	
	if(a) ret += (double)a / n * ( rek(a - 1, b, c) + 1);
	if(b) ret += (double)b / n * ( rek(a + 1, b - 1, c) + 1);
	if(c) ret += (double)c / n * ( rek(a, b + 1, c - 1) + 1);
	ret += (double) (n - a - b - c) / n;
	ret *= n;
	ret /= (double) (a + b + c);
	return ret;
}

int main() {
	
	scanf("%d",&n);
	
	for(int i = 0; i < n; i++) {
		scanf("%d", &p[i]);
		
		if(p[i] == 1) a++;
		else if(p[i] == 2) b++;
		else c++;
	}
	for(int i = 0; i < MAXN; i++) 
		for(int j = 0; j < MAXN; j++) 
			for(int k = 0; k < MAXN; k++) 
				dp[i][j][k] = -1;
		
	printf("%.12lf",rek(a,b,c));
	
	return 0;
}

Measured memory_bytes: 233088
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(long long i=a;i<=(b);++i)
#define dF(i,a,b) for(long long i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 2e5+10;
const int N = 1e5+10;
const int E = 1e5+10;  
ll n,m,k;
ll a[maxn];
ll cnt[maxn];

int main(){
	cin>>n;
	F(i,1,n){
		cin>>a[i];
	}
	ll lim = maxn-5;
	ll ans = 0,tmp;
	if(1+a[1]<=lim) cnt[1+a[1]]++;
	F(i,2,n){
		tmp = i-a[i];
		if(tmp>0) ans+=cnt[tmp];
		if(i+a[i]<=lim) cnt[i+a[i]]++;
	}
	cout<<ans<<endl;
}


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


//long long solve(long long n , long long w){
//
//    if(n == 0 || w==0)
//        return 0;
//    if(dp[n-1][w] != -1 )
//        return dp[n-1][w];
//    if(weight[n-1] > w) {
//        dp[n - 1][w] = solve(n - 1, w);
//        return dp[n - 1][w];
//    }
//    else{
//        dp[n-1][w] = max( solve(n-1, w) , value[n-1] + solve(n-1,w-weight[n-1]) );
//        return dp[n-1][w];
//    }
//
//
//}






int main() {


    long long n;
    long long w;
    cin >> n >> w;
    long long weight[n+1];
    long long value[n+1];
    for(int i=0;i<n;i++){
        cin >> weight[i] >> value[i];
    }
//    for(int i =0; i<=n;i++)
//         memset(dp[i] , -1 , 100005);
    long long dp[n+1][w+1];
//
//    for (int i = 0; i < n; i++)
//        for (int j = 0; j < w; j++)
//            dp[i][j] = -1;


    // cout << solve(n,w);



   for(long long i=0 ;i<=n;i++){
       for(long long j=0;j<=w;j++){
           if(i==0 || j==0)
               dp[i][j] =0;

           else if(weight[i-1] > j)
                dp[i][j] = dp[i-1][j];
           else
               dp[i][j] =  max(value[i-1] + dp[i-1][j - weight[i-1]] , dp[i-1][j]);

       }
   }
   cout << dp[n][w];

    return 0;
}


Measured memory_bytes: 82416
#include <bits/stdc++.h>
#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)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define MM multimap
#define PB push_back
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (b * a) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256