akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        String n = scan.next();
        
        String first_num = n.substring(0,1);
        String second_num = n.substring(1,2);
        
        if( first_num.charAt(0) == '9' || second_num.charAt(0) == '9' )System.out.println("Yes");
        else System.out.println("No");
            
        
	  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int main(){
	int H, W;
	while(cin >> H >> W){
		if(H==0 && W==0) return 0;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(i==0 || i==H-1) cout << "#";
				else if(j==0 || j==W-1) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1152
while True:
    a,op,b=input().split()
    if op=="?":
        break
    a=int(a)
    b=int(b)
    if op=="+":
        print(int(a+b))
    elif op=="-":
        print(int(a-b))
    elif op=="*":
        print(int(a*b))
    else:
        print(int(a/b))


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const pid_t pid = getpid();
// Problem Specific Parameter:

const int limit = 100010;
int dp[limit][3];
int ary[limit][3];

int main(void){
	int n;
	cin >> n;
	rep(i,n)rep(j,3) cin >> ary[i][j];

	rep(i,n)rep(j,3)rep(k,3){
		if(j==k) continue;
		chmax(dp[i + 1][k], dp[i][j] + ary[i][k]);
	}

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

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

struct cake { ll x, y, z; };
cake cakes[1000];

#define sig(op1, op2, op3) (a.x * (op1) + a.y * (op2) + a.z * (op3) < b.x * (op1) + b.y * (op2) + b.z * (op3))
bool comp1(struct cake& a, struct cake& b) { return sig(1,   1,  1); }
bool comp2(struct cake& a, struct cake& b) { return sig(1,   1, -1); }
bool comp3(struct cake& a, struct cake& b) { return sig(1,  -1,  1); }
bool comp4(struct cake& a, struct cake& b) { return sig(1,  -1, -1); }
bool comp5(struct cake& a, struct cake& b) { return sig(-1,  1,  1); }
bool comp6(struct cake& a, struct cake& b) { return sig(-1,  1, -1); }
bool comp7(struct cake& a, struct cake& b) { return sig(-1, -1,  1); }
bool comp8(struct cake& a, struct cake& b) { return sig(-1, -1, -1); }
bool (*COMP[8])(struct cake&, struct cake&) = { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8 };

int main()
{
	int N, M;
	ll ans = 0;

	cin >> N >> M;
	rep(i, N) cin >> cakes[i].x >> cakes[i].y >> cakes[i].z;

	rep(i, 8) {
		cake sum = { 0, 0, 0 };
		sort(cakes, cakes + N, COMP[i]);

		rep(j, M) {
			sum.x += cakes[j].x;
			sum.y += cakes[j].y;
			sum.z += cakes[j].z;
		}

		ans = max(ans, abs(sum.x) + abs(sum.y) + abs(sum.z));
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;
  int ac[N];
  int pe[N];
  for (int i = 0; i < N; i++) {
    ac[i] = 0;
    pe[i] = 0;
  }
  int p;
  string S;
  for (int i = 0; i < M; i++) {
    cin >> p >> S;
    if (ac[p-1] == 0) {
      if (S == "WA") {
        pe[p-1]++;
      } else {
        ac[p-1]++;
      }
    }
  }
  int ac_cnt = 0;
  int pe_cnt = 0;
  for (int i = 0; i < N; i++) {
    if (ac[i] == 1) {
      ac_cnt++;
      pe_cnt += pe[i];
    }
  }
  cout << ac_cnt << " " << pe_cnt << endl;
  return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  // 積が偶数になるのはどちらかが偶数の時
  string message;
  if(a % 2 == 0 || b % 2 == 0){
    message = "Even";
  } else {
    message = "Odd";
  }
  cout << message << endl;
}

Measured memory_bytes: 256
h,w = gets.chomp.split.map &:to_i
s = []
dp = []
h.times{ s << gets.chomp.chars && dp << Array.new(w,0) }

def is_w2b(from, to)
  from === '.' && to === '#'
end

def is_w(s)
  s === '.'
end

dp[0][0] = is_w(s[0][0])  ? 0 : 1

(h-1).times do |i|
  dp[i+1][0] = is_w2b(s[i][0], s[i+1][0]) ? dp[i][0] + 1 : dp[i][0]
end
(w-1).times do |j|
  dp[0][j+1] = is_w2b(s[0][j], s[0][j+1]) ? dp[0][j] + 1 : dp[0][j]
end

(1...h).each do |i|
  (1...w).each do |j|
    dp[i][j] = [
      is_w2b(s[i-1][j], s[i][j]) ? dp[i-1][j] + 1 : dp[i-1][j],
      is_w2b(s[i][j-1], s[i][j]) ? dp[i][j-1] + 1 : dp[i][j-1]
    ].min
  end
end

p dp.last.last


Measured memory_bytes: 15136
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        char[] c = sc.next().toCharArray();
        int result = 0;
        for (int i = 0; i < c.length / 2; i++) {
            if (c[i] != c[c.length - 1 - i]) {
                result++;
            }
        }
        System.out.println(result);
    }
}


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

int main(){
    int n = 5, ans = 0;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i] == 0) ans = i+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

set<ll> hor[100010], ver[100010];
vvll g(100010);
vi visited(100010, 0);
vll x, y;

// グラフに対する深さ優先探索
set<ll> htypes, vtypes;

void dfs(ll start){
    stack<ll> st;
    visited[start] = 1;
    st.push(start);
    htypes.emplace(x[start]);
    vtypes.emplace(y[start]);
    while (!st.empty()) {
        ll now = st.top(); st.pop();
        ll szg = SZ(g[now]);
        rep(i, szg){
            ll next = g[now][i];
            if(!visited[next]){
                visited[next] = 1;
                htypes.emplace(x[next]);
                vtypes.emplace(y[next]);
                st.push(next);
            }
        }
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<pll, ll> mp;
    rep(i, n){
        ll tx, ty;
        cin >> tx >> ty;
        x.emplace_back(tx);
        y.emplace_back(ty);
        ver[tx].emplace(ty);
        hor[ty].emplace(tx);
        mp.emplace(make_pair(tx, ty), i);
    }
    repr(i, 1, 100001){
        int j = 1;
        ll prev;
        if(ver[i].size() >= 2) for(auto e: ver[i]){
            if(j >= 2){
                g[mp[make_pair(i, prev)]].emplace_back(mp[make_pair(i, e)]);
                g[mp[make_pair(i, e)]].emplace_back(mp[make_pair(i, prev)]);
            }
            prev = e;
            j++;
        }
    }
    repr(i, 1, 100001){
        int j = 1;
        ll prev;
        if(hor[i].size() >= 2) for(auto e: hor[i]){
            if(j >= 2){
                g[mp[make_pair(prev, i)]].emplace_back(mp[make_pair(e, i)]);
                g[mp[make_pair(e, i)]].emplace_back(mp[make_pair(prev, i)]);
            }
            prev = e;
            j++;
        }
    }
    ll ans = 0;
    rep(i, n){
        htypes.clear();
        vtypes.clear();
        if(!visited[i]){
            dfs(i);
            ans += SZ(htypes)*SZ(vtypes);
        }
    }
    ans -= n;
    cout << ans << endl;
    return 0;
}

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

int main(){
	int y, x, i, j;
	bool stop;
	string str;
	while(true){
		cin>>y>>x;if(y==0 &&x==0) break;
		vector<vector<pair<char, bool> > > field(y, vector<pair<char, bool> >(x));
		for(i=0;i<y;i++){
			cin>>str;
			for(j=0;j<x;j++){
				field[i][j].first = str[j];
				field[i][j].second = false;
			}
		}
		stop=false;
		j = i = 0;
		while(true){
			if(stop==true){
				cout<<j<<" "<<i<<endl;
				break;
			}else if(field[i][j].second == true){
				cout<<"LOOP\n";
				break;
			}
			field[i][j].second = true;
			switch(field[i][j].first){
				case '.': stop=true; break;
				case '>': j++; break;
				case 'v': i++; break;
				case '<': j--; break;
				case '^': i--; break;
			}
		}
	}
	return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long INF = 1LL << 60;
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    UnionFind(int N) : par(N),siz(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
             par[i] = i;
             siz[i] = 1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        // merge technique（小を大にくっつける）
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    ll size(ll x){
        return siz[root(x)];
    }
};

signed main()
{   
    gearup;
    ll n,m,k; cin >> n >> m >> k;
    UnionFind uf(n);
    vector<set<ll> > sub(n);
    //友達リスト
    rep(i,m){
        ll a,b; cin >> a >> b;
        a--;b--;
        sub[a].insert(b);
        sub[b].insert(a);
        uf.unite(a,b);
    }
    //ブロックリスト
    rep(i,k){
        ll a,b; cin >> a >> b;
        a--;b--;
        if(!uf.same(a,b))continue;
        sub[a].insert(b);
        sub[b].insert(a);
    }
    //出力
    rep(i,n){
        if(i!=0)cout <<" ";
        cout << uf.size(i) - sub[i].size() -1;
    }
    cout << endl;
}


Measured memory_bytes: 25472
n = int(input())
s = [input() for i in range(n)]

# ソートしたsリスト作成（ss）
ss = ['']*n
for i in range(n):
    ss[i] = ''.join(sorted(s[i]))
    
# ssのsetを作成して重複要素削除(sss)
sss = list(set(ss))

# sssから辞書作成
dict_ss = {}
for i in range(len(sss)):
    dict_ss[sss[i]] = 0

# ssにおいて「sssの要素に合致する要素」の検索＆個数計上
for i in range(n):
    dict_ss[ss[i]] += 1

# 計上した個数のリストを作成
# その個数から2個の組み合わせを計算（n C 2）、足し合わせてans
ans_l = [dict_ss[sss[i]] for i in range(len(sss))]
ans = 0
for i in range(len(ans_l)):
    ans += (ans_l[i]*(ans_l[i]-1))/2

print(int(ans))

Measured memory_bytes: 30348
import math
import queue
from collections import defaultdict

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 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

n = readInt()
a = readInts()

d = [0]*(10**5+1)

for i in range(n):
	d[a[i]]+=1

ans = 1

for i in range(n-1):
	ans = max(ans, d[i]+d[i+1]+d[i+2])

print(ans)

Measured memory_bytes: 21772
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
using namespace std;

const int MAX = 1500 * 1000;
int cnt[MAX + 1];

inline void input(vector<int>& vec, int size) {
	vec.reserve(size + 1);
	vec.push_back(0);
	for(int i = 0; i < size; ++i) {
		int in;
		scanf("%d", &in);
		vec.push_back(vec[i] + in);
	}
}

int main() {
	for(int n, m; scanf("%d %d", &n, &m), n;) {
		vector<int> vertical, horizontal;
		input(vertical, n);
		input(horizontal, m);

		memset(cnt, 0, sizeof(cnt));
		for(int i = 0; i < n; ++i)
			for(int j = i + 1; j <= n; ++j)
				++cnt[vertical[j] - vertical[i]];

		int ans = 0;
		for(int i = 0; i < m; ++i)
			for(int j = i + 1; j <= m; ++j)
				ans += cnt[horizontal[j] - horizontal[i]];

		printf("%d\n", ans);
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 6916
#include <bits/stdc++.h>
using namespace std;
#define MAX 100001
int arr[MAX],N;

bool isprime(int x){
  if(x==2)return true;
  if(x<2||x%2==0)return false;
  int i=3;
  int sx=sqrt(x);
  while(i<=sx){
    if(x%i==0)return false;
    i+=2;
  }
  return true;
}

int main(){
  int count[MAX];
  count[0]=count[1]=count[2]=0;
  for(int i=3;i<=100000;i++){
    count[i]=count[i-1];
    if(isprime(i)&&isprime((i+1)/2))count[i]++;
  }
  int Q,l,r;
  cin >> Q;
  for(int i=0;i<Q;i++){
    cin >> l >> r;
    cout << count[r]-count[l-1] << endl;
  }
  return 0;
}



Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
minans = inf ;ans = 0 ;count = 0 ;pro = 1

n,K=map(int,input().split())
X=list(map(int,input().split()))
# n,K=50,0
# X=[50]*2+[-50]*2
A=[0]*2600
B=[0]*2600
for xi in X:
    xi-=K
    if xi>0:
        for i in range(2599-xi,-1,-1):
            A[i+xi]+=A[i]
        A[xi]+=1
    elif xi==0:count+=1
    else:
        xi=-xi
        for i in range(2599-xi,-1,-1):
            B[i+xi]+=B[i]
        B[xi]+=1
count=2**count
for i in range(2600):
    ans+=A[i]*B[i]*(count)
ans+=count-1
print(ans)
# print(A[50],B[50])
# print(A[:20],B[:20],count,sep="\n")


Measured memory_bytes: 39408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (ll i = (a); i < (n); i += (s))
#define rep(...) _overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void chmax(T& a, const T& b) {if (a < b) a = b;}
template<typename T> inline void chmin(T& a, const T& b) {if (a > b) a = b;}
template<typename T> inline void print(const T& x) {cout << x << "\n";}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main() {
    ll n, k;
    cin >> n >> k;
    ll cnt0 = 0, cntk2 = 0;
    rep(i, 1, n + 1) {
        if (i % k == 0) cnt0++;
        if (i % k == k/2) cntk2++;
    }
    if (k & 1) {
        print(cnt0 * cnt0 * cnt0);
    }
    else {
        print(cnt0 * cnt0 * cnt0 + cntk2 * cntk2 * cntk2);
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main (){
    int i;
    int n;
    long long int a[305000] = {0};
    long long int ans = 0;
    scanf("%d",&n);
    for(i=0;i<3 * n;i++){
        scanf("%lld",&a[i]);
    }
    sort(a,a + n * 3);
    
    for(i=0;i<n;i++){
        ans += a[3*n - 2*i -2];
    }
    printf("%lld\n",ans);

    
    return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 200005

const int INF = 1e9+7;

typedef struct union_find{
     
    vector<int> pa;//親
    vector<int> ra;//木の深さ
    //n要素で初期化
    void init(int n){
        pa.resize(n);
        ra.resize(n);
        for(int i = 0;i < n;i++){
            pa[i] = i;/*各ノードに番号を振る,この時par[x]=xとなる時は木の根となる*/
            ra[i] = 0;/*各ノード自体の高さは0*/
            
        }
    }
    //木の根を求める
    int find(int x){
        if(pa[x] == x){
            return x;/*根ならそのノードの番号を返す*/
        }else{
            return pa[x] = find(pa[x]);/*根でないならさらにノードの根を探す*/
        }
    }

    //xとyの属する集合を併合する
    void unite(int x,int y){
        x = find(x);//xの根の番号を探す
        y = find(y);//yの根の番号を探す
        if(x == y){//一致すればつながっている
            return;
        }
        if(ra[x] < ra[y]){//xの高さが低いなら高いほうにつなぐ、そして高さは大きい方(y)になる
            pa[x] = y;
        }else{
            pa[y] = x;//yの高さが低いなら高いほうにつなぐ、そして高さは大きいほう(x)になる
            if(ra[x] == ra[y]){//高さが一致しているなら併合の高さは1増える
                ra[x]++;
            }
        }
    }

    //xとyが同じ集合に属するか判定
    bool same(int x,int y){
        return find(x) == find(y);//同じ集合なら1、違うなら0が返る
    }
}UF;


int main(){

    UF tree;
    int n,m;
    cin >> n >> m;
    tree.init(n+m);

    for(int i = 0;i < n;i++){
        int k;
        cin >> k;
        for(int j = 0;j < k;j++){
            int a;
            cin >> a;
            a--;
            tree.unite(i,a+n);
        }
    }

    int r = tree.find(0);

    for(int i = 0;i < n;i++){
        if(tree.find(i) != r){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <utility>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define modp(x, y) (((y) + (x) % (y)) % (y))

int main(int argc, char* argv[])
{
	char str[5];
	scanf("%s", str);
	for(int i = 0; i < 4; i++) str[i] -= '0';

	int op[3];
	for(int i = 0; i < 2; i++)
	{
		op[0] = i;
		for(int j = 0; j < 2; j++)
		{
			op[1] = j;
			for(int k = 0; k < 2; k++)
			{
				op[2] = k;
				int ans = str[0];
				for(int n = 1; n < 4; n++)
				{
					if(op[n - 1] == 0)
					{
						ans += (int)str[n];
					}
					else
					{
						ans -= (int)str[n];
					}
				}
				if(ans == 7) goto fin;
			}
		}
	}
fin:
	char ops[3];
	for(int i = 0; i < 3; i++) ops[i] = (op[i] == 0) ? '+' : '-';
	printf("%d%c%d%c%d%c%d=7\n", (int)str[0], ops[0], (int)str[1], ops[1], (int)str[2], ops[2], (int)str[3]);

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int solve()
{
    int h,w,k;
    cin>>h>>w>>k;
    string s[h];
    for(int i=0; i<h; i++)
    {
        cin>>s[i];
    }
    int cnt=0;
    for(int i=0; i<(1<<h); i++)
    {
        for(int j=0; j<(1<<w); j++)
        {
            int black=0;
            for(int k=0; k<h; k++)
            {
                for(int l=0; l<w; l++)
                {
                    if(i&(1LL<<k) && j&(1LL<<l) && s[k][l]=='#')
                        black++;
                }
            }
            if(black==k)
                cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}
signed main()
{
    solve();
}






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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

LL n;

int main()
{
	cin >> n;
	
	LL res = 1LL;
	
	for (LL i = 1LL; i <= (n - 1LL) / i; i ++ )
		if ((n - 1LL) % i == 0LL)
		{
			if (i > 1LL) res ++ ;
			if ((n - 1LL) / i != i) res ++ ;
		}
		
	for (LL i = 2LL; i <= n / i; i ++ )
		if (n % i == 0LL)
		{
			LL t = n;
			while (t % i == 0LL) t /= i;
			if (t % i == 1LL) res ++ ;
		}
	
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
int main() {
  string _s; int n;
  cin>>skipws>>_s>>n;
  deque<char> s(_s.begin(),_s.end());
  bool f=false;
  for (int i=0;i<n;i++){
    int t;cin>>t;
    if (t==1){
      f^=1;
    }else{
      int t;char c;
      cin>>t>>c;
      if ((t==1)^f){
        s.push_front(c);
      }else{
        s.push_back(c);
      }
    }
  }
  if (f) reverse(s.begin(),s.end());
  string a(s.begin(),s.end());
  cout<<a<<endl;
}

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int x = fs.nextInt();
		int t = fs.nextInt();
		
		if(x > t) {
			System.out.println(x - t);
		}else {
			System.out.println(0);
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}


}


Measured memory_bytes: 21204
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static io;
public class CompetitiveProgramming
{
  public void Solve()
  {
    var N = Int1;
    int[] A = VerticalRead(N).Select(t => (int)t).ToArray();
    if (N == 1)
    {
      Write(1 + "\n" + 1 + "\n" + 0 + "\n" + 1);
      return;
    }
    var g = new List<int>();
    var m = 0;
    int h = 1;
    while (h < N)
    {
      g.Add(h);
      h = h * 3 * +1;
    }
    g.Reverse();
    m = g.Count();
    shell(ref A, N, m, g.ToArray());
    Write(m);
    Write(g);
    Write(cnt);
    Verticalwrite(A);
  }
  int cnt = 0;
  public void insert(ref int[] A, int N, int g)
  {
    for (int i = g; i < N; ++i)
    {
      var v = A[i];
      var j = i - g;
      while (j >= 0 && A[j] > v)
      {
        A[j + g] = A[j];
        j = j - g;
        cnt++;
      }
      A[j + g] = v;
    }
  }
  public void shell(ref int[] A, int N, int m, int[] G)
  {
    cnt = 0;
    for (int i = 0; i < m; ++i)
    {
      insert(ref A, N, G[i]);
    }
  }
}



class Program
{
  static void Main(string[] args)
  {
    var CompetitiveProgramming = new CompetitiveProgramming();
    CompetitiveProgramming.Solve();
  }
}
public static class io
{
  public static string Str => Console.ReadLine();
  public static string[] Strs => Str.Split(' ');
  public static long[] Longs => Strs.Select(long.Parse).ToArray();
  public static int[] Ints => Strs.Select(int.Parse).ToArray();
  public static char[] Chars => Str.ToArray();
  public static double[] Doubles => Strs.Select(double.Parse).ToArray();
  public static long Long1 => Longs[0];
  public static int Int1 => Ints[0];
  public static char Char1 => Chars[0];
  public static double Double1 => Doubles[0];
  public static long[] VerticalRead(int N) { long[] A = new long[N]; for (int i = 0; i < N; ++i) A[i] = Long1; return A; }
  public static void Write(string a) => Console.WriteLine(a);
  public static void Write(params object[] i) => Write(string.Join(" ", i));
  public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a));
  public static void Verticalwrite<T>(IEnumerable<T> a) { foreach (var z in a) Write(z); }
  public static void YN(bool i) { if (i) Write("Yes"); else Write("No"); }
}



Measured memory_bytes: 37856
#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<int,int>;

const int N = 50;

int n, k, v[N];

int main() {
  cin >> n >> k;
  rep(i, n) cin >> v[i];
  int ans = 0;
  for (int l = 0; l <= n; l++) {
    for (int r = 0; l + r <= min(n, k); r++) {
      vector<int> taken;
      rep(i, l) taken.push_back(v[i]);
      rep(i, r) taken.push_back(v[n - i - 1]);
      sort(taken.begin(), taken.end());
      int now = 0;
      rep(i, taken.size()) now += taken[i];
      rep(i, k - l - r) {
        if (i >= taken.size()) break;
        if (taken[i] >= 0) break;
        now -= taken[i];
      }
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
import math

D,G = map(int, input().split())
l=[list(map(int,input().split())) for i in range(D)]
lst=[[(i+1)*100]*(l[i][0]-1) + [(i+1)*100 + l[i][1]] for i in range(len(l))]
ans = 100*D
dis = 100000*D
for i in range(1<<D):
    point,num,maxp=0,0,0
    for j in range(D):
        if (i>>j)&1:
            num+=len(lst[j])
            point+=sum(lst[j])
        else:
            maxp=j
    if point + (maxp+1)*100*(len(lst[maxp])-1) >= G:
        mq = max(0,math.ceil((G-point)/((maxp+1)*100)))
        ans = min(ans, num+mq)
print(int(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N;
    cin >> N;
    cout << N * (N-1) / 2 << endl;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigInteger sum = new BigInteger("0");
		while(sc.hasNext()) {
			String str = sc.next();
			String [] a = str.split("[^0-9]");
			for(int i=0;i<a.length;i++) {
				if(a[i].length()>0) {
					sum = sum.add(new BigInteger(a[i]));
				}
			}
		}
		System.out.println(sum.toString());
	}
}


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

int main() {
int n,k;
cin >> n >> k;
long double ans=0;
for(int i=1;i<=n;i++){
  double pw=1;
    for(int j=0;;j++){
        if(i*pw<k) pw*=2;
        else {
        ans+=1/(pw*n);
        break;}
    }
 
}
cout <<fixed << setprecision(15) << ans << endl;
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	int d[21];
	int DP[50001];
	for (int i = 0;i < m;i++) {
		cin >> d[i];
	}
	for (int i = 0;i < n+1;i++) {
		DP[i] = 100000;
	}
	DP[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0; j < n-d[i]+1; j++) {
			if (DP[j + d[i]] > DP[j] + 1)
				DP[j + d[i]] = DP[j] + 1;
		}
	}

	cout << DP[n] << endl;

	return 0;
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    rep(i,n){
        ll l=-d*i+(n-i-1)*c;
        ll r=-c*i+(n-i-1)*d;
        if(b-a>=l&&r>=b-a){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long f[10000000][5],n,k,a[100000000],b[10000000],c[10000000],kq=-5,x[100];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;
    for (long i=1;i<=n;i++){
        cin>>a[1]>>a[2]>>a[3];
        for (long j=1;j<=3;j++)
        {
            for (long k=1;k<=3;k++)
            {
                if (j==k) continue;
                f[i][j]=max(f[i][j],f[i-1][k]+a[j]);
            }
        }
    }
    kq=max(f[n][1],f[n][2]);
    kq=max(kq,f[n][3]);
    cout<<kq;
}


Measured memory_bytes: 8448
N = gets.to_i
P = gets.split.map &:to_i
Q = gets.split.map &:to_i
a = 0
b = 0
n = N - 1
alist = Array.new()
blist = Array.new()
for i in 1..N
  alist.push(i)
  blist.push(i)
end
for p in P
  x = alist.index(p)
  a += x * (1..n).inject(1,:*)
  n -= 1
  alist.delete_at(x)
end
a = a - 1

n = N - 1
for q in Q
  x = blist.index(q)
  b += x * (1..n).inject(1,:*)
  n -= 1
  blist.delete_at(x)
end
b = b - 1
if a > b
  p a-b
else
  p b-a
end

Measured memory_bytes: 1788
"""
Union Find 木クラス
参考URL：https://note.nkmk.me/python-union-find/

parents
各要素の親要素の番号を格納するリスト
要素が根（ルート）の場合は-(そのグループの要素数)を格納する
例：
    parents[2] = 0 → 要素2の親は0
    parents[0] = -3 → 要素0は根であり、そのグループの要素数は3個
"""
class UnionFind():
    # 初期化（初期状態は全要素が根）
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # xの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            # 経路圧縮も同時に行う
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # 要素xが属するグループと要素yが属するグループとを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        # 根が同じならx,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

    # 要素xが属するグループのサイズ（要素数）を返す
    def size(self, x):
        return -self.parents[self.find(x)]

    # 要素x, yが同じグループに属するかどうかを返す
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        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()}

    # print()での表示用
    # ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
u = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    u.union(a-1, b-1)
ans = 0
for i in range(n):
    ans = max(ans, u.size(i))
print(ans)

Measured memory_bytes: 14648
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  int n;cin>>n;
  string ans="APPROVED";
  vector<int>p(n);
  rep(i,n)
    cin>>p.at(i);
  for(int i=0;i<n;i++)
  {
    if(p.at(i)%2==0)
    {
      if(p.at(i)%3!=0 && p.at(i)%5!=0)
        ans="DENIED";
    }
  }
  cout<<ans;
}

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



int main(){
    int N;
    cin >> N;
    std::vector<int> seq(N);

    for(int i=0; i < N; i++){
        cin >> seq.at(i);
    }
    double bumbo = 0.0;
    for(int i=0; i < N; i++){
        bumbo += 1.0 / seq.at(i);
    }
    std::cout << std::fixed;
    cout <<  std::setprecision(6) << 1.0 / bumbo << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    vector<int> A(N + 1);
    for (int i = 0; i < N + 1; i++)
    {
        cin >> A[i];
    }
    vector<int> B(N);
    for (int i = 0; i < N; i++)
    {
        cin >> B[i];
    }

    ll sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += min(A[i], B[i]);
        B[i] -= min(A[i], B[i]);
        A[i] -= min(A[i], B[i]);
        sum += min(A[i + 1], B[i]);
        A[i + 1] -= min(A[i + 1], B[i]);
        // if (A[i] <= B[i])
        // {
        //     sum += A[i];
        //     B[i] -= A[i];

        //     if (A[i + 1] <= B[i] && B[i] > 0)
        //     {
        //         sum += A[i + 1];
        //         B[i] -= A[i + 1];
        //     }
        //     else if (A[i + 1] >= B[i] && B[i] > 0)
        //     {
        //         sum += B[i];
        //         A[i + 1] -= B[i];
        //     }
        // }
        // else
        // {
        //     sum += B[i];
        //     A[i] -= B[i];
        // }
    }
    cout << sum << endl;
    return (0);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,n) for(int i=a;i<n;i++)
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min((dp[i-1]+abs(a[i]-a[i-1])),(dp[i-2]+abs(a[i]-a[i-2])));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 4372
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define MAXN 50000

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

	int a;
	string s;

	cin >> a >> s;
	if (a < 3200) cout << "red\n";
	else cout << s << "\n";

	return 0;
}


Measured memory_bytes: 764
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int H = in.nextInt();
        int W = in.nextInt();
        int M = in.nextInt();
        int[] Bh = new int[H];
        int[] Bw = new int[W];
        Set<Long> set = new HashSet<>();
        for (int m = 0; m < M; m++) {
            int h = in.nextInt() - 1;
            int w = in.nextInt() - 1;
            Bh[h]++;
            Bw[w]++;
            set.add((long) h * 1000000 + w);
        }
        int Mh = 0;
        for (int h = 0; h < H; h++)
            Mh = Math.max(Mh, Bh[h]);
        List<Integer> Mhh = new ArrayList<>();
        for (int h = 0; h < H; h++) if (Mh == Bh[h])
            Mhh.add(h);
        int Mw = 0;
        for (int w = 0; w < W; w++)
            Mw = Math.max(Mw, Bw[w]);
        List<Integer> Mww = new ArrayList<>();
        for (int w = 0; w < W; w++) if (Mw == Bw[w])
            Mww.add(w);

        boolean b = false;
        for (int h : Mhh) {
            for (int w : Mww) {
                b = !set.contains((long) h * 1000000 + w);
                if (b) break;
            }
            if (b) break;
        }
        if (b)
            out.println(Mh + Mw);
        else
            out.println(Mh + Mw - 1);

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}


Measured memory_bytes: 87028
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int a; cin >> a;
  int ans = a + a*a + a*a*a;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n,q = map(int, input().split())
    l = []
    for _ in range(n):
        s,t,x = map(int, input().split())
        l.append((s,t,x))
    l.sort(key=lambda a: a[2])
    start = [int(input()) for _ in range(q)]

    skip = [-1]*q
    res = [-1]*q

    for s,t,x in l:
        left = bisect_left(start, s-x)
        right = bisect_left(start, t-x)
        while left < right:
            if skip[left] == -1:
                res[left] = x
                skip[left] = right
                left += 1
            else:
                left = skip[left]
    
    for i in res:
        print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 106460
A, B = map( int, input().split() )

def countPalindromicNum( A, B ):
    ans = 0
    for i in range( A, B+1 ):
        c = str( i )
        if c[0] == c[4] and c[1] == c[3]:
            ans += 1
    return ans

print( countPalindromicNum( A, B ) )

Measured memory_bytes: 3060
import sys
input = sys.stdin.buffer.readline

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict
from itertools import combinations, permutations
from itertools import accumulate
from math import ceil, sqrt, pi

MOD = 10 ** 9 + 7
INF = 10 ** 18

X = int(input())

ans = 0
x = 100
while 1:
    if x >= X:
        print(ans)
        exit()
    x = int(x * 1.01)
    ans += 1


Measured memory_bytes: 68256
#include <string>
#include<iostream>
#include<queue>
#include<vector>
#include<utility>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
struct edge
{
  int  from,to,cost;
};

int main()
{
  string  N;
  cin >> N;
  if(N=="ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;

}



Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  char buf[9];
  char *str;
  int length = 8;

  fgets(buf, 9, stdin);
  str = (char *)malloc(sizeof(char) * length);
  memcpy(str, buf, 8);
  int cpypos = 0;
  //printf("0x%02x\n", buf[7] & 0x000000FF);
  while(strlen(buf) >= 8 && (buf[7] != 0x0d && buf[7] != 0x0a)) {
    fgets(buf, 9, stdin);
    cpypos += 8;
    if(cpypos + 8 > length) {
      length *= 2;
      str = (char *)realloc(str, sizeof(char) * length);
    }
    memcpy((str + cpypos), buf, 8);
  }

  int flag;
  char test = 'a';
  int i;
  for(i=0;i<26;i++) {
    flag = 0;
    int j;
    for(j=0;j<length;j++) {
      char chr = str[j];
      if(chr == 0x0d || chr == 0x0a || chr == 0x1a || chr == 0xff || chr == 0x00) break;
      //printf("0x%02X ", str[j] & 0x000000ff);
      if(chr == test) {
	flag = 1;
      }
    }
    if(flag == 0) {
      putchar(test);
      break;
    }
    test++;
  }
  if(flag != 0) printf("None");
  /*
  for(i=0;i<length;i++) {
    putchar(str[i]);
  }
  printf("\nlength=%d\n", length);
  */
  free(str);
  return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    n, c, k = map(int, input().split())
    t = [int(input()) for _ in range(n)]

    t.sort()

    waitP = 1
    l = t[0]
    ans = 0

    for i in range(1, n):
        if waitP == c:
            ans += 1
            l = t[i]
            waitP = 1
            if i == n - 1:
                ans += 1
        elif waitP != c:
            if t[i] - l <= k:
                waitP += 1
                if i == n - 1:
                    ans += 1
            elif t[i] - l > k:
                ans += 1
                l = t[i]
                waitP = 1
                if i == n - 1:
                    ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 7384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

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

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

void solve() {
  ll n; cin >> n;
  ll ans = 1;
  rep(i, n) {
    ll t; cin >> t;
    ans = lcm(ans, t);
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888