akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

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

/* -- template -- */
ll cnt[200000 + 1];

int main() {
    ll N; cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];
    ll ans = 0;
    rep(i, N) {
        if(1 + i - A[i] < 0)continue;
        cnt[1 + i - A[i]]++;
    }
    for(int i = 0; i < N; ++i) {
        if(i + A[i] + 1 > N)continue;
        ans += cnt[i + A[i] + 1];
    }
    cout << ans << endl;
}


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

int main() {
	int N, K, x, sum = 0;
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		cin >> x;
		if(x <= (K - x)){
			sum += x * 2;
		} else {
			sum += (K - x) * 2;
		}
	}
	
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
using namespace std;

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

int a[N][3];
int dp[N][3];



int main()
{
	IOS;
	int n;
	cin>>n;

	for (int i = 1; i <= n; ++i)
	{
		for (int j = 0; j<3; j++)
		{
			cin >> a[i][j];
		}
	}

	for (int i = 1; i <= n; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			for (int k = 0; k < 3; ++k)
			{
				if(j == k)
					continue;
				dp[i][j] = max(dp[i-1][k] + a[i][j] , dp[i][j]);
			}
		}
	}
	cout << max({ dp[n][0] , dp[n][1] , dp[n][2] });

	return 0;
}


Measured memory_bytes: 2560
X, Y = map(int, input().split())
if X * Y > 0:
    if X <= Y: print(Y-X)
    else: print(X-Y+2)
elif X == 0:
    print(Y if Y >= 0 else -Y+1)
elif Y == 0:
    print(-X if X <= 0 else X+1)
else:
    mi = abs(abs(Y)-abs(X))+1
    if X <= Y:
        mi = min(mi, Y-X)
    print(mi)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int k;
  int sum = 0;
  
  cin >> n >> k;
  int x[n];
  for(int i=0;i<n;i++){
    cin >> x[i];
	if( abs(k-x[i]) < x[i] ){
      sum += abs(k-x[i])*2;
    }else{
      sum += x[i]*2;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle{
	int f[N2];
	int space;
	string path;

	bool operator < (const Puzzle &p) const{
		for(int i=0;i<N2;i++){
			if(f[i] == p.f[i]) continue;
			return f[i] > p.f[i];
		}
		return false;
	}
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};

bool isTarget(Puzzle p){
	for(int i=0;i<N2;i++)
		if(p.f[i] != (i+1)) return false;
	return  true;
}

string bfs(Puzzle s){
	queue<Puzzle> Q;
	map<Puzzle, bool> V;
	Puzzle u, v;
	s.path = "";
	Q.push(s);
	V[s] = true;

	while(!Q.empty()){
		u = Q.front(); Q.pop();
		if(isTarget(u)) return u.path;
		int sx = u.space / N;
		int sy = u.space % N;
		for(int r=0;r<4;r++){
			int tx = sx + dx[r];
			int ty = sy + dy[r];
			if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
			v = u;
			swap(v.f[u.space], v.f[tx * N + ty]);
			v.space = tx * N + ty;
			if(!V[v]){
				V[v] = true;
				v.path += dir[r];
				Q.push(v);
			}
		}
	}

	return "unsolvable";
}

int main(){
	Puzzle in;

	for(int i=0;i<N2;i++){
		cin >> in.f[i];
		if(in.f[i] == 0){
			in.f[i] = N2;
			in.space = i;
		}
	}
	string ans = bfs(in);
	cout << ans.size() << endl;

	return 0;
}

Measured memory_bytes: 30476
use std::io::{self, Read};
use std::str::FromStr;
use std::i64;
use std::cmp;

pub struct Scanner<R: Read> {
    reader: R,
}
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let s = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        s.parse::<T>().ok().expect("failed to parse token")
    }
}

/// ワーシャルフロイド法を用いた重み付き有向グラフの全対最短経路問題の解決
/// 実行時間は頂点数Vを用いてO(V^3)となる
struct WarshallFloyd {
    n: usize,
    dist: Vec<Vec<i64>>,
}

impl WarshallFloyd {
    /// 与えられた隣接行列を委譲し、構造体を構築
    /// 隣接行列はd[i,i]=0、非接続点はi64::MAXとしている
    fn new(dist: Vec<Vec<i64>>) -> WarshallFloyd {
        WarshallFloyd {
            n: dist.len(),
            dist: dist,
        }
    }

    /// 最短コストの計算を行う
    fn solve(&mut self) {
        for k in 0..self.n {
            for i in 0..self.n {
                for j in 0..self.n {
                    // MAXを含む加算はエラーになるため除外しておく
                    if self.dist[i][k] != i64::MAX && self.dist[k][j] != i64::MAX {
                        self.dist[i][j] = cmp::min(self.dist[i][j], self.dist[i][k] + self.dist[k][j]);
                    }
                }
            }
        }
    }

