akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int 			long long int
#define ld 				long double
#define F 				first
#define S 				second
#define P 				pair<int,int>
#define pb 				push_back
#define mod             1000000007
#define inf             1e18
#define endl			'\n'
const int N = 1e5 + 5; //change it when needed

struct segment {
	vector<int>st;
	int n;
	void init(int nn) {
		n = nn;
		st.clear(); st.resize(4 * n, 0);
	}

	int query(int s, int e, int qs, int qe, int index) {
		if (s > qe or e < qs)
			return 0;
		if (s >= qs and e <= qe)
			return st[index];
		int mid = (s + e) / 2;
		int q1 = query(s, mid, qs, qe, 2 * index + 1);
		int q2 = query(mid + 1, e, qs, qe, 2 * index + 2);
		return max(q1 , q2);
	}
	void update(int s, int e, int index, int i, int val) {
		if (i < s or e < i)
			return ;
		if (s == e) {
			st[index] = val;
			return ;
		}
		int mid = (s + e) / 2;
		update(s, mid, 2 * index + 1, i, val);
		update(mid + 1, e, 2 * index + 2, i, val);
		st[index] = max(st[2 * index + 1] , st[2 * index + 2]);
	}
	int query(int l, int r) {
		return query(0, n - 1, l, r, 0);
	}
	void update(int index, int ele) {
		update(0, n - 1, 0, index, ele);
	}
} tree;
void solve() {
	int n;
	cin >> n;
	int a[n], b[n];
	P c[n];

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		c[i] = {a[i], i};
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	sort(c, c + n);
	tree.init(n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int idx = c[i].S;
		int val = c[i].F;
		ans = tree.query(0, idx) + b[idx];
		tree.update(idx, ans);
	}
	cout << tree.query(0, n - 1);
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 12800
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);    
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  int ans = a[0];
  for (int i = 2, j = 1; i < n; ++i) {
    ans += a[j];
    j += i & 1;
  }
  cout << ans;
  return 0;
}

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

int main()
{
  int n;
  int kanade = 0;

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

    kanade += b - a + 1;
  }

  cout << kanade << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	cn, _ := strconv.Atoi(Scanner())
	cs := make([][]int, cn)
	for i := 0; i < cn; i++ {
		cs[i] = make([]int, 100001)
	}
	for i := 0; i < n; i++ {
		s, _ := strconv.Atoi(Scanner())
		t, _ := strconv.Atoi(Scanner())
		c, _ := strconv.Atoi(Scanner())
		s--
		c--
		cs[c][s]++
		cs[c][t]--
	}
	for i := 0; i < cn; i++ {
		for j := 1; j < 100001; j++ {
			cs[i][j] = cs[i][j-1] + cs[i][j]
		}
	}
	ans := 0
	for j := 0; j < 100001; j++ {
		tmp := 0
		for i := 0; i < cn; i++ {
			tmp += smaller(cs[i][j], 1)
		}
		if ans < tmp {
			ans = tmp
		}
	}
	fmt.Println(ans)
}
func smaller(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}


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

signed main(void)
{
	long long q, h, s, d, n, ans;

	cin >> q >> h >> s >> d >> n;
	cout << min(n * min(q * 4, min(h * 2, s)), n / 2 * d + (n % 2) * min(q * 4, min(h * 2, s))) << endl;
}


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

