akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;


const int BIG_INT = 1000000000;
const ll BIG_NUM = 1000000000000000000;



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

	sort(a.begin(), a.end());

	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
	}
	int maxG = sum / n;
	if (sum % n != 0) {
		maxG++;
	}

	set<int> cd;
	for (int i = 1; i <= maxG; i++) {
		if (i > sum) {
			break;
		}

		if (sum % i == 0) {
			cd.insert(i);
		}
	}

	for (int i = 1; i < n; i++) {
		if (sum % i == 0) {
			cd.insert(sum / i);
		}
	}

	int ans = 0;
	for (auto it = cd.begin(); it != cd.end(); it++) {
		
		vector<int> rem(n);
		for (int i = 0; i < n; i++) {
			rem[i] = a[i] % (*it);
		}

		sort(rem.begin(), rem.end());

		int cnt = 0;
		int rp = n - 1;
		int r = 0;
		for (int i = 0; i < n; i++) {
		
			if (i == rp) {

				break;
			}
			
			r += rem[i];
			cnt += rem[i];
			while (r > 0) {
				if (rem[rp] + r > (*it)) {
					r -= (*it) - rem[rp];
					rp--;
				}
				else {
					rem[rp] += r;
					r = 0;
				}
			}
			
		}

		

		if (cnt <= k) {
			ans = max(ans, *it);
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
# coding: utf-8
import re
import bisect
from datetime import datetime as dt

S = raw_input()
i = 0
max = 0
tmp = 0
while i < len(S):
    if S[i] in 'ACGT':
        tmp += 1
    else:
        if max < tmp:
            max = tmp
        tmp = 0
    i += 1
if max < tmp:
    max = tmp
print max


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)


//template functions
/////////////////////////
long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}
long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}
/////////////////////////



//Answer


int main() {

long N,D;
cin>>N>>D;
long count=0;
vector<long> X(N);
vector<long> Y(N);
for(long i=0;i<N;i++){
cin>>X.at(i);
cin>>Y.at(i);
if(pow(X.at(i),2)+pow(Y.at(i),2)<=pow(D,2)){
    count++;
}
}

cout<<count<<endl;


}



Measured memory_bytes: 6420
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
using namespace std;

int h, w;
int m[1000][1000];

struct Item {
    Item(int x_, int y_, int c_) : x(x_), y(y_), c(c_) {}
    int x;
    int y;
    int c;
};

bool is_not_road(int x, int y) {
    return x < 0 || x >= h || y < 0 || y >= w || m[x][y] < 0;
}

int main()
{
    int cx, cy, dx, dy;
    cin >> h >> w;
    cin >> cx >> cy;
    cin >> dx >> dy;
    cx--; cy--; dx--; dy--;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char c;
            cin >> c;
            m[i][j] = (c == '.') ? 0 : -1;
        }
    }

    deque<Item> q;
    q.emplace_front(cx, cy, 1);

    while (!q.empty()) {
        Item item = q.front();
        q.pop_front();
        int x = item.x;
        int y = item.y;
        int c = item.c;

        if (is_not_road(x, y) || (m[x][y] > 0 && m[x][y] <= c))
            continue;
        m[x][y] = c;
        q.emplace_front(x - 1, y, c);
        q.emplace_front(x + 1, y, c);
        q.emplace_front(x, y - 1, c);
        q.emplace_front(x, y + 1, c);

        for (int i = -2; i < 3; i++) {
            for (int j = -2; j < 3; j++) {
                if (abs(i) + abs(j) <= 1) continue;
                q.emplace_back(x + i, y + j, c + 1);
            }
        }
    }

    if (m[dx][dy] > 0)
        cout << m[dx][dy] - 1 << endl;
    else
        cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 9784
N = input()
hlt = input().split()

for i in range(0, len(hlt)):
    hlt[i] = int(hlt[i])

cnt = 1
for i in range(1, len(hlt)):
    for j in range(0, i):
        if hlt[j] > hlt[i]:
            break
    else:
        cnt += 1

print(cnt)

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