    fn print(&self) {
        if self.has_negative_close() {
            println!("NEGATIVE CYCLE");
        } else {
            for i in 0..self.n {
                let str = self.dist[i].iter()
                    .map(|v| { match v {
                        &i64::MAX => "INF".to_string(),
                        x => x.to_string(),
                    }})
                    .collect::<Vec<String>>()
                    .join(" ");
                println!("{}", str);
            }
        }
    }

    /// 負の閉路を持っているか判定する
    fn has_negative_close(&self) -> bool {
        for i in 0..self.n {
            if self.dist[i][i] < 0 {
                return true;
            }
        }
        return false;
    }
}

fn main() {
    let sin = io::stdin();
    let sin = sin.lock();
    let mut sc = Scanner::new(sin);

    let v: usize = sc.read();   // 頂点数 < 100
    let e: usize = sc.read();   // 辺数 < 9900

    // 重みは2次元行列でよさげ

    let mut dist: Vec<Vec<i64>> = (0..v)
        .map(|_| vec![i64::MAX; v]).collect();
    for i in 0..v {
        dist[i][i] = 0;
    }

    for _ in 0..e {
        let s: usize = sc.read();
        let t: usize = sc.read();
        let d: i64 = sc.read();
        dist[s][t] = d;
    }

    let mut wf = WarshallFloyd::new(dist);
    wf.solve();
    wf.print();
}



Measured memory_bytes: 5056
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>
#include <bitset>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
}

Measured memory_bytes: 3032
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!.toMutableList()
    when(s[y - 1]){
        'A' -> s[y - 1] = 'a'
        'B' -> s[y - 1] = 'b'
        'C' -> s[y - 1] = 'c'
    }
    for(i in 0 until x){
        print(s[i])
    }
}

Measured memory_bytes: 36144
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    A, B = map(int, readline().split())

    cur = 1
    ans = 0
    while cur < B:
        cur += A - 1
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61624
/* 
	Author: ankrypt
*/

#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;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 10005
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V, V1;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;
ll cache[105][MAX_INT];

ll rec(ll ind, ll val) {
	if(ind >= V.size()) {
		if(val % 10 == 0) {
			return -val;
		}
		else {
			return 0;
		}
	}
	ll &ans = cache[ind][val];
	if(ans != -1) {
		return ans;
	}
	ans = -1e15;
	ans = max({ans, V[ind] + rec(ind + 1, (val + V[ind])), rec(ind + 1, val)});
	return ans;
}

int main() {
	go;
    cin >> N;
    ll maxVal = -1e15;
    ll sum = 0;
    fi(i, 0, N, 1) {
    	cin >> arr[i];
    	if(arr[i] % 10) {
    		V.push_back(arr[i]);
    	}
    	else {
    		V1.push_back(arr[i]);
    		sum += arr[i];
    	}
    }

    if(!V.size()) {
    	cout << 0 << "\n";
    }
    else {
    	mem(cache, -1);
    	sort(all(V1));
    	reverse(all(V1));
    	sum += rec(0, 0);
    	cout << sum << "\n";
    }

	return 0;
}
/*
	Powered by Buggy Plugin
*/




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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 2000000000;
constexpr auto MOD = 1000000007;


int main() {

	int k;
	cin >> k;
	k--;

	vector<ll> lun = { 1,2,3,4,5,6,7,8,9 };

	int i = 0;

	while (k >= lun.size()) {
		int l;
		l = lun[i] % 10;
		if (l > 0)
			lun.push_back(lun[i] * 10 + l - 1);
		lun.push_back(lun[i] * 10 + l);
		if (l < 9)
			lun.push_back(lun[i] * 10 + l + 1);
		i++;
	}

	cout<<lun[k]<<endl;

}

Measured memory_bytes: 1464
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<lli,lli> lmp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


