akhauriyash/Code-Regression huggingface dataset:
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;

typedef tree<pair<double,int> ,null_type,less<pair<double,int> >,rb_tree_tag,tree_order_statistics_node_update> Tree;

#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}


int n;
pair<pi,int> ps[40005];


typedef pair<double,double> pd;
pd event[40005];
lint count(double X){
  REP(i,n){
    double y=(ps[i].sc-(ps[i].fr.fr*X))/ps[i].fr.sc;
    double ang=-ps[i].fr.fr/(double)ps[i].fr.sc;
    event[i]={y,ang};
  }
  Tree T;
  sort(event,event+n);
  lint res=0;
  REP(i,n){
    res+=T.order_of_key({event[i].sc,i});
    T.insert({event[i].sc,i});
  }
  return res;
}
double solve(){
  const double MX=1e9;
  double lb=-MX,ub=MX;

  lint all=n*(lint)(n-1)/2;
  lint half=(all+1)/2;
  REP(hoge,80){
    double md=(lb+ub)/2;
    if(count(md)<half) lb=md;
    else ub=md;
  }
  return lb;
}
int main(){
#ifdef LOCAL_REDIR
  freopen("/home/hog/Dropbox/pg/working/in.txt","r",stdin);
#endif
  cin>>n;
  REP(i,n){
    cin>>ps[i].fr.fr>>ps[i].fr.sc>>ps[i].sc;
  }
  double X=solve();
  REP(i,n) swap(ps[i].fr.fr,ps[i].fr.sc);
  double Y=solve();

  printf("%.15f %.15f\n",X,Y);

  return 0;
}






Measured memory_bytes: 5888
# 入力
N, W = [int(_) for _ in input().split()]
vw = [[int(_) for _ in input().split()] for _ in range(N)]

# dp[i][j]:i番目までを採用したときに重さがjを超えない価値総和の最大値
dp = [[0 for i in range(W+1)] for j in range(N+1)]
# 0個採用なので価値は0 dp[0][w]=0
for i in range(W+1): dp[0][i] = 0

# dp計算
for i in range(N):
    for w in range(W+1):
        if w >= vw[i][1]:
            dp[i+1][w] = max(dp[i][w-vw[i][1]] + vw[i][0], dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]

# 出力
print(dp[N][W])



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

