akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var N = consoleReader.Int;
            var works = consoleReader.Repeat(N).SplitInt.Select(Work.Create).OrderBy(w => w.limit).ToArray();
            var time = 0;
            for (int workIndex = 0; workIndex < works.Length; workIndex++)
            {
                var work = works[workIndex];
                if (work.mustStartAt < time)
                    return "No";
                time += work.size;
            }
            return "Yes";
        }
        struct Work
        {
            public static Work Create(int[] l) => new Work { size = l[0], limit = l[1], mustStartAt = l[1] - l[0] };
            public int size;
            public int limit;
            public int mustStartAt;
            public override string ToString() => $"{mustStartAt}->{limit} size:{size}";
        }
        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader()).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

    public class ConsoleReader { public class SplitLine { string[] splited; public SplitLine(string line) { splited = line.Split(); } public string[] String => splited.ToArray(); public int[] Int => splited.Select(int.Parse).ToArray(); public long[] Long => splited.Select(long.Parse).ToArray(); public ulong[] ULong => splited.Select(ulong.Parse).ToArray(); public double[] Double => splited.Select(double.Parse).ToArray(); } public class RepeatLine { ConsoleReader reader; int num; public RepeatLine(ConsoleReader reader, int num) { this.reader = reader; this.num = num; } public IEnumerable<string> String { get { for (int i = 0; i < num; i++) yield return reader.String; } } public IEnumerable<int> Int { get { for (int i = 0; i < num; i++) yield return reader.Int; } } public IEnumerable<long> Long { get { for (int i = 0; i < num; i++) yield return reader.Long; } } public IEnumerable<string[]> SplitString { get { for (int i = 0; i < num; i++) yield return reader.Split.String; } } public IEnumerable<int[]> SplitInt { get { for (int i = 0; i < num; i++) yield return reader.Split.Int; } } } public virtual string String => Console.ReadLine(); public int Int => int.Parse(String); public long Long => long.Parse(String); public ulong ULong => ulong.Parse(String); public double Double => double.Parse(String); public SplitLine Split => new SplitLine(String); public RepeatLine Repeat(int count) => new RepeatLine(this, count); }
}

Measured memory_bytes: 32788
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    n = int(input())
    s = []
    if n == 0:
        print('0')
        return

    while n != 0:
        if n%2 == 0:
            s.append('0')
            n //= -2
        else:
            s.append('1')
            n -= 1
            n //= -2
    print(''.join(s[::-1]))

if __name__ =='__main__':
    main()   

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N;
	cin >> N;
	bool a[1000001];
	a[N] = true;
	int c = 1;
	while(true){
		if( N % 2 == 0) N /= 2;
		else N = 3*N+1;
		if(a[N]){
			cout << c+1;
			break;
		}
		c++;
		a[N] = true;
	}
			
	
}


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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

using i64 = long long;
using d64 = long double;
using pi = pair<int, int>;
using pli = pair<i64, i64>;
using ti = tuple<int, int, int>;
using tli = tuple<i64, i64, i64>;

#define iterall(cont) cont.begin(), cont.end()
#define prec(n) setprecision(n) << fixed

void setm(i64 &x, i64 y) {
    x = max(x, y);
}

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

    int R, C, K;
    cin >> R >> C >> K;

    vector<vector<i64>> mp(R + 1, vector<i64>(C + 1));
    for (int i = 0; i < K; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        mp[u][v] = w;
    }

    vector<vector<i64>> dp[4];
    for (int i = 0; i < 4; i++) dp[i].resize(R + 1, vector<i64>(C + 1));

    for (int i = 1; i <= R; i++) {
        for (int j = 1; j <= C; j++) {
            setm(dp[0][i][j], dp[0][i - 1][j]);
            setm(dp[0][i][j], dp[1][i - 1][j]);
            setm(dp[0][i][j], dp[2][i - 1][j]);
            setm(dp[0][i][j], dp[3][i - 1][j]);
            setm(dp[0][i][j], dp[0][i][j - 1]);

            setm(dp[1][i][j], dp[1][i][j - 1]);
            setm(dp[2][i][j], dp[2][i][j - 1]);
            setm(dp[3][i][j], dp[3][i][j - 1]);

            auto u1 = max(dp[1][i][j], dp[0][i][j] + mp[i][j]);
            auto u2 = max(dp[2][i][j], dp[1][i][j] + mp[i][j]);
            auto u3 = max(dp[3][i][j], dp[2][i][j] + mp[i][j]);

            tie(dp[1][i][j], dp[2][i][j], dp[3][i][j]) = tie(u1, u2, u3);
        }
    }

    cout << max({dp[0][R][C], dp[1][R][C], dp[2][R][C], dp[3][R][C]}) << endl;
    return 0;
}