lmp ds[100005];
int main(void){
	int n;
	scanf("%d",&n);
	rep(i,n){
		lli a;
		scanf("%lld",&a);
		ds[i]=lmp(abs(a),a);
	}
	sort(ds,ds+n,greater<lmp>());
	
	
	vector<lli> qs[2];
	rep(i,n){
		if(i+1==n){
			//printf("%d %d %d %d\n",i,n,qs[0].size(),qs[1].size());
			if(qs[0].size()==0){
				qs[0].push_back(ds[i].sec); continue;
			}
			else if(qs[1].size()==0){
				qs[1].push_back(ds[i].sec); continue;
			}
		}
		if(ds[i].sec >= 0)qs[0].push_back(ds[i].sec);
		else qs[1].push_back(ds[i].sec);
	}
	
	lli ans=0;
	rep(i,qs[0].size())ans += qs[0][i];
	rep(i,qs[1].size())ans -= qs[1][i];
	printf("%lld\n",ans);
	
	int ls=qs[0].size();
	lli t=qs[1][0];
	irep(i,ls){
		if(i>0){
			printf("%lld %lld\n",t,qs[0][i]);
			t = t - qs[0][i];
		}
		else{
			printf("%lld %lld\n",qs[0][i],t);
			t = qs[0][i] - t;
		}
	}
	
	ls = qs[1].size();
	reg(i,1,ls-1){
		printf("%lld %lld\n",t,qs[1][i]);
		t = t - qs[1][i];
	}

		
	return 0;
}






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


    long long int  getsum(long long int  n[],long long int  t)
    {
    long long int tool = 0;
    for (long long int  i=0;i<t-1;i++)
    {
     long long int  a=n[i+1]-n[i];
     if(a<0)
     {
         tool+=-a;
         n[i+1]+=-a;
     }
    }
    return tool;
    }


int main()

{
    long long int  n;
    cin>>n;
    long long int  line[n];
    for(long long int i=0;i<n;i++)
    {
        cin>>line[i];
    }
    long long int p=getsum(line,n);
    cout<<p;


    }


Measured memory_bytes: 5180
#include <stdio.h>
#include <string.h>

long long dp[105][30] = { 0 };
int N, a[105], i, j;

int main()
{
	scanf("%d", &N);
	for (i = 0;i < N;i++) 
		scanf("%d", &a[i]);
		dp[0][a[0]] = 1;
		for(i=1;i<N-1;i++)
			for (j = 0;j < 21;j++) {
				if (j - a[i] >= 0)
					dp[i][j - a[i]] += dp[i - 1][j];
				if (j + a[i] <= 20)
					dp[i][j + a[i]] += dp[i - 1][j];
			}
		printf("%lld\n", dp[N - 2][a[N - 1]]);
		return 0;

   
		
}

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