int main() {
    int t, p, r;    // 参加チーム数 T 、問題数 P、システムログのレコード数 R
    while (cin >> t >> p >> r, t) {
        vector<vector<int>> solved(t, vector<int>(p, -1));
        vector<vector<int>> cnt_wa(t, vector<int>(p, 0));
        for (int i = 0; i < r; i++) {
            // システムログのレコードとして、
            // チーム番号 tIDi、問題番号 pIDi、試合開始からの経過時間 timei、
            // メッセージの種類 messagei が含まれる。
            int tID, pID, time; string message;
            cin >> tID >> pID >> time >> message; tID--, pID--;
            if (message == "CORRECT") {
                // チーム tID の正解数に1が加算される。
                // チーム tID のペナルティに、
                // (チーム tID の問題 pID に対する誤答数*1200+time)が加算される。
                // 以後, チーム tID の問題 pID に対する解答は棄却され、
                // システムログにも送信履歴が残らない。
                if (solved[tID][pID] < 0) {
                    solved[tID][pID] = cnt_wa[tID][pID] * 1200 + time;
                }
            } else {
                // チーム tID の 問題 pID に対する誤答数に1が加算される。
                cnt_wa[tID][pID]++;
            }
        }
        /* iCPCにおける順位付けのルールは以下の通りである。
        - より多くの問題を解いたチームは順位が上になる
        - 解いた問題が同じ場合、ペナルティの少ないチームのほうが順位が上になる
        - 解いた問題もペナルティも同じ場合、チーム番号が小さいほうのチームが順位が上になる
        入力より与えられるコンテストの情報・システムログから各チームの成績を割り出し、
        チームの順位表を出力せよ。
        */
        vector<pair<pair<int, int>, int>> teams;
        for (int i = 0; i < t; i++) {
            int cnt_ac = 0, pena = 0;
            for (int j = 0; j < p; j++) {
                if (solved[i][j] >= 0) {
                    cnt_ac++;
                    pena += solved[i][j];
                }
            }
            teams.emplace_back(make_pair(-cnt_ac, pena), i + 1);
        }
        sort(teams.begin(), teams.end());
        // 順位が上のチームから順に、チーム番号、正解数、ペナルティ を出力
        for (auto& team : teams) {
            cout << team.second << " "
                 << -team.first.first << " "
                 << team.first.second << endl;
        }
    }
    return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define sp cout << " ";
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';              

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


int main(){

	ll n,m;
	cin >> n >> m;

	vl sw[n + 10];

	ll k,s;

	for(ll i = 1;i <= m; i++){
		cin >> k;
		while(k--){
			cin >> s;
			sw[s].pb(i);
		}
	}

	ll p[m + 1];
	for(ll i = 1;i <= m;i++){
		cin >> p[i];
	}

	ll ans = 0;

	for(ll i = 1;i <= (1 << n); i++){

		uml bulbs;

		for(ll j = 0;j < n;j++){

			if((i >> j) & 1){
				for(auto x : sw[j + 1]){
					bulbs[x]++;
				}
			}

		}
		ll cnt = 0;
		for(ll j = 1;j <= m;j++){
			cnt += (bulbs[j] % 2 == p[j]);
		}
		if(cnt == m)
			ans++;	
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
import sys
from fractions import gcd
from collections import defaultdict as dd
from bisect import bisect_left as bl
input = sys.stdin.readline
N, X, D = map(int, input().split())
if D == 0:
  if X == 0: print(1)
  else: print(N + 1)
  exit(0)
a = dd(list)
a[0].append((0, 0))
d = abs(D) // abs(gcd(X, D))
#print(d)

for i in range(1, N + 1):
  l = X * i + D * i * (i - 1) // 2
  r = X * i + D * (i * N - i * (i + 1) // 2)
  if r < l: l, r = r, l
  a[i % d].append((l, r))

res = 0
for x in a.keys():
  s = set()
  for l, r in a[x]:
    s.add(l)
    s.add(r)
    s.add(r + 1)
  xs = sorted(s)
  table = [0] * (len(xs) + 1)
  for l, r in a[x]:
    ll = bl(xs, l)
    rr = bl(xs, r + 1)
    table[ll] += 1
    table[rr] += -1
  for i in range(len(xs)): table[i + 1] += table[i]
  l = xs[0]
  for i in range(len(xs)):
    if table[i]:
      if l == -1: l = xs[i]
      continue
    res += (xs[i - 1] - l) // abs(D) + 1
    l = -1

print(res)

Measured memory_bytes: 121556
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
struct Node{
  int no;
  int par;
  int a;
  bool comp;
  vector<Node*> child;
  void build(int i){
    no=i;par=i;comp=true;
  }
};
class Tree{
    public:
    lint top;
    lint daihyo;
    priority_queue<lint,vector<lint>,greater<lint>> que;
    int get(){
        lint res=top;
        if(que.empty()){
            top=inf;
            return res;
        }
        top=que.top();que.pop();
        return res;
    }
};

void dfs(Node& node,Tree& tree){
    int num=node.child.size();
    node.comp=false;
    tree.que.push(node.a);
    rep(i,num){
        if(node.child[i]->comp){
            node.child[i]->comp=false;
            dfs(*node.child[i],tree);
        }
    }
}
bool operator > (const Tree& a,const Tree& b){
    return a.top>b.top;
}

signed main(){
  int n,m;cin>>n>>m;
  vector<Node> node(n);
  rep(i,n){
      node[i].build(i);
  }
  rep(i,n){
      cin>>node[i].a;
  }
  rep(i,m){
      int x,y;cin>>x>>y;
      node[x].child.push_back(&node[y]);
      node[y].child.push_back(&node[x]);
  }
  priority_queue<Tree,vector<Tree>,greater<Tree>> que;
  int v=0;
  lint res=0;
  rep(i,n){
      if(node[i].comp){
          Tree buf;
          ++v;
          dfs(node[i],buf);
          buf.top=buf.que.top();buf.que.pop();
          buf.daihyo=i;
          res+=buf.top;
          buf.get();
          que.push(buf);
      }
  }
  if(2*v-2>n){
      cout<<"Impossible"<<"\n";
      return 0;
  }
  if(v==1){
      cout<<0<<"\n";
      return 0;
  }
  rep(i,v-2){
      Tree buf=que.top();que.pop();
      res+=buf.get();
      que.push(buf);
  }
  if(res>=inf){
      cout<<"Impossible"<<"\n";
      return 0;
  }
  
  cout<<res<<"\n";

  return 0;
}

Measured memory_bytes: 13924
#include <stdio.h>

int main (){
	
	int n;
	int ac=0, wa=0, tle=0, re=0;
	scanf("%d", &n);
	
	char str[105];
	
	while(n--){
		scanf("%s", &str);
		if(str[0]=='A'){
			ac++;
		} else if(str[0]=='W'){
			wa++;
		} else if(str[0]=='T'){
			tle++;
		} else if(str[0]=='R'){
			re++;
		}
	}
	printf("AC x %d\n", ac);
	printf("WA x %d\n", wa);
	printf("TLE x %d\n", tle);
	printf("RE x %d\n", re);
	
	
	
	return 0;
}

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

#define vll vector<long long>
#define pb push_back
#define ll long long
#define umap unordered_map<ll, ll>

int main()
{
	int l;
	int r;
    int d;

    cin >> l >> r >> d;
    int left;
    int right;

    right = r / d * d;
    if(l % d == 0)
        left = l / d;
    else
        left = (l / d + 1)* d;
    if(l == r && l % d == 0)
        cout << 1;
    else if(l == r && l % d != 0)
        cout << 0;
    else
        cout << (right - left) / d + 1;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
                     int a,b,c;
                     cin>>a>>b;
                     c=a/b;
                     if(a%b!=0 && c>0) c++;
                     if(c==0) c=1;
                     cout<<c<<endl;
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n;
	
	string a,b;
	cin>>a>>b;
	
	int ans = 1e9;
	for(int i=0;i+size(b)<=size(a);++i){
		int c = 0;
		for(int k=0;k<size(b);++k) c+=b[k]!=a[i+k];
		ans = min(ans, c);
	}
	
	cout<<ans;
	
	
	return 0;
}


Measured memory_bytes: 3660
import math
N = int(input())
W = list(map(int, input().split()))
A = sum(W)
S1 = 0
ans = 10**9
for i in range(N):
    S1 += W[i]
    S2 = A - S1
    diff = abs(S1 - S2)
    if ans > diff:
        ans = diff
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void dfs(vector<int> g[], int i, int vis[])
{
    vis[i] = 1;
    for(auto j : g[i])
        if(!vis[j])
            dfs(g, j, vis);
}
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> g[n+1];
    int i;
    for(i=1;i<=m;i++)
    {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    int vis[n+1] = {0};
    int c = 0;
    for(i=1;i<=n;i++)
        if(!vis[i])
            dfs(g, i, vis), c++;
    cout << c-1 << '\n';
}

Measured memory_bytes: 10404
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
#include <complex>
using namespace std;
int main()
{
    int x,t;
    cin>>x>>t;
    if((x-t)>=0) cout<<x-t;
    else cout<<"0";
    system ("pause"); 
    return 0;
}


Measured memory_bytes: 504
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int ret = 0;
    for (int i = 0; i < n; ++i) {
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            ret++;
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;int n,a[1000010];
int tong[40];
bool check(int k)
{
	int tmp=a[k];
	for(register int i=0;i<=20;++i)
	{
		if(tmp&(1<<i))
		{
			if(tong[i])return 0;
		}
	}
	for(register int i=0;i<=20;++i)
	{
		if(tmp&(1<<i))
		{
			tong[i]++;
		}
	}
	return 1;
}
void remove(int k)
{
	int tmp=a[k];
	for(register int i=0;i<=20;++i)
	{
		if(tmp&(1<<i))
		{
			if(tong[i]) tong[i]--;
		}
	}
}
void add(int k)
{
	for(register int i=0;i<=20;++i)
	{
		if((1<<i)&a[k]) tong[i]++;
	}
}
int main()
{
	scanf("%d",&n);for(register int i=1;i<=n;++i) scanf("%d",&a[i]);
	int r=2;
	for(register int i=0;i<=20;++i)
	{
		if((1<<i)&a[1]) tong[i]++;
	}	
	long long ans=0;
	for(register int i=1;i<=n;++i)
	{
		if(r<=i) r++,add(i);
		while(check(r)&&r<n+1) r++;
		ans+=r-i;
		remove(i);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<queue>	
#include<functional>

using namespace std;

namespace MyLib {
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
}

using namespace MyLib;

int b[1000][100];

int main() {
	int n, m, a;
	while (cin >> n >> m >> a, n) {
		REP(i, 1000)
			fill(b[i], b[i] + 100, -1);
		int h, p, q;
		REP(i, m) {
			cin >> h >> p >> q;
			h--, p--, q--;
			b[h][p] = q;
			b[h][q] = p;
		}
		a--;
		RREP(i, 1000) {
			if (b[i][a] != -1)
				a = b[i][a];
		}
		cout << a + 1 << endl;
			




	}






}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N,M; cin >>N>>M;
  vector<int>L(M);
  vector<int>R(M);
  for(int i=0;i<M;i++){
    cin>>L.at(i)>>R.at(i);
  }
  int saisho=0;
  int saigo=INT_MAX;
  rep(i,M){
    saisho=max(saisho,L.at(i));
    saigo=min(saigo,R.at(i));
  }
  int kotae=0;
  kotae=saigo-saisho+1;
  if(kotae>0){
    cout<<kotae<<endl;
  }else{
    cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 1024
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    char a,b;
    cin>>a>>b;
    if(a=='H'&&b=='H'){
        cout<<"H"<<endl;
    }
    if(a=='H'&&b=='D'){
        cout<<"D"<<endl;
    }
    if(a=='D'&&b=='H'){
        cout<<"D"<<endl;
    }
    if(a=='D'&&b=='D'){
        cout<<"H"<<endl;
    }
    
}

Measured memory_bytes: 256
from sys import stdin
S = (stdin.readline().rstrip())
flag = False
for i in ["","A"]:
    for j in ["","A"]:
        for k in ["","A"]:
            for l in ["","A"]:
                s = i + "KIH" + j + "B" + k + "R" + l
                if S == s:
                    flag = True
if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include<iostream>
int long long GCD(long long a,long long b);
using namespace std;
int main(){
    long long x,y;
    cin>>x>>y;

    long long ans;
    ans=GCD(x,y);

    cout<<ans<<"\n";
}

long long GCD(long long a,long long b){
    while(b!=0){
        long long r=a%b;
        a=b;
        b=r;
    }
    return(a);
}


Measured memory_bytes: 3084
fun main(args: Array<String>) {
  val S = readString()
  println(
    when (S) {
      "Sunny" -> "Cloudy"
      "Cloudy" -> "Rainy"
      "Rainy" -> "Sunny"
      else -> ""
    }
  )
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 33528
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 998244353
#define INT_MAX1 900000000
#define MAXN 1000000
#define INF INT_MAX



void solve()
{
   int n;
   cin >> n;
   int arr[n];
   inp(arr, n);
   int c[n+1] = {0};
   for(int i=0; i<n; i++)
        c[arr[i]]++;
    int ans = 0;
    rep(i,1,n)
    {
        ans += c[i]*(c[i]-1); 
    }
    ans /=2;
    for(int i=0; i<n; i++)
    {
        int x = c[arr[i]];
        cout << ans-x+1 << endl;
    }
}

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


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))
#define bitcount    __builtin_popcountll
#define mod 1000000007
#define N 1000009
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss(s) cin>>s;
#define si(x)  scanf("%d",&x);
#define sl(x)  cin>>x;
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define ll long long 
//int some_primes[10] = {24443, 100271, 500179, 1000003, 1000333, 2000321, 5000321, 98765431, 1000000123};
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define mod         1000000007
#define PI          3.14159265358979323
ll power(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//string a,b,c;
ll q,h,s,d,n;
int arr[N];
int brr[N];
int main(){
//fast                          //uncomment on submission
cin>>q>>h>>s>>d>>n;
ll m1 = s;
m1 = min(m1 , 2*h);
m1 = min(m1, 4*q);
cout << min(n*m1 , (n/2)*d + (n%2)*m1) ;



               











}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int gcd(int a,int b){
  if(a == 0){return b;}
  return gcd(b%a,a);
}
int main(){
  int a,b;
  while(cin >>a>>b){
    int g = gcd(a,b);
    int l = a/g*b;
    cout <<g<<" "<<l<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <queue>
#include <utility>
using namespace std;
#define mp make_pair
typedef pair<int, int> pint;
const int INF = 100000000;

int h, w, n;
char maze[1024][1024];
int i, j;

struct {
	int x, y;
} dir[4] = {
	{1, 0}, // right
	{0, 1}, // down
	{-1, 0}, // left
	{0, -1} // up
};

int dist[1000][1000];

int bfs(int hp) {
	for(int x = 0; x < w; x++) {
		for(int y = 0; y < h; y++) {
			dist[y][x] = INF;
		}
	}
	dist[i][j] = 0;
	queue<pint> q;
	q.push(mp(i, j));
	while(1) {
		int y = q.front().first;
		int x = q.front().second;
		q.pop();
		if(maze[y][x] == (char)('0' + hp)) {
			i = y;
			j = x;
			maze[i][j] = '.';
			break;
		}
		for(int k = 0; k < 4; k++) {
			int nx = x + dir[k].x;
			int ny = y + dir[k].y;
			if(0 <= nx && nx < w && 0 <= ny && ny < h && maze[ny][nx] != 'X') {
				if(dist[ny][nx] == INF) { // never searched
					dist[ny][nx] = dist[y][x] + 1;
					q.push(mp(ny, nx));
				}
			}
		}
	}
	int ret = dist[i][j];
	return ret;
}

int main() {
	scanf(" %d %d %d", &h, &w, &n);
	for(int y = 0; y < h; y++) {
		scanf(" %s", maze[y]);
	}
	int ans = 0;
	{
		bool loop = true;
		for(int x = 0; x < w; x++) {
			for(int y = 0; y < h; y++) {
				if(maze[y][x] == 'S') {
					i = y;
					j = x;
					maze[y][x] = '.';
					loop = false;
					break;
				}
			}
			if(!loop) break;
		}
	}
	for(int x = 1; x <= n; x++) {
		ans += bfs(x);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	int tmp;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d",&tmp);
		n-=tmp;
	}
	if(n<0)printf("-1\n");
	else printf("%d\n",n);
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
//#include<iostream>
#define pb push_back
#define pf push_front


using namespace std;	
typedef long long int lli;

lli n,k,l,m,t,a,b,r,c,temp1,temp2,x,y,temp,q,d,mod=1e9+7,w,p;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>n;
    vector<lli>v(n);
    lli cnt=0;
    for(int i=0;i<n;i++)cin>>v[i];
    
    for(int i =0;i<n;i++)
    {
    	a=v[i];
    	for(int j=i+1;j<n;j++)
    	{
    		if(v[j]!=a)
    		{
    			b=v[j];
    			
    			for(int k=j+1;k<n;k++)
	    		{
	    			if(v[k]!=a&&v[k]!=b)
	    			{
	    				c=v[k];
	    				if(a+b>c &&b+c>a && c+a>b)cnt++;
	    			}
	    			
	    			
	    		}
    		}
    		
    		
    	}
    }
    
    cout<<cnt<<endl;
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    int i,j,k;
    int N,A[100001],B[100000];
    unsigned long long answer = 0;
    
    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%d\n",&A[i]);
    }
    scanf("%d",&A[i]);
    
    for(i = 0;i < N-1;i++){
        scanf("%d\n",&B[i]);
    }
    scanf("%d",&B[i]);
    
    for(i = 0;i < N;i++){
        if(B[i] <= A[i]){
            answer += B[i];
        }else{
            answer += A[i];
            B[i] -= A[i];
            if(B[i] <= A[i+1]){
                answer += B[i];
                A[i+1] -= B[i];
            }else{
                answer += A[i+1];
                A[i+1] = 0;
            }
        }
    }
    
    printf("%lld\n",answer);
    
    return 0;
}



Measured memory_bytes: 896
<>;$h[$|--]{$_}--for@n=glob<>;($u,$x,$v,$y)=map$h[$i++/2]{$_},@a=map{(sort{$$_{$a}-$$_{$b}}keys%$_)[0,1]}@h;print@n+$u+("@a"-$a[2]?$v:$y-($-=$u+$y-$v-$x))

Measured memory_bytes: 38016
#include <bits/stdc++.h>
 
using namespace std;
 
int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i <n; ++i)
	{
		cin >> arr[i];
	}
	for (int i = 0; i <30; ++i)
	{
		sort(arr,arr+n);
		for (int i = 0; i <n; ++i)
		{
			if (arr[i]%arr[0]==0)
			{
				arr[i]=arr[0];
			}else{
				arr[i]=arr[i]%arr[0];
				if (arr[i]==1)
				{
					cout << 1 << '\n';
					return 0;
				}
			}
		}
	}
	sort(arr,arr+n);
	cout << arr[0] << '\n';
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder177
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToCharArray();
            var T = Console.ReadLine().ToCharArray();

            int ans = T.Length;

            for (int i = 0; i < S.Length; i++)
            {
                if (S.Length - i < T.Length) break; 
                int count = T.Length;
                for(int j = 0; j < T.Length; j++)
                {
                    if(S[i + j] == T[j])
                    {
                        count--;
                    }
                }

                ans = Math.Min(ans, count);
            }

            Console.WriteLine(ans);
        }


    }
}

Measured memory_bytes: 25892
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int main(){
  int n;
  string s[110],l[110];
  
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s[i];
    if(s[i] == "goto"){
      cin >> l[i];
      l[i] = l[i].substr(0,l[i].size()-1);
    }else s[i] = s[i].substr(0,s[i].size()-1);
  }

  vector< vector<pii> > g(n+1);
  for(int i=0;i<n;i++){
    if(s[i]=="goto")g[i].push_back(pii(1,i+1));
    else g[i].push_back(pii(0,i+1));
  }

  for(int i=0;i<n;i++){
    if(s[i] == "goto"){
      for(int j=0;j<n;j++){
	if(l[i] == s[j])g[i].push_back(pii(0,j));
      }
    }
  }

  vector<int> d(n+1,1e9);
  d[0] = 0;
  deque<int> q;
  q.push_back(0);

  while(q.size()){
    int v = q.front(); q.pop_front();
    if(v == n)break;

    for(int i=0;i<(int)g[v].size();i++){
      int u = g[v][i].second, c = g[v][i].first;
      if(d[u] <= d[v]+c)continue;
      d[u] = d[v] + c;
      if(c == 0)q.push_front(u);
      else q.push_back(u);
    }
  }
  cout << d[n] << endl;
}

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

#define all(a) (a).begin(), (a).end()
#define pb push_back
#define sz(a) (int)(a).size()
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    //ifstream cin("input.txt");
    //freopen("input.txt", "r", stdin);
    //ofstream cout("output.txt");

	ll q, h, s, d;
	cin >> q >> h >> s >> d;
	ll n;
	cin >> n;

	h = min(h, 2 * q);
	s = min({s, 2 * h, 4 * q});
	d = min({d, 2 * s, 4 * h, 8 * q});

	ll ans = (n / 2) * d + (n % 2) * s;
	cout << ans << "\n";

}


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

typedef pair<int,int> PII;
const int M=105;

int main()
{
	int n,k; scanf("%d%d",&n,&k);
	if(k>(n-1)*(n-2)/2)
	{
		puts("-1");
		return 0;
	}
	vector<PII> ans;
	for(int i=1;i<n;i++)
		ans.push_back({i,n});
	k=(n-1)*(n-2)/2-k;
	for(int i=1;i<n;i++)
	{
		for(int j=i+1;j<n&&k;j++,k--)
		{
			ans.push_back({i,j});
		}
		if(!k) break;
	}
	printf("%d\n",ans.size());
	for(auto p:ans)
		printf("%d %d\n",p.first,p.second);
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int[][] c = new int[3][3];

    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++){
        c[i][j] = sc.nextInt();
      }
    }

    sc.close();

    String result = "Yes";

    int d1 = c[0][0] - c[0][1];
    int d2 = c[1][0] - c[1][1];
    int d3 = c[2][0] - c[2][1];
    int d4 = c[0][1] - c[0][2];
    int d5 = c[1][1] - c[1][2];
    int d6 = c[2][1] - c[2][2];

    if (d1 != d2 || d2 != d3) {
      result = "No";
    }

    if (d4 != d5 || d5 != d6) {
      result = "No";
    }

    System.out.println(result);

  }

}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,k; cin>>n>>k; --k;
	vector<int>x(n); for(auto&i:x)cin>>i;
	int ans=1e9;
	for(int i=k;i<n;++i){
		int l=x.at(i-k),r=x.at(i);
		ans=min({ans,abs(l)+abs(l-r),abs(r)+abs(r-l)});
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int n;
char s[55][55];
bool vis[55][55], md[55];
char ans[55];
int dp[55][55];
int main()
{
	while(scanf("%d", &n) != EOF)
	{
		int cnt = 0;
		int minlen = 100, minpos = 0;
		for(int i = 1; i <= n; i++)
		{
			scanf("%s", s[i] + 1);
			s[i][0] = strlen(s[i] + 1);
			if(s[i][0] < minlen)
			{
				minlen = s[i][0];
				minpos = i;
			}
			sort(s[i] + 1, s[i] + s[i][0] + 1);
		}
		bool flag, f;
		for(int i = 1; i <= s[minpos][0]; i++)
		{
			char x = s[minpos][i];
			flag = 1;
			for(int j = 1; j <= n; j++)
			{
				f = 0;
				for(int k = 1; k <= s[j][0]; k++)
				{
					if(s[j][k] == x && !vis[j][k])
					{
						f = 1;
						vis[j][k] = 1;
						break;
					}
				}
				if(f == 0)
				{
					for(int k = 1; k <= j; k++)
					{
						for(int l = 1; l <= s[k][0]; l++)
						{
							if(s[k][l] == x)
							{
								vis[k][l] = 0;
								break;
							}
						}
					}
					flag = 0;
					break;
				}
			}
			if(flag == 1)
				ans[++cnt] = x;
		}
		if(cnt == 0)
			printf("\n");
		else
		{
			for(int i = 1; i <= cnt; i++)
				printf("%c", ans[i]);
			printf("\n");
		}
	}
}

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

int main(){
 int a,b;
 char c;
 while(cin>>a>>c>>b){
    if(c=='+')cout<<a+b<<endl;
    if(c=='-')cout<<a-b<<endl;
    if(c=='*')cout<<a*b<<endl;
    if(c=='/')cout<<a/b<<endl;
    if(c=='?')break;
 }
}



Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>

using namespace std;
using ll = long long;

#define all(a) (a).begin(),(a).end()
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

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

  vector<ll> A(N);
  rep(i, N) {
    in(A[i]);
  }
  sort(all(A));
  if (A[0] > 0) {
    ll sum = -A[0];
    loop(i, 1, N) {
      sum += A[i];
    }
    out(sum);
    sum = A[0];
    loop(i, 1, N-1) {
      out(sum << " " << A[i]);
      sum -= A[i];
    }
    out(A[N-1] << " " << sum);
  } else {
  // } else if (A[N-1] >= 0) {
    reverse(all(A));
    ll sum = A[N-1];
    stringstream ss;
    loop(i, 1, N-1) {
      if (A[i] < 0) {
        ss << A[0] << " " << A[i] << "\n";
        A[0] -= A[i];
      } else {
        ss << sum << " " << A[i] << "\n";
        sum -= A[i];
      }
    }
    out(A[0] - sum);
    cout << ss.str();
    out(A[0] << " " << sum);
  }
  return 0;
}