int main() {
  
  vector<int> a(3);
  for (int i = 0; i < 3; i++)
    cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  bool judge = false;
  if (a.at(0) != a.at(2)){
    if ((a.at(0) == a.at(1)) || (a.at(1) == a.at(2)))
      judge = true;
  }
  
  if (judge)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::{HashMap,HashSet};
use std::cmp::{max,min};
fn main(){
    input!{
        n:usize,
        an:[(i64,i64,i64);n],
    }
    let &(a,b,c) = an.iter().filter(|&x|x.2 >= 1).nth(0).unwrap();
    let mut set = HashSet::new();
    for cx in 0..101 {
        for cy in 0..101 {
            let h = c + (a-cx).abs()+(b-cy).abs();
            set.insert((cx,cy,h));
        }
    }
    for &(cx,cy,h) in &set {
        if an.iter().all(|&x| x.2 == max(h-(x.0 - cx).abs()-(x.1-cy).abs(),0)) {
            println!("{} {} {}",cx,cy,h);
            break;
        }
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll a,b,c;
	cin>>a>>b>>c;
	string s="";
	s+=(a+'0');
	s+=(b+'0');
	s+=(c+'0');
	sort(s.rbegin(),s.rend());
	
	ll ans=((s[0]-'0')*10)+(s[1]-'0');
	ll k=s[2]-'0';
	cout<<ans+k<<endl;
	
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <unistd.h>
#include <cctype>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
using ll = long long;
using Pll = pair<ll,ll>;
using Pii = pair<int,int>;
using Pdd = pair<double,double>;
using dcomplex = complex<double>;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;for(ll i=1;i<=a;i++)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}
double inf() {return std::numeric_limits<double>::infinity();}

ll N, K;
ll dp[4010][4010];

// void print(void){
//   REP(i,4*K) {
//     REP(j,4*K) {
//       cout << dp[i][j] << " ";
//     }
//     cout << endl;
//   }
//   cout << endl;
// }

int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  REP(i,N) {
    ll x, y; string c;
    cin >> x >> y >> c;
    if(c[0]=='W') y += K;
    x %= 2*K; y %= 2*K;
    dp[x][y]++;
    dp[x+K][y]--;
    dp[x][y+K]--;
    dp[x+K][y+K]++;
    x += K; y+=K;
    dp[x][y]++;
    dp[x+K][y]--;
    dp[x][y+K]--;
    dp[x+K][y+K]++;
  }
  FOR(i,0,4*K) FOR(j,1,4*K) dp[i][j] += dp[i][j-1];
  FOR(j,0,4*K) FOR(i,1,4*K) dp[i][j] += dp[i-1][j];
  // print();
  FOR(i,0,4*K) FOR(j,0,4*K) {
    ll tmp = dp[i][j];
    dp[i][j] = 0;
    dp[i%(2*K)][j%(2*K)] += tmp;
  }
  // print();
  ll ans = 0;
  REP(i,2*K) REP(j,2*K) ans = max(ans,dp[i][j]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 125568
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
def f(A,N):
    ans = 0
    for i in range(len(A)):
        ans += -(-A[i]//N) - 1
    return ans
ok = 10000000000
ng = 0
while abs(ok-ng) > 1:
    mid = (ok+ng) // 2
    if f(A,mid) <= K:
        ok = mid
    else:
        ng = mid
print(ok)


Measured memory_bytes: 93884
import java.util.*;

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

        String odd = sc.nextLine();
        String even = sc.nextLine();

        int length = odd.length() + even.length();

        for(int i = 0;i<length;i++){
            char c;
            if(i%2==0){
                c = odd.charAt(i/2);
            }else{
                c = even.charAt(i/2);
            }
            System.out.print(c);
        }
    }
}

Measured memory_bytes: 23636
#include<stdio.h>
int main()
{
    int n,b,f,r,v,i,j,k,info[4][3][10]={0};
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d %d %d",&b,&f,&r,&v);
        info[b-1][f-1][r-1]+=v;
    }
    for(i=0;i<4;i++)
    {
        for(j=0;j<3;j++)
        {
            for(k=0;k<10;k++)
            {
                printf(" %d",info[i][j][k]);
            }
            printf("\n");
        }
        if(i>=0 && i<3)
        {
            printf("####################\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2128
import math

nd = [map(int, input().split()) for _ in range(1)]
n, d = [list(i) for i in zip(*nd)]
xy = [map(int, input().split()) for _ in range(n[0])]
x, y = [list(i) for i in zip(*xy)]

num = 0
for i in range(len(x)):
  sq = math.sqrt(x[i] ** 2 + y[i] ** 2)
  if sq <= d[0]:
    num += 1

print(num)

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

using namespace std;

int main(){
   int N,M;
   cin >> N >> M;
   vector<int> sw[N];
   for(int i=0;i<M; i++){
      int k;
      cin >> k;
      for(int j=0;j<k; j++){
         int s;
         cin >> s;
         sw[s-1].push_back(i);
      }
   }
   int p[M];
   for(int i=0; i<M; i++){
      cin >> p[i];
   }
   int cnt[M];
   int ans = 0;
   for(int i=0; i<(1<<N);i++){
      memset(cnt,0,sizeof(cnt));
      for(int j=0;j<N; j++){
         if(((1<<j)&i)!=0){
            for(int k = 0; k < (int)sw[j].size(); k++){
               cnt[sw[j][k]]++;
            }
         }
      }
      bool ok = true;
      for(int i=0;i<M; i++){
         if(cnt[i]%2!=p[i]){
            ok=false;
            break;
         }
      }
      if(ok) ans++;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int ans[4];
int main() {
  int t, n;
  for (int i = 0; i < 4; i++) {
    cin >> t >> n;
    switch (t) {
      case 1:
        ans[i] = 6000 * n;
        break;
      case 2:
        ans[i] = 4000 * n;
        break;
      case 3:
        ans[i] = 3000 * n;
        break;
      case 4:
        ans[i] = 2000 * n;
    }
  }
  for (int i = 0; i < 4; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	ll N, K, Q, j, c=0;
	cin >> N >> K >> Q;
	ll b[N] = {0};
	REP(i, 0, Q){
		cin >> j;
		++b[j-1];
		++c;
	}
	REP(i, 0, N){
		if(K - c + b[i] > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	

}


Measured memory_bytes: 1408
while True:
    dataset = input().split(" ")

    n = int(dataset[0])
    x = int(dataset[1])

    if n == 0 and x == 0:
        break

    answer = []
    for i in range(n, 0, -1):
        for j in range(i-1, 0, -1):
            for k in range(j-1, 0, -1):
                if i + j + k == x:
                    obj = [i, j, k]
                    answer.append(obj)

    print(len(answer))



Measured memory_bytes: 5696
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;
#define INF 100000000
#define MOD 1000000007

int main()
{
	const int N  = 200000;
	int n, t;
	int time[N];
	ll x = 0;
	
	cin >> n >> t;
	for (int i = 0; i < n; i++) {
		cin >> time[i];
	}
	for (int i = 0; i < n - 1; i++) {
		if (time[i + 1] - time[i] <= t) x += time[i + 1] - time[i];
		else x += t;
		//cout << x << endl;
	}
	x += t;

	cout << x << endl;

	return (0);
}

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

int main()
{
    char s[200000];
    cin >> s;
    
    int length= strlen(s);
    int a,b;
    
   
    for (int i=0;i < length;i++){
        if (s[i]=='A'){
            a = i ;
            break;}
    }
    for (int j=length-1;j > -1;j--){
        if (s[j]=='Z'){
            b = j ;
            break;}
    }
    
    cout << b - a +1;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define lld long long int 
#define vll vector<long long int>
#define vs vector<string> 
#define vint vector<int> 
#define vp vector<pair<int,int>>
#define vpll vector<pair<long long int , long long int>>
#define forl(i,a,b) for(int i = a ; i <= b ; i++)
#define forln(i,a,b) for(int i = a; i < b ; i++)
#define forb(i,b,a) for(int i = b ; i >= a ; i--)
#define forbn(i,b,a) for(int i = b ; i > a ; i--)
lld mod = 1e9 + 7;
#define len(str) lld len = str.length();
#define ps push_back
#define B begin
#define E end
#define mk make_pair
#define F first 
#define S second 
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL)
#define test()                  lld t; cin>>t; while(t--)

typedef tree< pair<lld, lld>, null_type,less<pair<lld, lld>>,rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

#define o_set tree<lld, null_type,greater_equal<lld>, rb_tree_tag,tree_order_statistics_node_update> 

/*
struct cmp
{
	bool operator()(const pair<int,int>& l , const pair<int,int>&r){
		if(l.F > r.F) return true;
		if(l.F == r.F){
			if(l.S < r.S) return true;
			else return false;
		}else return false;
	}
};

*/
lld power(lld x, lld y) 
{ lld temp; if( y == 0) return 1; temp = power((x%mod), (y%mod)/2); if (y%2 == 0) return ((temp%mod)*(temp%mod))%mod;else return (((x%mod)*(temp%mod))%mod*(temp%mod))%mod;} 


void solution( void );

int main()
{
	FAST;
	solution();
	return 0;
}
void solution()
{
	lld n,tmp,res=(lld)1;
	cin>>n;
	bool f = false , z = false;;
	forl(i,0,n-1){
		cin>>tmp;
		if(tmp == 0ll){
			z = true;
			continue;
		}
		if(res > (1000000000000000000/tmp)){
			f = true;
		}
		res *= tmp;
		if(res > 1000000000000000000  || res < 0){
			f = true;
		}
	}
	if(z)cout<<"0";
	else if(f){ cout<<"-1"<<endl; }
	else
	cout<<res<<endl;
}

// void sol()
// {
// 	double a,b;
// 	cin>>a>>b;
// 	lld tmp = a*b;
// 	cout<<tmp;
// }

Measured memory_bytes: 3652
#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
  if(i%2==1 && s[i]=='R'){
    cout<<"No"<<endl;
    return 0;
  }
    else if(i%2==0 && s[i]=='L'){
      cout<<"No"<<endl;
      return 0;
  }
  }
    cout<<"Yes"<<endl;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int s[3005][2];

int main(){
	int n,x;
	int i,j,k;
	int a,b,c;
	while(1){
		a=0;
		cin>>n>>x;
		if(n==0 && x==0)break;
		for(i=1;i<=n;i++){
			for(j=i+1;j<=n;j++){
				for(k=j+1;k<=n;k++){
					if(i+j+k==x)a++;
				}
			}
		}
		cout<<a<<endl;
	}
}



Measured memory_bytes: 3076
/*版权所有，拷贝必究！*/
/*若想获得，请联系许希泉*/
#include<bits/stdc++.h>
#pragma GCC optimize("O999")
const int INF = 0x3f3f3f3f;
int maxn=5000005;
using namespace std;
const int N = 998244353;
#define ll long long
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    int n, k;
    cin>>n>>k;
    set<int> s;
    ll dp[n+1];
    vector<pair<int, int> > vp;
    for(int i = 0; i < k; i++){ 
        int l, r;
        cin>>l>>r;
        vp.push_back(make_pair(l, r));
    }
    sort(vp.begin(), vp.end());
    dp[1] = 1;
    dp[0] = 0;
    ll predp[n+1];
    predp[0] = 0;
    predp[1] = 1;
    for(int i = 2; i <= n; i++){
       
        ll ans = 0;
        for(int j = 0; j < k; j++){
            int start = vp[j].first;
            int end = vp[j].second;
            int s = i - end, e = i - start;
           
            if(e <= 0)
            break;
            if(s <= 0){
                ans+=predp[e];
                
                ans %= N;
                break;
            }
            ans += (predp[e] - predp[s] + N + dp[s]);
            
            ans %=N;
        }
       
        dp[i] = ans;
        predp[i] = predp[i-1]+dp[i];
        predp[i] %= N;
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 6792
#include<bits/stdc++.h>
using namespace std;
int b[110];
int main(){
    int cou=0, n;
    cin >> n;
    for(int i = 1; i <= n-1; i++){
        cin >> b[i];
    }
    for(int i = 1; i <= n; i++){
        if(i == 1)  cou += b[i];
        else if(i == n) cou += b[i-1];
        else cou += min(b[i-1],b[i]);
    }
    cout << cou << endl;
}


Measured memory_bytes: 256
i=0
H, W=map(int,input().split())
if H==1 or W==1:
  i=1
elif H%2==1:
  if W%2==1:
    i+=((W+1)//2)*((H+1)//2)+(W//2)*(H//2)
  elif W%2==0:
    i+=(W//2)*((H+1)//2)+(W//2)*(H//2)
elif H%2==0:
  if W%2==1:
    i+=((W+1)//2)*(H//2)+(W//2)*(H//2)
  elif W%2==0:
    i+=(W//2)*(H//2)+(W//2)*(H//2)
print(i)

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

int main(){
    int n;
    cin >> n;
    vector<long long int> a(n);
    vector<long long int> d(n);
    long long int mx = INT_MIN;
    long long int mn = INT_MAX;
    long long total = 0;
    for(int i = 0;i<n;++i){
        cin >> a[i];
        ++d[a[i]];
        mn = min(mn,a[i]);
        mx = max(mx,a[i]);
    }
    for(int i = mn;i<=mx;++i){
        total += (d[i] * (d[i]-1)/2);
    }
    
    for(int i = 0;i<n;++i){
        long long int ans = total -(d[a[i]]*(d[a[i]]-1)/2) + ((d[a[i]]-1)*(d[a[i]]-2)/2);
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <cmath>
#include <valarray>
#include <algorithm>

using namespace std;

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

	A[0] = B[0];
	for (int i = 1; i < N - 1; ++i) {
		A[i] = min(B[i], B[i - 1]);
	}
	A[N - 1] = B[N - 2];
	cout << A.sum() << endl;
//	system("PAUSE");
}

Measured memory_bytes: 256
li = list(map(int,input().split()))
k = int(input())

for i in range(1,len(li)):
    while li[i] <= li[i-1] and k:
        li[i] = li[i]*2
        k-=1
for i in range(1,len(li)):
    if li[i] <= li[i-1]:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// BFSの関数を作ってきれいに書く
int n, u, v;
struct pqdata {
    int pos; int dist;
};

vector< vector<int> > graph(100100, vector<int>());
vector<int> Tgraph(100100, -1);
vector<int> Agraph(100100, -1);

void bfs(vector<int> &vec, int start) {
    pqdata first;
    first.pos = start; first.dist = 0;
    queue<pqdata> que;
    que.push(first);
    vec.at(start) = 0;
    while(!que.empty()) {
        pqdata now = que.front();
        que.pop();
        for(int i = 0; i < (int)graph.at(now.pos).size(); ++i) {
            int npos = graph.at(now.pos).at(i);
            int ndist = now.dist+1;
            if(vec.at(npos) == -1) {
                vec.at(npos) = ndist;
                pqdata next;
                next.pos = npos; next.dist = ndist;
                que.push(next);
            }
        }
    }
}

int main() {
    cin >> n >> u >> v;
    u--; v--;
    for(int i = 0; i < n-1; ++i) {
        int aa, bb; cin >> aa >> bb;
        aa--; bb--;
        graph.at(aa).emplace_back(bb);
        graph.at(bb).emplace_back(aa);
    }
    bfs(Tgraph, u);
    bfs(Agraph, v);

    int Alen = 0;
    for(int i = 0; i < n; ++i) {
        if(Agraph.at(i) > Tgraph.at(i)) {
            chmax(Alen, Agraph.at(i));
        }
    }
    cout << Alen-1 << endl;
}

Measured memory_bytes: 6784
#include <iostream>
#include <cstdlib>
using namespace std;
const int limit=50;
int n,m;
int a[limit],b[limit];
bool graph[limit][limit];
bool vis[limit];
void dfs(int v){
	vis[v]=true;
	for(int v2=0;v2<n;++v2){
		if(graph[v][v2]==false)continue;
		if(vis[v2]==true)continue;
		dfs(v2);
	}
}

int main(void) {
	cin >>n>>m;
	for(int i=0;i<m;++i){
		cin >>a[i]>>b[i];
		a[i]--,b[i]--;
		graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
		
	}
	int ans=0;
	for(int i=0;i<m;++i){
		graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
		for(int j=0;j<n;++j)vis[j]=false;
		dfs(0);
		bool bridge=false;
		for(int j=0;j<n;++j)if(vis[j]==false)bridge=true;
		if(bridge)ans+=1;
		graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
		
	}
	cout << ans <<endl;
	return 0;
}
	







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
#define rep(h) for (int e=0; e<h; e++) 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"
	
int Lroom(bool room[10],int N)
{
	rep(N) if (room[e]==0) {room[e]=1; break;}
	return room[10];
}

int Rroom(bool room[10],int N)
{
	for (int e=9;e>=0;e--) if (room[e]==0) {room[e]=1; break;}
  //cout<<'R'<<endl;
	 return room[10];
}

int as(bool room[10],int l)
{
	//room[l]=0;
cout<<l<<endl;
	return room[10];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
char a;
cin >>a;
cout << (char) ( (int)a +1 );
     return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int n, y;
    int k;
    cin >> n >> y;
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= n - i; j++)
        {
            int k = n -i -j;
            int total = 10000*i +5000*j +1000*k;
            if(total == y)
            {
                cout << i << ' ' << j << ' ' << k << endl;
                return 0;
            }
        }
        
    }
    cout << -1;
    cout << ' ';
    cout << -1;
    cout << ' ';
    cout << -1 << endl;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
points = []
for _ in range(N):
    templist = list(map(int, input().split()))
    points.append(templist)

count = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        dis = 0
        for k in range(D):
            dis += (points[i][k] - points[j][k]) ** 2
        dis = dis ** (1 / 2)
        if dis.is_integer():
            count += 1

print(count)


Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
int main (){
  int N,M;
  scanf("%d %d",&N,&M);
  int *x=NULL;
  x=malloc(M * sizeof(int));
for (int i=0;i<M;i++)
  scanf("%d",&x[i]);
  int s=0;
for (int i=0;i<M;i++)
    s+=x[i];
  if (s>N)
    printf("-1");
  else
    printf("%d",N-s);
  free(x);
return 0;
}


Measured memory_bytes: 1720
#include <iostream>
#include <vector>
#include <string>
#define input std::cin

using vector = std::vector<int>;
using lint = long long int;
using string = std::string;

int main() {
  std::vector<bool> sieve (1001, true);
  for (int i=2; i<=1000; i++) {
	if (sieve[i]) {
	  for (int j=i*i; j<=1000; j+=i) {
		sieve[j] = false;
	  }
	}
  }
  vector primes;
  for (int i=2; i<=1000; i++)
	if (sieve[i])
	  primes.push_back(i);
  // 168 Primes are there

  int n; input >> n;
  vector freqs (1000001, 0);
  for (int i=0; i<n; i++) {
	int num; input >> num;
	for (int p=0; p<primes.size(); p++) {
	  int prime = primes[p];
	  if (prime > num)
		break;
	  if (num % prime == 0)
		freqs[prime] ++;
	  while (num % prime == 0)
		num /= prime;
	}
	if (num > 1)
	  freqs[num] ++;
  }
  bool pairwise = false, setwise = false;
  for (int freq : freqs) {
	if (freq > 1)
	  pairwise = true;
	if (freq == n)
	  setwise = true;
  }
  if (pairwise && setwise)
	std::cout << "not coprime" << std::endl;
  else if (pairwise)
	std::cout << "setwise coprime" << std::endl;
  else
	std::cout << "pairwise coprime" << std::endl;
}



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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
//const int dc[4] = {1, -1, 0,  0};
//const int dr[4] = {0,  0, 1, -1};
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

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

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

int main(void)
{
    int h, w, k;
    cin >> h >> w >> k;
    
    v_string s(h);
    irep(i, h) {
        cin >> s[i];
    }
    int ans = 0;
    for(int i = 0; i < (1<<h); i++) {
        for(int j = 0; j < (1<<w); j++) {
            int cnt = 0;
            irep(x, h) {
                if(i&(1<<x)) { continue; }
                irep(y, w) {
                    if(j&(1<<y)) { continue; }
                    if(s[x][y] == '#') { cnt++; }
                }
            }
            if(cnt==k) { ans++; }
        }
    }
    cout << ans << endl;
    return 0;
}

/*atcoder*/


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <array>
#include <numeric>
#include <algorithm>
#include <set>
#include <deque>
using namespace std;
using ll = long long;
constexpr double INF{ 1e9 };
constexpr int MAGIC_PRIME{ 1000000000 + 7 };
constexpr array<int, 4> dy{ -1, 1, 0, 0 };
constexpr array<int, 4> dx{ 0, 0, -1, 1 };
constexpr int div_ru(int a, int b)
{
    return (a - b + 1) / b;
}
ll pow_mod(ll b, ll e, ll m)
{ // https://atcoder.jp/contests/atc002/tasks/atc002_b
    ll r = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            r = (r * b) % m;
        b = (b * b) % m;
    }
    return r;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (string& x : s) {
        cin >> x;
        x.push_back('#');
    }
    s.push_back(string(w, '#'));

    vector<vector<pair<int, int>>> mm(h, vector<pair<int, int>>(w, make_pair(0, 0)));

    for (int i = 0; i < h + 1; i++)
    {
        for (int j = 0, l = 0; j < w + 1; j++)
        {
            if (s[i][j] == '.')
                ;
            else {
                for (int k = l; k < j; k++)
                {
                    mm[i][k].first = j - l;
                }
                l = j + 1;
            }
        }
    }

    for (int i = 0; i < w + 1; i++)
    {
        for (int j = 0, t = 0; j < h + 1; j++)
        {
            if (s[j][i] == '.')
                ;
            else {
                for (int k = t; k < j; k++)
                {
                    mm[k][i].second = j - t;
                }
                t = j + 1;
            }
        }
    }

    int max_area = -1;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '.')
                max_area = max(mm[i][j].first + mm[i][j].second - 1, max_area);
        }

    cout << max_area << endl;
}
// vector<vector<int>> mm(h, vector<int>(w, -1));


Measured memory_bytes: 39296
package main

import "fmt"

func groupId(n int) int {
	switch n {
	case 1, 3, 5, 7, 8, 10, 12:
		return 1
	case 4, 6, 9, 11:
		return 2
	case 2:
		return 3
	}
	return 0
}

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	if groupId(x) == groupId(y) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
a,b,c = gets.chomp.split(" ").map(&:to_i)
k = gets.chomp.to_i

# a < b < c を目指す
k.times do
  if a >= b
    b *= 2
  elsif b >= c
    c *= 2
  end
end

if a < b && b < c
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 14232
s=str(input())
a="Y"
b="Y"
if 0<int(s[0:2])<13:
    a="MY"
if 0<int(s[2:5])<13:
    b="MY"

if a==b=="Y":
    ans="NA"
elif a=="Y" and b=="MY":
    ans="YYMM"
elif a=="MY" and b=="Y":
    ans="MMYY"
else:
    ans="AMBIGUOUS"
print(ans)

Measured memory_bytes: 8840
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d%d",&A,&B);
    int temp;
    int mid;
    mid = (A+B)/2;
    if(A>B)
    {
        temp = B;
        B = A;
        A = temp;
    }
    A-=mid;
    A=-A;
    B-=mid;
    (A==B)?printf("%d\n",mid):printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n; cin >> n; ll ans = 0; vector<bool> dp(1000001,true);
  map<ll,ll> table;
  
  rep(i,n){
    ll x; cin >> x;
    table[x]++;
  }
  
  for(auto p : table){
    ll a = p.first; ll b = p.second;
    
    if(table[a] == 1 and dp[a]){
      ans++;
    }
    
    for(ll i=a; i <= 1000000; i+=a){
      dp[i] = false;
    }
  }
  
  
  cout << ans << endl;
  
  
}

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

int a[11][11];

void init(int n) {
  for(int i = 0; i <= n; ++i) {
	a[i][n] = 0;
	a[n][i] = 0;
  }
}

void Comp(int n) {
  for(int i = 0; i < n; ++i) {
	for(int j = 0; j < n; ++j) {
	  a[i][n] += a[i][j];
	  a[n][j] += a[i][j];
	  a[n][n] += a[i][j];
	}
  }
}

void print(int n) {
  for(int i = 0; i <= n; ++i) {
	for(int j = 0; j <= n; ++j) {
	  printf("%5d", a[i][j]);
	}
	printf("\n");
  }
}

int main() {
  int n;
  
  while(scanf("%d", &n)) {
	if(n == 0) break;

	init(n);
	for(int i = 0; i < n; ++i) {
	  for(int j = 0; j < n; ++j) {
		cin >> a[i][j];
	  }
	}
	Comp(n);
	print(n);
  }
  return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof a) ;
#define vi vector<int>
#define ull unsigned long long
#define ll long long 
#define db double 
#define ldb long double
#define fl float
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lrep(i,a,b) for(ll i=a;i<b;i++)
#define mod 1000000007
#define mpr make_pair
#define pb push_back
#define fr first
#define sn second
#define bpp(x) __builtin_popcountll(x)
const int INF = 1e9;
const ldb PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899863;
bool ok(string &s ,int l ,int r)
{
while(s[l]==s[r]) l++,r--;
return l>=r; 
}
ll cnk(ll n, int k)
{
    ll res = 1;
    if(k==0)
    return 0;
    for(int i = 0 ; (i) < (k) ; ++i) res = (res * (n - i)) / (i + 1);
    return res;
}
void solve()
{
double l,x; cin>>l;
x=l/3;
x=x*x*x;
printf("%.9lf",x);
}
int main()
{
ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	// cin >> t;
	while(t--){
	solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int w, i;
	const char *format;
	while (scanf(" %d", &w) != EOF) {
		format = "%d";
		for (i = 1; i < 513; i <<= 1) {
			if (w & i) {
				printf(format, i);
				format = " %d";
			}
		}
		putchar('\n');
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    if ( s[2] == s[3] && s[4] == s[5] ) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

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

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int x, y;
    cin >> x >> y;
    rep(a, x + 1) {
        int b = x - a;
        if (2 * a + 4 * b == y) {
            print("Yes");
            return 0;
        }
    }

    print("No");
    return 0;
}



Measured memory_bytes: 3648
#include <inttypes.h>
#include <stdio.h>

int main(void)
{
  uint64_t a;
  double b;
  scanf("%"SCNu64"%lf", &a, &b);
  printf("%"PRIu64"\n", a * (uint64_t)(b * 100 + .5) / 100);
}


Measured memory_bytes: 1744
#include <iostream>
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 << "No";
    else cout << "Yes";
    cout << endl;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int n,m,head[100100],cnt,dsu[100100],pos[100100];
bool sta[100100],vis[100100];
pair<int,bool>p[100100];
struct edge{
	int to,next,id;
}edge[1001000];
void ae(int u,int v,int w){
	edge[cnt].id=w,edge[cnt].next=head[u],edge[cnt].to=v,head[u]=cnt++;
	edge[cnt].id=w,edge[cnt].next=head[v],edge[cnt].to=u,head[v]=cnt++;
}
vector<int>v;
int fd(int x){return dsu[x]==x?x:dsu[x]=fd(dsu[x]);}
bool mg(int x,int y){
	x=fd(x),y=fd(y);
	if(x==y)return false;
	dsu[x]=y;
	return true;
}
bool dfs(int x){
	bool res=sta[x];
	vis[x]=true;
	for(int i=head[x];i!=-1;i=edge[i].next){
		if(vis[edge[i].to])continue;
		bool now=dfs(edge[i].to);
		if(now)v.push_back(edge[i].id);
		res^=now;
	}
	return res;
}
int main(){
	scanf("%d%d",&n,&m),memset(head,-1,sizeof(head));
	for(int i=1;i<=n+1;i++)dsu[i]=i;
	for(int i=1;i<=n;i++)scanf("%d%d",&p[i].first,&p[i].second);
	sort(p+1,p+n+1);
	for(int i=1;i<=n;i++)pos[i]=p[i].first,sta[i]=p[i].second;
	for(int i=n;i;i--)sta[i]^=sta[i-1];
	for(int i=1,l,r;i<=m;i++){
		scanf("%d%d",&l,&r),l=lower_bound(pos+1,pos+n+1,l)-pos,r=upper_bound(pos+1,pos+n+1,r)-pos;
		if(mg(l,r))ae(l,r,i);
	}
	dfs(n+1);
	for(int i=1;i<=n;i++){
		if(vis[i])continue;
		if(dfs(i)){puts("-1");return 0;}
	}
	sort(v.begin(),v.end());
	printf("%d\n",v.size());
	for(int i=0;i<v.size();i++)printf("%d ",v[i]);
	return 0;
}

Measured memory_bytes: 8572
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int D;
vector<int> C(26);
vector<vector<int>> S(365, vector<int>(26));

// int calc(vector<int> schedule) {
//     vector<int> last(26);
//     for(int day = 1; day <= D; day++) {
//     }
// }

int main() {
    cin >> D;
    rep(i, 26) cin >> C[i];
    rep(i, D) rep(j, 26) cin >> S[i][j];
    vector<int> last(26);
    int score = 0;
    vector<int> schedule(D);
    for(int day = 1; day <= D; day++) {
        int next_choice = 0;
        int max_advantage = -INF;
        for(int j = 0; j < 26; j++) {
            int next_score = score + S[day - 1][j];
            int tmp = last[j];
            last[j] = day;
            for(int k = 0; k < 26; k++) {
                next_score -= C[k] * (day - last[k]);
            }
            int adv = next_score - score;
            if(adv > max_advantage) {
                max_advantage = adv;
                next_choice = j;
            }
            last[j] = tmp;
        }
        schedule[day - 1] = next_choice + 1;
        last[next_choice] = day;
        score = score + max_advantage;
    }
    rep(i, D) { cout << schedule[i] << endl; }
    cerr << score << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
    using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string a, b;
    cin >> a >> b;
    if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0])
        cout << "YES";
    else
        cout << "NO";
    return  0;
}

Measured memory_bytes: 256
X,N=map(int,input().split())
p=list(map(int,input().split()))
ans=0
sa=1000
if N==0:
    print(X)
    exit()
for i in range(-1,102):
    tmp=0
    if i in p:
        continue
    else:
        tmp=abs(X-i)
        if tmp<sa:
            sa=tmp
            ans=i
print(ans)



Measured memory_bytes: 9188
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  for(int i = 0;i < n;i++){
    if(i + 2 < n && s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

using namespace std;

const int MX = 20 * 1000 + 7;
const int X = 22 * 1000;

int id[MX];
int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        id[x] = i + 1;
    }
    for (int i = 1; i <= n; i++) {
        cout << X * i << " ";
    }
    cout << "\n";
    for (int i = 1; i <= n; i++) {
        cout << X * (n - i + 1) - (n - id[i] + 1) << " ";
    }
    cout << "\n";
}




Measured memory_bytes: 768
N,K,Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
cnt =[0,]*N
for i in range(Q):
    cnt[(A[i]-1)] += 1
for i in range(N):
    if K-Q+cnt[i] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 8648
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  ll r, D, x;
  cin >> r >> D >> x;
  REP(i, 10) {
    x = r*x - D;
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
/*Node treeMinimum(Node x){
 
 
}
 
Node treeMaximum(Node x){
 
 
}
*/
Node treeSearch(Node u, int k){
 
  // 現在のノードがNULLもしくは対象のキーである場合ノードを返す
  if(u == NIL || k == u->key){
    return u;
  }
 
  if(k < u->key){
    return treeSearch(u->left, k);
  }
  else{
    return treeSearch(u->right, k);
  }
   
}
/*
Node treeSuccessor(Node x){
 
 
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
 
 
 
}
*/
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    } 
    else {
      x = x->right;
    }
  }
  z->parent = y;
   
  if( y == NIL ){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else {
    y->right = z;
  }
   
 
}
 
void inorder(Node u){
   
  // 左のノードがある場合左のノードへ
  if(u->left != NIL){ 
    inorder(u->left);
     
  }
   
  // 左のノードがない、もしくは左側を踏破したとき現在のノードのキーを表示
  printf(" %d",u->key);
 
 
  // 右のノードがある場合右のノードへ
  if(u->right != NIL){
    inorder(u->right);
     
  }
 
 
}
void preorder(Node u){
   
   
  // 現在のノードのキーを表示
  printf(" %d",u->key);
   
  // 左のノードがある場合左のノードへ
  if(u->left != NIL){ 
    preorder(u->left);
     
  }
   
  // 右のノードがある場合右のノードへ
  if(u->right != NIL){
    preorder(u->right);
     
  }
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
 
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } /*else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }*/
  }
 
  return 0;
}

Measured memory_bytes: 19364
#include<iostream>
using namespace std;
int main() {
	pair<int, int>p;
	int n; cin >> n;
	cin >> p.first >> p.second;
	for (int i = 1; i < n; i++) {
		int a, b; cin >> a >> b;
		if (p.first < a) p = make_pair(a, b);
	}
	cout << p.first + p.second << endl;
}

Measured memory_bytes: 256