namespace code_festival_2017_quala_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            bool ret = false;
            for (int i = 0; i <= x[0]; i++)
            {
                for (int j = 0; j <= x[1]; j++)
                {
                    if ((x[0] - i) * j + (x[1] - j) * i == x[2]) ret = true;
                }
            }
            Console.WriteLine(ret ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13396
import collections
n = int(input())
a = [int(i) for i in input().split()]
pl = []
dic_mn = collections.defaultdict(int)

for i in range(n):
    pl.append(a[i] + i)
    dic_mn[i - a[i]] += 1
ans = 0
for i in range(n):
    ans += dic_mn[pl[i]]

print(ans)
#print(pl)
#print(dic_mn)


Measured memory_bytes: 164040
import java.util.*;

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

    Scanner sc=new Scanner(System.in);
    
    String s=sc.next();
    
    char[]sArray=s.toCharArray();
    
    String result = "No";
		if ((sArray[0] == sArray[1] && sArray[2] == sArray[3] && sArray[0] != sArray[2])
				|| (sArray[0] == sArray[2] && sArray[1] == sArray[3] && sArray[0] != sArray[1])
				|| (sArray[0] == sArray[3] && sArray[1] == sArray[2] && sArray[0] != sArray[1])) {
			result = "Yes";
		}
 
		System.out.println(result);
		sc.close();
	}
}
    


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
int  main()
{
	string s; cin >> s;
	rep(i, 3)
	{
		if (s[i] == s[i+1])
		{
			cout << "Bad\n"; return 0;
		}
	}
	cout << "Good\n";
	return (0);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define Pi 3.1415
 
int main(){

    double rad,x,y,step,deg;
 
    x=0;
    y=0;
    rad=0;
    step=0;
    deg=0;

    while(1){
        scanf("%lf,%lf",&step,&deg);

        if(step==0 && deg==0) break;
         
        x+=sin(rad*Pi/180.0)*step;
        y+=cos(rad*Pi/180.0)*step;

        rad+=deg;
    }

    printf("%d\n%d\n",(int)x,(int)y);
 
    return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    vector<ll> X(N),t;
    rep(i,N) cin >> X[i];
    t = X;
    sort(ALL(t));
    ll ans = t[(N/2) - 1];
    rep(i,N){
        if(X[i]>ans)cout << ans << endl;
        else cout << t[(N/2)] << endl;
    }
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int modpow(int a, int p, int m){
	int res = 1;
	for(int i=0; (p>>i)>0; ++i){
		if((p >> i) & 1) res = res * a % m;
		a = a * a % m;
	}
	return res;
}
int modinv(int a, int m){
	return modpow(a, m-2, m);
}
int fact[2999];
int invfact[2999];
int comb(int n, int r, int m){
	return fact[n] * invfact[r] % m * invfact[n-r] % m;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int p; cin >> p;
	vector<int> a(p);
	for(auto &i:a) cin >> i;
	fact[0] = 1;
	for(int i=1; i<p; ++i)
		fact[i] = fact[i-1] * i % p;
	for(int i=0; i<p; ++i)
		invfact[i] = modinv(fact[i], p);
	vector<int> ans(p);
	for(int i=0; i<p; ++i){
		if(a[i] == 0) continue;
		++ans[0];
		ans[0] %= p;
		for(int j=0; j<=p-1; ++j){
			int t = modpow(i, p-1-j, p) * comb(p-1, j, p) % p;
			if((p-1-j) % 2 == 0) ans[j] += p - t;
			else ans[j] += t;
			ans[j] %= p;
		}
	}
	for(int i=0; i<p; ++i)
		cout << ans[i] << " \n"[i==p-1];
/*	for(int i=0; i<p; ++i){
		int t = 0;
		for(int j=0; j<p; ++j)
			t = (t + ans[j] * modpow(i, j, p)) % p;
		if(t != a[i])
			cout << i << "\n";
	}
*/
}

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

int main()
{
  int n, ans = 0;
  string s;

  cin >> n >> s;
  for (int i = 1; i < n; i++)
  {
    vector<bool> sp(26, false);
    int tmp = 0;
    for (int j = 0; j < i; j++)
      sp[s[j] - 'a'] = true;
    for (int j = 0; j < n - i; j++)
    {
      if (sp[s[n - j - 1] - 'a'])
      {
        sp[s[n - j - 1] - 'a'] = false;
        tmp++;
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll a, b;
    while(cin >> a >> b)
    {
        if(a < b) swap(a, b);
        ll g, l;
        g = gcd(a, b);
        l = (a*b)/gcd(a, b);
        cout << g << " " <<  l << "\n";
    }
    return 0 ;
}



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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string foo; cin >> foo;
    if (foo == "ABC") cout << "ARC\n";
    else cout << "ABC\n";
    
    return 0;
}



Measured memory_bytes: 3608
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
l,m,h = 0,0,0
for i in p:
  if i <= a:
    l += 1
  elif i > b:
    h += 1
  else:
    m += 1
print(min(l, m, h))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	map<int, int> mp;
	for(int i = 0; i < n; ++i) {
		int d;
		cin >> d;
		mp[d]++;
	}
	
	int m;
	cin >> m;
	
	vector<int> t(m);
	for(int i = 0; i < m; ++i) {
		cin >> t[i];
	}
	
	bool yes = true;
	for(int i = 0; i < m; ++i) {
		if( mp[t[i]] == 0 ) {
			yes = false;
			break;
		}
		
		mp[t[i]]--;
	}
	
	if( yes ) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}


Measured memory_bytes: 13032
def gcd(a,b):
    a,b = max(a,b),min(a,b)
    while a%b!=0:
        a,b = b,a%b
    return b

A,B,C,D = list(map(int,input().split()))

cs = B//C-(A-1)//C
ds = B//D-(A-1)//D

E = C*D//gcd(C,D)

es = B//E-(A-1)//E

print(B-A+1-cs-ds+es)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int a, b;
  cin >> a >> b;
  if(a == 1) a = 14;
  if(b == 1) b = 14;
  if(a == b){
    cout << "Draw" << endl;
  }
  else if(a > b){
    cout << "Alice" << endl;
  }
  else{
    cout << "Bob" << endl;
  }
} 






Measured memory_bytes: 256
#include<stdio.h>
#define MAX 1000000

int parent(int i){ return i/2; }
int left(int i){ return i*2; }
int right(int i){ return i*2+1; }

int main(){
  int n,i,A[MAX+1];

  scanf("%d",&n);
  for(i=1;i<=n;i++) {
    scanf("%d",&A[i]);
  }

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ", i, A[i]);
    
    if(parent(i)>=1) printf("parent key = %d, ", A[parent(i)]);
    if(left(i)<=n) printf("left key = %d, ", A[left(i)]);
    if(right(i)<=n) printf("right key = %d, ", A[right(i)]);

    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main(){
	int N;
	cin >> N;
	int *d;
	d = new int[N];
	rep(i,N) cin >> d[i];
	sort(d,d+N);
	int cnt=0;
	int cur=d[0];
	rep(i,N-1){
		if(cur<d[i+1]) {
			cnt++;
			cur=d[i+1];
		}
	}
	cout << cnt+1 << endl;
	return 0;
}

Measured memory_bytes: 256
f=lambda:map(int,input().split())
R,C,K=f()
g=[[0]*(R+1) for _ in range(C+1)]
for _ in range(K):
  r,c,v=f()
  g[c][r]=v
dp=[[0]*4 for _ in range(R+1)]
for i in range(1,C+1):
  for j in range(1,R+1):
    t=g[i][j]
    if t:
      for k in range(3,0,-1):
        dp[j][k]=max(dp[j][k],dp[j][k-1]+t)
      dp[j][1]=max(dp[j][k],max(dp[j-1])+t)
    dp[j][0]=max(dp[j][0],max(dp[j-1]))
print(max(dp[R]))

Measured memory_bytes: 145836
using System;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine();

			string sCurrent = string.Empty;
			string sNext = string.Empty;
			int count = 0;

			for (int index = 0; index < input.Length ; )
			{
				sNext = input.Substring(index, 1);
				if (sCurrent.Equals(sNext))
				{
					if (index + 1 < input.Length)
					{
						sCurrent = input.Substring(index, 2);
						index += 2;
						count++;
					}
					else
					{
						break;
					}
				}
				else
				{
					sCurrent = sNext;
					index++;
					count++;
				}
			}
			Console.WriteLine(count);
		}
	}
}


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

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

