akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        r: usize,
    }
    println!("{}", r * r);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll n, x, y, ans, par[111111];
vector <pair<ii, int> > town;
priority_queue <pair<ll, ii>, vector<pair<ll, ii> >, greater<pair<ll, ii> > > edges;

ll root(ll a){
	if(par[a]<0){
		return a;
	}
	else{
		par[a]=root(par[a]);
		return par[a];
	}
}

void merge(ll a, ll b){
	a=root(a);
	b=root(b);
	if(a==b){
		return;
	}
	else{
		if(par[a]>par[b]){
			swap(a,b);
		}
		par[a]+=par[b];
		par[b]=a;
	}
}

bool cmp(pair<ii, int>  a, pair<ii, int>  b){
	return a.fi.fi<b.fi.fi;
}
bool cmp1(pair<ii, int>  a, pair<ii, int>  b){
	return a.fi.se<b.fi.se;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x >> y;
		town.pb(mp(mp(x,y),i));
	}
	sort(town.begin(),town.end(),cmp);
	for(int i = 1; i < n; i++){
		edges.push(mp(town[i].fi.fi-town[i-1].fi.fi,mp(town[i-1].se,town[i].se)));
	}
	sort(town.begin(),town.end(),cmp1);
	for(int i = 1; i < n; i++){
		edges.push(mp(town[i].fi.se-town[i-1].fi.se,mp(town[i-1].se,town[i].se)));
	}
	for(int i = 0; i < n; i++){
		par[i]=-1;
	}
	while(!edges.empty()){
		auto cur = edges.top();
		edges.pop();
		if(root(cur.se.fi)!=root(cur.se.se)){
			ans+=cur.fi;
			merge(cur.se.fi,cur.se.se);
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 10864
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int n, a; cin >> n;
  if(n % 2 == 0 || n % 5 == 0) a = -1;
  else{
    v1i v(1e6+1);
    v[0] = 0;
    rep(i, 1e6){
      v[i+1] = (v[i]*10+7) % n;
      if(v[i+1] == 0){
        a = i+1; break;
      }
    }
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 7188
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


string S;


signed main(){
    cin >> S;

    int n = SZ(S);
    int ans = 0;
    rep(i, 0, n) repe(j, 1, n){
        string s;
        if(i+j <= n){
            s = S.substr(i, j);
            if(all_of(ALL(s), [](auto c){ return c == 'A' or c == 'G' or c == 'C' or c == 'T'; })) chmax(ans, SZ(s));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0,a[10001],b[10001],c[10001];
	cin>>n;
	for(int i=1;i<=n;i++)
	  {
	  	cin>>a[i]>>b[i];
	  	c[i]=b[i]-a[i]+1;
	  }
	for(int i=1;i<=n;i++)
	  ans+=c[i];
	cout<<ans<<endl;
}

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

int main()
{
    const ll m = 1e9+7;
    int n,k;
    cin >> n >> k;
    vector<vector<int>> g(n);
    rep(i,n-1) {
        int a,b;
        cin >> a >> b;
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
    }

    vector<bool> seen(n, false);
    queue<pair<int,int>> que;
    que.push({0,0});
    ll ans = k;

    while(!que.empty()) {
        int cv = que.front().first;
        int cd = que.front().second;
        que.pop();

        seen[cv] = true;
        int nv_cnt = 0;
        for(auto nv:g[cv]) {
            if(seen[nv]) continue;
            que.push({nv,cd+1});
            ++nv_cnt;
        }

        int kc = k - min(2, cd+1);
        rep(i,nv_cnt) {
            ans = (ans*kc) % m;
            kc = max(0, kc-1);
        }
    }

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

Measured memory_bytes: 6904
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef long double td;
typedef vector<td> vd;
typedef pair<ll,ll> ii;
typedef vector<ii> vii; typedef vector<bool> vb;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(ll i = ll(a); i < (ll)(b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define show(v,n) cerr << #v << " = "; forn(i,n) cerr << v[i] << " "; cerr << endl;
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
int MAXN = 500005;


ll solve(vector <int> &v, int n, int k)
{
	ll MAXN = (ll)(1e18);
	vector <ll> dp(n,MAXN);
	dp[0]=0;
	forr(i,1,n)
	{
		forr(j,1,k+1)
		{
			if(i-j < 0) break;
			dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
		}
	}
	return dp[n-1];
}
 
int main()
{ 	
	FIN;
	#ifdef input
		freopen("test1.txt", "r", stdin);
	#endif

	int n, k;
	cin >> n >> k;
	vector <int> v(n);
	forn(i,n) cin >> v[i];
	cout << solve(v,n,k) << endl;
    return 0;
}


Measured memory_bytes: 4500
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""
n = onem()

le = []

ri = []

if n % 2 != 0:
	for i in range(n):
		a,b = m()
		le.append(a)
		ri.append(b)
	le.sort()
	ri.sort()
	print(ri[n//2] - le[n//2]+1)



else:
	for i in range(n):
		a,b = m()
		le.append(a*2)
		ri.append(b*2)
	le.sort()
	ri.sort()
	print(((ri[n//2]+ri[n//2-1]) - (le[n//2]+le[n//2-1]))//2+1)




Measured memory_bytes: 25808
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int count = 0;
		for(int i=A;i<B+1;i++) {
			if(i%K == 0) {
				count ++;
			}
		}
		if(count>0) {
			System.out.println("OK");
		}else {
			System.out.println("NG");
		}
	}
}
		

Measured memory_bytes: 35656
h, w, k = map(int, input().split())
c = [input() for _ in range(h)]
ans = 0

for x in range(2**h):
    for y in range(2**w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if (x&(1<<i)) or (y&(1<<j)):
                    continue
                if c[i][j] == "#":
                    cnt += 1

        if cnt == k:
            ans += 1

print(ans)

Measured memory_bytes: 73652
# seishin.py
N = int(input())
*X, = map(int, input().split())
L = int(input())

K = 20

D = [[N]*(K+1) for i in range(N)]
j = N-1
for i in range(N-1, -1, -1):
    while j > 0 and X[j] - X[i] > L:
        j -= 1
    D[i][0] = j
for k in range(K):
    for i in range(N):
        if D[i][k] != N:
            D[i][k+1] = D[D[i][k]][k]
def solve(a, b):
    if not a < b:
        a, b = b, a
    res = 1
    for k in range(K, -1, -1):
        if D[a][k] < b:
            a = D[a][k]
            res += 2**k
    return res
Q = int(input())
ans = []
for i in range(Q):
    a, b = map(int, input().split())
    ans.append(solve(a-1, b-1))
print(*ans, sep='\n')


Measured memory_bytes: 41172
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<long long> v(n);
	long long cnt=0;
	for(long long i=0;i<n;i++){
		cin>>v[i];
		if(v[i]<0){
			cnt++;
			v[i]=abs(v[i]);
		}
	}
	sort(v.begin(),v.end());
	long long ans=0;
	for(long long i=0;i<n;i++)ans+=v[i];
	cnt=cnt%2;
	if(cnt)ans=ans-v[0]*2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef set<ii> sii;
typedef set<int> si;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef queue<ii> qii;

const int INF = 1000000010;
const ll MOD = 1000000007;

class UnionFind {
	private: 
		vi p, rank;
	public:
		UnionFind(int N) { 
			rank.assign(N, 0);
			p.assign(N, 0); 
			for (int i = 0; i < N; i++) 
				p[i] = i;
		}
		int findSet(int i) { 
			return (p[i] == i) ? i : (p[i] = findSet(p[i])); 
		}
		bool isSameSet(int i, int j) { 
			return findSet(i) == findSet(j);
		}
		void unionSet(int i, int j) {
			if (!isSameSet(i, j)) {
				int x = findSet(i), y = findSet(j);
				if (rank[x] > rank[y]) {
					p[y] = x;	
				} else {
					p[x] = y;
					if (rank[x] == rank[y])
						rank[y]++;
				}
			}
		}
};

int main() {FIN
	
	int n, m, i, j, a, b, x, y, p, q, c = 0;
	cin >> n >> m;
	cin >> a >> b;
	cin >> x >> y;
	vs tb(n);
	vvi pr(n, vi(m, -1));
	UnionFind UF(n*m);
	
	for (i = 0; i < n; i++) {
		cin >> tb[i];
		for (j = 0; j < m; j++) {
			if (tb[i][j] == '.') {
				if (i > 0 and tb[i-1][j] == '.')
					UF.unionSet(i*m+j, (i-1)*m+j);
				if (j > 0 and tb[i][j-1] == '.')
					UF.unionSet(i*m+j, i*m+(j-1));
			}
		}
	}
	
	sii ed;
	vvi gf(n*m);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if(tb[i][j] == '.')
				pr[i][j] = UF.findSet(i*m+j);
		}
	}
	
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if (pr[i][j] != -1) {
				for (p = min(n-1, i+2); p >= max(0, i-2); p--) {
					for (q = min(m-1, j+2); q >= max(0, j-2); q--) {
						if (pr[p][q] != -1 and pr[i][j] != pr[p][q]) {
							auto it = ed.find(ii(min(pr[i][j], pr[p][q]), max(pr[i][j], pr[p][q])));
							if (it == ed.end()) {
								gf[pr[i][j]].push_back(pr[p][q]);
								gf[pr[p][q]].push_back(pr[i][j]);
							}
						}
					}
				}
			}
		}
	}
	
	a--, b--, x--, y--;
	if (pr[a][b] != pr[x][y]) {
		qii tr; 
		tr.push(ii(pr[a][b], 0));
		vi vis(n*m); vis[pr[a][b]] = 1;
		while (!tr.empty()) {
			ii e = tr.front(); tr.pop();
			for (i = 0; i < (int)gf[e.first].size(); i++) {
				if (vis[gf[e.first][i]] == 0) {
					if (gf[e.first][i] == pr[x][y]) {
						cout << e.second+1 << "\n";
						return 0;
					}
					vis[gf[e.first][i]] = 1;
					tr.push(ii(gf[e.first][i], e.second+1));
				}
			}
		}
		c = -1;
	}
	cout << c << "\n";
		
	return 0;
}


Measured memory_bytes: 65448
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
INF = 10**9

def main():
    N, A, B, C = input_nums()
    ll = [int(input()) for _ in range(N)]

    def dfs(idx, a, b, c):
        if idx == N:
            # a,b,cそれぞれ最低1本は必要で合成をしているため、-30が必要
            return abs(a-A)+abs(b-B)+abs(c-C) - 30 if min(a, b, c) > 0 else INF
        ret0 = dfs(idx+1, a, b, c)
        ret1 = dfs(idx+1, a+ll[idx], b, c) + 10
        ret2 = dfs(idx+1, a, b+ll[idx], c) + 10
        ret3 = dfs(idx+1, a, b, c+ll[idx]) + 10
        return min(ret0, ret1, ret2, ret3)

    print(dfs(0,0,0,0))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9240
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
#include<map>
using namespace std;
typedef pair<int, pair<int, int> >PP;
typedef long long ll;
typedef pair<int, int>P;
typedef vector<int>vec;
int inf=-1;
ll mod = pow(10, 9) + 7;

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(i%2==0){
            if(s[i]!='R'&&(s[i]!='U'&&s[i]!='D')){
                cout<<"No"<<endl;
                return 0;
            }
        }
        else if(i%2==1){
            if(s[i]!='L'&&(s[i]!='U'&&s[i]!='D')){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
i = 1
ans = sum(b)
while i <= n-1:
    if a[i]  == a[i-1] + 1:
        ans = ans + c[a[i-1]-1]
    i +=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define n_max int(1e5 + 5)


int main(){
    int n,t;
    cin >> n >> t;
    int A[n_max];
    REP(i,n) scanf("%d",&A[i]);
    int profit =0;
    int tmp_min=int(1e9+1);
    REP(i,n){
        if(A[i] < tmp_min) tmp_min = A[i];
        profit = max(profit,A[i] - tmp_min);
    }

    int min_cnt=0,max_cnt=0;
    tmp_min = A[0];
    int ans=0;
    REP(i,n){
        if(A[i] < tmp_min){
            tmp_min =A[i];
            ans += min(min_cnt,max_cnt);
            min_cnt = 1;
            max_cnt = 0;
        }
        else if(A[i] == tmp_min) min_cnt +=1;
        else if( A[i] == tmp_min +profit) max_cnt +=1;
    }

    ans+= min(min_cnt,max_cnt);
    cout << ans << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main(){
	cin.sync_with_stdio(0);
	// cin.tie(0);

	ll n;
	cin >> n;

	unordered_map<string, pll> anas;

	string s;
	FOR(i,0,n) {
		cin >> s;
		sort(s.begin(), s.end());
		if (!anas.insert({s, {1, 0}}).yy) {
			anas[s] = {anas[s].xx + 1, anas[s].yy + anas[s].xx};
		}
	}

	ll result = 0ll;
	for (auto ele : anas) {
		TR(ele.xx);
		TR(ele.yy.xx);
		TR(ele.yy.yy);
		result += ele.yy.yy;
	}
	cout << result << '\n';
}


Measured memory_bytes: 10660
#include<stdio.h>

int main(){
  int a,b,c;
  int i,count=0;

  scanf("%d %d %d", &a, &b, &c);
  for(i=a;i<=b;i++){
    if (c%i==0){
      count++;
    }
  }
  printf("%d\n",count);

  return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	pair<int, int> p[n];
	rep(i, n) cin >> p[i].second >> p[i].first;
	sort(p, p + n, greater<pair<int, int>>());
	ll now = 0;
	set<int> s;
	priority_queue<int, vector<int>, greater<int>> que;
	rep(i, k) {
		now += p[i].first;
		if (s.count(p[i].second)) que.push(p[i].first);
		s.insert(p[i].second);
	}
	ll S = s.size();
	now += S * S;
	priority_queue<int> Que;
	repl(i, k, n) {
		if (s.count(p[i].second) == 0) {
			Que.push(p[i].first);
			s.insert(p[i].second);
		}
	}
	ll ans = now;
	while (true) {
		if (Que.empty() or que.empty()) break;
		now += Que.top() - que.top();
		Que.pop(), que.pop();
		now -= S * S;
		S++;
		now += S * S;
		ans = max(ans, now);
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int H, W;
  cin >> H >> W;
  vector<string> vecs(H);

  for(int i = 0; i < H; i++){
    cin >> vecs[i];
    vecs[i] = "#" + vecs[i] + "#";
  }

  string ue = "";
  for(int i = 0; i < W+2; i++){
    ue += "#";
  }

  cout << ue << endl;
  for(int i = 0; i < H; i++){
    cout << vecs[i] << endl;
  }
  cout << ue << endl;
  

  return 0;
}


Measured memory_bytes: 256
N = int(input())
D = {}
ma = 0
for _ in range(N):
    s = input()
    if s not in D: D[s] = 0
    D[s] += 1
    ma = max(ma, D[s])

ANS = []
for d in D:
    if D[d] == ma:
        ANS.append(d)
for ans in sorted(ANS):
    print(ans)

Measured memory_bytes: 97040
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

//<editor-fold defaultstate="collapsed" desc="Headers & Macros">
#include <bits/stdc++.h>

#pragma GCC optimize("O3")

using namespace std;
//</editor-fold>

class CForbiddenList {
public:
    int testNumber = 0;
    void solve(std::istream& in, std::ostream& out) {
        int x, n;

        in >> x >> n;

        vector<int> p(n);

        for (auto &y: p) {
            in >> y;
        }

        unordered_set<int> used(p.begin(), p.end());

        for (int diff = 0; diff <= n; diff++) {
            for (int sign = -1; sign < 2; sign += 2) {
                int y = x + sign * diff ;
                if (used.find(y) == used.end()) {
                    out << y << '\n';
                    return;
                }
            }
        }
    }
};


int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    CForbiddenList solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

typedef long long ll;
#define fore(i,ii,iii) for(ll i=ii;i<iii;i++)

const ll N=1e5+15,INF=1e12;
ll n,w,dp[110][N],pesos[110],val[110];

ll f(ll x,ll y){
  if(x<0){
    if(y==0) {return 0;}else {return INF;}
  }
  
  if(dp[x][y]>=0) return dp[x][y];
  dp[x][y]=f(x-1,y);
  if(y>=val[x])
    dp[x][y]=min(dp[x][y],pesos[x]+f(x-1,y-val[x]));
  return dp[x][y];
}

int main() {
  cin>>n>>w;
  fore(i,0,n) cin>>pesos[i]>>val[i];
  memset(dp,-1,sizeof dp);
  for(int i=1e5;i>0;i--){if(f(n-1,i)<=w){cout<<i;break;}}

}

Measured memory_bytes: 86144
#include <iostream>
#include <string>
 
int check_length(std::string S)
{
  int length = 0;
  
  while(S[length] != NULL)
  {
    length++;
  }
  
  return length;
}
 
int main()
{
  std::string S;
  int length;
  std::cin >> S;
  
  length = check_length(S);

  std::cout << S[0] << length - 2 << S[length -1];
  return 0;
}

Measured memory_bytes: 3196
main = readLn >>= print . solve

solve n = minimum $ [f6 m + f9 (n-m) | m <- [0..n]]
    where f6 = \k -> sum $ map ((`mod` 6) . (k `div`)) [46656,7776,1296,216,36,6,1]
          f9 = \k -> sum $ map ((`mod` 9) . (k `div`)) [59049,6561,729,81,9,1]


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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

struct Solution
{
    Solution() {}
    void solveCase();
};

void Solution::solveCase()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll res = a * c;
    res = max(res, a * d);
    res = max(res, b * c);
    res = max(res, b * d);
    cout << res << '\n';
}

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/

#define double long double
const double pi = acosl(-1.0);

const double eps = 1e-10;

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

    double angle; cin >> angle;
    angle = pi * angle / 180.0;
    double x = 0, y = 0;
    int ans = 1;
    double curr = 0;
    auto move = [&]() {
        y += cosl(curr);
        x += sinl(curr);
        curr += angle;
    };
    move();
    while (fabs(x - 0) > eps or fabs(y - 0) > eps) {
        move();
        ans++;
    }

    cout << ans;

    

    return 0;
}


Measured memory_bytes: 4116
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000




int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }
  for(j=1;j<=n;j++){
    scanf("%hd",&A[j]);
    C[A[j]]++;
  }
  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }

  for(j=1;j<=n;j
	++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    if(i>1){
      printf(" ");
    }
    printf("%d",B[i]);
  }
  printf("\n");
  

  return 0;
}



Measured memory_bytes: 9652
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
typedef long long ll; 
char str[305]; 
int dp[305][305][305], n; 
int calc(int l, int r, int k)
{
	if (k < 0)
		return -1e9; 
	if (l > r || l >= n || r < 0)
		return 0; 
	if (~dp[l][r][k])
		return dp[l][r][k]; 
	int res = std::max(calc(l + 1, r, k), calc(l, r - 1, k)); 
	if (str[l] == str[r])
		res = std::max(res, calc(l + 1, r - 1, k) + (l != r) + 1); 
	return dp[l][r][k] = std::max(res, calc(l + 1, r - 1, k - 1) + (l != r) + 1); 
}
int main()
{
	// freopen("AGC021-D.in", "r", stdin); 
	int k; 
	scanf("%s%d", str, &k); 
	n = strlen(str); 
	memset(dp, -1, sizeof(dp)); 
	printf("%d\n", calc(0, n - 1, k));
	return 0; 
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

int main(){
    ll N, R;
    cin >> N >> R;
    ll ans = 0;
    if(N >= 10){
        ans = R;
    }
    else{
        ans = R + 100*(10-N);
    }
    cout << ans << endl;
    return 0;
}


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

using ll=long long;

int f(int x){
    if(x==2){
        return 3;
    }
    else if(x==4 || x==6 || x==9 || x==11){
        return 2;
    }else{
        return 1;
    }
}

void solve(){
    int x,y;
    cin>>x>>y;
    if(f(x)==f(y)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int x = 0,max = 0;
  for(int i = 0;i < n;i++){
    if(s[i] == 'I') x++;
    else x--;
    if(x > max) max = x;
  }
  cout << max << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
	vector <int> N(3);
	for (int i = 0; i < 3; i++) {
		cin >> N[i];
	}
	sort(N.begin(), N.end(),greater<int>());
	cout << N[0] * 10 + N[1] + N[2] << endl;


	return 0;
}

Measured memory_bytes: 256
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	K := nextInt()
	N := nextInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}

	maxDistance := 0
	distance := 0
	for i := 0; i < N; i++ {
		if i+1 == N {
			distance = (K - A[N-1] + A[0])
		} else {
			distance = A[i+1] - A[i]
		}
		if distance > maxDistance {
			maxDistance = distance
		}
	}
	fmt.Println(K - maxDistance)
}


Measured memory_bytes: 3840
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    while(S.size()) {
        S.pop_back();
        if(S.length() % 2 == 1) continue;
        bool ok = true;
        rep(i, S.length() / 2) {
            if (S[i] != S[i + S.length() / 2]) ok = false;
        }
        if(ok) break;
    }
    cout << S.length() << endl;

    return 0;
}


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

int main()
{
    long long int n, i, j, k, sum;
    cin>>n;
    long long int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    map<long long int, long long int>cn;
    map<long long int, long long int>::iterator itt;
    for(i=0;i<n;i++)
    {
        cn[a[i]]++;
    }
    long long int sum1=0;
    for(itt=cn.begin();itt!=cn.end();++itt)
    {
        j=(itt->second);
        sum1=sum1+(j*(j-1)/2);
    }
    for(i=0;i<n;i++)
    {
        j=cn[a[i]];
        sum=sum1-(j*(j-1)/2)+((j-2)*(j-1)/2);
        cout<<sum<<endl;
    }

    return 0;
}


Measured memory_bytes: 11008
// https://beta.atcoder.jp/contests/abc062
// status: [review]

#define SUBMIT

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;

const int MAX_N = 100000;
i64 a[MAX_N * 3];
i64 left_sum[MAX_N + 1], right_sum[MAX_N + 1];
int N, N2, N3;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(3
8 2 2 7 4 6 5 3 8
)");
#endif
    stream >> N;
    N2 = 2 * N, N3 = 3 * N;
    for (int i = 0; i < N3; ++i) stream >> a[i];

    i64 ls = 0, rs = 0;
    priority_queue<i64, vector<i64>, greater<>> left_pq;
    priority_queue<i64> right_pq;
    for (int i = 0; i < N; ++i) {
        ls += a[i];
        left_pq.push(a[i]);

        rs += a[(N3 - 1) - i];
        right_pq.push(a[(N3 - 1) - i]);
    }

    left_sum[0] = ls;
    right_sum[N] = rs;
    for (int k = 0; k < N; ++k) {
        left_sum[1 + k] += left_sum[k];
        if (left_pq.top() < a[N + k]) {
            left_sum[1 + k] += a[N + k] - left_pq.top();
            left_pq.pop();
            left_pq.push(a[N + k]);
        }

        right_sum[(N - 1) - k] = right_sum[N - k];
        if (a[(N2 - 1) - k] < right_pq.top()) {
            right_sum[(N - 1) - k] += a[(N2 - 1) - k] - right_pq.top();
            right_pq.pop();
            right_pq.push(a[(N2 - 1) - k]);
        }
    }

    i64 ans =  numeric_limits<i64>::min();
    for (int i = 0; i <= N; ++i) ans = max(ans, left_sum[i] - right_sum[i]);

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

Measured memory_bytes: 5996
import java.util.*;

public class Main {

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int rimit = sc.nextInt();

    List<Integer> numList = new ArrayList<Integer>();

    for(int num = 1; num<=rimit ; num++){
      numList.add(sc.nextInt());
    }

    int ans = 0;
    int turn = 2;

    Collections.sort(numList, Collections.reverseOrder());

    for(int num : numList){
      if(turn % 2 == 0){
        ans += num;
      }else{
        ans -= num;
      }
      
      turn++;

    }

    System.out.println(ans);
  }

}

Measured memory_bytes: 21844
#include<stdio.h>
int countDigit(int a)
{
	int ret=0;
	while(a>0){ret++;a/=10;}
	return ret;
}

int main()
{
	int a,b;
	while(scanf("%d %d",&a,&b)!=EOF){
		printf("%d\n",countDigit(a+b));	
	}
	return 0;
}

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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n; cin >> n;
  int a[n+2], left[n+2], right[n+2];
  a[0] = 0;
  left[0] = 0;
  right[0] = 0;
  right[n+1] = 0;
  for(int i=1; i<=n; ++i){
    cin >> a[i];
  }
  for(int i=1; i<=n; ++i){
    left[i] = __gcd(left[i-1], a[i]);
  }
  for(int i=n; i>=1; --i){
    right[i] = __gcd(right[i+1], a[i]);
  }
  int g_cd, res = 0;
  for(int i=1; i<=n; ++i){
    if(i == 1)
      g_cd = right[i+1];
    else if(i==n)
      g_cd = left[i-1];
    else
      g_cd = __gcd(left[i-1], right[i+1]);
    res = max(res, g_cd);
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};

void solve(){
  string s,t;
  cin>>s>>t;
  sort(all(s));
  sort(all(t),greater<char>());
  if(s<t) cout<<"Yes\n";
  else cout<<"No\n";
}

int main(){
    optimizeIO();
    int r=1;
    {solve();}
}


Measured memory_bytes: 6972
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
int INF = 1<<29;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
long long int i,j;

int main(){
	int n,a;
	cin>>n>>a;
	int x[54];
	for(i=0;i<n;i++){
		cin>>x[i];
	}
	for(i=0;i<n;i++){
		x[i] -= a;
	}
	long long int dp[55][2002];
	// dp[i][j] = i+1番目まででj-1000を作る方法は何通り？
	for(i=0;i<n;i++){
		for(j=0;j<2001;j++){
			dp[i][j]=0;
		}
	}
	dp[0][1000] += 1;
	dp[0][1000 + x[0]] += 1;
	for(i=0;i<n-1;i++){
		for(j=0;j<2001;j++){
			if(j-x[i+1]>=0)dp[i+1][j]= dp[i][j] + dp[i][j-x[i+1]];
			else dp[i+1][j]=dp[i][j];
		}
	}
	cout<<dp[n-1][1000]-1<<endl;

	return 0;
}

Measured memory_bytes: 1024
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        
        int[] v = new int[a];
        int[] c = new int[a];
        
        for(int i = 0; i < a; i++){
            v[i] = sc.nextInt();
        }
        
        for(int j = 0; j < a; j++){
            c[j] = sc.nextInt();
        }
        
        int result = 0;
        for(int k = 0; k < a; k++){
            int g = v[k] - c[k];
            if(g > 0){
                result += g;
            }
        }
        
        System.out.println(result);
    }
}

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

namespace B_ABC141
{
    class MainClass
    {

        static string s;

        public static void Main(string[] args)
        {
            s = ReadLine();
            for(int i=0;i<s.Length;i++){
                if(i%2==0){
                    if(s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
                        WriteLine("No");
                        return;
                    }


                }else{
                    if(s[i]!='L'&&s[i]!='U'&&s[i]!='D'){
                        WriteLine("No");
                        return;
                    }

                }
            }
            WriteLine("Yes");
        }
    }
}


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

string S;

bool odd_string(string S, int i){
    if((S.size() - i) % 2 == 1) return false;
    for(int j = 0; j < (S.size()-i)/2; ++j){
        if(S[j] != S[j+(S.size()-i)/2]) return false;
    }
    return true;
}

int main(){
    cin >> S;
    int i = 1;
    while(!odd_string(S, i)){
        ++i;
    }
    cout << S.size() - i << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#define long long long
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;


signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> a(N);

  iota(ALL(a), 1);

  do {
    for(int i=0; i<N; ++i) cout << a[i] << (i+1 < N ? ' ' : LF);
  } while(next_permutation(ALL(a)));

  return 0;
}




Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a) (a).begin(), (a).end()

const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T &r, T &l)
{
    T tmp = r;
    r = l;
    l = tmp;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
    return is;
}

int main()
{
    ll n, m;
    cin >> n >> m;

    vector<ll> h(n);
    vector<pair<ll, ll>> ab(m);

    vector<vector<ll>> other_towerlist(n,vector<ll>());

    cin >>h;
    for (ll i = 0; i < m; i++)
    {
        ll aa,bb;
        cin >> aa >> bb;
        // ab[i]=make_pair(aa,bb);
        
        if (h[aa-1] < h[bb-1]){ //bが高い
            other_towerlist[aa-1].push_back(1);
        }else if (h[aa-1] > h[bb-1]){
            other_towerlist[bb-1].push_back(aa-1);
        }else{
            other_towerlist[aa-1].push_back(bb-1);
            other_towerlist[bb-1].push_back(aa-1);
        }
    }
    ll ans =0;

    
    for (ll i = 0; i < n; i++)
    {
        if (other_towerlist[i].size() ==0 ){
            ans++;
            cerr << i << endl;
        }
    }
    


    cout<< ans<<endl;
}


Measured memory_bytes: 9912
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	int x,y,z;
	x=a+b;
	y=a+c;
	z=b+c;
	if(x<=y && x<=z){
		printf("%d\n",x);
	}
	else if(y<=x&&y<=z){
		printf("%d\n",y);
	}
	else{
		printf("%d\n",z);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   long long n,i,m=1,count=0;
   cin>>n;
   long long a[n];
   for(i=0;i<n;i++)cin>>a[i];
   for(i=0;i<n;i++){
       if(a[i]==0)count++;
   }
   if(count>0)m=0;
   else{
       for(i=0;i<n;i++){
           if(a[i]<=1000000000000000000/m)m=m*a[i];
           else {m=-1;}
       }
   }
   cout<<m;
   
    return 0;
}

Measured memory_bytes: 4336
import sys

def main():
    input = sys.stdin.readline
    A, B, C, D = map(int, input().split())
    
    if (A+B) > (C+D):
        print('Left')
    elif (A+B) == (C+D):
        print('Balanced')
    else:
        print('Right')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

#define MAX (10+300000/7)

int gd[2*MAX];
int prime[35820];
int cnt;
char *p;

int inv[3] = {2,1,0};
int mul[3][3]={
  {0,0,0},
  {0,1,1},
  {0,1,2}
};
int add[3][3]={
  {0,1,2},
  {1,1,2},
  {2,2,2}
};

int perse(){
  int ret;
  if(*p == '('){
    p++;
    int op1 = perse();
    char op = *p++;
    int op2 = perse();
    p++;
    if(op == '*')
      ret = mul[op1][op2];
    else
      ret = add[op1][op2];
  }else if(*p == '-'){
    p++;
    ret = inv[perse()];
  }else{
    ret = *p - '0';
    p++;
  }
  return ret;
}

int main(){
  char mapping[255];
  char buff[100];
  REP(i,255) mapping[i] = i;

  while(fgets(buff,sizeof(buff),stdin), *buff != '.'){
    int ans = 0;
    REP(P,3){
      mapping['P'] = P+'0';
      REP(Q,3){
        mapping['Q'] = Q+'0';
        REP(R,3){
          char str[100];
          mapping['R'] = R+'0';
          for(int i=0; str[i] = mapping[buff[i]]; i++);
          p = str;
          if(perse() == 2){
            ans++;
          }
        }
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main() {
  int a, b, c, ans = 0;
  scanf("%d%d%d", &a, &b, &c);
  if (a*c >= b) {
    ans = b/a;
  } else {
    ans = c;
  }
  printf("%d\n", ans);
  return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

int main() {
    IOS;

    long int n;
    cin>>n;

    unordered_map<string,long int> freq;

    for(long int i = 0; i < n; i++){
        string s;
        cin>>s;

        sort(s.begin(),s.end());
        freq[s]++;
    }

    long int ans = 0;
    for(auto ele : freq)
        ans += ((ele.second) * (ele.second - 1)) /2;
    
    cout<<ans;
    return 0;
}


Measured memory_bytes: 10660
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        multiset<int> s;
        int a[n];
        for(int i = 0; i < n; i++){
            cin >> a[i];
            s.insert(a[i]);
        }
        for(int i = 0; i < n; i++){
            s.erase(s.find(a[i]));
            cout << *s.rbegin() << '\n';
            s.insert(a[i]);
        }
    }
}

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

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    set<int> w = {};
    for (int i = 0; i < 3001; i++) {
        for (int j = 0; j < 3001; j++) {
            int x = A * i * 100 + B * j * 100;
            if (x > F) continue;
            w.insert(x);
        }
    }

    set<int> s = {};
    for (int i = 0; i < 3001; i++) {
        for (int j = 0; j < 3001; j++) {
            int x = i * C + j * D;
            if (x > F) continue;
            s.insert(x);
        }
    }

    int ans1;
    int ans2;
    double con = -1;
    double t_con = (double) E / ((double) 100 + (double) E);
    for (auto x : w) {
        for (auto y : s) {
            if (x + y > F) continue;

            double ncon = (double) y / ((double) x + (double) y);
            if (ncon > t_con) {
                continue;
            }

            if (ncon > con) {
                ans1 = x + y;
                ans2 = y;
                con = ncon;
            }
        }
    }

    cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 3600