akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()

using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
ll L;
vi A(210000);
ll dp[210000][5];
ll cost(ll sta,ll i){
  if(sta==0||sta==4){
    return A[i];
  }else if(sta==1||sta==3){
    if(A[i]%2==0&&A[i]!=0)return 0;
    else if(A[i]==0)return 2;
    else return 1;
  }else if(sta==2){
    return (A[i]%2==0)?1:0;
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>L;
  for(int i=0;i<L;i++)cin>>A[i];
  for(int i=0;i<210000;i++)for(int j=0;j<5;j++)dp[i][j]=llINF;
  dp[0][0]=0;
  for(int i=0;i<L;i++){
    for(int j=0;j<5;j++){
      for(int k=j;k<5;k++)
      dp[i+1][k]=min(dp[i+1][k],dp[i][j]+cost(k,i));
    }
  }
  ll ans=llINF;
  for(int i=0;i<5;i++)ans=min(ans,dp[L][i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 10112
use std::error::Error;
use std::io;
use std::collections::{HashMap, HashSet};
use std::collections::hash_map::Entry;

fn main() {
    if let Err(e) = run() {
        println!("{}", e);
    }
}

fn run() -> Result<(), Box<Error>> {
    let mut n = String::new();
    io::stdin().read_line(&mut n)?;
    let n: usize = n.trim().parse()?;
    let mut adjs: HashMap<usize, Vec<(usize, usize)>> = HashMap::new();
    for _ in 0..n-1 {
        let mut abc = String::new();
        io::stdin().read_line(&mut abc)?;
        let abc: Vec<usize> = abc.trim().split(" ").map(|x| x.parse().expect("")).collect();
        match adjs.entry(abc[0]) {
            Entry::Occupied(o) => {o.into_mut().push((abc[1], abc[2]));},
            Entry::Vacant(v) => {v.insert(vec![(abc[1], abc[2])]);},
        };
        match adjs.entry(abc[1]) {
            Entry::Occupied(o) => {o.into_mut().push((abc[0], abc[2]));},
            Entry::Vacant(v) => {v.insert(vec![(abc[0], abc[2])]);},
        };
    }
    let mut qk = String::new();
    io::stdin().read_line(&mut qk)?;
    let qk: Vec<usize> = qk.trim().split(" ").map(|x| x.parse().expect("")).collect();
    let q = qk[0];
    let k = qk[1];
    let mut m: HashMap<usize, usize> = HashMap::new();
    let mut set: HashSet<usize> = HashSet::new();
    let mut v = Vec::new();
    for t in adjs.get(&k).unwrap() {
        v.push((t.0, t.1));
        set.insert(t.0);
    }
    while v.len() > 0 {
        let t = v.pop().unwrap();
        m.insert(t.0, t.1);
        for t2 in adjs.get(&t.0).unwrap() {
            if set.contains(&t2.0) {
                continue;
            }
            v.push((t2.0, t2.1 + t.1));
            set.insert(t2.0);
        }
    }
    for _ in 0..q {
        let mut xy = String::new();
        io::stdin().read_line(&mut xy)?;
        let xy: Vec<usize> = xy.trim().split(" ").map(|x| x.parse().expect(" ")).collect();
        let x = xy[0];
        let y = xy[1];
        println!("{}", m.get(&x).unwrap() + m.get(&y).unwrap());
    }
    Ok(())
}


Measured memory_bytes: 24068
#include <stdio.h>
#include <math.h>
int main(void){
int n,x,t;
scanf("%d %d %d",&n,&x,&t);
int cnt=0;
	for(;;){
		if(n>x){n=n-x;cnt++;}
		else{cnt++;break;}
	}
	printf("%d",cnt*t);
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
int main()
{
fast;
string s,t;cin>>s>>t;
ll ans=0;
  fr(i,0,s.size())
  {
	if(s[i]!=t[i]) ans++;
  }
  cout<<ans;
return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
	string s;
	cin >> s;
	string a, b, c;
	a = s.substr(0, 4);
	b = s.substr(5, 2);
	c = s.substr(8, 2);
	if (stoi(a) < 2019)
	{
		cout << "Heisei" << endl;
	}
	else if (stoi(a) == 2019 && stoi(b) <= 4)
	{
		cout << "Heisei" << endl;
	}
	else
	{
		cout << "TBD" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	int n, in, sum, ans = 0;
	cin >> n >> sum;
	vi v;
	rep(i, n) {
		cin >> in;
		v.push_back(in);
	}
	sort(all(v));
	rep(i, n) {
		if (sum - v[i] < 0)break;
		sum -= v[i];
		ans++;
	}
	if (sum!=0 && ans==n)ans--;
	cout << ans << endl;
}


Measured memory_bytes: 256
function Main(input) {
    a = []; itr = 0; i = 0;
    transpose = t => t[0].map((_, c) => t.map(r => r[c]));
    compress = t => t.every(e => e == '.');
    input = input.split("\n");
    for (i = 1; i <= input.length - 1; i++) {
        a[itr] = input[i].split("");
        if (compress(a[itr])) a.splice(itr, 1);
        else itr++;
    }
    a = transpose(a);
    for (i = 0; i < a.length;) {
        if (compress(a[i])) a.splice(i, 1);
        else i++;
    }
    a = transpose(a);
    for (i = 0; i < a.length; i++) console.log(a[i].join(''));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

long long res = 0;
vector < vector <int> > g;

bool visitados[8];

void dfs(int nodo, int may, int cont) {
	if (may == cont) {
		res++;
		return;
	}
	for (int i = 0; i < g[nodo].size(); i++) {
		if (!visitados[g[nodo][i]]) {
			visitados[g[nodo][i]] = true;
			dfs(g[nodo][i], may, cont + 1);
			visitados[g[nodo][i]] = false;
		}
	}
}



int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	vector < vector <int> > aux(n);
	g = aux;
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}
	visitados[0] = true;
	dfs(0, n, 1);
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
//const ll mod=1e9+7;
const ll mod=998244353;
const ll inf=5e15;

struct query{
  ll type;//0=empty, 1=add-sum ,2=set-max
  ll value;
  query(ll a=0,ll b=0):type(a),value(b) {}
};

ll INF=(1LL<<60);

struct segtree{
  ll SIZE;
  vector<query> s;
  vector<ll> t;// sum-add
  vector<ll> u;// max-set

  segtree(ll n=1){
    SIZE=1;
    while(SIZE<n)SIZE*=2;
    s.clear();
    t.clear();
    u.clear();
    s.resize(SIZE*2, query());
    t.resize(SIZE*2, 0);
    u.resize(SIZE*2, 0);
  }
  
  void func(ll k,ll l,ll r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
      t[k]+=q.value*(r-l);
      u[k]+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }

  void compute(ll k,ll l,ll r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    ll m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }

  void Update(ll a,ll b,query x,ll k,ll l,ll r){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      ll m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=max(u[k*2+1],u[k*2+2]);
    }
  }

  ll Dfs(ll type,ll a,ll b,ll k,ll l,ll r){
    if(b<=l || r<=a){
      if(type==1)return 0; //add
      if(type==2)return -inf; // max
    }
    compute(k,l,r);
    if(a<=l && r<=b){
      if(type==1)return t[k];
      if(type==2)return u[k];
    }else{
      ll m=(l+r)/2;
      ll lv=Dfs(type,a,b,k*2+1,l,m);
      ll rv=Dfs(type,a,b,k*2+2,m,r);
      if(type==1)return lv+rv; // add
      if(type==2)return max(lv,rv); // max
    }
  }

  void Add(ll a,ll b,ll x){
    Update(a,b,query(1,x), 0,0,SIZE);
  }
  void Set(ll a,ll b,ll x){
    Update(a,b,query(2,x), 0,0,SIZE);
  }
  ll Getsum(ll a,ll b){
    return Dfs(1,a,b, 0,0,SIZE);
  }

  ll Getmax(ll a,ll b){
    return Dfs(2,a,b, 0,0,SIZE);
  }
  
};

int main() {
  ll n;
  cin >> n;
  vector<pll> a(n);
  vector<pll> b(n);
  for(ll i=0;i<n;i++) {
    ll x,d;
    cin >> x >> d;
    a[i]={x,x+d};
  }
  sort(a.begin(),a.end());
  segtree d(n+10);
  d.Set(0,n+1,-inf);
  vec dp(n+1);
  dp[0]=1;
  for(ll i=0;i<n;i++) {
    ll x=a[n-i-1].second;
    ll it=upper_bound(a.begin(),a.end(),pll(x,-inf))-a.begin();
    d.Set(n-i-1,n-i,it);
    d.Set(n-i-1,n-i,d.Getmax(n-i-1,it));
    ll id=n-d.Getmax(n-i-1,n-i);
    (dp[i+1]=dp[i]+dp[id])%=mod;
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 24448
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a,a + n);
    int ans = 1;
    for(int i = 1; i < n; i++)
        if(a[i] != a[i - 1])
            ans ++;
    cout << ans << endl;
    return 0;   
}

Measured memory_bytes: 9860
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

long double getRadian(double x, double y, double x2, double y2) {
	double radian = atan2(y2 - y, x2 - x);
	return radian;
}

int n, d[100000];
int ans = 1;
int cnt[100010];

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> d[i];
	if (d[0] > 0) {
		cout << 0 << endl;
		return 0;
	}
	else cnt[0] = 1;
	sort(d, d + n);
	for (int i = 1; i < n; i++) {
		ans *= cnt[d[i] - 1];
		ans %= mod;
		cnt[d[i]]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 50

	char sInput[MAX_STRING+1]="";
	int anX[100000];
	int anY[100000];

	int compar(const int *val1, const int *val2);

int main() {
//	char* psInput;

	int i=0;
	int j=0;
	int nNumber=0;
	int nTargetNumber=0;
	int nLastTarget=0;
	int nFriends=0;
	int nNeedChanges=0;

	// read line 1
    scanf("%d", &nNumber);
	// read line 2
	for(i=0; i<nNumber; i++) {
        scanf("%d", &anX[i]);
	}
	// sort
    qsort(anX, nNumber, sizeof(int),
        (int (*)(const void *, const void *))compar
    );
	nTargetNumber=anX[0];
	nLastTarget=anX[nNumber-1];
	for (i=0;i<nNumber;i++){
		if (anX[i]==nTargetNumber){
			nFriends++;
		} else {
			// ここまでチェックした数について精算する
			if (nFriends<nTargetNumber){
				nNeedChanges=nNeedChanges+nFriends;
			} else if (nFriends>nTargetNumber){
				nNeedChanges=nNeedChanges+(nFriends-nTargetNumber);
			}
			// ターゲットを更新
			nTargetNumber=anX[i];
			nFriends=1;
		}
	}
	// 最終ターゲットの精算
	if (nFriends>0){
		if (nFriends<nTargetNumber){
			nNeedChanges=nNeedChanges+nFriends;
		} else if (nFriends>nTargetNumber){
			nNeedChanges=nNeedChanges+(nFriends-nTargetNumber);
		}
	}

	printf("%d\n",nNeedChanges);
	

    return 0;
}
int compar(const int *val1, const int *val2) {
    if ( *val1 < *val2 ) {
        return -1;
    } else if ( *val1 == * val2 ) {
        return 0;
    } else {
        return 1;
    }
}



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

int n,m,q;
vector<long long> a,b,c,d;

long long score(const vector<int> &A){
    long long res=0;
    for(int i=0;i<q;i++){
        if(A[b[i]]-A[a[i]]==c[i]) res+=d[i];
    }
    return res;
}

long long dfs(vector<int> &A){
    if(A.size()==n){
        return score(A);
    }

    long long res = 0;
    int prev_last = (A.empty() ? 1:A.back());
    for(int add = prev_last;add<=m;add++){
        A.push_back(add);
        res = max(res,dfs(A));
        A.pop_back();
    }
    return res;
}

int main(){
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    for(int i=0;i<q;i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    vector<int> A;
    cout << dfs(A) << endl;
}

Measured memory_bytes: 3628
using System;

namespace ABC170
{
    class A_FiveVariables
    {
        static void Main(string[] args)
        {
            // 入力
            string[] input = Console.ReadLine().Split(' ');
            for (int i = 0; i < 5; i++)
            {
                // 繰り返し判定する
                if (input[i] == "0")
                {
                    // 0ならば添え字を+1して出力
                    Console.WriteLine(i+1);
                }
            }
        }
    }
}


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

int main() {
	int r, c;
	int ori_table[100][100] = {0};
	int res_table[101][101] = {0};

	cin >> r >> c;
	for(int i = 0; i<r; i++)
		for (int j = 0; j < c; j++)
		{
			cin >> ori_table[i][j];
		}

	for (int i = 0; i < r + 1; i++)
	{
		if(i!=r)
		for (int j = 0; j < c + 1; j++)
		{
			if (j != c)
			{
				res_table[i][j] = ori_table[i][j];
				res_table[i][c] += ori_table[i][j];
				res_table[r][j] += ori_table[i][j];
				cout << res_table[i][j] << " ";
			}
			else
			{
				res_table[r][c] += res_table[i][c];
				cout << res_table[i][c] <<endl;
			}

		}
		else
			for (int j = 0; j < c + 1; j++)
			{
				if(j<c)
					cout << res_table[r][j] << " ";
				else
					cout << res_table[r][j] << endl;
			}
	}

	return 0;
}

Measured memory_bytes: 3140
import java.util.Scanner;
 
class Main{
 public static void main(String[] args){
   Scanner scanner = new Scanner(System.in);
   long a = (long)scanner.nextInt();
   long b = (long)scanner.nextInt();
   long c = (long)scanner.nextInt();
   long d = (long)scanner.nextInt();
   
   long[] e= new long[]{a*c,a*d,b*c,b*d};
   
   long num = e[0];
   
   for(int i=1;i<4;i++) if(num < e[i]) num = e[i];
   
   System.out.println(num);
   
 }
   
}

Measured memory_bytes: 35644
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

int main(){

	int a, b;
	char s;
	cin >> a >> s >> b;
	if( s == '+' ) cout << a+b << endl;
	else cout << a-b << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll x;cin >> x;
    ll c500=x/500;
    x-=c500*500;
    ll c5=x/5;
    cout << c500*1000+c5*5 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,a=0;
	char s[5];
	scanf("%s", s);
	for (i = 0; i < 4; i++)
	{
		if (s[i] == '+')a++;
		else if (s[i] == '-')a--;
	}
	printf("%d\n", a);
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define ZERO(a) memset(a,0,sizeof(a))

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin >> n;
  vll a(n);
  REP(i, n)cin >> a[i];

  sort(a.begin(), a.end());
  ll min_sum = INF;
  for (ll i = a[0]; i <= a[n - 1]; i++){
      ll sum_sq = 0;
      REP(j, n)
          sum_sq += pow((i - a[j]), 2);

      min_sum = min(min_sum, sum_sq);
  }

  cout << min_sum << endl;

  

}



Measured memory_bytes: 256
/**
 * Title: D - Banned K
 * Url: https://atcoder.jp/contests/abc159/tasks/abc159_d
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

ll comb(ll n) {
    return n*(n-1)*(long double)0.5;
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    map<int, ll> dic;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        if(dic.count(a[i])==0) {
            dic[a[i]] = 1;
        } else {
            dic[a[i]] += 1;
        }
    }
    ll sum = 0;
    for(auto i:dic) {
        sum += comb(i.second); 
    }
    for(int i=0; i<n; i++) {
        cout << sum - (comb(dic[a[i]]) - comb(dic[a[i]]-1)) << endl;
    }
    return 0;
}

Measured memory_bytes: 10240
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

int dp[41][401][401];
int main(){
	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	vector<int> A(N), B(N), C(N);
	for(int i=0; i<N; i++) cin >> A[i] >> B[i] >> C[i];

	for(int i=0; i<=N; i++) for(int a=0; a<=400; a++) for(int b=0; b<=400; b++){
		dp[i][a][b] = 1e9;
	}
	dp[0][0][0] = 0;

	for(int i=0; i<N; i++) for(int a=0; a<=400; a++) for(int b=0; b<=400; b++){
		dp[i+1][a][b] = dp[i][a][b];
		if(a>=A[i]&&b>=B[i]) dp[i+1][a][b] = min(dp[i][a][b], dp[i][a-A[i]][b-B[i]]+C[i]);
	}

	int ans = 1e9;
	for(int a=1; a<=400; a++) for(int b=1; b<=400; b++){
		if(a*Mb == Ma*b) ans = min(ans, dp[N][a][b]);
	}
	if(ans < 1e9) cout << ans << endl;
	else cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 25984
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = True
show_flg = False


def divisor(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret

def eucledean(A, N):
    # A = sorted(A)
    ans = A[0]
    for i in range(1, N):
        ans = gcd(A[i], ans)
    print(ans)


def main():
    N, M = MI()
    data = sorted(divisor(M))
    ans = 1

    for i in data:
        c = M // i
        # print(i, c)
        if c >= N:
            ans = i

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64268
N, T = [int(i) for i in input().split()]  # 数字はなるべく早い段階でint型にしておいた方がわかりやすい
all_pattern_list = []
# all_list = [[c1, t1], [c2, t2], ... , [cN, tN]] という2次元リストを作る
for i in range(N):
  all_pattern_list.append([int(j) for j in input().split()])

INF = 1001
ans = INF  # 解が見つからなかった場合を判定できるようにコストが取り得ない大きな値を初期値に設定しておく
# どうせ最悪全部見ることになるのでソートしなくてもOK
for c, t in all_pattern_list:  # アンパックを使うとわかりやすい
  if t <= T:
    ans = min(ans, c)  # 暫定最小コストより小さい場合は最小コストを更新

if ans == INF:
  print("TLE")
else:
  print(ans)


Measured memory_bytes: 62624
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(c,i) for(i = c.begin(); i != c.end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e;++i)
#define forsn(i,s,e) for(int i = s; i < e;++i)
#define rforn(i,s) for(int i = s; i >= 0;--i)
#define rforsn(i,s,e) for(int i = s; i >= e;--i)
# define INF 0x3f3f3f3f 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=1e5+5,MOD=1e9+7;

int main()
{
    ll i,j,k,m,n;
    cin>>n;
    ll a[n][3];
    forn(i,n)
    {
        ll x1,x2,x3;
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    ll dp[n][3];
    forn(i,n)
    {
        for(j=0;j<3;j++)
        {
            dp[i][j]=a[i][j];
            if(i==0)
            {
                continue;  
            }
            for(k=0;k<3;k++)
            {
                if(j==k)
                    continue;
                dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
}

Measured memory_bytes: 8256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = 0;
		for (int i = 0; i < 3; i++) {
			a += scanner.nextInt();
		}
		if (a >= 22) {
			System.out.println("bust");
		} else {
			System.out.println("win");
		}
	}

}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define rep1(i,n) for(int i=1,_n=(int)(n);i<_n;++i)
#define all(v) (v).begin(),(v).end()
#define clr(t,v) memset(t,(v),sizeof(t))
template<class T1, class T2>ostream& operator<<(ostream& os, const pair<T1, T2>&a)
{
   return os << "(" << a.first << "," << a.second << ")";
}
template<class T>void pv(T a, T b)
{
   for(T i = a; i != b; ++i)
      cout << (*i) << " ";
   cout << endl;
}
template<class T>void chmin(T&a, const T&b)
{
   if(a > b)
      a = b;
}
template<class T>void chmax(T&a, const T&b)
{
   if(a < b)
      a = b;
}

int nxint()
{
   int x;
   scanf("%d", &x);
   return x;
}

int main()
{
   int A, B, C, X, Y;
   while(cin >> A >> B >> C >> X >> Y) {
      if(A + B <= 2 * C){
         cout << A * X + B * Y << endl;
      }
      else{
         int ans;
         if(X > Y){
            ans = C * 2 * Y;
            if(2 * C <= A)
               ans += (X - Y) * 2 * C;
            else
               ans += (X - Y) * A;
         }
         else{
            ans = C * 2 * X;
            if(2 * C <= B)
               ans += (Y - X) * 2 * C;
            else
               ans += (Y - X) * B;
         }
         cout << ans << endl;

      }



   }

   return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

x = sum(B)
for a,b in zip(A,A[1:]):
    if b == a+1:
        x += C[a-1]

print(x)

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


int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n,m,c;
  cin>>n>>m>>c;
  int b[25];
  int a[25][25];
  for(int i=1;i<=m;i++){
     cin>>b[i];
  }
  int sum[25];
  for(int i=1;i<=n;i++){
    sum[i]=c;
  }
  for(int i=1;i<=n;i++){
    for (int j=1;j<=m;j++){
      cin>>a[i][j];
      sum[i] +=a[i][j]*b[j];
    }
  }
  int d=0;
  for(int i=1;i<=n;i++){
    if(sum[i]>0){
      d++;
    }
  }
  cout<<d;
  
}



Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    S = input().strip()
    stack = []
    for s in S:
        if s == 'B':
            if stack:
                stack.pop()
        else:
            stack.append(s)
    return ''.join(stack)


if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 61960
import sys
W = input().lower()
cnt = 0
for line in sys.stdin:
    s = line.lower()
    T = s.split(" ")
    for i in range(len(T)):
        if T[i] == "end_of_text":
            break
        if T[i].strip("\".,\n") == W:
            cnt += 1
print(cnt)

Measured memory_bytes: 7336
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A+B+1<C) cout << A+2*B+1 << endl;
  else cout << B+C << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  string un = "UNRESTORABLE";
	string s,t;
  cin>>s;
  cin>>t;
  if(t.sz>s.sz){
    cout << un << endl;
    return 0;
  }
  ll flag1 = 0;
  per(i,0,s.sz-t.sz+1){
    ll flag = 1;
    rep(j,0,t.sz){
      if(s[i+j]=='?')continue;
      if(s[i+j]!=t[j])flag = 0;
    }
    if(flag==1){
      flag1 = 1;
      rep(j,0,t.sz){
        s[i+j] = t[j];
      }
      break;
    }
  }
  if(flag1==0){
    cout << un << endl;
    return 0;
  }
  rep(i,0,s.sz){
    if(s[i]=='?'){
      s[i] = 'a';
    }
  }
  cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll d, g;
    cin >> d >> g;
    vector<ll> p(d), c(d);
    for(int i=0;i<d;i++) cin >> p[i] >> c[i];

    ll ans = INF;
    ll maki = (1LL << d);
    for(int bit = 0; bit < maki; bit++){
    	ll id = -1;
    	ll cnt = 0;
    	ll num = 0;
    	ll cost = 0;
    	for(int i=0;i<d;i++){
    		if(bit >> i & 1){
    			num += p[i] * (i+1) * 100 + c[i];
    			cost += p[i];
    		}else{
    			id = 100LL * (i+1);
    			cnt = p[i];
    		}
    	}
    	if(num < g){
    		ll pos = (g - num + id - 1)/ id;
    	    if(pos <= cnt) {
    	    	num = g;
    	    	cost += pos;
    	    }
    	}
    	if(num < g) continue;
    	ans = min(ans, cost);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

ll gcd(ll n, ll m){
  if(m == 0) return n;
  return gcd(m, n%m);
}

ll lcm(ll n, ll m){
  return n / gcd(n, m) * m;
}

map<ll, ll> allmp;
// auto MP = PrimeFac(N);
// for(auto i : MP){
//   cout << i.first << " " << i.second << endl;
// }
map<ll, ll> PrimeFac(ll n){
  map<ll, ll> mp;
  ll cnt = 0;
  while(n%2 == 0){
    n /= 2;
    cnt++;
  }
  if(cnt != 0){
    mp[2] = cnt;
    allmp[2] += cnt;
  }
  for(ll i = 3; i*i <= n; i += 2){
    cnt = 0;
    while(n%i == 0){
      n /= i;
      cnt++;
    }
    if(cnt != 0){
      mp[i] = cnt;
      allmp[i] += cnt;
    }
  }
  if(n != 1){
    mp[n] = 1;
    allmp[n] += 1;
  }
  return mp;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<ll> A(N);
  REP(i, N){
    cin >> A[i];
  }
  // 全体でcoprimeかどうか
  ll g = gcd(A[0], A[1]);
  bool flagcop = false;
  if(g == 1){
    flagcop = true;
  }else{
    REP(i, N){
      g = gcd(A[i], g);
      if(g == 1){
        flagcop = true;
        break;
      }
    }
  }
  // pairでcoprimeかどうか
  vector<map<ll, ll> > Amp;
  REP(i, N){
    Amp.push_back(PrimeFac(A[i]));
  }
  bool flagpai = true;
  REP(i, N){
    for(auto i : Amp[i]){
      if(allmp[i.first] != i.second){
        flagpai = false;
        break;
      }
    }
    if(flagpai == false) break;
  }

  if(flagcop && flagpai){
    cout << "pairwise coprime" << endl;
  }else if(flagcop){
    cout << "setwise coprime" << endl;
  }else{
    cout << "not coprime" << endl;
  }
}

Measured memory_bytes: 373584
# 2019-11-13 01:34:25(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *h = [int(x) for x in sys.stdin.read().split()]

    count = 0
    for i in range(n):
        if max(h[:i+1]) <= h[i]:
            count += 1

    print(count)



if __name__ == "__main__":
    main()

    

Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int max = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (j == i) continue;

			for (int k = 0; k < 3; k++) {
				if (k == i || k == j) continue;

				int temp = a[i] + a[j] * 10 + a[k];
				if (temp > max) max = temp;
			}
		}
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
arr = []
for _ in range(N):
    arr.append(list(map(int, input().split())))
arr.sort()
# print(arr)
count = 0
for i in arr:
    count += i[1]
    if K <= count:
        print(i[0])
        exit()

Measured memory_bytes: 27872
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    int n,m,R,mi=INF;
    cin>>n>>m>>R;
    int a,b,c,r[R],d[n][n]={0};
    rep(i,n)rep(j,n)d[i][j]=(i!=j)*INF;
    rep(i,R) cin>>r[i],r[i]--;
    rep(i,m) {
        cin>>a>>b>>c;
        d[a-1][b-1]=d[b-1][a-1]=c;
    }
    rep(i,n)rep(j,n)rep(k,n)d[j][k]=min(d[j][k],d[j][i]+d[i][k]);

    sort(r,r+R);
    do{
        int sum=0;
        rep(i,R-1) sum+=d[r[i]][r[i+1]];
        mi=min(sum,mi);
      //  if(mi>sum){mi=sum;rep(i,R)cout<<r[i]+1<<" ";cout<<mi<<endl;}
    }while(next_permutation(r,r+R)); 
    cout<<mi<<endl;

    return 0;
}


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

using namespace std;

int N;
pair<int, int> arr[200005];

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> N;
    for(int i = 1; i<=N; i++){
        cin >> arr[i].second >> arr[i].first;
    }
    sort(arr+1, arr+1+N);
    long long crnt = 0;
    bool p = 1;
    for(int i = 1; i<=N; i++){
        crnt += arr[i].second;
        if(crnt > arr[i].first){
            p = 0;
            break;
        }
    }
    if(p){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 1792
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string s;
	std::cin >> s;
	auto it = std::find(s.begin(), s.end(), 'C');
	it = std::find(it, s.end(), 'F');
	if (it != s.end())
		std::cout << "Yes\n";
	else
		std::cout << "No\n";
}


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

using namespace std;
typedef long long ll;

int main() {
  int h, w, D;
  cin >> h >> w >> D;
  vector<string> c(h);
  for (int i = 0; i < h; ++i) cin >> c[i];

  ll ans = 0;
  for (int i = 0; i < 1 << h; ++i) {
    for (int j = 0; j < 1 << w; ++j) {
      vector<string> tmp = c;      
      for (int k = 0; k < h; ++k) {
	if (i >> k & 1) {
	  for (int x = 0; x < w; ++x) {
	    tmp[k][x] = '-';
	  }
	}
      }
      for (int k = 0; k < w; ++k) {
	if (j >> k & 1) {
	  for (int x = 0; x < h; ++x) {
	    tmp[x][k] = '-';
	  }
	}
      }

      int cnt = 0;
      for (int k = 0; k < h; ++k) {
	for (int x = 0; x < w; ++x) {
	  if (tmp[k][x] == '#') cnt++;
	}
      }
      if (cnt == D) ans++;
    }

  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

typedef long long lli;

const lli N = 1e5;

lli n, m, s[N], t[N], p[N], sum[2][N];

main(){
  cin >> n >> m;
  for(lli i=0;i<n;i++) cin >> s[i] >> t[i];
  for(lli i=0;i<m;i++) cin >> p[i];
  sort(p, p+m);
  fill(sum[0], sum[2], 0);
  for(lli i=0;i<m-1;i++){
    //for(lli j=0;j<2;j++) sum[j][i+1] = sum[j][i];
    //sum[i%2][i+1] += p[i+1] - p[i];
    sum[0][i+1] = sum[0][i] + ((i % 2 == 0) ? (p[i + 1] - p[i]) : 0);
    sum[1][i+1] = sum[1][i] + ((i % 2 == 1) ? (p[i + 1] - p[i]) : 0);
  }
  lli ans = 0;
  for(lli i=0;i<n;i++){
    lli tmp = 0;
    bool f = false;
    if(s[i] > t[i]){
      swap(s[i], t[i]);
      f = true;
    }
    lli l = upper_bound(p, p+m, s[i]) - p;
    lli r = upper_bound(p, p+m, t[i]) - p;
    if(l >= r) tmp += t[i] - s[i];
    else{
      r--;
      if(f){
        tmp += t[i] - p[r];
        if((r - l) % 2) tmp += p[l] - s[i];
        tmp += sum[r%2][r] - sum[r%2][l];
      }else{
        tmp += p[l] - s[i];
        if((r - l) % 2) tmp += t[i] - p[r];
        tmp += sum[1-l%2][r] - sum[1-l%2][l];
      }
    }
    ans += tmp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5080
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;

int main(){
    vector<int> an(5);
    rep(i,5) cin >> an[i];
    int k; cin >> k;
    int ans=0;
    rep(i,4){
        for(int j=i+1; j<5; j++){
            if(abs(an[i]-an[j])>k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if ((x - r >= 0 && x + r <= w) && (y - r >= 0 && y + r <= h)) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert
#ifdef LOCAL
template <class S, class T>
ostream &operator<<(ostream &str, const pair<S, T> &p) {
  return (str << "{" << p.fi << ", " << p.se << "}");
}
template <template <class...> class Container, class... T>
ostream &operator<<(ostream &str, const Container<T...> &vec) {
  str << '[';
  for (auto it = vec.begin(); it != vec.end(); it++) {
    if (it != vec.begin())
      str << ", ";
    str << *it;
  }
  str << ']';
  return str;
}
#define var(x) "[" << #x << ": " << (x) << "] "
struct dbg {
  dbg() { cout << "  "; }
  ~dbg() { cout << endl; }
  template <class T> dbg &operator<<(T oth) {
    cout << oth;
    return *this;
  }
};
#else
#define var(x) 0
struct dbg {
  template <class T> dbg &operator<<(T oth) { return *this; }
};
#endif
using ll = long long;
using ull = unsigned long long;
using ld = long double;
int main(int argc, char **argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  auto solve = [&]() {
    ll n;
    cin >> n;
    vector<ll> ans(n + 1);
    for (ll x = 1; x * x <= n; x++) {
      for (ll y = x; x * x + y * y <= n; y++) {
        for (ll z = y; x * x + y * y + z * z <= n; z++) {
          ll t = x * x + y * y + z * z + x * y + y * z + z * x;
          if (t > n)
            continue;
          if (x == y && y == z)
            ans[t]++;
          else if (x != y && y != z)
            ans[t] += 6;
          else
            ans[t] += 3;
        }
      }
    }
    ans.erase(ans.begin());
    for (auto s : ans)
      cout << s << '\n';
  };
  int t;
  t = 1;
  while (t--)
    solve();
  return 0;
}


Measured memory_bytes: 3600
<?php /*atcoder.php*/

$t = new temp();

$t->stdin(fgets(STDIN));

unset($t);

class temp{
	public function stdin($data = null){
		$cnum = $data;
		$card = explode(" ", fgets(STDIN));

		$a = 0;
		$b = 0;

		arsort($card);

		$f = true;

		foreach($card as $i){
			if($f){
				$a += $i;
				$f = false;
			}else{
				$b += $i;
				$f = true;
			}	
		}
		unset($i);

		$buf = $a - $b;

		echo $buf;

	}
	
}

?>


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;
int N;
long long dp[100010];
long long h[100010];

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

long long rec(int i){
    if(dp[i]!=INF)return dp[i];

    if(i==1)return 0;

    long long ret=INF;

    chmin(ret,rec(i-1)+abs(h[i]-h[i-1]));
    if(i>2)chmin(ret,rec(i-2)+abs(h[i]-h[i-2]));
    
    return dp[i]=ret;
}
int main(){

    
    int N;
    cin>>N;
    rep2(i,N)dp[i]=INF;
    rep2(i,N)cin>>h[i];

    cout<<rec(N)<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define int long long
#define ld long double
#define endl '\n'
const int mod= 1e9+7;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define trace(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
#define reset(x,val) memset(x,val,sizeof(x))
#define flush fflush(stdout)
#define sz(a) a.size()
#define pii pair<int,int>
using namespace std;
const int N=100005;
int dp[N][4],A[N],B[N],C[N];
void smin(int &x,int y)
{
 x=min(x,y);
}
int32_t main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>A[i]>>B[i]>>C[i];
    
    dp[1][1]=A[1];
    dp[1][2]=B[1];
    dp[1][3]=C[1];
    
    for(int i=2;i<=n;i++)
    {
     dp[i][1]=max(dp[i-1][2],dp[i-1][3])+A[i];
     dp[i][2]=max(dp[i-1][1],dp[i-1][3])+B[i];
     dp[i][3]=max(dp[i-1][2],dp[i-1][1])+C[i];
    }
    cout<<max({dp[n][1],dp[n][2],dp[n][3]})<<endl;
    return 0;
}



Measured memory_bytes: 5760
#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>

using namespace std;

int main(){    


    string s;
    cin >> s;

    string res = "";

    for(int i = 0; i< 3; i++){
        res += s[i];
    }

    cout << res;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define   ll          long long int
#define   sz          200010
#define   sc(a)       scanf("%lld",&a)
#define   sc2(a,b)    scanf("%lld %lld",&a,&b)
#define   py          printf("Yes\n")
#define   pn          printf("No\n")
using namespace std;


ll num[sz];



int main()
{

     ll mn=10000000000;
     ll n,i,j,k,d,p,s;

     cin>>n;

     for(i=1;i<=n;i++)
     {
         cin>>num[i];
     }

     for(p=1;p<=100;p++)
     {
         s=0;

         for(i=1;i<=n;i++)
         {
             s+=((num[i]-p)*(num[i]-p));
         }
         mn=min(mn,s);
     }
    cout<<mn<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int main() {
  int N, K;
  scanf("%d %d", &N, &K);

  int res=0;
  for (int i=0; i<N; ++i) {
    int x;
    scanf("%d", &x);

    res += std::min(x, K-x);
  }

  printf("%d\n", res*2);
  return 0;
}


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

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            abc064_a();
        }

        static void abc064_a()
        {
            // A - RGB Cards
            int[] input = Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
            int number = 100 * input[0] + 10 * input[1] + 1 * input[2];
            string ans;
            if (number % 4 == 0) ans = "YES";
            else ans = "NO";
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
namespace atcoder
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using static Ex;

    class Program
    {
        static void Main(string[] _) => new Program().Solve();

        void Solve()
        {
            var N = GetInputs.AsInt().First();
            var A = GetInputs.AsInt();
            var sieve = new bool[A.Max() + 5];
            var ans = 0;
            foreach (var a in A.OrderBy(x => x).GroupBy(x => x))
            {
                if (!sieve[a.Key] && a.Count() == 1) ans++;
                for (var i = 1; a.Key * i < sieve.Length; i++)
                {
                    sieve[a.Key * i] = true;
                }
            }
            Console.WriteLine(ans);
        }
    }

    static class Ex
    {
        public static IEnumerable<string> GetInputs => Console.ReadLine().Split();
        public static IEnumerable<int> AsInt(this IEnumerable<string> xs) => xs.Select(int.Parse);
    }

}


Measured memory_bytes: 67556
import java.util.Scanner;

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

        int count = 0;
        int n = Integer.parseInt(sc.nextLine());
        int[] array = new int[n];
        String[] input = sc.nextLine().split(" ");
        
        for(int i = 0; i < n; i++){
            array[i] = Integer.parseInt(input[i]);
        }
        for(int i = 0; i < n-1; i++){
            for(int j = 0; j < n-1; j++){
                if(array[j] > array[j+1]){
                    int tmp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = tmp;
                    count++;
                }
            }
        }
        System.out.print(array[0]);
        for(int i = 1; i < n; i++){
            System.out.print(" "+array[i]);
        }
        System.out.println("\n"+count);
        
    }
}


Measured memory_bytes: 26100
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN=1000+10;
int a[MAXN];

int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=2*n;++i) scanf("%d",&a[i]);
	sort(a+1,a+2*n+1);
	int ans=0;
	for(int i=1;i<=n;++i) ans+=a[i*2-1];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import fractions
n, m = map(int, input().split())
l = []
r = []
for i in range(m):
    x, y = map(int, input().split())
    l.append(x)
    r.append(y)
ans = 0
M = max(l)
m = min(r)
for i in range(1,n+1):
    if M <= i and i <= m:
        ans += 1
print(ans) 

Measured memory_bytes: 13020
import numpy as np

def main():
    N, K, Q = [int(x) for x in input().split()]
    X = np.array([K - Q] * N)
    for _ in range(Q):
        X[int(input())-1] += 1
    
    for x in X:
        if x > 0:
            print("Yes")
        else:
            print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 13928