using namespace std;

int main(){
  int N;
  cin >> N;
  rep(_,N){
    int x,y,b,p;
    cin >> x >> y >> b >> p;
    double mincost = x * b + y * p;
    REP(i,b,20){
      REP(j,p,20){
	if( i >= 5 && j >= 2 ) {
	  mincost = min(mincost, ( x * i + y * j ) * 0.8 );
	}
      }
    }
    printf("%.0f\n",mincost);
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <memory.h>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <set> 
typedef long long ll;
using namespace std;
int mod=998244353;
#define maxn 100005
struct pir
{
	int a,b;
	bool operator <(const pir&x)const
	{
		return b>x.b;
	}
}arr[maxn];
int main()
{
	set<int>s;
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&arr[i].a,&arr[i].b);
	sort(arr+1,arr+1+n);
	for(int i=1;i<=m;i++)
		s.insert(i);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		set<int>::iterator it=s.lower_bound(arr[i].a);
		if(it!=s.end())
		{
			ans+=arr[i].b;
			s.erase(it);
		}
	} 
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String x = sc.next();
        String y = sc.next();
        if (x.compareTo(y) > 0) {
            System.out.println(">");
        } else if (x.compareTo(y) == 0) {
            System.out.println("=");
        } else {
            System.out.println("<");
        }

    }
}


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

int dp1[3001][3001], dp2[3001][3001];

template<typename T>
bool chmax(T &_a, T _b){
    if(_a < _b){
        _a = _b;
        return true;
    }else{
        return false;
    }
}

