akhauriyash/Code-Regression huggingface dataset:
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
bc=[list(map(int,input().split())) for i in range(m)]
bc=sorted(bc,reverse=True,key=lambda x:x[1])
c=[]

cnt=0
for B,C in bc:
    for i in range(B):
        if cnt==n:break
        cnt+=1
        c.append(C)
c=sorted(c,reverse=True)

ans=sum(a)
temp=ans
for i in range(n):
    if cnt<=i:continue
    temp+=-a[i]+c[i]
    if temp>ans:ans=temp
print(ans)

Measured memory_bytes: 33680
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

int main() {
	char c;
	cin >> c;

	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
		cout << "vowel" << endl;	
	}
	else {
		cout << "consonant" << endl;	
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<(k) ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=(k) ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef jayinnn
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 100005;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();
    int a, b, c;
    cin >> a >> b >> c;
    if((a == b && a != c) || (a == c && a != b) || (b == c && a != b)){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

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

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

    vector<int> c(m), d(m);
    for (int i = 0; i < m; i++) {
        cin >> c[i] >> d[i];
    }

    for (int i = 0; i < n; i++) {
        int minDist = 1e9;
        int minCheck = 0;
        for (int j = 0; j < m; j++) {
            int dif = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (dif < minDist) {
                minDist = dif;
                minCheck = j + 1;
            }
        }
        cout << minCheck << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
ll n,a[N],dp[N];
vector<ll> vt[N],vp;
void dfs(ll x,ll lst)
{
	ll pos=lower_bound(vp.begin(),vp.end(),a[x])-vp.begin(),tt,i;
	bool hs=false;
	if(pos>=vp.size())
	{
		vp.push_back(a[x]);
		hs=true;
	}
	else
	{
		tt=vp[pos];
		vp[pos]=a[x];
	}
	dp[x]=vp.size();
	for(i=0;i<vt[x].size();i++)
	{
		if(vt[x][i]!=lst)
		{
			dfs(vt[x][i],x);
		}
	}
	if(hs)
	{
		vp.pop_back();
	}
	else
	{
		vp[pos]=tt;
	}
	return;
}
int main(){
	ll i,x,y;
	scanf("%lld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(i=1;i<n;i++)
	{
		scanf("%lld%lld",&x,&y);
		x--;
		y--;
		vt[x].push_back(y);
		vt[y].push_back(x);
	}
	dfs(0,-1);
	for(i=0;i<n;i++)
	{
		printf("%lld\n",dp[i]);
	}
	return 0;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const int INF = 1001001001;
const ll mod = 998244353;
const ll INFL = 1001001001001001000;

vector<ll> divisor(ll N) {
    vector<ll> RES;
    for (ll I = 1; I*I <= N; I++) {
        if (N%I == 0) {
            RES.push_back(I);
            if (I != N/I) RES.push_back(N/I);
        }
    }
    return RES;
}

ll gcd(ll A, ll B) {
    return B ? gcd(B,A%B) : A;
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

int main() {
    ll n; cin >> n;
    if (n <= 100) {
        ll k = 1;
        while (1) {
            if ((k*(k+1)/2)%n == 0) {
                cout << k << endl;
                return 0;
            }
            k++;
        }
    }
    vector<ll> divi = divisor(2*n);
    ll ans = INFL;
    for (ll pp : divi) {
        ll p = pp;
        ll q = (2*n)/p;
        ll g = gcd(p,q);
        if (g != 1) continue;
        ll a,b;
        extGCD(p,q,a,b);
        a = -a;
        //printf("%lld %lld\n", a,b);
        if (a == 0 || b == 0) continue;
        if (a < 0) {
            ll dd1 = (-a+q-1)/q;
            ll dd2 = (-b+p-1)/p;
            ll dd = max(dd1, dd2);
            a += q*dd;
            b += p*dd;
        }
        //printf("a = %lld, b = %lld\n", a,b);
        ans = min(ans, min(p*a, q*b-1));

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


Measured memory_bytes: 3744
#include<iostream>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <vector> 
#include <unordered_map>
using namespace std; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main()
{   
	//IOS;
	#define int long long int
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a;

    return 0;
}


Measured memory_bytes: 3620
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int T = 1,A = 1;
	rep(i,n){
		int t,a;
		cin >> t >> a;
		int maxv = max((T + t -1) / t,(A + a -1) / a);
		T = maxv * t;
		A = maxv * a;
	}
	cout << T + A << '\n';
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int N = 1e3+10;

//head

int h, w;
P S, G;
string s[N];
PQG<P> q;
int dist[N][N];

int di[] = {0 ,1, 0, -1};
int dh[] = {1, 0, -1, 0};
inline bool able(int i, int j) {return i >= 0 and j >= 0 and i < h and j < w;}
inline int num(int i, int j) {return i*w+j;}
inline int num(P o) {return num(o.first, o.second);}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> h >> w;
  cin >> S >> G;
  rep(i, h) cin >> s[i];
  memset(dist, -1, sizeof(dist));
  S.first--;
  S.second--;
  q.emplace(0, num(S));
  dist[S.first][S.second] = 0;
  while(!q.empty()) {
    int now, dis;
    tie(dis, now) = q.top();
    q.pop();
    int i = now/w;
    int j = now%w;
    if(dist[i][j] != dis) continue;
    for(int u = -2; u < 3; u++) for(int v = -2; v < 3; v++) {
      int ni = i+u;
      int nj = j+v;
      if(able(ni, nj) and s[ni][nj] != '#') {
        int ky = !(abs(u)+abs(v) < 2);
        if(dist[ni][nj] == -1) {
          dist[ni][nj] = dist[i][j] + ky;
          q.emplace(dist[ni][nj], num(ni, nj));
        }
        else {
          if(chmin(dist[ni][nj], dist[i][j]+ky)) {
            q.emplace(dist[ni][nj], num(ni, nj));
          }
        }
      }
    }
  }

  cout << dist[G.first-1][G.second-1] << endl;
}

Measured memory_bytes: 8796
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

using namespace std;

struct person{ int no; double diff; };

const double EPS = 1e-10;

bool operator<(const person& l, const person& r) 
{
    if(fabs(l.diff - r.diff) < EPS) {
        return l.no < r.no;
    } else {
        return l.diff < r.diff;
    }
}

bool operator>(const person& l, const person& r) 
{
    if(fabs(l.diff - r.diff) < EPS) {
        return l.no > r.no;
    } else {
        return l.diff > r.diff;
    }
}

bool operator==(const person& l, const person& r) 
{
    return (fabs(l.diff - r.diff) < EPS && l.no == r.no);
}

int n;
int main()
{
    while(cin >> n && n) {
        vector<person> ps(n);
        int i, h, w;
        double bmi;
        for(int k = 0; k < n; k++) {
            cin >> i >> h >> w;
            bmi = ((double)w / (h * h)) * 10000;
            ps[k] = (person){i, fabs(22.0 - bmi)};
        }
        sort(ps.begin(), ps.end());
        cout << ps[0].no << endl;
    }
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N;
    cin >> N;
    int K;
    cin >> K;

    vector<double> p(N);
    REP0(i, N)
    {
        double a;
        cin >> a;
        p[i] = (a + 1.0) / 2.0;
    }

    double ans = 0;
    double cum = 0;

    REP0(i, K)
    {
        cum += p[i];
    }

    ans = cum;

    FOR(i, K, N)
    {
        cum += p[i] - p[i - K];
        ans = max(ans, cum);
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
using namespace std;
const int mxn=200010;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int R,C;
int n;
struct node{
	int x1,y1,x2,y2;
}a[mxn];
int cmp1(node a,node b){
	return (a.x1==b.x1 && a.y1<b.y1)|| a.x1<b.x1;
}
int check(int x,int y){
	bool flag1=(x==R)||(x==C)||(x==0);
	bool flag2=(y==R)||(y==C)||(y==0);
//	printf("%d %d %d %d\n",x,y,flag1,flag2);
	return flag1|flag2;
}
struct point{
    int x,y;//点
    bool tp;
    int id;
    point operator - (const point &b){
    	return (point){x-b.x,y-b.y,0};
	} 
}p[mxn];
LL Cross(point a,point b){
	return (LL)a.x*b.y-(LL)a.y*b.x;
}
int cmp(point a,point b){
	return Cross(a-p[0],b-p[0])<0;
}
int st[mxn],top=0;
int main(){
	int i,j;
	R=read();C=read();
	n=read();
	for(i=1;i<=n;i++){
		a[i].x1=read();a[i].y1=read();
		a[i].x2=read();a[i].y2=read();
		if(a[i].x1>a[i].x2){
			swap(a[i].x1,a[i].x2);
			swap(a[i].y1,a[i].y2);
		}
		if(a[i].x1==a[i].x2 && a[i].y1>a[i].y2){
			swap(a[i].y1,a[i].y2);
		}
	}
	sort(a+1,a+n+1,cmp1);
	int ed=0;
	for(i=1;i<=n;i++){
		if(!check(a[i].x1,a[i].y1) || !check(a[i].x2,a[i].y2))continue;
		a[++ed]=a[i];
	}
	n=ed;ed=0;
	p[0].x =(a[1].x1+a[n].x2)/2;
	p[0].y =(a[1].y1+a[n].y2)/2;
	for(i=1;i<=n;i++){
		p[++ed]=(point){a[i].x1,a[i].y1,0,i};
		p[++ed]=(point){a[i].x2,a[i].y2,1,i};
	}
	sort(p+1,p+ed+1,cmp);
	for(i=1;i<=ed;i++){
		if(top && p[st[top]].id==p[i].id)top--;
		else st[++top]=i;
			/*else {
				printf("NO\n");return 0;
			}*/
	}
	if(top){
		printf("NO\n");return 0;
	}
	printf("YES\n");
	return 0;
}

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

using namespace std;

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> a(q);
    vector<int> b(q);
    vector<int> c(q);
    vector<int> d(q);
    for (int i = 0; i < q; ++i) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i];
        --b[i];
    }
    vector<int> s(n, 1);
    long max_score = 0;
    do {
        long score = 0;
        for (int i = 0; i < q; ++i) {
            if (s[b[i]] - s[a[i]] == c[i])
                score += d[i];
        }
        if (score > max_score)
            max_score = score;
        int last = n - 1;
        while (last >= 0 && s[last] == m)
            --last;
        if (last < 0)
            break;
        ++s[last];
        for (int i = last + 1; i < n; ++i)
            s[i] = s[last];
    } while (true);
    cout << max_score << "\n";
    return 0;
}


Measured memory_bytes: 3624
s = gets.to_i

h = {
  0 => 0,
  1 => 0,
  2 => 0,
  3 => 1,
}

r = 0

if s <= 3
  puts h[s]
else
  3.upto(s) do |x|
    r = 0
    3.upto(x-3) do |i|
      t = x - i
      r += h[t]
    end
    r += 1
    h[x] = r
  end

  puts h[s] % 1000000007
end


Measured memory_bytes: 14960
X, Y, A, B, C = map(int, input().split())
*p, = map(int, input().split())
*q, = map(int, input().split())
*r, = map(int, input().split())

p.sort(key=lambda x: -x)
q.sort(key=lambda x: -x)
r.sort(key=lambda x: -x)

p = p[:X]
q = q[:Y]
p.sort()
q.sort()

psum = sum(p)
qsum = sum(q)
pi, qi, ri = 0, 0, 0
while ri < len(r):
    found = ""
    if pi < X and qi < Y:
        if p[pi] <= q[qi]:
            if p[pi] < r[ri]:
                found = "p"
        else:
            if q[qi] < r[ri]:
                found = "q"
    elif pi < X:
        if p[pi] < r[ri]:
            found = "p"
    elif qi < Y:
        if q[qi] < r[ri]:
            found = "q"

    if found == "p":
        psum -= p[pi]
        psum += r[ri]
        pi += 1
        ri += 1
    elif found == "q":
        qsum -= q[qi]
        qsum += r[ri]
        qi += 1
        ri += 1
    else:
        break

print(psum+qsum)


Measured memory_bytes: 122852
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  
  string s;
  cin>>s;
  
  int plus=0;
  int minus=0;
  
  for(int i=0; i<4; i++){
  if(s[i]=='+'){
    
    plus++;
  }
  
  if(s[i]=='-'){
    
    minus++;
  }
  }
  
  cout<<plus-minus<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define len(s) s.size()
#define all(x) x.begin(), x.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;

void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5 + 1, M = N + 1;
//==================================

vi g[N];
int a[N];

void solve()
{
    int n, m, ans = 0, k;
    cin>>n;
    int ac=0,wa=0,tle=0,re=0;
    f(i,0,n) {
        string s;
        cin>>s;
        if(s=="AC") ac++;
        else if(s=="WA") wa++;
        else if(s=="TLE") tle++;
        else if(s=="RE") re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re;
}

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

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

void ipgraph(int n, int m)
{
    int i, u, v;
    while (m--)
    {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par)
{
    for (int v : g[u])
    {
        if (v == par)
            continue;
        dfs(v, u);
    }
}

Measured memory_bytes: 10668
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{
    int n;
    int ans=0;
    string str;
    string ring[100];
    cin >> str;
    cin >> n;
    for(int i=0;i<n;++i)
    {
        cin >> ring[i];
        ring[i] = ring[i]+ring[i]+ring[i];
        if(ring[i].find(str)!=string::npos) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1220
import Control.Applicative
import Control.Monad

shapingData :: String -> [[Int]]
shapingData = map (map read . words) . takeWhile ( /= "0 0") . lines

evenLine :: Int -> String
evenLine a = take a startDotList
    where startDotList = concat $ repeat "#."

oddLine :: Int -> String
oddLine a = take a startSharpList
    where startSharpList = concat $ repeat ".#"

takeAlternately :: a -> a -> Int -> [a]
takeAlternately _ _' 0 = []
takeAlternately theOne theOther num = theOne : takeAlternately theOther theOne (num-1)


makeContents :: [Int] -> String
makeContents [a, b] = let evenLineNum = evenLine b
                          oddLineNum = oddLine b
                      in unlines $ takeAlternately evenLineNum oddLineNum a

main = do 
    line <- getContents
    mapM_ putStrLn (map makeContents (shapingData line))


Measured memory_bytes: 4668
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007

int now,a,b;

int main(){
  int ans=0;
  cin >> a >> b;
  int c=abs(a+b)/2;
  if (abs(a-c)==abs(b-c)){
    cout<<c<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second
#define MP make_pair
#define PB push_back

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;


int main()
{
  double n, k ;
  cin >> n >> k ;
  vector<double> vec(n,1/n) ;
  double ans = 0 ;
  double i = 1 ;
  double tmp = 1 ;
  
  while(tmp<=n){
    if(i<k){
      i = i*2 ;
      vec.at(tmp-1) = (vec.at(tmp-1))/2 ;
    }
    else{
      i = tmp+1 ;
      tmp = i ;
    }
  }
  
  REP(i,n){
    ans += vec.at(i) ;
  }
  
  cout << setprecision(10) << ans <<endl ;


  return 0 ;
}



Measured memory_bytes: 1024
using System;

namespace B別解
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var d = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var dSum = 0;
            foreach (int i in d) dSum += i;

            var result = 0;
            foreach (int i in d)
            {
                dSum -= i;
                result += dSum * i;
            }
            Console.WriteLine(result);
        }
    }
}


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

int main() {
  int n;
  cin >> n;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if ((i*4 + j*7) == n) {
        flag = true;
      }
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

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

using namespace std;

template <class T>
void printv(vector<T> v)
{
  cout << '[';
  for (auto vec: v)
  {
    cout << vec << ' ';
  }
  cout << ']' << endl;
}

int main()
{
  long long n, k;
  long long point = 0;
  cin >> n >> k;

  vector<int> v;
  vector<long long> result;

  rep(i, n)
  {
    int tmp;
    cin >> tmp;

    point += (tmp < 0);

    v.push_back(tmp);
  }

  point--;
  rep(i, n - k + 1)
  {
    if (i + k - 1 == point)
    {
      result.push_back(abs(v[i]));
    }
    else if (i == point + 1)
    {
      result.push_back(abs(v[i + k - 1]));
    }
    else if ((i <= point && i + k -1 > point))
    {
      result.push_back(abs((v[i]) * 2) + abs((v[i + k -1])));
      result.push_back(abs((v[i])) + abs((v[i + k -1]) * 2));
    }
  }

  sort(result.begin(), result.end());
  cout << result[0] << endl;
}

Measured memory_bytes: 1784
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

const int N = 3e5 + 7;

namespace Fenwick {
    int t[N];

    void add(int x, int val) {
        for (int i = x; i < N; i = (i | (i + 1))) {
            t[i] += val;
        }
    }

    int get(int x) {
        int ans = 0;
        for (int i = x; i >= 0; i = (i & (i + 1)) - 1) {
            ans += t[i];
        }
        return ans;
    }

    void init(vector<int> a) {
        add(0, a[0]);
        for (int i = 1; i < (int)a.size(); i++) {
            add(i, a[i] - a[i - 1]);
        }
    }

    void sub(int len, int val) {
        add(0, -val);
        add(len, val);
    }
}

int n, d;
vector<int> xs;
vector<int> cnt;

int solve() {
    int ans = 0;
    Fenwick::init(cnt);
    for (int i = 0; i < n; i++) {
        if (Fenwick::get(i) > 0) {
            int lol = Fenwick::get(i);
            ans += lol;
            int bc = (upper_bound(xs.begin(), xs.end(), xs[i] + 2 * d)) - xs.begin();
            Fenwick::sub(bc, lol);
        }
    }
    return ans;
}

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

    int a;
    cin >> n >> d >> a;
    vector<pair<int, int>> kek(n);
    for (auto &t : kek) {
        cin >> t.first >> t.second;
        t.second = (t.second + a - 1) / a;
    }
    sort(kek.begin(), kek.end());
    for (auto t : kek) {
        xs.push_back(t.first);
        cnt.push_back(t.second);
    }
    cout << solve() << endl;

}   


Measured memory_bytes: 9828
#include<bits/stdc++.h>
#define int long long
using namespace std;
int A[3100][3100],B[3100][3100][5];
signed main(){
  int H,W,K;
  cin>>H>>W>>K;
  for(int i=0;i<K;i++){
    int x,y,c;
    cin>>x>>y>>c;
    A[x-1][y-1]=c;
  }
  for(int i=0;i<H;i++){
    B[i+1][0][0]=max({B[i+1][0][0],B[i][0][0],B[i][0][1],B[i][0][2],B[i][0][3]});
    if(A[i][0])B[i+1][0][1]=B[i+1][0][0]+A[i][0];
    for(int j=1;j<W;j++){
      for(int k=0;k<4;k++)B[i+1][j][k]=B[i+1][j-1][k];
      B[i+1][j][0]=max(B[i+1][j][0],max({B[i][j][0],B[i][j][1],B[i][j][2],B[i][j][3]}));
      if(A[i][j])B[i+1][j][1]=max(B[i+1][j][1],B[i+1][j][0]+A[i][j]);
      for(int k=0;k<3;k++)
        if(B[i+1][j-1][k])B[i+1][j][k+1]=max(B[i+1][j][k+1],B[i+1][j-1][k]+A[i][j]);
    }
  }
  cout<<max({B[H][W-1][0],B[H][W-1][1],B[H][W-1][2],B[H][W-1][3]})<<endl;
}

Measured memory_bytes: 439480
import java.util.Scanner;

public class Main {
	private Scanner sc;
	private void run() {
		sc = new Scanner( System.in );
		int n = sc.nextInt();
		sc.nextLine();  // pass '\n'
		for( int i = 0; i < n; i++ ) {
			String line = sc.nextLine();
			System.out.println( line.replace( "Hoshino", "Hoshina" ) );
		}
	}
	
	
	public static void main( String[] args ) {
		new Main().run();
	}
}

Measured memory_bytes: 17304
#include <bits/stdc++.h>
using namespace std;
#define loop(i,a,n) for(int i=a;i<n;i++)
int main()
{
  int n ;
  cin>>n;
  int odd=0 , even=0 ;
  if(n%2==0)
    {
        odd=n/2;
        even=n/2;
    }
  else 
    {
        even=n/2;
        odd=n/2+1;
    }
    cout <<even*odd;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
matrix = list()
for i in range(n):
    hoge = list()
    for elem in map(int, input().split()):
        hoge.append(elem)
    hoge.append(sum(hoge))
    matrix.append(hoge)
last_raw = list()
for j in range(m+1):
    hoge = 0
    for i in range(n):
        hoge += matrix[i][j]
    last_raw.append(hoge)
matrix.append(last_raw)
for i in range(n+1):
    print (' '.join(map(str, matrix[i])))


Measured memory_bytes: 5680
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    string a, b;
    cin >> a >> b;
    int ans = 0;
    rep(i,3)if(a[i] == b[i])ans++;
    cout << ans << endl;
}

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

int x,a,b,c,d,cnt;
while(scanf("%d",&x)==1){
    cnt=0;
for(a=0;a<=9;a++){
for(b=0;b<=9;b++){
    for(c=0;c<=9;c++){
        for(d=0;d<=9;d++)
        if((a+b+c+d==x))
        cnt++;
    }
}
}
printf("%d\n",cnt);

}


return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
        int a;
        cin >> a;
        return a;
};

void inputArray(int * p, int a){
        rep(i, a){
                cin >> p[i];
        }
};

void inputVector(vector<int> * p, int a){
        rep(i, a){
                int input;
                cin >> input;
                p -> push_back(input);
        }
}

template <typename T>
void output(T a, int precision=0) {
        if(precision > 0){
                cout << setprecision(precision)  << a << "\n";
        }
        else{
                cout << a << "\n";
        }
}

int main(int argc, const char * argv[]) {

        // source code
        int a,b;
        a=inputValue();
        b=inputValue();

        if (a>12)
        {
                output<int>(b);
        }else if(a >= 6 && a <=12)
        {
                output<int>(b/2);
        }else
        {
                output<int>(0);
        }
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

string s = "MARCH";
map<char, long long> m;
long long ans = 0;

void dfs(vector<int> p){
	if(p.size() == 3){
		ans += m[s[p[0]]] * m[s[p[1]]] * m[s[p[2]]];
		return;
	}

	rep(i,5){
		if(not p.empty() and i <= p.back()) continue;
		p.emplace_back(i);
		dfs(p);
		p.pop_back();
	}
}

int main(){
	int n;
	cin >> n;
	rep(i,n){
		string t;
		cin >> t;
		m[t[0]]++;
	}

	dfs(vector<int>());
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> v;
    for (int i = 0; i < n; ++i) {
        int r, c;
        cin >> r >> c;
        v.emplace_back(r, c);
    }

    vector<vector<int>> dp(n, vector<int>(n, numeric_limits<int>::max()));

    for (int i = 0; i < n; ++i) {
        dp[i][i] = 0;
    }

    auto cost = [&v](int i, int k, int j) {
        return v[i].first * v[k].second * v[j].second;
    };

    // auto p = [&dp, n] {
    //    for (int i = 0; i < n; ++i) {
    //        for (int j = 0; j < n; ++j) {
    //            cout << dp[i][j] << ' ';
    //        }
    //        cout << endl;
    //    }
    //    cout << endl;
    //};
    for (int l = 2; l <= n; ++l) {
        for (int i = 0; i < n - l + 1; ++i) {
            int j = i + l - 1;
            for (int k = i; k < j; ++k) {
                dp[i][j] =
                    min(dp[i][j], dp[i][k] + dp[k + 1][j] + cost(i, k, j));
            }
        }
    }
    cout << dp[0][n - 1] << endl;
}

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

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

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

	int ans=(n-1 +k-2)/(k-1);
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K;
    cin >> K;
    ll sum = 0;
    REP(i, 1, K + 1) {
        REP(j, 1, K + 1) {
            REP(k, 1, K + 1) {
                sum += gcd(gcd(i, j), k);
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define MAXSIZE 100001
#define MAXL 100
typedef long long int lli;

int main(){
    int n, a[MAXSIZE];
    cin >> n;
    int flag = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(flag == 0 && a[i] % 2 != 0){
            flag = 1;
        }
    }

    if(flag){
        cout << "first" << endl;
    }else{
        cout << "second" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
N = int(input())
H = list(map(int, input().split()))
mah = 0
for i in range(N):
    if mah >= H[i] + 2:
        print("No")
        break
    elif mah >= H[i]:
        pass
    else:
        mah = H[i]
else:
    print("Yes")

Measured memory_bytes: 14396
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        ll arr[3],count=0;
        for (ll i = 0; i < 3; ++i)
            cin>>arr[i];

        sort(arr,arr+3);

        for (ll i = 0; i < 2; ++i)
        {
            if(arr[i]==arr[i+1])
                count++;
        }
        if(count==1)
            cout<<"Yes";
        else
            cout<<"No";
      
        return 0;
    }


Measured memory_bytes: 256
k=int(input())
a=[]
def dfs(v):
    if v>3234566667:
        return
    a.append(v)
    for i in range(max(0,v%10-1),min(v%10+2,10)):
        dfs(10*v+i)
for i in range(1,10):
    dfs(i)
a.sort()
print(a[k-1])

Measured memory_bytes: 7708
n=int(input())
d={}
for i in range(1,100):
    for j in range(i,100):
        if i**2>n or j**2>n: break
        for k in range(j,100):
            tmp=i**2+j**2+k**2+i*j+j*k+k*i
            if tmp>n: break
            if i==k: x=1
            elif i==j or j==k: x=3
            else: x=6
            if tmp in d: d[tmp]+=x
            else: d[tmp]=x
for i in range(1,n+1):
    if i in d: print(d[i])
    else: print(0)

Measured memory_bytes: 74520
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define N (ll)(1e17+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll t=1;
   //cin>>t;
   while(t--)
   {
     ll n,i,x,f=0;
     cin>>n;
     map <ll,ll> mp;
     for(i=0;i<n;i++)
     {
         cin>>x;
         mp[x]++;
     }  
     for(auto it=mp.begin(); it!=mp.end(); it++)
     {
         if(it->ss>1)
         {
             f=1;
             break;
         }
     }
     if(f)
      cout<<"NO\n";
     else
      cout<<"YES\n"; 
   }
}

Measured memory_bytes: 12800
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <fstream>
#include <unordered_map>

using namespace std;

ifstream fin("../data.txt");

string s;
int stones, n;

int main() {

  getline(cin, s);
  n = s.size();
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i-1]) stones++;
  }

  cout << stones;

  return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

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

    ll ans=0;
    for(ll i=1; i*i<=m; i++){
        if(m%i==0){
            if(m/i>=n and i>=ans){
                ans=i;
            }
            if(i>=n and m/i>=ans){
                ans=m/i;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string a, b, aa;
    cin >> a >> b;
    aa += a[2];
    aa += a[1];
    aa += a[0];
    if (aa == b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	set<char> s;
	for(int i = 0; i < 3; i++){
		char c;
		cin >> c;
		s.insert(c);
	}
	if(s.size() == 2)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n;
		cin >> n;
		map<int,int> m;
		int a[n];
		int ans = 0;
		rep(i,0,n){
			int t;
			cin >> t;
			a[i] = t;
			m[t]++;
		}
		for(auto j:m){
			ans += j.sc*(j.sc-1)/2;
		}
		rep(i,0,n){
			int tans = ans;
			tans -= (m[a[i]]*(m[a[i]]-1))/2;
			m[a[i]]--;
			tans += (m[a[i]]*(m[a[i]]-1))/2;
			m[a[i]]++;
			cout << tans << endl;
		}
	}
}

Measured memory_bytes: 11136
#include<stdio.h>
#include<string.h>
int main(){
	char nums[1001];
	while(scanf("%s",nums)!=EOF){
 		if(nums[0]=='0'&&nums[1]=='\0')break;
		int ans=0;
		for(int i=0;nums[i]!='\0';i++)ans+=(nums[i]-'0');
		printf("%d\n",ans);
	}
}



Measured memory_bytes: 2080
#include <stdlib.h>
#include<stdio.h>
int desc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main(){
  int N,SumA=0,SumB=0;
  scanf("%d",&N);
  
  int a[N];
  for(int i=0;i<N;i++){
  scanf("%d",&a[i]);
  }
  qsort(a, sizeof(a) / sizeof(*a), sizeof(*a), desc);
  for(int i=0;i<N;i++){ 
    if(i%2==0) SumA+=a[i];
    if(i%2==1) SumB+=a[i];
  }
  
  printf("%d",SumA-SumB);
}


Measured memory_bytes: 128
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import itertools as ite
import math
import random
import sys
import codecs
from collections import defaultdict

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

sys.setrecursionlimit(1000000)

N = input()
a = map(int, raw_input().split())

ans = [0] * (N + 1)

for i in range(1, N + 1)[::-1]:
    cnt = 0
    for j in range(i * 2, N + 1, i):
        cnt += ans[j]
    cnt %= 2
    if a[i - 1] != cnt:
        ans[i] = 1
ls = []
for i in range(1, N + 1):
    if ans[i]:
        ls += [i]
print len(ls)
if len(ls) == 0:
    exit()
print " ".join(map(str, ls))


Measured memory_bytes: 24312
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 10005;
typedef unsigned long  long  ll;
ll a[MAXN], b[MAXN], cnt, ans;
ll ta[MAXN], tb[MAXN], tcnt;
void tMerge(ll l, ll mid, ll r);
void tMergesort(ll l, ll r);
void Merge(ll l, ll mid, ll r);
void Mergesort(ll l, ll r);
int main(void)
{
	ll n, k;
	cin >> n >> k;
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
		ta[n - 1 - i] = a[i];
	}
	Mergesort(0, n - 1);
	tMergesort(0, n - 1);
	for (int i = 0; i < cnt; i++)
	{
		ans += (k + 1) * k / 2;
		ans %= 1000000007;
	}
	for (int i = 0; i < tcnt; i++)
	{
		ans += (k - 1) * k / 2;
		ans %= 1000000007;
	}
	cout << ans << endl;
	return 0;
}
void Merge(ll l, ll mid, ll r)
{
	ll i = l, j = mid + 1, t = 0;
	while (i <= mid && j <= r)
	{
		if (a[i] > a[j])
		{
			b[t++] = a[j++];
			cnt += mid - i + 1;
		}
		else
		{
			b[t++] = a[i++];
		}
	}
	while (i <= mid)
	{
		b[t++] = a[i++];
	}
	while (j <= r)
	{
		b[t++] = a[j++];
	}
	for (i = 0; i < t; i++)
	{
		a[l + i] = b[i];
	}
}
void Mergesort(ll l, ll r)
{
	if (l < r)
	{
		ll  mid = (l + r) / 2;
		Mergesort(l, mid);
		Mergesort(mid + 1, r);
		Merge(l, mid, r);
	}
}
void tMerge(ll l, ll mid, ll r)
{
	ll i = l, j = mid + 1, t = 0;
	while (i <= mid && j <= r)
	{
		if (ta[i] > ta[j])
		{
			tb[t++] = ta[j++];
			tcnt += mid - i + 1;
		}
		else
		{
			tb[t++] = ta[i++];
		}
	}
	while (i <= mid)
	{
		tb[t++] = ta[i++];
	}
	while (j <= r)
	{
		tb[t++] = ta[j++];
	}
	for (i = 0; i < t; i++)
	{
		ta[l + i] = tb[i];
	}
}
void tMergesort(ll l, ll r)
{
	if (l < r)
	{
		ll  mid = (l + r) / 2;
		tMergesort(l, mid);
		tMergesort(mid + 1, r);
		tMerge(l, mid, r);
	}
}




Measured memory_bytes: 384
#include <stdio.h>
#define MAX 101

void serch(int);
int n, M[MAX][MAX], c[MAX], d[MAX], f[MAX], time;

int main(){
  int i, j, m, r, p;
  time = 0;

  scanf("%d",&n);
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      M[i][j] = 0;
    }
  }
  for(i = 1; i <= n; i++){
    c[i] = 0;
  }
  for(i = 1; i <= n; i++){
    scanf("%d%d",&m,&r);
    for(j = 1; j <= r; j++){
      scanf("%d",&p);
      M[i][p] = 1;
    }
  }

  for(i = 1; i <= n; i++){
    if(c[i] == 0) serch(i);
  }
  for(i = 1; i <= n; i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }
  return 0;
}

void serch(int a){
  int i;
  c[a] = 1;
  ++time;
  d[a] = time;

  for(i = 1; i <= n; i++){
    if(M[a][i] == 0) continue;
    if(c[i] == 0){
      serch(i);
    }
  }
  c[a] = 2;
  time++;
  f[a] = time;
  return;
}



Measured memory_bytes: 2056
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main(){

	string l;
	cin>>l;
	int a=0;int b=0;
	for(int i= 0;i<l.size();i++){
		if(l[i]=='0'){a++;}
		else{b++;}
	}
	
	cout<<2*min(a,b)<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
  int cnt = 0;
  int a[3];
  scanf("%d%d%d",a,a+1,a+2);
  if(a[0] == a[1]) cnt++;
  if(a[1] == a[2]) cnt++;
  if(a[0] == a[2]) cnt++;
  if(cnt == 3) cnt--;
  printf("%d\n",3-cnt);
  return 0;
}


Measured memory_bytes: 1724
import sys

n = input()
x = {}

for i in range(1,5):
    for j in range(1,4):
        for k in range(1,11):
            x[(i,j,k)] = 0

for i in range(n):
    b, f, r, v = map(int, raw_input().split())
    x[(b,f,r)] += v

for i in range(1,5):
    for j in range(1,4):
        for k in range(1,11):
            sys.stdout.write(' ')
            sys.stdout.write(str(x[(i,j,k)]))
        print
    if(i != 4):
        for l in range(20):
            sys.stdout.write('#')
        print
exit(0)

Measured memory_bytes: 4260
#include<iostream>
//#include<algorithm>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	long long sum;
	if(n==1)
	cout<<k<<endl;
	else{
		sum=k;
		n=n-1;
		while(n--)
		sum*=(k-1); 
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
int main() {
	ll i,j,k,l,m,n,t;
	t=1;
	while(t--)
	{
		cin>>n;
		ll a[n];
		double d;
		for(i=0;i<n;i++)
		{
			cin>>j;
			d=d+(1.0/j);
		}
		d=1/d;
		printf("%.10lf",d);
	}
	return 0;
}

Measured memory_bytes: 256
from numpy import array
a = list(map(int, input().split()))

x = array([a[0],a[1]])
y = array([a[2],a[3]])
n = array([a[2]-a[0],a[3]-a[1]])
c = n[1]
n[1]=n[0]
n[0]=-c
w = y + n
c = n[1]
n[1]=n[0]
n[0]=-c
z = w + n
k = w[0]
i = w[1]
o = z[0]
p = z[1]
print("{0} {1} {2} {3}".format(k,i,o,p))


Measured memory_bytes: 23680