int main() {
  lint X;
  cin >> X;

  if(400 <= X and X <= 599) {
    cout << 8 << endl;
  }

  if(600 <= X and X <= 799) {
    cout << 7 << endl;
  }

  if(800 <= X and X <= 999) {
    cout << 6 << endl;
  }

  if(1000 <= X and X <= 1199) {
    cout << 5 << endl;
  }

  if(1200 <= X and X <= 1399) {
    cout << 4 << endl;
  }

  if(1400 <= X and X <= 1599) {
    cout << 3 << endl;
  }

  if(1600 <= X and X <= 1799) {
    cout << 2 << endl;
  }

  if(1800 <= X and X <= 1999) {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }
vector<pair<int, int>> move_list = { make_pair(0, 1), make_pair(1, 0), make_pair(0, -1), make_pair(-1, 0) };

ll bfs(vector<vector<char>>& field, vector<vector<bool>>& already, int s_r, int s_c, int H, int W) {
    queue<pair<int, int>> q;
    q.push(make_pair(s_r, s_c));
    already[s_r][s_c] = true;
    ll black_count = 0;
    ll white_count = 0;
    
    while (1) {
        if (q.size() <= 0) {
            break;
        }
        auto nd = q.front();
        q.pop();
        if (field[nd.first][nd.second] == '.') white_count++;
        else black_count++;
        for (auto& m : move_list) {
            auto n_r = nd.first + m.first;
            auto n_c = nd.second + m.second;
            if (n_r >= 0 && n_c >= 0 && n_r < H && n_c < W) {
                if ((field[nd.first][nd.second] == '.' && field[n_r][n_c] == '#') ||
                    (field[nd.first][nd.second] == '#' && field[n_r][n_c] == '.')) {
                    if (already[n_r][n_c] == false) {
                        already[n_r][n_c] = true;
                        q.push(make_pair(n_r, n_c));
                    }
                }
            }
        }
    }
    return black_count * white_count;
}


int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> field(H, vector<char>(W, '.'));
    rep(i, H) {
        rep(j, W) {
            cin >> field[i][j];
        }
    }
    vector<vector<bool>> already(H, vector<bool>(W, false));
    ll count = 0;
    rep(i, H) {
        rep(j, W) {
            if((already[i][j] == false) && (field[i][j] == '#'))
                count += bfs(field, already, i, j, H, W);
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 512
import math
import queue
from collections import defaultdict
import itertools as it

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1

a,b,h,m = readInts()

sa = 30*h+m*0.5
sb = m*6

cal = (a*math.sin(math.radians(sa))-b*math.sin(math.radians(sb)))**2+(a*math.cos(math.radians(sa))-b*math.cos(math.radians(sb)))**2

print(cal**0.5)

Measured memory_bytes: 10188
#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
#include <cstddef>
#include <vector>
#include <list>
#include <iterator>
#include <unordered_map>	

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long long> vl;

typedef pair<int,int> pi;
typedef pair<double,double> pd;

#define pb push_back
#define pf push_front
#define mp make_pair

#define endl "\n"
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned int uint;

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}

ll INF = 1e10;
ll MOD = 1e9+7;

ll fast_power(ll base, ll power){
    ll result = 1;
    while(power > 0){
        if(power % 2 == 1)
            result = (result*base) % MOD;
        base = (base * base) % MOD;
        power = power / 2;
    }
    return result;
}

bool ans = 0;

void solve(int arr[3][3], int x){
	for(int i=0;i<3;++i)
		for(int j=0;j<3;++j)
			if (arr[i][j] == x)
				arr[i][j] = -1;
	//row
	for(int i=0;i<3;++i)
		if(arr[i][0] == arr[i][1] && arr[i][0] == arr[i][2]){
			ans = 1;
			return;
		}
	for(int i=0;i<3;++i)
		if(arr[0][i] == arr[1][i] && arr[0][i] == arr[2][i]){
			ans = 1;
			return;
		}
	if (arr[0][0] == arr[1][1] && arr[0][0] == arr[2][2]){
		ans = 1;
		return;
	}
	if (arr[0][2] == arr[1][1] && arr[2][0] == arr[0][2]){
		ans = 1;
		return;
	}
}
	
			 
				
	
int main(){
	fastio();
	int arr[3][3];
	for(int i=0;i<3;++i)
		for(int j=0;j<3;++j)
			cin>>arr[i][j];
	int n;
	cin>>n;
	int b[n];
	for(int i=0;i<n;++i)
		cin>>b[i];
	for(int i=0;i<n;++i)
		solve(arr,b[i]);
	string f = ans ? "Yes" : "No";
	cout<<f;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}
const ll MOD = 1000000007;

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< MOD >;

void solve(ll n, ll a, ll b){
    modint x=modint(2).pow(n)-1;
    modint y=modint(1);
    rep(i,a){
        y*=n-i;
        y/=i+1;
    }
    modint z=modint(1);
    rep(i,b){
        z*=n-i;
        z/=i+1;
    }
    cout<<x-y-z<<endl;
}

int main(){
    ll n;
    scanf("%lld",&n);
    ll a;
    scanf("%lld",&a);
    ll b;
    scanf("%lld",&b);
    solve(n, a, b);
}


Measured memory_bytes: 384
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = input()
n = len(s)
nx = []
for i in range(n):
    if s[i]=="R":
        nx.append(i+1)
    else:
        nx.append(i-1)
v = 1
while v<10*n:
    nx = [nx[i] for i in nx]
    v *= 2
ans = [0]*n
for num in nx:
    ans[num] += 1
write(" ".join(map(str, ans)))

Measured memory_bytes: 174372
def main():
    h1, m1, h2, m2, k = map(int, input().split())

    h_diff = h2 - h1
    m_diff = m2 - m1

    if h_diff == 0:
        if m_diff >= 0:
            ans = m_diff - k
        else:
            ans = 24 * 60 + m_diff - k
    elif h_diff > 0:
        ans = h_diff * 60 + m_diff - k
    else:
        ans = 24 + h_diff + m_diff - k

    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
#include <iostream>
using namespace std;
//B - Ruined Square
int main(void){
    int x1,x2,y1,y2;
    std::cin >> x1 >> y1 >> x2 >>y2;
    int x3=y1+x2-y2;
    int y3=x2+y2-x1;
    int x4=x1+y1-y2;
    int y4=y1+x2-x1;
    std::cout << x3 <<" " << y3 <<" " << x4 <<" " << y4 << std::endl;
}


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

int main()
{
  int N, M;  //N個の都市とM個の道路
  cin>>N>>M;
  vector<int> A(M);
  vector<int> B(M);
  for(int i=0; i<M; i++)
    cin>>A[i]>>B[i];

  vector<int> counter(N,0);
  for(int i=1; i<=N; i++){
    for(int a: A){
      if(i==a)  counter[i-1]++;
    }
    for(int b: B){  
      if(i==b)  counter[i-1]++;  
    }
  }

  for(int i=0; i<N; i++)
    cout<<counter[i]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>    
using namespace std;
 
#define CIN1(a) long long a;cin >> a;
#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)
 
int main(){
    CIN1(n)
    CIN2(t,a)
    double ans;
    int ans_element;
    rep(i,n){
        int h;cin >> h;
        double tmp = abs((t-0.006*(double)h)-a);
        if(!i){
            ans = tmp;
            ans_element = i+1;
        }else{
            ans = min(ans,tmp);
            if(ans==tmp) ans_element = i+1;
        } 
    } 
    cout << ans_element << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    char s[1005];
    char t[1005];
    int i;
    for(i=0;i<1005;i++){
        s[i] = '0';
        t[i] = '0';
    }
    scanf("%s",&s);
    scanf("%s",&t);
    int slen,tlen;
    for(slen=0;s[slen] != '0';slen++){

    }
    slen = slen-1;
    //printf("%d\n",slen);
    for(tlen=0;t[tlen] != '0';tlen++){

    }
    tlen = tlen-1;
    //printf("%d\n",tlen);
    int j = 0;
    i = 0;
    int max = 0;
    int key = 0;
    for(i=0;i <= slen-tlen;i++){
        for(j=0;j<tlen;j++){
            if(s[i+j] == t[j]){
                key++;
            }
        }
        if(key>max){
            max = key;
        }
        if(max == tlen){
            break;
        }
        key = 0;
    }
    printf("%d\n",tlen-max);
    return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  int count = min(s.size(), t.size());
  for( int i = 0; i < count; i++ ){
    if( s.at(i) < t.at(i) ){
      cout << "Yes" << endl;
      return 0;
    }else if( s.at(i) > t.at(i) ){
      cout << "No" << endl;
      return 0;
    }
    if( i == count-1 ){
      if( s.size() < t.size() ){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
    }
  }  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
        
        int result = 0;
        for (int i = 0; i < 4; i++) {
            if (s[i].equals("+")) result++;
            else if (s[i].equals("-")) result--;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 35608
N = int(input())

robots = []

for i in range(N):
    x, l = [int(v) for v in input().split()]

    robots.append((x - l, x + l))

robots.sort()


def opt(robots):
    l = len(robots)
    count = 0
    i = 1
    robot1 = robots[0]
    while i < l:
        robot2 = robots[i]
        if robot1[1] > robot2[0]:
            if robot1[1] < robot2[1]:
                robot2 = robot1
            count += 1
        robot1 = robot2
        i += 1
    return l - count

print(opt(robots))


Measured memory_bytes: 16928
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  rep(i,N)
  {
    cin >> h[i];
  }
  int count = 0;
  rep(i,N)
  {
    if(h[i]>=K)
    {
      count ++;
    }
  }
  cout << count << endl;
  return 0;
}


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

int main(void) {
  long long N, tmp;
  cin >> N;
  tmp = N;
  long long S = 0;
  while (tmp != 0) {
    S += tmp % 10;
    tmp /= 10;
  }

  cout << (N % S == 0 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int m,d,temp=0;
    cin>>m>>d;

    for(int i=1;i<=m;i++){
        for(int j = 21;j<=d;j++){
            int ones = j%10;
            int tens = j/10;
            int multi = ones*tens;
            if(multi == i && tens>=2 && ones>=2){
                temp++;
            }
        }
    }
    cout<<temp<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S;
    cin >> S;
    ll counte = S.size()*(S.size()+1)/2+1;
    sort(ALL(S));
    REP(i,26){
        ll kazu = count(ALL(S),'a' + i);
        counte -= kazu*(kazu+1)/2;
    }
    cout << counte << "\n";
}

Measured memory_bytes: 720
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
 
    int n = sc.nextInt();
		int[] nums = new int[n];
		for(int i = 0; i < n; i++){
			nums[i] = sc.nextInt();
		}
 
 		int ans = 0;
		for(int i = 1; i < n - 1; i++){
			if((nums[i-1] < nums[i] && nums[i] < nums[i+1]) || (nums[i-1] > nums[i] && nums[i] > nums[i+1])){
				ans++;
			}
		}
		
		System.out.println(ans);
 
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define all(v) (v).begin(), (v).end()

typedef long long ll;

template <class T = int>
T in() { T x; cin >> x; return x; }
#define output(e) cout << e << '\n'

#ifdef LOCAL
    #define dr(x) cout << "L" << __LINE__ << ": " << #x << " -> " << x << "\n"
#else
    #define dr(x)
#endif

//
// Implementation
//

int main() {
    int N = in();
    vector<int> a(N);
    rep(i, N) a[i] = in();

    sort(all(a), greater<int>());

    int alice = 0;
    int bob = 0;
    bool isalice = true;
    rep(i, N) {
        if (isalice) {
            alice += a[i];
            isalice = false;
        } else {
            bob += a[i];
            isalice = true;
        }
    }
    output(alice - bob);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int N;
    long long C;
    cin >> N >> C;
    vector<long long> x(N+1, 0), v(N+1, 0);
    for(int i=1; i<=N; i++) cin >> x[i] >> v[i];

    vector<long long> a0(N+2, 0), a1(N+2, 0), a3(N+2, 0), a4(N+2, 0);
    vector<long long> b0(N+2, 0), b1(N+2, 0);

    for(int i=1; i<=N; i++)
        b0[i] = b0[i-1] + v[i];
    for(int i=N; i>=1; i--)
        b1[i] = b1[i+1] + v[i];

    for(int i=1; i<=N; i++)
        a0[i] = b0[i] - x[i];
    for(int i=N; i>=1; i--)
        a1[i] = b1[i] - (C - x[i]);

    vector<long long> aa0(N+2, 0), aa1(N+2, 0);
    for(int i=1; i<=N; i++)
        a4[i] = b0[i] - 2*x[i];

    for(int i=N; i>=1; i--)
        a3[i] = b1[i] - 2*(C-x[i]);

    long long ans = 0;

    vector<long long> c0 = a0, c1 = a1, c3 = a3, c4 = a4;
    for(int i=1; i<=N; i++) c0[i] = max(c0[i], c0[i-1]);
    for(int i=1; i<=N; i++) c4[i] = max(c4[i], c4[i-1]);
    for(int i=N; i>=1; i--) c1[i] = max(c1[i], c1[i+1]);
    for(int i=N; i>=1; i--) c3[i] = max(c3[i], c3[i+1]);
    for(int i=1; i<=N; i++)
        ans = max(ans, c0[i] + c3[i+1]);
    for(int i=1; i<=N; i++)
        ans = max(ans, c4[i] + c1[i+1]);

    sort(a0.begin(), a0.end());
    sort(a1.begin(), a1.end());
    ans = max(ans, a0.back());
    ans = max(ans, a1.back());

    cout << ans << endl;

    return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define br() p("")
#define p(s) cout<<(s)<<endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

// 複素数雨セット
typedef complex<double> C;
// 内積
double dot(C a, C b){
    return a.real() * b.real() + a.imag() * b.imag();
}
// 外積
double cross(C a, C b){
    return a.real() * b.imag() - a.imag() * b.real();
}
double round(double a){
    if(abs(a) < 0.00000000001){
        return 0;
    }
    else{
        return a;
    }
}

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

    // input
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    C p0(x1, y1);
    C p1(x2, y2);
    C v = p1 - p0;
        
    ll Q; cin >> Q;
    while(Q--){
        ll x, y;
        cin >> x >> y;
        C p2(x, y);
        C w = p2 - p0;

        double a = cross(v, w);
        a = round(a);

        if(a>0){
            p("COUNTER_CLOCKWISE");
        }
        else if(a<0){
            p("CLOCKWISE");
        }else{
            double d = dot(v, w);
            if(d<0){
                p("ONLINE_BACK");
            }
            else{
                if(abs(w)>abs(v)){
                    p("ONLINE_FRONT");
                }else{
                    p("ON_SEGMENT");
                }
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 3232
import sys
input = sys.stdin.readline
p=int(input())
A=[int(i) for i in input().split()]
mod=p
B=[0]*p
for i in range(p):
  C=[1]*p
  B[0]=(B[0]-A[i])%mod
  for j in range(1,p):
    C[j]=(C[j-1]*i)%mod
    B[j]=(B[j]-A[i]*C[j])%mod
    if j==p-1:
      B[j]=(B[j]+A[i])%mod
B=B[::-1]
print(*B)
    


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

/** Problem0028 : Mode Value **/
int main()
{
	int num[101] = {0}, max=0, input;
	while (cin >> input) {
		if (++num[input] > max)
			max = num[input];
	}
	for (int i=0; i<101; i++) {
		if (num[i] == max)
			cout << i << endl;
	}
	return 0;
}

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

int main() {
  int x;
  cin>>x;
  int min_x,max_x;
  min_x=x/100*100;
  max_x=x/100*105;
  if(min_x<=x&&x<=max_x){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum PS = [3, 13, 23, 43, 53, 73, 83, 103, 113, 163, 173, 193, 223, 233, 263, 283, 293, 313, 353, 373, 383, 433, 443, 463, 503, 523, 563, 593, 613, 643, 653, 673, 683, 733, 743, 773, 823, 853, 863, 883, 953, 983, 1013, 1033, 1063, 1093, 1103, 1123, 1153, 1163, 1193, 1213, 1223, 1283, 1303];

void main()
{
    writeln(PS[0..readln.chomp.to!int].to!(string[]).join(" "));
}

Measured memory_bytes: 256
import string
from sys import stdin
N = int(stdin.readline().rstrip())
S = list(stdin.readline().rstrip())
alpha = list(string.ascii_uppercase)
dic = {c:i for i, c in enumerate(alpha)}
ans = []
for c in S:
  idx = dic[c]+N
  if idx >= 26:
    idx -= 26
  ans.append(alpha[idx])
print(''.join(ans))

Measured memory_bytes: 31084
n = int(input(""))
data = input("")
a = data.split(" ")
ans = 0

for i in range(n):
    a[i] = int(a[i])
a.sort(reverse = True)

for i in range(n):
    if i%2 == 0:
        ans += int(a[i])
    else: ans -= int(a[i])
print(ans)

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

int main(){
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    
    vector<P> all;
    rep(i,a){
        ll zz;
        cin >> zz;
        P p(zz,1);
        all.push_back(p);
    }
    rep(i,b){
        ll zz;
        cin >> zz;
        P p(zz,2);
        all.push_back(p);
    }
    rep(i,c){
        ll zz;
        cin >> zz;
        P p(zz,3);
        all.push_back(p);
    }

    sort(all.begin(),all.end());
    reverse(all.begin(),all.end());
    /*
    for(auto ringo:all){
        cout << ringo.first <<" " <<ringo.second << endl;
    }*/
    ll res=0;
    ll z=0;
    ll num_x = 0;
    ll num_y = 0;
    rep(i,all.size()){

        if(all[i].second==1){
            if(num_x>=x) continue;
            res+=all[i].first;
            num_x++;
        }
        if(all[i].second==2){
            if(num_y>=y) continue;
            res+=all[i].first;
            num_y++;
        }
        if(all[i].second==3){
            res+=all[i].first;
            z++;
        }
        
        //条件を満たしたら打ち切り
        if((num_x+num_y+z)>=(x+y)) break;
    }

    cout << res << endl;
}


Measured memory_bytes: 10476
def solve():
    N = int(input())
    ans = ""

    i = 1
    sub = 0
    while True:
        if N <= 26 ** i:
            N -= 1

            for j in range(i):
                ans += chr(ord('a') + N % 26)
                N //= 26
            
            break

        else:
            N -= 26 ** i
            
        i += 1
    
    print(ans[::-1])
        
if __name__ == '__main__':
    solve()


Measured memory_bytes: 79876
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
#define rep(i,n) for(ll i = 0;i<(ll)n;i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
class DisjointSet {
public:
	vector<int> rank, p;

	DisjointSet() {};
	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		for (int i = 0; i < size; i++)makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}
	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}
	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}
	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
		}
		return p[x];
	}
};

map<pair<int, int>, int> mp;
int main()
{
	int n, s, t;

	cin >> n >> s >> t;
	DisjointSet ds_road = DisjointSet(n);
	DisjointSet ds_rail = DisjointSet(n);

	rep(i, s) {
		int c1, c2;
		cin >> c1 >> c2;
		ds_road.unite(c1 - 1, c2 - 1);
	}

	rep(i, t) {
		int c1, c2;
		cin >> c1 >> c2;
		ds_rail.unite(c1 - 1, c2 - 1);
	}
	rep(i, n) {
		mp[make_pair(ds_road.findSet(i), ds_rail.findSet(i))]++;
	}

	rep(i, n) {
		cout << mp[make_pair(ds_road.findSet(i), ds_rail.findSet(i))] << endl;
	}
	return 0;
}

Measured memory_bytes: 15104
while True:
    a, b = map(int, input().split())

    if a == 0 and b == 0:
        break
    else:
        for i in range(a):
            if i == 0 or i == a - 1:
                print('#' * b)
            else:
                print('#' + '.' * (b - 2) + '#')
    print()
    


Measured memory_bytes: 5612
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8, i8)")
def chmax(a, b):
    if a > b:
        return a
    else:
        return b


@nb.njit("i8(i8,i8,i8[:,:])")
def solve(N, W, wv):
    dp = [[0] * (W + 1) for _ in range(N + 1)]
    for i in range(1, N + 1):
        w, v = wv[i - 1]
        for j in range(1, W + 1):
            if j < w:
                dp[i][j] = dp[i - 1][j]
            else:
                dp[i][j] = chmax(dp[i - 1][j - w] + v, dp[i - 1][j])
    return dp[-1][-1]


def main():
    N, W = map(int, input().split())
    wv = np.zeros(shape=(N, 2), dtype=np.int64)
    for i in range(N):
        w, v = map(int, input().split())
        wv[i] = w, v

    ans = solve(N, W, wv)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 192500
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n,m;
  ll x[100009],d[100009];
  ll sum=0;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>x[i];
  }
  sort(x,x+m);
  for(int i=0;i<m-1;i++){
    d[i]=x[i+1]-x[i];
    sum+=d[i];
  }
  sort(d,d+m-1);
  reverse(d,d+m-1);
  for(int i=0;i<min(m-1,n-1);i++){
    sum-=d[i];
  }
  cout<<sum<<endl;
  return(0);
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main(void){
  string a, b, c;
  cin >> a >> b >> c;
  size_t sa = a.length();
  size_t sb = b.length();
  if(a[sa-1] == b[0] && b[sb-1] == c[0]) cout<< "YES" <<endl;
  else cout << "NO" <<endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
ll=[]
for i in range(n):
    l=list(map(int,input().split()))
    ll.append(l)
dp=[[0]*3 for i in range(n)]
dp[0]=ll[0]

for i in range(1,n):
    for j in range(3):
        if(j==0):
            dp[i][j]=ll[i][j]+max(dp[i-1][1],dp[i-1][2])
        if(j==1):
            dp[i][j]=ll[i][j]+max(dp[i-1][0],dp[i-1][2])
        if(j==2):
            dp[i][j]=ll[i][j]+max(dp[i-1][1],dp[i-1][0])
print(max(dp[n-1]))

Measured memory_bytes: 74200
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 100000000
#define N 400005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int k,a,b;
   cin>>k>>a>>b;
   for(int i=a;i<=b;i++)
   {
       if(i % k ==0)
       {
           cout<<"OK"<<endl;
           return 0;
       }
   }
   cout<<"NG"<<endl;

}



Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <ostream>
#include <queue>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

inline void init() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
}

int main() {
  init();

  int h, w;
  const int vx[4] = { 0, 1, 0, -1 }, vy[4] = { 1, 0, -1, 0 };
  std::string s[51];

  cin >> h >> w;

  for (int i = 0; i < h; ++i) {
    cin >> s[i];
  }

  bool used[51][51];

  std::memset(used, false, sizeof used);

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (!used[i][j] && s[i][j] == '#') {
        for (int k = 0; k < 4; ++k) {
          int nx = i + vx[k], ny = j + vy[k];

          if (0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] == '#') {
            used[nx][ny] = true;
            used[i][j] = true;
          }
        }
      }
    }
  }

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (s[i][j] == '#' && !used[i][j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
import sys

h, w, m = map(int, input().split())

h_bomb = [0 for _ in range(h)]
w_bomb = [0 for _ in range(w)]

bomb_xy = {}
for ij in range(m):
    y, x = map(int, input().split())
    h_bomb[y-1] += 1
    w_bomb[x-1] += 1
    bomb_xy[str(y-1)+str(x-1)] = 1

h_max = max(h_bomb)
h_max_index = [i for i, y in enumerate(h_bomb) if y == h_max]
w_max = max(w_bomb)
w_max_index = [j for j, x in enumerate(w_bomb) if x == w_max]

ans = 0
# print("ans:", ans)
for j in h_max_index:
    for i in w_max_index:
        if str(j)+str(i) in bomb_xy:
            ans = h_bomb[j] + w_bomb[i] - 1
        else:
            print(h_bomb[j] + w_bomb[i])
            sys.exit()

print(ans)


Measured memory_bytes: 194908
n = gets.chop.to_i
x = []
x = gets.chop.split.map(&:to_i)

sorted = x.sort

ans = [sorted[n/2-1], sorted[n/2]]

for i in 0..n-1

  if x[i] <= ans[0]
    puts ans[1]
  else
    puts ans[0]
  end

end


Measured memory_bytes: 25316
n = int(input())
marks = ["S", "H", "C", "D"]
cards = {mark:[] for mark in marks}
for _ in range(n):
    suit, rank = input().split()
    cards[suit].append(int(rank))
for mark in marks:
    card = cards[mark]
    for num in range(1, 14):
        if num not in card:
            print("{} {}".format(mark, num))


Measured memory_bytes: 5604
class union_find:
    def __init__(self, node_num):
        self.root_array = [-1] * node_num

    def root(self, x):
        if self.root_array[x] < 0:
            return x
        else:
            self.root_array[x] = self.root(self.root_array[x])
            return self.root_array[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.root_array[x] > self.root_array[y]:
            x, y = y, x
        self.root_array[x] += self.root_array[y]
        self.root_array[y] = x

    def size(self, x):
        return -self.root_array[self.root(x)]


def solve(n, m, ab_array):
    uf = union_find(n)
    for ab in ab_array:
        a, b = ab
        uf.unite(a - 1, b - 1)

    ans = 0
    for i in range(n):
        ans = max(ans, uf.size(i))

    return ans

if __name__ == '__main__':
    n, m = map(int, input().split())
    ab_array = [list(map(int, input().split())) for _ in range(m)]
    ans = solve(n, m, ab_array)
    print(ans)

Measured memory_bytes: 49736
using System;

class Program
    {
        static void Main(string[] args)
        {
            // 入力
            var N = int.Parse(Console.ReadLine());
            var A = int.Parse(Console.ReadLine());

            // 出力
            Console.WriteLine((int)(Math.Pow(N, 2) - A));
            Console.ReadLine();
        }
    }

Measured memory_bytes: 13140
<?php
fscanf(STDIN, '%d %d %d', $n, $a, $b);
 
$sum = $a + $b;
$fraction = $n % $sum;
if ($n >= $sum) {
  $count = (int)floor($n / $sum);
  $result = $count * $a;
} else {
  $result = 0;
}
 
if ($a >= $fraction) {
  $result += $fraction;
} else {
  $result += $a;
}
 
echo $result;

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

int main() {
    string X; cin >> X;
    stack<char> s;
    for (char x : X) {
        if (x == 'S') {     // (
            s.push(x);
        } else {            // )
            if (!s.empty() and s.top() == 'S') {
                s.pop();
            } else {
                s.push(x);
            }
        }
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
  int n, k;
  string s;
  cin >> n;
  cin >> s;
  cin >> k;
  k--;
  for (char c : s) {
    if (c == s[k]) {
      cout << c;
    } else {
      cout << "*";
    }
  }
  cout << endl;
  return 0;
}


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

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

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  int N, W;
  cin >> N >> W;
  
  Vi We(110);
  Vi V(110);
  
  rep(i, N){
    cin >> We[i] >> V[i];
  }
  
  vector<vector<ll>> dp(110, vector<ll>(100100, 100000000000));
  
  dp[0][0] = 0;
  
  
  rep(i, N){
    rep(sum_v, 100000){
      
     if(sum_v + V[i] <= 100100){
        dp[i+1][sum_v + V[i]] = dp[i][sum_v] + We[i];
      }
      
      dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v]);
       
    }
  }
  
  ll sum = 0;
  int ans = 0;
  rep(i,100005){
    if(dp[N][i]<=W){
      sum = max(sum, dp[N][i]);
      ans = i;
    }
  }
  
  cout << ans << endl;
}

      
      
       




Measured memory_bytes: 90384
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		StringBuilder sb=new StringBuilder();
		for(int i = 0;i<n;i++) {
			var e=sc.Ia;
			var a=Gp1(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]);
			sb.Append(a.Item1).Append(" ").Append(a.Item2).Append("\n");
		}
		Console.Write(sb);
	}
	static Tuple<double,double> Gp1(double p1x,double p1y,double p2x,double p2y,double p3x,double p3y,double p4x,double p4y){
		double t1=(p4y-p3y)*(p4x-p1x)-(p4x-p3x)*(p4y-p1y);
		double t2=(p2x-p1x)*(p4y-p1y)-(p2y-p1y)*(p4x-p1x);
		double t3=(p2x-p1x)*(p4y-p3y)-(p2y-p1y)*(p4x-p3x);
		double t4=t1/t3,t5=t2/t3;
		return Tuple.Create(p1x+t4*(p2x-p1x),p1y+t4*(p2y-p1y));
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 17976
class PriorityQueue
  def initialize(&comp)
    @heap = []
    @node_num = 0
    if !block_given?
      @comp = Proc.new { |x, y| x <= y }
    else
      @comp = comp
    end
  end

  attr_reader :heap

  def push(x)
    current_node_num = @node_num
    @node_num += 1
    while current_node_num > 0
      parent_node_num = (current_node_num - 1) / 2
      break if @comp.call(@heap[parent_node_num], x) # 逆転してないなら抜ける
      # 親ノードを下ろして自分を上に
      @heap[current_node_num] = @heap[parent_node_num]
      current_node_num = parent_node_num
    end
    @heap[current_node_num] = x
  end

  alias_method(:<<, :push)

  def pop
    # 最(小|大)値
    ret = @heap[0]
    # 根にもってくる値
    @node_num -= 1
    x = @heap[@node_num]
    # 根から下ろしていく
    i = 0
    while (a = i * 2 + 1) < @node_num
      # 子どうしを比較
      b = a + 1
      a = b if b < @node_num && @comp.call(@heap[b], @heap[a])
      break unless @comp.call(@heap[a], x)
      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    return ret
  end

  def get
    @node_num == 0 ? nil : @heap[0]
  end

  def empty?
    return get.nil?
  end
end

x, y, a, b, c = gets.split.map(&:to_i)
oa = gets.split.map(&:to_i).sort.reverse
ob = gets.split.map(&:to_i).sort.reverse
oc = gets.split.map(&:to_i).sort.reverse

q1 = PriorityQueue.new { |x, y| x > y }
oa[0...x].map { |i| q1.push(i) }
ob[0...y].map { |i| q1.push(i) }

q2 = PriorityQueue.new { |x, y| x > y }
oc.map { |i| q2.push(i) }

ans = 0

(x + y).times do |_|
  if q2.empty?
    ans += q1.pop
  else
    if q2.get > q1.get
      ans += q2.pop
    else
      ans += q1.pop
    end
  end
end
p ans


Measured memory_bytes: 30944