int main(){
    int n, t, s;
    cin >> n >> t >> s;

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

    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j <= t ; ++j){
            chmax(dp1[i + 1][j], dp1[i][j]);
            if(j + b[i] <= t){
                chmax(dp1[i + 1][j + b[i]], dp1[i][j] + a[i]);
            }

            chmax(dp2[n - i - 1][j], dp2[n - i][j]);
            if(j + b[n - i - 1] <= t){
                chmax(dp2[n - i - 1][j + b[n - i - 1]], dp2[n - i][j] + a[n - i - 1]);
            }
        }
    }

    int ans = 0;
    for(int i = 0 ; i <= n ; ++i){
        chmax(ans, dp1[i][s] + dp2[i][t - s]);
    }

    cout << ans << endl;

    return 0;
}


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

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

      int a,b;
      cin>>a>>b;
      if(b%a==0) cout<<a+b;
      else cout<<b-a;
}
/* If today were the last day of my life,would I want to do what I'm about to do today? */

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<pair<double,double>>X(N);
  for(int i=0;i<N;i++){
    cin>>X.at(i).first>>X.at(i).second;
  }
  double sum=0;
  sort(X.begin(),X.end());
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      double x=X.at(i).first-X.at(j).first;
      double y=X.at(i).second-X.at(j).second;
      sum=sum+sqrt(x*x+y*y);
    }
  }
  int NN=N;
  for(int i=1;i<N;i++){
    NN=NN*i;
  }
  cout<<fixed<<setprecision(10)<<2*sum/N<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S;
    int N;
    cin >> N >> S;

    rep(i, S.size()) {
        int t;
        t = (int)(S[i] - 'A') + N;
        if (t >= 26) t %= 26;
        cout << (char)(t + 'A');
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// abc172_a
#include <iostream>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>

#define US unsigned short
#define UI unsigned int
#define UC unsigned char
#define UL unsigned long
#define ULL unsigned long long
using namespace std;

int main(int argc, char const *argv[])
{
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  string s, t;
  cin >> s >> t;
  vector<int> S(26,0), T(26,0);
  
  for(int i = 0; i < s.size(); i++){
    S[s[i] - 'a']++;
    T[t[i] - 'a']++;
  }
  
  sort(S.begin(), S.end());
  sort(T.begin(), T.end());
  
  for(int i = 0; i < 26; i++){
    //cout << S[i] << " " << T[i] << endl;
	if(S[i]!=T[i]){
		cout << "No" << endl;
        return 0;
    }
  }
  
  cout << "Yes" << endl;
}
  
  

Measured memory_bytes: 776
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define pb push_back
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
#define mx(a,b) (a>b?a:b)
#define mn(a,b) (a<b?a:b)
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
    const uint32 Buffsize=1<<15,Output=1<<23;
    static char Ch[Buffsize],*S=Ch,*T=Ch;
    inline char getc()
    {
        return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
    }
    static char Out[Output],*nowps=Out;
    
    inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

    template<typename T>inline void read(T&x)
    {
        x=0;static char ch;T f=1;
        for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
        for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
        x*=f;
    }

    template<typename T>inline void write(T x,char ch='\n')
    {
        if(!x)*nowps++='0';
        if(x<0)*nowps++='-',x=-x;
        static uint32 sta[111],tp;
        for(tp=0;x;x/=10)sta[++tp]=x%10;
        for(;tp;*nowps++=sta[tp--]^48);
        *nowps++=ch;
    }
}
using namespace IO;

void file(void){
#ifndef ONLINE_JUDGE
    FILE*Z=freopen("water.in","r",stdin);
    FILE*P=freopen("water.out","w",stdout);
#endif
}

const int MAXN=2e5+7;

static int n,a[MAXN];

inline void init()
{
	read(n);
	Rep(i,1,n)read(a[i]),a[i]-=i;
}

static ll ans;

inline void solve()
{
	sort(a+1,a+n+1);
	Rep(i,1,n)ans+=abs(a[i]-a[(n+1)/2]);
	printf("%lld\n",ans);
}
int main()
{
    init();
    solve();
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
char a[10],b[10];
int main()
{
    cin>>a>>b;
    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])
    {
        printf("YES");
        return 0;
    }
    printf("NO");
    return 0;
}

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

using namespace std;
vector<int>edge[100005];
int deg[100005],dp[100005];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		x--,y--;
		edge[x].push_back(y);
		deg[y]++;
	}
	stack<int>s;
	for(int i=0;i<n;i++){
		if(deg[i]==0){
			s.push(i);
//			cout<<i<<" ";
		}
	}
	/*for(int i=0;i<n;i++){
		cout<<i+1<<" "<<deg[i]<<endl;
	}*/
	memset(dp,-1,sizeof(dp));
	while(!s.empty()){
		int p=s.top();
		s.pop();
		for(int i=0;i<edge[p].size();i++){
			int k=edge[p][i];
			if(dp[k]<dp[p]+1){
				dp[k]=dp[p]+1;
			}
			deg[k]--;
			if(deg[k]==0)s.push(k);
		}
	}
	int ans=0;
	for(int i=0;i<n;i++)ans=max(ans,dp[i]);
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>
using namespace std;
bool flag;
int ball[15];
bool dfs(int x, int l, int r){
    if(ball[x] > l){
        if(x == 9) return true;
        if(dfs(x+1, ball[x], r)) return true;
    }
    if(ball[x] > r){
        if(x == 9) return true;
        if(dfs(x+1, l, ball[x])) return true;
    }
    return false;
}
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    while(n--){
        for(int i = 0; i < 10; ++i) cin >> ball[i];
        bool flag = dfs(0, 0, 0);
        cout << (flag ? "YES" : "NO") << endl;
    }
    return 0;
}

Measured memory_bytes: 1184
using System;
using System.Linq;
using System.Collections.Generic;

public class Hello
{
    public static void Main()
    {
        int kosu=int.Parse(Console.ReadLine());
        List<int>list=new List<int>();
        
        for(int q=0;q<kosu;q++)
        {
            list.Add(int.Parse(Console.ReadLine()));
        }
        int max=list[1]-list[0];
        int maxi=list[0];
        
        for(int i=0;i<kosu;i++)
        {
            if(maxi<list[i])continue;
            maxi=list[i];
            for(int j=i+1;j<kosu;j++)
            {
                if(list[j]-list[i]>max)max=list[j]-list[i];
            }
        }
        Console.WriteLine(max);
    }
}