Measured memory_bytes: 6148
#include <bits/stdc++.h>
#define F first
 #define S second
#define PB push_back
#define MP make_pair
#define ll long long int

#define PI 3.14159


using namespace std;

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



	int r;
	
	cin >> r;
	
	float a;
	
	a = (float) 2 * PI * r;
	
	cout << a << "\n";


return 0;
}


Measured memory_bytes: 3744
X,N = map(int, input().split())
l = [int(x) for x in input().split()]
i = 1
if X not in l:
        print(X)
else:    
    while i <= N//2 + 1 :
        if X - i  not in l:
            print(X-i)
            break
        elif X + i not in l:
            print(X+i)
            break
        i += 1

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

int main(){
	long long int a,b,c;
	cin >> a >> b >> c;
	if(a+b>=c){
		cout << "No" << endl;
	}else{
		if(4*a*b<(c-a-b)*(c-a-b)){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;


static const long long mod = 1000000007;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, x, y;
  cin >> n >> x >> y;
  x--, y--;
  vll ans(n);

  rep(i, n-1){
    repLRE(j, i+1, n-1){
      ll can1 = j - i;
      ll can2 = abs(x - i) + 1 + abs(j - y);
      ll vote = min(can1, can2);
      ans.at(vote)++;
    }
  }

  repLRE(i,1,n-1){
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3604
// =====================================================
//   File    :   main.cpp
//   Author  :   eezyl
//   Synopsis:   codeforces/atcoder template
//   Address :
//   Date    :   2020/08/15
// =====================================================

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

//#define rep(i, a, b) for (int i = (a); i < int(b); ++i)
typedef long long LL;

const int MOD = 1e9+7;

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

void solve() {
    int n;
    LL K;
    cin >> n >> K;
    vector<int> P(n+1);
    for (int i = 1; i <= n; ++i)
        cin >> P[i];
    vector<LL> C(n+1);
    for (int i = 1; i <= n; ++i)
        cin >> C[i];


    LL ans = C[1];
    for (int i = 1; i <= n; ++i) {
        int start = P[i];
        int cur = P[start];
        LL score = C[start];
        ans = max(ans, score);
        LL count = 1;

        vector<LL> rem(1, 0);
        while (count < K && cur != start) {
            rem.push_back(score);
            ++count;
            score += C[cur];
            ans = max(ans, score);
            cur = P[cur];
        }
        if (count < K && cur == start) {
            LL rep = K / count;
            LL new_k = K % count;

            LL lar = rem[0];
            for (LL j = 1; j <= new_k; ++j)
                lar = max(lar, rem[j]);
            LL p = rep * score + lar;
            ans = max(ans, p);

            if (new_k == 0) {
                --rep;
                new_k = count-1;
            }
            lar = rem[0];
            for (LL j = 1; j <= new_k; ++j)
                lar = max(lar, rem[j]);
            p = rep * score + lar;
            ans = max(ans, p);
        }
    }
    cout << ans << endl;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
//#define LOCAL
#ifdef LOCAL
freopen("data.in", "r", stdin);
while (!feof(stdin)) {
#endif // LOCAL

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

#ifdef LOCAL
}
printf("Time used = %.2lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif // LOCAL
    return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ROCK ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define sec second
using namespace std;
using namespace __gnu_pbds;
const long long int linf =(long long)9223372036854775807;
const int dx[8] =  {0,0,1,-1,1,-1,1,-1},dy[9] = {1,-1,0,0,1,-1,-1,1};
typedef long long int ll;

const int N=1e5+3;
ll arr[N],dp[N],n,k=2;

ll solve(int pos){
    if(pos>=n)return 1e9+5;
    if(pos==n-1)return 0;
    if(dp[pos]!=-1)return dp[pos];
    ll ans=1e9+5;
    for(int i=1;i<=k;i++)ans=min(ans,solve(pos+i)+abs(arr[pos]-arr[pos+i]));
    return dp[pos]=ans;
}

int main()
{
    ROCK;
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0;i<n;i++)cin>>arr[i];
    cout<<solve(0)<<endl;
    return 0;
}












Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<vector>

#define REP(i,n) for(int i=0;i<n;i++)
#define llong long long

using namespace std;

int main(){

	int a, b, c;

	cin >> a >> b >> c;

	if ((a + b )>= c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

  return 0;
}


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


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int p = (c + b - 1) / b;
  int q = (a + d - 1) / d;
  cout << (p <= q ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<pair<int,int> >G[1<<17];
int n,m;
long x[1<<17];bool used[1<<17];
bool dfs(int u,int p)
{
	used[u]=1;
	for(int i=0;i<G[u].size();i++)
	{
		if(G[u][i].first==p)continue;
		if(used[G[u][i].first]&&x[G[u][i].first]!=x[u]+G[u][i].second)return false;
		else if(!used[G[u][i].first])
		{
			x[G[u][i].first]=x[u]+G[u][i].second;
			if(!dfs(G[u][i].first,u))return false;
		}
	}
	return true;
}
main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int l,r,d;cin>>l>>r>>d;
		G[l].push_back(make_pair(r,d));
		G[r].push_back(make_pair(l,-d));
	}
	for(int i=1;i<=n;i++)
	{
		if(!used[i])x[i]=0;
		if(!dfs(i,0))
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

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

struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

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

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

    vector<pint> ab(m);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b, --a, --b;
        ab[i] = pint(a, b);
    }
    reverse(ab.begin(), ab.end());

    vector<ll> ans(m);
    ll incom = n * (n - 1LL) / 2;

    UnionFind tree(n);
    vector<int> connect(n, 1);
    rep(i, m)
    {
        ans[i] = incom;
        int a = ab[i].first;
        int b = ab[i].second;

        if (!tree.same(a, b))
        {
            int &at = connect[tree.root(b)];
            int bt = connect[tree.root(a)];
            incom -= at * ll(bt);
            tree.unite(a, b);
            at += bt;
        }
    }

    for (int i = m - 1; i >= 0; --i)
        cout << ans[i] << endl;
}

Measured memory_bytes: 5768
import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		char[] n = sc.next().toCharArray();
		int K = sc.nextInt();
		long[][][] dp = new long[n.length + 1][K + 1][2];
		dp[0][0][0] = 1;

		for (int i = 0; i < n.length; i++) {
			int d = Integer.parseInt(String.valueOf(n[i]));

			for (int j = 0; j <= K; j++) {
				if (d == 0) {
					dp[i + 1][j][0] += dp[i][j][0];
					dp[i + 1][j][1] += dp[i][j][1];
					if (j != K) dp[i + 1][j + 1][1] += dp[i][j][1] * 9;
				} else {
					dp[i + 1][j][1] += dp[i][j][0];
					dp[i + 1][j][1] += dp[i][j][1];
					if (j != K) {
						dp[i + 1][j + 1][0] += dp[i][j][0];
						dp[i + 1][j + 1][1] += dp[i][j][0] * (d - 1);
						dp[i + 1][j + 1][1] += dp[i][j][1] * 9;
					}
				}
			}
		}

		System.out.println(dp[n.length][K][0] + dp[n.length][K][1]);
	}
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> l(m), r(m);
    rep(i, m) {
        cin >> l[i] >> r[i];
    }
    vector<int> left(m), right(m);
    int ans;
    bool flag = true;
    rep(i, m) {
        if (i == 0) {
            left[i] = l[i];
            right[i] = r[i];
        } else {
            if (l[i] > right[i-1] || r[i] < left[i-1]) {
                
                flag = false;
                break;
            } else {
                if (l[i] > left[i-1]) left[i] = l[i];
                else left[i] = left[i-1];
                if (r[i] < right[i-1]) right[i] = r[i];
                else right[i] = right[i-1];
            }
        }
    }
    if (flag) {
        if (right[m-1] <= n) {
            ans = right[m-1] - left[m-1] + 1;
        } else if (left[m-1] >= n) {
            ans = n - left[m-1] + 1;
        } else {
            ans = 0;
        }
    } else {
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4728
// Created by sz
#include <bits/stdc++.h>
using namespace std;

int N, L[11];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    cin>>N;
    for(int i = 0;i<N;i++)cin>>L[i];
    sort(L, L+N);
    int sum = 0;
    for(int i = 0; i<N-1;i++)sum+= L[i];
    if(sum<=L[N-1])cout<<"No\n";
    else cout<<"Yes\n";
    
    
    return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

vector<int> v;
int a[20];
int m;
int n, q;

void dp(int cnt, int value)
{
	if (cnt >= n) {
		v.push_back(value);
		return;
	}
	dp(cnt + 1, value + a[cnt]);
	dp(cnt + 1, value);
}

int main(){
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	dp(0, 0);
	sort(v.begin(), v.end());
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> m;
		bool flag = false;
		for (int j = 0; j < v.size(); j++) {
			if (v[j] > m) {
				break;
			} else if (v[j] == m) {
				flag = true;
				break;
			}
		}
		if (flag) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 6988
#!/use/bin/env python3

from collections import defaultdict

a = input()

b = defaultdict(int)


for c in a:
    b[c] += 1

d = []

for c in b.values():
    d.append(c % 2)

e = set(d)

ans = 'No' if 1 in e else 'Yes'

print(ans)


Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>
#define N 1000000
int dequeue(void);
void enqueue(int);
int tim=0,i,n,q,pnumber[N],head=0,tail;
char pname[N][10];
int main(){
  int x; 
  scanf("%d %d",&n,&q);
  for(i=0;i<n;i++) scanf("%s%d",pname[i],&pnumber[i]);
  tail=n;
  while(1){
    if(head==tail)break;
   
    x= dequeue();
    if(x>q){ 
      tim+=q;
      enqueue(x-q);
    }
    else{
      tim+=x;
        
      printf("%s %d\n",pname[head-1],tim);
    }

  }


  return 0;
}

int dequeue(void){
  int x;
  x = pnumber[head];
if (head + 1 == N)
    head = 0;
  else head = head + 1;
 return x;

}
void enqueue(int x){
  pnumber[tail] = x;
  strcpy( pname[tail],pname[head-1]) ;
if(tail + 1 == N)
    tail = 0;
  else tail = tail + 1;
}

Measured memory_bytes: 5452
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a, b,c,d,sum=0;
    cin >> a>> b >>c>>d;
    if(a>b){
    for(int i=0;i<b;i++){
        sum+=c;
    }
    }else{
        for(int j=0;j<a;j++){
            sum+=c;
        }
    }
    if(a-b>=1){
    for(int j=0;j<a-b;j++){
        sum+=d;
    }
    }
    cout << sum;
}


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


using namespace std;

void solve2() {
	int N,L;
	vector< string> v;
	cin >> N>>L;
	for (int i = 0; i < N; i++)
	{
		string s;
		cin >> s;
		v.push_back(s);

	}
	sort(v.begin(), v.end());
	for (int i = 0; i < N; i++)
	{
		cout << v[i];
	}
	cout << endl;
}


void solve1() {
	int A, B, C;
	cin >> A >> B >> C;
	vector<int> v;
	v.push_back(A);
	v.push_back(B);
	v.push_back(C);
	sort(v.begin(), v.end());
	if (v[0] == 5 && v[1] == 5 && v[2] == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

int main() {
	solve2();
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int a[110];
int main() {
	int n, mn = 100, mx = -100, ans = 1<<30, sum; scanf("%d", &n);
	for(int i = 1; i <= n; i ++ ) scanf("%d", &a[i]), mx = max(mx, a[i]), mn = min(mn, a[i]);
	for(int i = mn; i <= mx; i ++ ) {
		sum = 0;
		for(int j = 1; j <= n; j ++ ) sum += (a[j]-i)*(a[j]-i);
		ans = min(ans, sum);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256