Measured memory_bytes: 355532
//「魔法陣2」(https://beta.atcoder.jp/contests/cf16-relay-open/tasks/relay_d)

#include<iostream>
#include<vector>

int main(){
	//標準入力
	int A,B,C;
	std::cin>>A>>B>>C;

	//処理
	//魔法陣は次のように一意に求められる
	//A			B			-A-B+3C
	//-2A-B+4C	C			2A+B-2C
	//A+B-C		-B+2C		-A+2C

	//出力
	std::cout<<A<<" "<<B<<" "<<-A-B+3*C<<std::endl;
	std::cout<<-2*A-B+4*C<<" "<<C<<" "<<2*A+B-2*C<<std::endl;
	std::cout<<A+B-C<<" "<<-B+2*C<<" "<<-A+2*C<<std::endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,p;
    string s;
    cin >> n;
    vector<pair<pair<string,int>,int>> pp(n);
    rep(i,n){
        cin >> s >> p;
        pp[i]=m_p(m_p(s,-p),i+1);
    }
    sort(all(pp));
    rep(i,n) cout << pp[i].second << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const long long MOD=1000000007;
using namespace std;
long d[60][110][2510]={0};
 int main() 
{
  long n,k;
  cin>>n>>k;
  d[0][0][0]=1;
  for(long long a=0;a<n;a++) 
  {
    for(long long b=0;b<=n*2;b++) 
	{
      for(long c=0;c<=n*n;c++) 
	  {
        if (c+b<2510) 
		{
          d[a+1][b][c+b]+=d[a][b][c];
          d[a+1][b][c+b]%=MOD;
        }
        if(b-2>=0&&c+b-2<2510)
	    {
          d[a+1][b-2][c+b-2]+=d[a][b][c]*(b/2)*(b/2);
          d[a+1][b-2][c+b-2]%=MOD;
        }
        if(b+2<110&&c+b+2<2510)
	    {
          d[a+1][b+2][c+b+2]+=d[a][b][c];
          d[a+1][b+2][c+b+2]%=MOD;
        }
        if (c+b<2510)
		{
          d[a+1][b][c+b]+=d[a][b][c]*b;
          d[a+1][b][c+b]%=MOD;
        }
      }
    }
  }
  cout<<d[n][0][k]<<endl;
  return 0;
}

Measured memory_bytes: 108800
using System;
using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            var ABC = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            Console.WriteLine((ABC[0]<=ABC[2]&& ABC[2] <= ABC[1])?"Yes":"No");
        }
    }