Measured memory_bytes: 23460
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//constexpr ll MOD = 1e9 + 7;
constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  string S;
  cin >> S;

  cout << ((S.at(2) == S.at(3) && S.at(4) == S.at(5)) ? "Yes" : "No") << endl;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int k;
	cin >> k;
	vector<ll> a(k);
	for(int i = 0; i < k; i++) cin >> a[i];
	ll min_n = 2, max_n = 2;
	for(int i = k - 1; i >= 0; i--) {
		ll min_num = ((min_n + a[i] - 1) / a[i]) * a[i];
		ll max_num = (max_n / a[i]) * a[i] + a[i] - 1;
		if(min_num > max_n || max_num < min_n){
			cout << -1 << endl;
			return 0;
		}
		min_n = min_num;
		max_n = max_num;
	}
	cout << min_n << endl;
	cout << max_n << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[300000];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < 3*n; i++)
		cin >> a[i];
	int m = 3 * n;
	sort(a, a + 3 * n);
	reverse(a, a + 3 * n);
	ll sum = 0;
	for (int i = 1; i < m; i += 2) {
		sum += a[i];
		m--;
	}
	cout << sum << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n,possible=0;cin>>n;
	int a[n];
	
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	if(n<=2)
	cout<<0<<"\n";
	else{
	
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[k]+a[j]>a[i]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])
				{
				  possible++;
				}
			}
			
		}
		
	}
	cout<<possible<<"\n";
}
return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int>
#define rep(a,n) for(int i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int n,vin &a){
    rep(0,n){
        cin>>a.at(i);
    }
}

signed main(){
    typedef pair<int,int> P;
    int N;
    cin>>N;
    vin A(N);
    fin(N,A);
    sort(A.begin(),A.end());
    rep(0,N-1){
        if(A.at(i)==A.at(i+1)){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  int a = 0;
  int i;
  char moji[3];
  if(scanf("%s",moji)==1){
  	for(i=0;i< sizeof(moji);i++){
    	if(moji[i] == '1')a++;
    }
  }
  printf("%d",a);
  
  return 0;
}


Measured memory_bytes: 128
import sys

h,w = map(int,input().split())
s = [input() for i in range(h)]
do = []

mxm = 0
mmm = 0
mxcx = -1
mxcy = -1

for i in range(h):
    for j in range(w):
      #if(mxcx == i and mxcy == j):
        #print(mxm)
        #sys.exit()
        
      if(s[i][j] == '.'):
        do.append([i,j])
        ex = [[0]*w for i in range(h)]
        ex[i][j] = 1
      else:
        continue
        
      while(len(do)!=0):
        x,y = do.pop(0)
        
        for k,l in [[1,0],[-1,0],[0,1],[0,-1]]:
          a = x+k
          b = y+l
          
          if(-1 < a < h and -1 < b < w):
            if(s[a][b] == '.' and ex[a][b] == 0):
              hantei = ex[x][y] + 1
              ex[a][b] = hantei
              o = a
              p = b
              do.append([a,b])
              
      
      #for i in range(h):
      #  if(mmm < max(ex[i])):
      #    mmm = max(ex[i])
          
      #for i in range(h):
      #  print(ex[i])
      #print(hantei -1) 
      #print("")
                
        
      if(mxm < hantei - 1):
        #print(mxm ,hantei - 1)
        mxm = hantei - 1
        mxcx = o
        mxcy = p
print(mxm)  

Measured memory_bytes: 3188
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
MOD = 10**9+7

A = input().rstrip()
d = defaultdict(int)
for i in range(len(A)):
    d[A[i]] += 1
    
s = 0
for k in d.keys():
    s += d[k]

ans = 0
for k in d.keys():
    s -= d[k]
    ans += d[k]*s
print(ans+1)

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

int main() {
    long long a;
    long long b;
    long long c;
    cin >> a >> b >> c;
    long long sum = (b + c);
    if (sum > a) {
        cout << (sum - a) << endl;
    }
    else {
        cout << "0" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x,a[100005];
int solve(int a[]){
	int cnt=0;
	for (int i=1;i<=n;i++)
		if (a[i]%2==0)cnt++;
	if (cnt&1)return 1;
	if (n==1)return 0;
	if (cnt!=n-1)return 0;
	for (int i=1;i<=n;i++)
		if (a[i]&1){
			if (a[i]==1)return 0;
			a[i]--;
		}
	int k=0;
	for (int i=1;i<=n;i++)k=__gcd(k,a[i]);
	for (int i=1;i<=n;i++)a[i]/=k;
	return !solve(a);
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	if (solve(a))puts("First");
	else puts("Second");
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define abu ios_base::sync_with_stdio(0)
#define said cin.tie(0)
using namespace std;
ll const MOD = 998244353;

void yes(){
    cout<<"YES"<<'\n';
}

void no(){
    cout<<"NO"<<'\n';
}

ll fact(int n){
    ll ans = 1;
    for(int i=2;i<=n;i++){
        ans = (ans*i)%MOD;
    }

    return ans;
}

ll powM(int n, int x){
    if(x==0){
        return 1;
    }
    if(x==1){
        return n%MOD;
    }

    if(x%2==0){
        ll a = powM(n,x/2);
        return (a*a)%MOD;
    }else{
        return (n*powM(n,x-1))%MOD;
    }
}

ll C(int n, int k){
    return (fact(n) * powM((fact(k)*fact(n-k))%MOD,MOD-2))%MOD;
}

ll A(int n, int k){
    return (fact(n) * powM(fact(n-k)%MOD,MOD-2))%MOD;
}


int dp[20010][20010];

void solve(){
    string s,t;
    cin>>s;
    cin>>t;
    int n = s.length();
    int m = t.length();
    if(s[0]==t[0]) dp[0][0] = 1;
    else dp[0][0] = 0;
    for(int i=1;i<n;i++){
        if(t[0] == s[i]){
            dp[0][i] = 1;
        }else{
            dp[0][i] = dp[0][i-1];
        }
    }
    for(int i=1;i<m;i++){
        if(t[i] == s[0]){
            dp[i][0] = 1;
        }else{
            dp[i][0] = dp[i-1][0];
        }
    }

    for(int j=1;j<n;j++){
        for(int i=1;i<m;i++){
            if(s[j] == t[i]){
                dp[i][j] = dp[i-1][j-1]+1;
            }else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    

    int x = m-1;
    int y = n-1;
    string ans = "";
    while(x>=0 && y>=0){
        if(t[x] == s[y]){
            ans=s[y]+ans;
            x--;
            y--;
        }else{
            if(x>0 && y>0){
                if(dp[x-1][y]>dp[x][y-1]){
                    x--;
                }else{
                    y--;
                }
            }else{
                if(x>0){
                    x--;
                }else if(y>0){
                    y--;
                }else{
                    break;
                }
            }
        }
    }
    cout<<ans<<'\n';
}

int main(){
    abu;
    said;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 234240
//By Ralif Rakhmatullin
#include<iostream>
#include<fstream>
#include<string>
#include<cstring>
#include<math.h>
#include<cassert>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<ctime>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<bitset>
#include<valarray>
#include<iterator>
#include<list>
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define S second
#define ld long double
#define F first
#define y1 LOL
#define ld long double
#define pb push_back
#define len length
#define sz size
#define beg begin
const ll INF = (ll)1e18 + 123;
const int inf=(int)2e9 + 123; 
const int mod=1e9+7;
using namespace std;
int n;
int a[511 * 511];       
pair<int, int> x[511];
multiset<pair<int, int> > s;
multiset<pair<int, int> > :: iterator it;
queue<int> q;
void out(){
	cout << "No";
	exit(0);
}
int main(){
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  	srand(FOR);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin >> n;
	for(int i = 1; i <= n; i ++){
		cin >> x[i].F;
		x[i].S = i;
	}
	sort(x + 1, x + 1 + n);
	for(int i = 1; i <= n; i ++){
		a[x[i].F] = x[i].S;
		for(int j = 1; j < x[i].S; j ++){
			s.insert(mp(x[i].F, x[i].S));
		}
	}
	for(int i = 1; i <= n * n; i ++){
		if(a[i] > 0){
			for(int j = a[i] + 1; j <= n; j ++)
				q.push(a[i]);
			continue;
		}
		if((int)s.sz() == 0 && (int)q.sz() == 0){
			cout << "No";
			return 0;
		}
		if((int)s.sz() == 0){
			a[i] = q.front();
		//	cout << i << " " << q.front() << endl;
			q.pop();
			continue;
		}
		it = s.beg();
	//	cout << i << " "  << it -> F << " " << it -> S << endl;
		if(it -> F <= i){
			out();
		}
		a[i] = it -> S;
		s.erase(s.find(*it));
	}
	cout << "Yes\n";
	for(int i = 1; i <= n * n; i ++){
		cout << a[i] << " ";
	}	 
	return 0;
}

Measured memory_bytes: 7040