Measured memory_bytes: 13396
s= input()
flag = True
for i in range((len(s)-1)//2):
	if s[i] == s[len(s)-i-1]:
		continue
	else:
		flag = False
		break

if flag:
	left = s[:(len(s)-1)//2]
	right = s[(len(s)+3)//2-1:]
	if left == right:
		print("Yes")
	else:
		print("No")
else:
	print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int K, N;
  cin >> K >> N;
  vector<int> A(N+1);
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  A[N]=A[0]+K;
  vector<int> B(N);
  for (int i=0; i<N; i++) {
    B[i]=A[i+1]-A[i];
  }
  sort(B.begin(),B.end());
  cout << K-B[N-1] << endl;
}

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

using namespace std;
#define int long long

const int N = 5e5 + 10;
const int MOD = 1e9 + 7;

int n;
int has[N], powe[N];
bool pre[N], suff[N];
string s;

int getm(int l, int r)  {
    int res = (has[r] - has[l - 1] * powe[r - l + 1] * 1ll % MOD + 1ll*MOD*MOD) % MOD;
    return res;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    char rem = s[0]; bool flag = false;
    for(int i = 0; i < s.length(); ++i) if(s[i] != rem) flag = true;
    if(!flag)   {
        cout << s.length() << '\n' << "1";
        return 0;
    }

    for(int i = 1; i <= s.length(); ++i)  has[i] = (has[i - 1] * 26 + s[i - 1] - 'a') % MOD;

    powe[0] = 1ll;
    for(int i = 1; i <= s.length(); ++i)    powe[i] = powe[i - 1] * 26 % MOD;

    // check prefix
    for(int i = 1; i <= s.length(); ++i)   if(!pre[i]){
        int cur = getm(1, i);
        for(int idem = 2; i * idem <= s.length(); ++idem) {
            int tmp = getm(i*idem - i + 1, i*idem);
            if(tmp != cur) break;
            pre[idem*i] = true;
        }
    }
//cout << getm(1, 2) << ' ' << getm(3, 4) << '\n';
    for(int i = s.length(); i >= 1; --i)    {
        int cur = getm(i, s.length());
        int dem = s.length() - i + 1;
        for(int idem = 2; idem * dem <= s.length(); ++idem) {
            int tmp = getm(s.length() - dem*idem + 1, s.length() - dem*(idem - 1));
            if(tmp == cur) suff[s.length() - dem*idem + 1] = true;
            else break;
        }
    }
   // cout << pre[s.length()] << '\n';
    if(pre[s.length()] == false)    {
        cout << "1\n1";
    }else {
        cout << "2\n";
        int idem = 0;
        for(int i = 1; i < s.length(); ++i) if(pre[i] == false && suff[i + 1] == false) idem ++;
        cout << idem;
    }
}


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

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

    vector<int> vec(N);
    for (int i = 0; i < N; i++)
    {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end(), greater<int>());

    int A = 0, B = 0;
    for (int i = 0; i < N; i += 2)
        A += vec.at(i);
    for (int i = 1; i < N; i += 2)
        B += vec.at(i);

    cout << A - B << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;
	
	List<Integer>[] g;
	int[] b;
	int k;
	
	int dfs(int v, int p) {
		int depth = 0;
		for (int u : g[v]) {
			if (u == p) {
				continue;
			}
			depth = Math.max(depth, dfs(u, v) + 1);
		}
		
		if (depth == k - 1) {
			b[v] = 0;
			return -1;
		}
		return depth;
	}
 
	void solve() throws IOException {
		int n = nextInt();
		k = nextInt();
		int[] a = new int[n];
		
		for (int i = 0; i < n; i++) {
			a[i] = nextInt() - 1;
		}
		
		b = a.clone();
		b[0] = 0;
		
		g = new List[n];
		for (int i = 0; i < n; i++) {
			g[i] = new ArrayList<>();
		}
		
		for (int i = 1; i < n; i++) {
			g[b[i]].add(i);
		}
		
		dfs(0, -1);
		
		int ret = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] != b[i]) {
				ret++;
			}
		}
		
		out.println(ret);
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		
		Thread t = new Thread(null, new Runnable() {
 
			@Override
			public void run() {
				try {
					solve();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			
		}, "lul", 1 << 26);
		
		t.start();
		try {
			t.join();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		out.close();
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}
 
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 44360
// Akshit Awasthi
#include <bits/stdc++.h>
#define int long long
#define float long double
#define ar array
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define all(x) x.begin(), x.end()
#define deb(...) cerr << "[" << #__VA_ARGS__ << ": " << (__VA_ARGS__) << "]\n"
#define deb2(x, y) cerr << #x << " = " << x << "\t" << #y << " = " << y << endl
#define fastio                    \
    std::ios::sync_with_stdio(0); \
    std::cin.tie(NULL);           \
    std::cout.tie(NULL)
#define mod1 1000000007
#define mod2 998244353
#define mod mod1
#define MAX 200015
using namespace std;

template <class T>
istream& operator>>(istream& stream, vector<T>& v) {
    for (int i = 0; i < (int)v.size(); i++) stream >> v[i];
    return stream;
}
template <class T1, class T2>
istream& operator>>(istream& stream, pair<T1, T2>& p) {
    return stream >> p.first >> p.second;
}
template <class T>
ostream& operator<<(ostream& stream, const vector<T>& v) {
    for (int i = 0; i < (int)v.size(); i++) stream << v[i] << ' ';
    stream << '\n';
    return stream;
}
template <class T1, class T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& pair) {
    return stream << pair.first << ' ' << pair.second;
}
int pow(int a, int n) {
    if (n < 0) return 0;
    int ans = 1;
    while (n) {
        if (n & 1) ans = ans * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ans;
}
int __lcm(int a, int b) { return (a / __gcd(a, b)) * b; }
int fact(int n) { return n == 0 ? 1LL : n * fact(n - 1) % mod; }
int inverse(int x, int p = mod) { return pow(x, p - 2); }
int nck(int n, int k, int p = mod) {
    return fact(n) * inverse(fact(k), p) % p * inverse(fact(n - k)) % p;
}

vector<int> arr;

void solve(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int w = 0, r = 0;
    int ans = 0;
    for (char i : s) {
        if (i == 'W') {
            w++;
        } else {
            r++;
        }
    }
    for (int i = 0; i < r; i++) {
        if (s[i] == 'W') ans++;
    }
    cout << ans << '\n';
}

int32_t main(void) {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
    fastio;
    // cout.setf(std::ios::unitbuf);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
ll p[100002];
ll find(ll x)
{
  return p[x]==x ? x :p[x]=find(p[x]);//p[x]=find(p[x]) necessary else TLE as it takes longer time to find parent
}
int main()
{
  IOS;
  ll n,m,i;
  cin>>n>>m;
  ll link[m][2],sum[n],ans[m];
  for(i=0;i<n;i++)
  {
    p[i]=i;
    sum[i]=1;
  }
  for(i=0;i<m;i++)
  {
    cin>>link[i][0]>>link[i][1];
  }
  ans[m-1]=(n*(n-1)/2);
  for(i=m-1;i>=0;i--)
  {
    ll q,w;
    q=find(link[i][0]);
    w=find(link[i][1]);
    if(q!=w)
    {
      ans[i-1]=ans[i]-(sum[q]*sum[w]);
      sum[w]+=sum[q];
      p[q]=w;
    }
    else ans[i-1]=ans[i];
  }
  for(auto g: ans) cout<<g<<endl;
  return 0;
}


Measured memory_bytes: 5248
import sys
import itertools
from math import sqrt
input = sys.stdin.readline
mod = 10 ** 9 + 7

X, Y = map(int, input().split())
a_3 = -X + 2 * Y
b_3 = 2 * X - Y
if a_3 % 3 != 0 or b_3 % 3 != 0:
    print(0)
    exit()

a = a_3 // 3
b = b_3 // 3

if a < 0 or b < 0:
    print(0)
    exit()

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

comb = Combination(1000000)
print(comb(a+b, b))

Measured memory_bytes: 126280
n = int(input())
a = list(map(int,input().split()))
a1 = [i+1 for i in a]
a2 = [i-1 for i in a]
a3 = a+a1+a2
d = {}
for i in range(3*n):
  if a3[i] in d:
    d[a3[i]] += 1
  else:
    d[a3[i]] = 1
print(max(d.values()))

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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) {
	return b < a ? a = b, 1 : 0;
}
template<typename T> inline bool chkmax(T &a, T b) {
	return b > a ? a = b, 1 : 0;
}

inline int read() {
	int x(0), sgn(1);
	char ch(getchar());
	for (; !isdigit(ch); ch = getchar())
		if (ch == '-')
			sgn = -1;
	for (; isdigit(ch); ch = getchar())
		x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

const int N = 2e5 + 1e3;

int n;

pair<int, int> a[N];

multiset<int> R, B;

#define Max(S) *S.rbegin()
#define Min(S) *S.begin()

int main() {

	File();

	n = read();
	For (i, 1, n)
	{
		int x = read(), y = read();
		if (x > y)
			swap(x, y);
		B.insert(x);
		R.insert(y);
		a[i] = make_pair(x, y);
	}
	long long ans = 1ll * (Max(R) - Min(R)) * (Max(B) - Min(B));

	sort(a + 1, a + n + 1);
	For (i, 1, n)
	{
		B.erase(B.find(a[i].first));
		R.erase(R.find(a[i].second));
		R.insert(a[i].first);
//		if (Min(B) <= a[i].second)
//			break;
		B.insert(a[i].second);
		chkmin(ans , 1ll * (Max(R) - Min(R)) * (Max(B) - Min(B)));
	}
	printf("%lld\n", ans);

	return 0;

}


Measured memory_bytes: 24084
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

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

    ll n, t;
    cin >> n >> t;
    vector<ll> A(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    ll ans = t;
    for (ll i = 0; i < n - 1; i++)
    {
        ans += min(t, A[i + 1] - A[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<utility>

using namespace std;

#define INF 1 << 29
#define LL long long int

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

    int h,w,d;
    cin >> h >> w >> d;

    vector<pair<int,int>> vec(h*w+1);

    for(int i = 1; i < h + 1; i++){
        for(int j = 1; j < w + 1; j++){
            int a;
            cin >> a;
            vec[a] = make_pair(i,j);
        }
    }

    int q;
    cin >> q;

    vector<pair<int,int>> query(q);

    for(int i = 0; i < q; i++){
        int a,b;
        cin >> a >> b;
        query[i] = make_pair(a,b);
    }

    vector<int> total(h*w+1);
    for(int i = 1; i <= d; i++){
        total[i] = 0;
        for(int j = i + d; j < h * w + 1; j += d){
            total[j] = total[j-d] + abs(vec[j].first - vec[j-d].first) + abs(vec[j].second - vec[j-d].second);
        }
    }

    for(int i = 0; i < q; i++){
        cout << total[query[i].second] - total[query[i].first] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, m, c, b[20], a[20];
int main() {
  cin >> n >> m >> c;
  read_n(b, m);
  lli ans = 0;
  for (lli i=0; i<n; ++i) {
    read_n(a, m);
    lli s=c;
    for (lli j=0; j<m; ++j) {
      s += a[j]*b[j];
    }
    if (s > 0) ++ans;
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
c = [int(i) for i in input().split()]
dp = [5*10**4]*(n+1)

dp[0] = 0
for i in range(1,n+1):
  dp[i] = min([dp[i-j]+1 for j in c if i>=j])
print(dp[n])  


Measured memory_bytes: 7260
#include <stdio.h>
#include <math.h>
#include <iostream>
using namespace std;

int main(void){
	int x[10],top[3];
	int i;

	for(i=0;i<3;i++){
		top[i] = 0;
	}
	for(i=0;i<10;i++){
		std::cin >> x[i];
		if(top[0] < x[i]){
			top[2] = top[1];
			top[1] = top[0];
			top[0] = x[i];
		}else if(top[1] < x[i]){
			top[2] = top[1];
			top[1] = x[i];
		}else if(top[2] < x[i]){
			top[2] = x[i];
		}
	}

	std::cout << top[0] << "\n" << top[1] << "\n" <<top[2] << "\n";
	return 0;
}

Measured memory_bytes: 0
a,b = gets.split.map(&:to_i)
p1 = 12.5 * a
p2 = 12.5 * (a+1)
q1 = 10.0 * b
q2 = 10.0 * (b+1)
if p1 >= q1
  x = p1
else
  x = q1
end
if p2 <= q2
  y = p2
else
  y = q2
end
if x.ceil < y
  puts x.ceil
else
  puts -1
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=10010;
char s[maxn];
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%s",s+1);
	for (int i=1;i<=strlen(s+1);i++) {
		if (i%2==1&&s[i]=='L') { printf("No\n"); return 0; }
		if (i%2==0&&s[i]=='R') { printf("No\n"); return 0; }
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
import math

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


def combinations_count(N, R):
    return math.factorial(N) // (math.factorial(N - R) * math.factorial(R))


for i in range(1, k + 1):
    # 注意！もし青玉の置く場所がiより少なかったら置くことができないので、0通り
    if n - k + 1 < i:
        print(0)
    else:
        answer = combinations_count(k - 1, i - 1) * combinations_count(n - k + 1, i)
        # print(combinations_count(i - 1 + k, i - 1), combinations_count(n - k + 1, i))
        print(answer % (10 ** 9 + 7))

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

//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
/*
template<typename... Args>
void print(Args... args) {
	#ifdef LOCAL
	((std::cout << args << " "), ...);
	cout << endl;
	#endif
}
 */
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 1e6 + 5;
const int INF = 2e9;

ll fact[MAXN];

ll modPow(ll p, ll pow){
	ll ans = 1;
	while(pow){
		if(pow & 1)
			ans = (ans * p) % MOD;
		p = (p * p) % MOD;
		pow >>= 1;
	}
	return ans;
}

int main() {
	//usaco("milkvisits");

#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
#endif

	ll x, y;
	cin >> x >> y;

	fact[0] = 1;

	for(int i = 1; i < MAXN; i++){
		fact[i] = (i * fact[i - 1]) % MOD;
	}

	int x1 = -1, x2 = -1;
	for(int i = 0; i < x + y; i++){
		int a = x - i;
		int b = y - 2 * i;
		
		if(a < 0 || b < 0) continue;
		if(a % 2 == 0 && (b == a / 2)){
			x1 = i, x2 = a / 2;
			break;
		}
	}

	if(x1 == -1 || x2 == -1){
		finish(0);
	}
	cout << (fact[x1 + x2] * modPow((fact[x1] * fact[x2]) % MOD, MOD - 2)) % MOD;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i=0;i<N;i++){
    cin >> v[i];
  }
  int ans=0,count=0;
  for (int i=N-1;i>0;i--){
    if (v[i-1]>=v[i]){
      count++;
    }
    else {
      ans=max(ans,count);
      count=0;
    }
  }
  ans=max(ans,count);
  cout << ans << endl;
}

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

#define max(a,b) (a>b?a:b)

#define leftzero(n) (num[n][dig[n]-1]==-1&&dig[n]>1)
#define altx(n,i) (num[n][i]==-1?x:num[n][i])

int main() {
	int num[3][126], dig[3], n, c;
	int car, tmp, ans;
	string str;
	while(cin >> str) {
		c = 2; n = 0;
		for(int i=(signed)str.length()-1; i>=0; --i) {
			if(str[i]=='=' || str[i]=='+') {
				c--; n = 0;
			}else {
				num[c][n] = str[i]=='X'?-1:(int)(str[i]-'0');
				dig[c] = ++n;
			}
		}
		ans = -1;
		if(max(dig[0], dig[1])<=dig[2]) for(int x=0; x<=9&&ans==-1; ++x) {
			if(!x&&(leftzero(0)||leftzero(1)||leftzero(2))) continue;
			ans = x; car = 0;
			for(int i=0; i<dig[2]; ++i) {
				tmp = (i<dig[0]?altx(0,i):0)+(i<dig[1]?altx(1,i):0)+car;
				if((tmp%10)!=altx(2,i)) {
					ans = -1; break;
				}
				car = tmp/10;
			}
			if(car) ans = -1;
		}
		if(ans==-1) cout << "NA" << endl;
		else cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int R;cin >> R;
    double ans = R * 2 * M_PI;
    printf("%0.5f\n", ans);
    return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 2e5+1;
int tot=3,one,zero,mi[66];
struct node{
	char c;int x,y,z;
};vector<node>ans;
void cmp(int i, int j, int k){
	ans.pb((node){'<',i,j,k});
}
void add(int i, int j, int k){
	ans.pb((node){'+',i,j,k});
}
int getpower(int a, int n){
	int res=a;
	while(n--){
		int cur=++tot;add(res,res,cur);res=cur;
	}
	return res;
}
Vi getfac(int pos){
	Vi res(31,0);
	add(one,pos,pos);//<=x ---> <x+1
	int cur=++tot;add(zero,zero,cur);
	per(i,30,0){
		int tmp=++tot;add(cur,mi[i],tmp);
		int c=++tot;cmp(tmp,pos,c);
		res[i]=c;
		int d=getpower(c,i);
		add(cur,d,cur);
	}
	return res;
}
int main() {
	zero=++tot;cmp(0,5,zero);
	one=++tot;
	int ttt=++tot;add(0,1,ttt);cmp(zero,ttt,one);
	mi[0]=one;
	rep(i,1,60)mi[i]=++tot,add(mi[i-1],mi[i-1],mi[i]);
	Vi a=getfac(0);
	Vi b=getfac(1);
	static int yzr[66];
	rep(i,0,60)yzr[i]=++tot;
	rep(i,0,30)rep(j,0,30){
		int tmp=++tot;cmp(a[i],b[j],tmp);
		add(tmp,a[i],tmp);
		int tmp2=++tot;cmp(a[i],b[j],tmp2);
		int tmp3=++tot;cmp(b[j],a[i],tmp3);
		add(tmp2,tmp3,tmp2);
		cmp(tmp2,tmp,tmp);
		add(yzr[i+j],tmp,yzr[i+j]);
	}
	int cur=++tot;add(zero,zero,cur);
	per(i,60,0){
		add(cur,cur,cur);
		add(cur,yzr[i],cur);
	}
	add(cur,zero,2);
	
	static ll val[N];
	val[0]=2;val[1]=3;
	for(auto q:ans)
		if(q.c=='+')val[q.z]=val[q.x]+val[q.y];
		else val[q.z]=val[q.x]<val[q.y];
	/*cout<<val[2]<<endl;
	rep(i,0,20)cerr<<val[mi[i]]<<endl;
	cerr<<val[zero]<<' '<<val[one]<<endl;
	rep(i,0,20)cerr<<val[a[i]]<<' ';cerr<<endl;
	rep(i,0,20)cerr<<val[b[i]]<<' ';cerr<<endl;
	cerr<<tot<<' '<<SZ(ans)<<endl;
	return 0;*/
	
	printf("%d\n",SZ(ans));
	
	
	for(auto q:ans)printf("%c %d %d %d\n",q.c,q.x,q.y,q.z);
	
	
	return 0;
}


Measured memory_bytes: 3900
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

// 素因数分解
vector<pair<long, long>> prime_factorize(long n) {
  vector<pair<long, long>> v;

  for (long p = 2; p * p <= n; ++p) {
    if (n % p != 0) {
      continue;
    }
    long num = 0;
    while (n % p == 0) {
      ++num;
      n /= p;
    }
    v.push_back(make_pair(p, num));
  }

  if (n != 1) {
    // 素数ではないが、この問題ではn自体も追加しておく
    v.push_back(make_pair(n, 1));
  }

  return v;
}

const int MOD = 1000000007;
const int MAX = 200001;
long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void comb_init() {
  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;
  }
}

// 二項係数計算 (combination. nCkを求める.)
long 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;
}

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

  long N, M;
  cin >> N >> M;
  vector<pair<long, long>> primes = prime_factorize(M);

  long res = 1;
  for (auto &p : primes) {
    long num = p.second;
    res = (res * comb(num + N - 1, N - 1)) % MOD;
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <map>
using namespace std; 
int main(){
    int n,m,x; cin >> n >> m >> x;
    vector<int> a(n+1);
    int ans=0;
    int ans2=0;
    for (int i=0;i<m;i++){
        int s; cin >> s;
        a[s-1]=1;
    }
    for (int i=0;i<x;i++){
        ans+=a[i];
    }
    if (x<=n){
        for (int i=x;i<n;i++){
            ans2+=a[i];
        }
    }
    else{
        for (int i=n;i<x;i++){
            ans2+=a[i];
        }
    }
    if (ans<=ans2){
        cout << ans << "\n";
    }
    else{
        cout << ans2 << "\n";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

bool c[2]={false,false};
ll a[10],b[2];
string s;

void init(){
	cin>>s;
	rep(i,4)a[i]=s[i]-'0';
	b[0]=a[0]*10+a[1];
	b[1]=a[2]*10+a[3];
	if(1<=b[0] && b[0]<=12)c[0]=true;
	if(1<=b[1] && b[1]<=12)c[1]=true;
}

int main(void){
	init();
	if(c[0]){
		if(c[1]){
			cout<<"AMBIGUOUS"<<endl;
		}else{
			cout<<"MMYY"<<endl;
		}
	}else{
		if(c[1]){
			cout<<"YYMM"<<endl;
		}else{
			cout<<"NA"<<endl;
		}
	}
	return 0;
}

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

int main() {
    int N,count = 0;
    cin >> N;
    vector<int> data(N);
    vector<int> seisuu(N);
    for (int i = 0; i < N; i++) {
        cin >> data.at(i);
        seisuu.at(i) = i+1;
    }
    rep(i,N){
        if(data[i] != seisuu.at(i)){
            count++;
        }
    }
    if(count == 0 || count == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void){

    int A,B; cin>>A>>B;
    int cnt=0;
    int ans=1;

    if(B==1){
        cout<<0<<endl;
        return 0;
    }
    while(ans<B){
        ans += A - 1;
        cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    string s; cin >> s;
    if(s[0] == 'W'){
        cout << 0 << endl;
        return 0;
    }

    vi a(2*n);
    a[0] = 0;
    REP(i,1,2*n){
        if(s[i] != s[i-1]){
            a[i] = a[i-1];
        }else{
            a[i] = a[i-1] ^ 1;
        }
    }
    ll cnt = 0;
    ll ans = 1;
    rep(i,2*n){
        if(a[i] == 1){
            ans *= cnt;
            ans %= mod;
            cnt--;
        }else{
            cnt++;
        }
        if(cnt < 0){
            cout << 0 << endl;
            return 0;
        }
    }
    if(cnt != 0){
        cout << 0 << endl;
    }else{
        rep(i,n){
            ans *= i+1;
            ans %= mod;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4408
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] t = new int[n + 2], v = new int[n + 2];
        int tSum = 0;
        for (int i = 1; i <= n; i++) {
            t[i] = in.nextInt() * 2;
            tSum += t[i];
        }
        for (int i = 1; i <= n; i++) {
            v[i] = in.nextInt();
        }
        double[] vMax = new double[tSum + 1];
        int idx = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < t[i]; j++) {
                vMax[idx + j] = v[i];
            }
            idx += t[i];
        }
//        System.out.println(Arrays.toString(vMax));
        idx = 0;
        for (int i = 0; i < n; i++) {
            double max = v[i];
            int tmp = idx + 1;
            while(max < vMax[tmp]) {
                max += 0.5;
                vMax[tmp++] = max;
                if(vMax.length <= tmp) break;
            }
            idx += t[i+1];
        }
        idx = tSum + 1;
        for (int i = n+1; i > 0 ; i--) {
            double max = v[i];
            int tmp = idx - 1;
            while(max < vMax[tmp]) {
                vMax[tmp--] = max;
                max += 0.5;
                if(tmp < 0) break;
            }
            idx -= t[i-1];
        }
//        for (int i = 0; i < vMax.length; i++) {
//            System.out.println("idx = " + i  + " time = " + (i / 2.0) + " v = " + vMax[i]);
//        }
        double ans = 0, now = 0;
        for (int i = 0; i < vMax.length - 1; i++) {
            ans += now * 0.5;
            if(vMax[i] < vMax[i + 1]) {
                ans += 0.125;
                now += 0.5;
            }
            if(vMax[i + 1] < vMax[i]) {
                ans -= 0.125;
                now -= 0.5;
            }
        }
        System.out.println(ans);
    }
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;

    cin >> N;
    vector< pair<string, pair<int, int> > > points;
    REP(i,N){
        string S;
        int P;
        cin >> S >> P;
        points.push_back(make_pair(S, make_pair(-P, i+1)));
    }

    sort(points.begin(), points.end());
    REP(i, N){
        cout << points[i].second.second << endl;
    }
}


Measured memory_bytes: 256
import math
a,b,x = map(float,input().split())



p1 = ((2*x)/(a*a)) - b
p2 = b - p1

pp1 = (2*(a*a*b-x))/(a*b) -a
pp2 = a - pp1

ans1 = math.degrees(math.atan(p2/a))
ans2 = math.degrees(math.atan(b/pp2))



if x >= a*a*b/2:
  print(ans1)
else:
  print(ans2)

Measured memory_bytes: 3064
#include <string>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int n;string s[200001],ans[200001];int cnt;
int main()
{
	cin>>n;for(int i=1;i<=n;++i)cin>>s[i];sort(s+1,s+1+n);int cur=1,maxx=0;
	for(int i=2;i<=n;++i){if(s[i]!=s[i-1]){if(cur>maxx)maxx=cur,cnt=1,ans[cnt]=s[i-1];else if(cur==maxx)ans[++cnt]=s[i-1];cur=1;}else ++cur;}if(cur>maxx)maxx=cur,cnt=1,ans[cnt]=s[n];else if(cur==maxx)ans[++cnt]=s[n];cur=1;for(int i=1;i<=cnt;++i)cout<<ans[i]<<endl;return 0;
}

Measured memory_bytes: 15872
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//おまじない



int main() {

	int n = 0;

	cin >> n;
	cout << (1 + n)*n / 2 << endl;

	

	return 0;
}

Measured memory_bytes: 256
private val scanner = java.util.Scanner(System.`in`)

private fun readInts(n: Int) = Array(n) { scanner.nextInt() }
private fun readLongs(n: Int) = Array(n) { scanner.nextLong() }
private fun readLineInts() = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
private fun readLineLongs() = readLine()!!.split(" ").map { it.toLong() }.toTypedArray()

fun main(args: Array<String>) {
    val (N, X) = readLine()!!.split(" ").map { it.toDouble() }

    println(N / X)
}

Measured memory_bytes: 38516
#include<iostream>
using namespace std;
char a[3],b[3];
int s;
int main()
{
	for(int i=0;i<3;i++)
	cin>>a[i];
	for(int i=0;i<3;i++)
	cin>>b[i];
	for(int i=0;i<3;i++)
		if(a[i]==b[2-i])
		s++;
	if(s==3)
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl; 
	return 0;
}


Measured memory_bytes: 256
s = input()
l = len(s)
n = int(input())
ans = ["A"]*l
for i in range(l-1):
  if s[i]=="a":
    ans[i]="a"
    continue
  temp = ord("z")-ord(s[i])+1
  if temp <= n:
    n-=temp
    ans[i]="a"
  else:
    ans[i]=s[i]

last = ord(s[l-1])+n
#print(last)
while last>ord("z"):
  last-=26
ans[l-1]=chr(last)
print("".join(ans))

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

#define INF INT_MAX

typedef long long ll;

using namespace std;

int main(void){
	ll n,m;
	cin >> n >> m;
	if(abs(n - m) > 1){cout << 0 << endl;return 0;}
	ll nn = 1;
	for(int i = 1;i <= n;i++){
		nn = (nn * i)%1000000007;
	}
	ll mm = 1;
	for(int i = 1;i <= m;i++){
		mm = (mm * i)%1000000007;
	}
	ll ans = 0; 
	if(n == m){
		ans = (nn*mm*2)%1000000007;
	}else{
		ans = (nn*mm)%1000000007;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll cnt[28];

int main(void){
    scanf("%d",&n);
    string str;
    cin >> str;
    for(int i=0;i<n;i++){
        cnt[str[i]-'a']++;
    }
    ll ans=1;
    for(int i=0;i<26;i++){
        ans=ans*(cnt[i]+1)%MOD;
    }
    ans+=(MOD-1LL);
    ans%=MOD;
    printf("%lld\n",ans);
    return 0;
}




Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long int a[100000000],n,m=0;
int main()
{
	cin>>n;
	cin>>a[1];
	for (int i=2;i<=n;i++)
     {
	   cin>>a[i];
	   if (a[i]<a[i-1]) 
	   {
	   	m=a[i-1]-a[i]+m;
        a[i]=a[i-1];
	   }
	 }
     cout<<m;
return 0;
 } 

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

int main()
{
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int difx,dify;
    difx=x2-x1;dify=y2-y1;
    int x3=x2-dify;int y3=y2+difx;
    int x4=x3-difx;int y4=y3-dify;
    cout << x3 << " " << y3 <<" " << x4  << " "<< y4 << endl;
}

Measured memory_bytes: 3436
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"--------------------------"<<endl; 
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin >> n;
    ll A[4];
    rep(i,0,4)  A[i] = 0;
    rep(i,0,n){
        string s;
        cin >> s;
        if(s == "AC")   A[0]++;
        if(s == "WA")   A[1]++;
        if(s == "TLE")   A[2]++;
        if(s == "RE")   A[3]++;
    }
    cout << "AC x " << A[0] << endl;
    cout << "WA x " << A[1] << endl;
    cout << "TLE x " << A[2] << endl;
    cout << "RE x " << A[3] << endl;
    return 0;
}

Measured memory_bytes: 3596
h,w = list(map(int,input().split()))

mat = []
for i in range(h):
    row = input()
    mat.append(row)

mat2 = []
for row in mat:
    isAllWhite = True
    for x in row:
        if x == '#':
            isAllWhite = False
            break
    if not isAllWhite:
        mat2.append(row)

hh = len(mat2)
mat3 = [[] for i in range(hh)]
for i in range(w):
    isAllWhite = True
    for j in range(hh):
        if mat2[j][i] == '#':
            isAllWhite = False
            break
    if not isAllWhite:
        for j in range(hh):
            mat3[j].append(mat2[j][i])

for row in mat3:
    print("".join(row))


Measured memory_bytes: 39280